MySQL Debugging Method for UDF

Source: Internet
Author: User
Tags manual sprintf

MySQL's UDF is essentially a dynamic connection library that does not need to set an entry point (*nix is called a shared library). Debugging a DLL can be a personal act. Now let me introduce you to a very simple, easy-to-use debugging method. This approach uses the Windows API directly, language-independent, development-tool-independent, project-type independent, and a typical three-no debugging method. Also, the debugging methods we discussed here support remote debugging, which is very useful for friends who are unable to master the original debugger of development tools and are eager to find bugs in the program.

First of all, we need to download the receiver, of course, 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! Because the API that it invokes can only receive one char * type parameter, there are times when we need to use other functions to organically combine to produce human-readable hints.

In order to reduce the complexity of the simple discussion from http://Delphi.ktop.com.tw/topic.ASP?TOPIC_ID=35166 For example, explain how I use the tools here to debug.

1 Simple output one line of information, at the beginning of the debugging output a simple information to let us know where the Debug.

In your program code, add the following line as needed:
Outputdebugstringa ("--udf:my_name () called");
So I knew that my definition of my_name was used by the client, and then I had to care about the return value.

2 Output return value

The output return value method is many, can combine freely. The ultimate goal of a free combination is to pass a valid char * type parameter to the Windows API. Here is a simple example of a C-language character control function.

Example:

#include /* 函数- sprintf */
#include /* 挂接windows api */
/* ...........省略 */
char* __stdcall my_name(UDF_INIT *initid,
UDF_ARGS *args, char *is_null, char *error)
{
OutputDebugStringA("--UDF:my_name()被调用"); /* 调用了?*/
char *me = "my name";
/*---- debuger start----*/
char debugermsg[256]={0};
sprintf(debugermsg, "%s", me);
OutputDebugStringA(debugermsg);
/*---- debuger end----*/
return me;
}

When you add similar code to your program, debugging starts, and you can still get the debug information you need, even without using the "Debuger" way to compile.

Receive debugging information

Receive debugging information just open the DebugView program, the main program window can return the required debugging information in real time.

Other platforms please consult the manual to obtain the corresponding API, the use of this way to debug the appropriate method does not cause any trouble.

Related Article

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.