Methods related to MySQL UDF debugging mode debugview

  • 2020-05-06 11:45:56
  • OfStack

MySQL's UDF is essentially a dynamic connection library (*Nix calls it a Shared library) that does not require an entry point. There is a personal way to debug DLL. Now let me introduce a very simple and easy-to-use debugging method. This method directly makes use of Windows   API, which is language independent, development tool independent, project type independent, and typical three-no-debugging method. Moreover, the debugging method we discussed here supports remote debugging, which is very useful for those who cannot grasp the development tool and are eager to find the program error.  
First we need to download the receiver, of course, there are people can write their own. In   http: / / www. sysinternals. com ntw2k/freeware/debugview shtml  . Through the debugview manual we can know that this tool supports the win9x/nt series and supports kernel debugging! Since the API it invokes can only receive one char   *   type parameter, there are times when we need to organically combine other functions to produce human-readable hints.  
In order to reduce the complexity of simple in   http: / / delphi ktop. com. tw/topic asp? TOPIC_ID=35166   discuss, for example, how I used the tools here to debug.  

1   simply prints a line of information, and a simple message at the beginning of debugging helps us understand where debug is.  
Add the following line  
to the program code as needed OutputDebugStringA("--UDF:my_name() called ");  
This way I know that the my_name I defined is being used by the customer, and then I care about the return value.  

2   output returns the value  
Output return value methods are numerous and can be freely combined. The ultimate goal of free composition is to pass a valid   char   *   type parameter to WiNDOWS   API. Here is a simple example of the C language character control function.  
Example:  
include     /*   function -   sprintf   */  
include     /*   hook windows   api   */  
/ *  ... Omit       */  
char*   __stdcall   my_name(UDF_INIT   *initid,   UDF_ARGS   *args,   char   *is_null,   char   *error)  
{  
OutputDebugStringA("--UDF:my_name() called ");   /*   called? * /  
char   *me   =   "my   name";  
/*----   debuger   start----*/  
                char   debugermsg[256]={0};  
                sprintf(debugermsg,   "%s",   me);  
                OutputDebugStringA(debugermsg);  
                /*----   debuger   end----*/  
  return   me;  
}  
When similar code is added to the program, debugging can begin. In this way, you can still get the necessary debugging information without compiling in the "debuger" mode.  
Receive debugging information  
To receive debugging information, just open the debugview program. The main window of the program can return the needed debugging information in real time.  
For other platforms, please refer to the manual for the corresponding api. Appropriate debugging methods in this way will not cause any trouble.

Related articles: