KB: Visual C Q196755 - HOWTO: Determine The Location of a Crash How to Locate Procedures Crash
Overview This document describes how to find an error occurred in an address in the error message. For example, a user reports crashes when using the Release version, unique information is an error address.
[Tips 1: Using Map files]
By using the MAP file, you can locate functions that contain the error code. To generate an MAP file, open the "/ map" link switch value in the engineering option, the setting steps are as follows: 1. Open the project option settings, set the Release option. 2. Select the "General" section of the "LINK" page and select "Generate Debug Info". 3, recompile the program.
For example, suppose the error message is as follows:
Testcrash.exe - Application ErrorThe Instruction at "0x004011a9" Reference Memory AT "0x00000000". Thememory Could Not Be "Written"
The error address is 0x004011A9, check the "RVA Base" value in the map file (the start position of the function "to find the most match. Suppose the contents of the MAP file are as follows:
<... lines removed ...> Address Publics by Value Rva Base Lib: Object 0001: 00000000 _GetBaseMessageMap @ CTestcrashApp @@ KGPBUAFX_MSGMAP @@ XZ 00401000 f testcrash.obj 0001:? 00000010 GetMessageMap @ CTestcrashApp @@ MBEPBUAFX_MSGMAP @@? XZ 00401010 f testcrash.obj 0001: 00000020 ?? 0CTestcrashApp @@ QAE @ XZ 00401020 f testcrash.obj 0001: 00000080 ?? _ ECTestcrashApp @@ UAEPAXI @ Z 00401080 f testcrash.obj 0001: 00000080 ?? _ GCTestcrashApp @@ UAEPAXI @ Z 00401080 f testcrash.obj 0001: 00000170 InitInstance @ CTestcrashApp @@ UAEHXZ 00401170 f testcrash.obj 0001:? 00000210 ?? 1CTestcrashDlg @@ UAE @ XZ 00401210 f testcrash.obj 0001:? 00000260 Serialize @ CObject @@ UAEXAAVCArchive @@@ Z 00401260 f Testcrash.obj <... lines removed ...>
We found that the function? InitInstance @ ctestcrashapp @@ uaehxz start address is 00401170, the next function ?? 1 ctestcrasedlg @@ uae @ xz start address, the error address 0x004011A9 is located between the two, then the error can be determined in the function InitInstance. Using the MAP file can locate the error function, but it cannot narrow the range to an error.
[Technique 2: Using PDB files]
Using the PDB file can accurately locate the error-occurred statement, the setting steps are as follows: 1. Save the Map file generated in the tip. 2. Open the project option settings, set the release option. 3. Select the "General" section of the C / C page and select "Program Database" in "Debug Info". 4. Select the "General" section of the "Link" page and select "Generate Debug Info". 5. Select the "Customize" section of the "LINK" page and select "Use Program Database". 6, recompile the program. 7. With Windiff or FC control, the newly generated MAP file and the previous MAP file. 8, "RVA BASE" "RVA BASE" changes, if there is no change, skip step 9.9, calculate the difference value of "RVA Base", then use this value to correct the error address, so it gets new execution Address in the file.
Now you have a PDB file, it can be used to determine the specific location of the error, steps are as follows: 1, open the project in VC 2, press the F11 single-step execution program 3, press Alt F9 to open the breakpoint dialog box 4 To set a breakpoint with the wrong address (Note: Add 0X) 5, open the file containing the error function, then you can see the breakpoint is the wrong statement.
[Reference] To learn more about the tester, please see the "Using Visual C - VC User's Guide - Debugger" section in the VC online document.