Skip to content

Nested generic functions create invalid debug-line-info

Original Reporter info from Mantis: Martin @martin_frb
  • Reporter name: Martin Friebe

Description:

This applies to dwarf AND stabs

See issue #38200
To reproduce use https://bugs.freepascal.org/file_download.php?file_id=34247&type=bug
tested with -O-

The project specializes Test2 (in unit2)
Test2 specializes Test1 (in unit1)

Debug line info for test1 is correctly attributed to unit1.
But by the look of it, after Test1 was specialized, specialization of Test2 resumes, but line info is not reset to unit2. So remaining lines are attributed to unit1.

Additional information:

Dwarf
objdump.exe --dwarf=decodedline project1.exe

project1.exe: file format pei-i386

Decoded dump of debug contents of section .debug_line:

CU: project1.lpr:
File name Line number Starting address

./unit1.pas:
unit1.pas 12 0x4015c0
unit1.pas 13 0x4015c7
unit1.pas 14 0x4015ce

./unit2.pas:
unit2.pas 15 0x4015e0
unit2.pas 16 0x4015e8

./unit1.pas:
unit1.pas 17 0x4015f0 //////////////////////////////////////////////////////// This should be in UNIT2 ///////////////////////////////////////////////
unit1.pas 18 0x4015f9
unit1.pas 19 0x401620
project1.lpr 8 0x401630
project1.lpr 9 0x401638
project1.lpr 10 0x40163d

CU: unit2.pas:
File name Line number Starting address

./unit2.pas:

CU: unit1.pas:
File name Line number Starting address

--------------
Stabs
objdump.exe -G project1.exe

project1.exe: file format pei-i386

Contents of .stab section:

Symnum n_type n_othr n_desc n_value n_strx String

-1 HdrSym 0 37 0000013c 1
0 SO 0 0 004015c0 1 B:/tmp/New Folder (3)/
1 SO 0 0 004015c0 24 project1.lpr
2 LSYM 0 0 00000000 37 void:t1=1
3 LSYM 0 0 00000000 47 LONGINT:t2=r2;-2147483648;2147483647;
4 FUN 0 7 004015c0 85 TEST11CRC713F463B:f2,TEST11CRC713F463B,TEST21CRC713F463B
5 LSYM 0 7 00000000 148 T:t2
6 PSYM 0 7 fffffffc 153 result:2
7 PSYM 0 0 fffffffc 162 TEST11CRC713F463B:X2
8 PSYM 0 0 fffffffc 185 RESULT:X2
9 SOL 0 0 004015c0 195 unit1.pas
10 SLINE 0 12 00000000 0
11 SLINE 0 13 00000007 0
12 SLINE 0 14 0000000e 0
13 LBRAC 0 0 00000000 0
14 RBRAC 0 0 00000015 0
15 FUN 0 10 004015e0 205 TEST21CRC713F463B:f2
16 LSYM 0 10 00000000 228 T:t2
17 PSYM 0 10 fffffffc 233 result:2
18 PSYM 0 0 fffffffc 242 TEST21CRC713F463B:X2
19 PSYM 0 0 fffffffc 265 RESULT:X2
20 SOL 0 0 004015e0 275 unit2.pas
21 SLINE 0 15 00000000 0
22 SLINE 0 16 00000008 0
23 SOL 0 0 004015f0 285 unit1.pas /////////////////////////////////////////////////// switching to unit1
24 SLINE 0 17 00000010 0 ///////////////////////////////////////////////////////// code in unit2
25 SLINE 0 18 00000019 0
26 SLINE 0 19 00000040 0
27 LBRAC 0 0 00000000 0
28 RBRAC 0 0 00000048 0
29 FUN 0 8 00401630 295 main:F1
30 SOL 0 0 00401630 303 project1.lpr
31 SLINE 0 8 00000000 0
32 SLINE 0 9 00000008 0
33 SLINE 0 10 0000000d 0
34 LBRAC 0 0 00000000 0
35 RBRAC 0 0 00000013 0
36 SO 0 0 00401650 0

Mantis conversion info:

  • Mantis ID: 38209
  • OS: win 10
  • OS Build: 10
  • Build: 47763
  • Platform: 64bit Intel
  • Version: 3.3.1
  • Monitored by: » @OkobaPatino (OkobaPatino)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information