Find the number of wrong lines through the crash address in Delphi

Source: Internet
Author: User
When I was bored, I flipped through my favorites and saw the "Delphi version of the wrong number of lines found through the collapsed address", but the address has expired. After searching through Google, it turned out to be CSDN's beyondtkl (Big Dragon Horse <* has not been here for a long time, bro. *>) Sent to the Forum.
Put it here for backup.
I used to read "The VC version of the wrong number of lines through the crashed address". At that time, I didn't use DELPHI. I just saw it again last night, so I tried DELPHI and shared it with everyone. Pai_^
What is a MAP file? In short, a MAP file is the unique text representation of the program's global symbols, source files, and code line numbers. It can be used anywhere and anytime, no additional programs are required. Moreover, this is the only savior that can find the place where the program crashes.
How to generate a MAP file in DELPHI: I only know the following two methods. If anyone knows other methods, please let me know. Thank you!
How to generate detailed MAP information:
  1. Project-> options-> linker-> Map file select detailed.
  2. D: \ Fred \ Code \ DELPHI \ MyPas \ ErrLineByAddr2> dcc32-GD project1.dpr

Our code is: Unit Unit1;

// {$ D +, L +}


Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

TForm1 = class (TForm)
Button1: TButton;
Procedure Button1Click (Sender: TObject );
{Private declarations}
{Public declarations}

Form1: TForm1;


{$ R *. dfm}

Procedure TForm1.Button1Click (Sender: TObject );
I, J: Integer;
P: PChar;
I: = 10;
J: = 0;
// I: = I div J; // 32
// ShowMessage (IntToStr (I ));
P: = nil;
P ^: = 'a'; // 38


As you may see, there will be a 0 address error... we are here to let it crash, let me let you crash !! Pai_^
Then execute-> click-> then error-> my machine-> crash address: 0044d946
To find the code row number, use the following formula to perform hexadecimal subtraction:

  • Crash line offset = Crash Address-base Address (ImageBase Address)-0x1000

0044d946-00400000 = 0004d946-00001000 = 0004c946
0004C946 is it. We use tools such as UltraEdit32 to open the. map File, search for "0004C94", find it, and find the address of 0004c946. Then we can see it: Line numbers for Unit1 (Unit1.pas) segment. text

37 0001: 0004C944 38 0001: 0004C946 39 0001: 0004C949 41 0001: 0004C97C
41 0001: 0004C983

O Yeah... <sound of doping injection in interstellar space ^_^> ..
"38 0001: 0004C946" Is it !! Row 38th of unit1.pas !! Go to the code and check that there are 38 rows. ^_^ .....
Sharing ing... if anything is inappropriate, please stay tuned! Thank you ....

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: 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.