Debug Windows programs using drwtsn32

Source: Internet
Author: User

I 've been busy debugging code and writing server code. Sometimes it's really depressing. What's depressing is that it's not enough to keep the program running with High Performance for more than N days. This is what programmers should do, however, some problems that have been accumulated for a long time may cause program designation ~~~

When writing this program, no memory leakage occurs during code debugging on the local machine, and the debugging process is clear, however, it is depressing to log on to the customer for one or two days.

No error is reported ~~ Helpless,

Enable drwtsn32 to detect program running errors

Drwtsn32 is a tool for Windows debugging. It can be used when debugging programs with uncommon errors and when errors are accumulated.

In the command line window, enter drwtsn32

Then you can see the running interface of drwtsn32.

Then set "Save to symbol table"

"Dumping all thread contexts" will record the context and context of the program running when an error occurs. If you only want to know the record of the location where the error occurred, do not select this option. It looks much more convenient.

Then confirm to save the information

When the corresponding windows program is generated, you must make some changes to generate the map file so as to locate the problematic code.

VC settings:
1. Configure properties-> C/C ++-> General-> debug information format, and select "program database (/Zi )"
2. Configure properties-> C/C ++-> optimization and select "Disable (/OD )"
3. Configure properties-> connector-> debugging-> Generate debugging information and select "Yes (/debug )"
4. Configure properties-> connector-> debug-> Generate the image file and select "Yes (/MAP )"
5. Configure properties-> connector-> debugging-> image file name, and select "$ (outdir)/$ (projectname). Map"
6. Configure Properties> connector> debugging> export, and select "Yes (/MapInfo: exports )"
7. Configure Properties> connector> debugging> shadow row and select "Yes (/MapInfo: lines )"
8. Configure Properties> connector> advanced> fixed base address and select "generate relocation section (/fixed: No )"

Run drwtsn32 on the command line.

An error occurred while waiting for the program ~~

After a program error occurs, logs and a DMP file are stored in the directory of the Failover and log file path. You can set this directory by yourself.

 

There is such information in the log information

Microsoft (r) Windows 2000 (TM) Version 5.00 drwtsn32
Copyright (c) 1985-1999 Microsoft Corp. All rights reserved.

 

Unexpected application error:
Application: (pid = 1248)
Time: @ 09:49:29. 613
Unexpected situation no.: c0000005 (access violation)

* ----> System Information <----*
Computer Name: f6b2548c83754cf
User name: Administrator
Number of processors: 1
Processor type: x86 family 6 Model 8 stepping 6

............

0041e6bb 8b45e0 mov eax, [EBP + 0xe0] ss: 00d9907e = ????????
Error-> 0041e6be 8b500c mov edX, [eax + 0xc] DS: 00c69ee6 = ????????
0041e6c1 52 push edX
0041e6c2 ff1518af4300 call dword ptr [0043af18] DS: 0043af18 = 7c177c00

..............................

Many information

Find the location of the map file generated by your VC ~~

Find the location where the code is in that situation ~~

~~~ Then let your program VC debug, disassemble, and find the corresponding location ~~

 

PS: This is just the simplest method :)

For more methods, see Windows program debugging.

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.