MySQLUDF debugging method debugview MySQL UDF debugging method
The UDF of MySQL is a dynamic connection Library (* Nix is called a shared library) that does not need to set the entry point ). You can call this method to debug a DLL. Now I will introduce a very simple and easy-to-use debugging method. This method directly utilizes Windows APIs, including language-independent, development tool-independent, and project-type-Independent. a typical three-way debugging method is not supported. In addition, the debugging method we discussed here supports remote debugging. this method is very practical for friends who cannot grasp the development tool's original debugger and are eager to find program errors!
First, we need to download the acceptor. of course, you can write one by yourself. 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 all APIs called by the API can only receive one char * type parameter, sometimes we need to use other functions to generate human readable prompts. To reduce complexity since simple http://delphi.ktop.com.tw/topic.asp? The topic id = 35166 is used as an example to describe how to use the tool here for debugging.
1. simple output of a line of information. a simple line of information is output at the beginning of debugging to help us understand where debug is.
Add the following line to the program code as needed
OutputDebugStringA ("-- UDF: my_name () called ");
In this way, I will know that my_name is used by the customer, and then I will be concerned about the return value.
2. return value
There are many methods to return output values, which can be freely combined. The ultimate goal of free combination is to pass a valid char * type parameter to WiNDOWS API. Here, the C character control function is used as an example.
Example:
# Include /* Function-sprintf */
# Include /* Hook up windows api */
/* ...... Omitted */
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 be started. the required debugging information can be obtained even if the "debuger" method is not used for compilation.
Receive debugging information
To receive debugging information, you only need to open the debugview program. The main window of the program can return the required debugging information in real time.
For other platforms, please consult the manual to obtain the corresponding api. using this method for debugging will not cause any problems.