Use outputdebugstring for debugging output

Source: Internet
Author: User

Yesterday, I found that there was a problem with the server communication concurrency, so I hope to add the write debugging information output at the communication layer. At that time, I first thought of codesite, which is commonly used. However, after I added the debugging code to the communication unit, the compilation failed, and it was discovered after a trace, it turns out that codesite actually reports an address error. Let's take a closer look... My mom... The codesite object is actually nil. Originally, this object was supposed to be made during csintf unit initialization. It was used well before. Why can't I initialize the codesite object this time ???? That's strange. I went to study this damn codesite most of the afternoon... Fruitless ....

Get up in the morning... I suddenly thought of using an outputdebugstring function that I used earlier. This is a WIN32API function in a Windows Unit. It is green, pollution-free, and no residue. In the debugging status, you can use various debuggers to capture the output information of outputdebugstring in the program. In fact, outputdebugstring writes a piece of data to a shared image memory and creates two enevts, indicating that the data write event is triggered. The output information of outputdebugstring in Delphi is displayed in the event log window. If it is run outside the debugging environment, you can also use debugging tools such as debugview and aqtime to view the output information. If you use the debugview tool, you can also remotely view the output information, so that you can easily capture and process the output of debugging information in the Code. It is actually a developer who travels at home and kills people, essential Medicine ...... Pretty cool ~~~~~ In the afternoon, I went to test the communication layer of the Department to debug the server. It turned a lot of credit to find the cause ~~~ I made up my mind to abandon codesite in the future and return to outputdebugstring. I also considered how to organically integrate outputdebugstring into the log module of the platform when appropriate, added platform debuggable!

Outputdebugstring (pchar (syserrormessage (getlasterror )));

You can also encapsulate layer functions for outputdebugstring to make it easier to use:

Procedure outputdebugstr (const adebuginfo: string );
Begin
Outputdebugstring (pchar (adebuginfo ));
End;

Debugview:

Http://download.sysinternals.com/Files/DebugView.zip

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.