1. What is a MAP file?
Simply put, a MAP file is a unique textual representation of the program's global symbols, source files, and code line number information, which can be used anywhere, at any time, without the need for additional programs to support it.
2.DELPHI the method of generating a map file: I only know the following two kinds, if anyone know other methods, please inform, thank you!
A way to generate detailed map information:
1). Map file selection detailed, Linker, options, Project.
2). D:\FRED\CODE\DELPHI\MYPAS\ERRLINEBYADDR2>DCC32-GD PROJECT1.DPR
3. Example
Our code is:
Unit Unit1; {$D +,l+} interface uses Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms, Dialogs, Stdctrl S Type TForm1 = Class (Tform) Button1:tbutton; Procedure Button1Click (sender:tobject); Private {Private declarations} public {public declarations} end; var form1:tform1; Implementation {$R *.DFM} procedure Tform1.button1click (Sender:tobject); var I, J:integer; P:pchar; Begin I: = ten; J: = 0; I: = i div J; //showmessage (IntToStr (I)); P: = nil;
Presumably you see, there will be a return 0 address error .... We're here to let it crash, let me break you down ^_^
Then execute, click, and then make an error on my machine, the crash address is D9 46.
If you are looking for a code line number, you need to do some hexadecimal subtraction using the following formula:
Crash Line offset = crash address (Crash addresses)-base address (ImageBase address)-0x1000
0044d946-00400000 = 0004d946-00001000 = 0004c946 <= The 0004c946 listed later is it.
We open the. map file with tools such as Ultraedit32, search for 0004c94, find it, and find it.
<= the address of 0004c946, and then saw:
Line numbers for Unit1 (Unit1.pas) segment. Text
Panax Notoginseng 0001:0004c944 0001:0004c946-0001:0004c949-0001:0004c97c
The 0001:0004c946 is it ... The 38th line of Unit1.pas!! Go to the code to see, sure enough is 38 lines ^_^ .....
4. Supplement
If the line of code is not found by the address, the
Debugging's use Debug Dcus in Compiler, options, Project, is checked for compilation,
The system files that are called are compiled into the execution file and recorded in the map file.
At this point in the search address, do not believe to find;
How to debug a Delphi access violation at address error