#1 2025-01-30 09:08:07

zen010101
Member
Registered: 2024-06-15
Posts: 106

Issue about .mab debug file

To compile the LoggingTest.dpr project with debug information and generate a .map file with the FPC, followed by executing the program, a .mab debug file will be created. The log file will display the source line number during the initial execution. However, upon running the program a second time, it loads the .mab file but does not include the line numbers in the log file. This suggests there may be an issue with the .mab file. I have traced the problem for some time but have not found anything conclusive; the following statement consistently returns -1:

u := debug.FindUnit(offset, Line) 

Offline

#2 2025-01-30 09:38:39

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,895
Website

Re: Issue about .mab debug file

On which Operating System?

(it may be due to wrong offset calculation due to ASLR)

Offline

#3 2025-01-30 09:48:33

zen010101
Member
Registered: 2024-06-15
Posts: 106

Re: Issue about .mab debug file

Yeah, you're right! I tried it on Linux and it worked fine. The issue only popped up on my Windows 11.

But I'm curious, why did it work the first time I ran it?

Last edited by zen010101 (2025-01-30 11:56:45)

Offline

#4 2025-01-31 14:49:04

zen010101
Member
Registered: 2024-06-15
Posts: 106

Re: Issue about .mab debug file

Supplementary Note:

The information I provided earlier was incorrect. Through today's testing, I found that whether on Windows or Linux, only the first run can obtain the program's line number information. As long as the .mab file is generated, in subsequent runs, the program will not be able to find the line number information as long as the .mab is loaded.

Offline

#5 2025-02-01 10:15:25

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,895
Website

Re: Issue about .mab debug file

I see no problem with Delphi + Windows.
I see no problem with FPC + Linux (and Dwarf 3 debug info).
I see indeed some problems with FPC + Windows (and Dwarf 2 or 3 debug info).

Offline

#6 2025-02-01 16:21:44

zen010101
Member
Registered: 2024-06-15
Posts: 106

Re: Issue about .mab debug file

Wired.

Here is my environment:

OS: Windows 11
Compiler: Free Pascal Compiler version 3.2.3-1404-g57e84ef714 [2024/11/20] for aarch64
Target: Linux  aarch64 (and Dwarf3 debug info)

Every time I delete the .mab file, I can see line number information in the Log.

How can I find some more useful information?

Offline

#7 2025-02-14 04:00:44

zen010101
Member
Registered: 2024-06-15
Posts: 106

Re: Issue about .mab debug file

I finally know the reason.  My FPC + Linux combination doesn't work is because:

The .mab file I generated relies on the .dbg file, and the SmartLink option is automatically disabled during its creation. However, after generating the .mab file and subsequently switching to Release Mode (which explicitly enables SmartLink), the previously created .mab file becomes invalid. This occurs even when using the -Xm compilation flag to generate the .map file – the map2mab tool appears incompatible with Free Pascal Compiler (FPC)-generated .map files, throwing an "Error: EInOutError Read past end of file" during processing.

The root cause has been identified - SmartLink optimization invalidates the .mab file. This leads to another  question:

Could we make TDebugFile to extract line number and symbol information directly from FPC-generated .map files (created via the -Xm compilation flag)? or make map2mab work?

Offline

#8 2025-02-14 19:03:41

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,895
Website

Re: Issue about .mab debug file

AFAIR the .map format of FPC has nothing to do with the .map format of Delphi - which is the one used for map2mab.

Offline

Board footer

Powered by FluxBB