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, and is eager to find the development tool that cannot grasp the original debugger at the moment. Program Incorrect friend. This method is very practical!
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.
In the programCodeAdd the following line 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. Output return values
there are many methods for output return 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 Windows API */
/*........... omit */
char * _ stdcall my_name (udf_init * initid, udf_args * ARGs, char * is_null, char * error)
{< br> 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;
}< br> when similar code is added to the program, debugging can begin, by using this method, you can obtain the required debugging information even if you do not use the "debuger" Method 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.