Debugging method of MySQLUDF: debugview_MySQL

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.