View Issue Details

IDProjectCategoryView StatusLast Update
0019466FPCCompilerpublic2020-11-22 18:02
ReporterMartin Friebe Assigned To 
Status newResolutionopen 
Product Version2.5.1 
Summary0019466: Dwarf Stabs,line info not correct for line with "begin"
DescriptionThis appears to happen for dwarf and stabs, with and with external linker.

with the code below, line info is generated for the "begin" line (of TestMe).
At least "-symbol-list-lines p" does return info for that line.

However when single stepping the debugger will not stop on this line (a breakpoint will stop on the next line too)

Uncommenting the line "s := s +'a'" and it will work as expected.

Though even with the line commented (when the debugger does not stop on this line), code is generated for that line. From the assembler:

# [project1.lpr]
# [6] begin
    pushl %ebp
    movl %esp,%ebp
    subl $48,%esp
    movl %ebx,-48(%ebp)
# Var s located at ebp-4
    movl %eax,-4(%ebp)
    .stabn 68,0,7,.Ll2 - P$PROJECT1_TESTME$ANSISTRING
# [7] writeln(s);
    leal -16(%ebp),%ecx

The problem occurs too with simplier code
  procedure TestMe;
But even this code has assembler instructions for the "begin" line.

Checking the disassembler of the actual produced exe, shows that the code was *not* inlined.
Additional Informationprogram project1;

{$mode objfpc}{$H+}

procedure TestMe(s: string);
  //s:= s+'a';

TagsNo tags attached.
Fixed in Revision
Attached Files


related to 0015719 resolvedMartin Friebe Lazarus debugger doesn't stop on 'begin' (keyword) of a procedure 


Martin Friebe

2011-06-08 13:05

manager   ~0048955

Further conversation on the mailinglist:

It may be that fpc is correct, and the issue is by "design" of gdb

Jonas Maebe

2011-06-09 00:26

manager   ~0048979

Last edited: 2011-06-15 10:55

I think the correct behaviour would be that the debugger never stops on the "begin" line itself. At that point, the function prologue hasn't been executed yet and hence most debug information will still be bogus (e.g. parameters won't be yet in their final destination).

Using temporary ansistrings (such as when concatenating strings) indeed adds code to the prologue that gdb does not recognize as belonging to the prologue (which is not really surprising, since it doesn't look different from other code), and hence cannot skip it automatically.

DWARFv3 has support for encoding the start/end of the function prologue and epilogue into the debug information, but FPC doesn't do this yet.

Martin Friebe

2020-11-22 17:58

manager   ~0127113

Just reviewing this, I believe this may be a gdb issue. Afaik gdb has some smart "prologue detection" => and this leads to the line being skipped.

Please feel free to close this issue, (not fixable)

Jonas Maebe

2020-11-22 18:01

manager   ~0127114

Last edited: 2020-11-22 18:02

View 2 revisions

We should at least try emitting a DW_LNS_set_prologue_end to fix this.

Edit: ah no, this is stabs. Not sure whether Stabs also has a prologue end marker.

Issue History

Date Modified Username Field Change
2011-06-03 00:28 Martin Friebe New Issue
2011-06-08 13:04 Martin Friebe Relationship added related to 0015719
2011-06-08 13:05 Martin Friebe Note Added: 0048955
2011-06-09 00:26 Jonas Maebe Note Added: 0048979
2011-06-15 10:55 Jonas Maebe Note Edited: 0048979
2020-11-22 17:58 Martin Friebe Note Added: 0127113
2020-11-22 18:01 Jonas Maebe Note Added: 0127114
2020-11-22 18:02 Jonas Maebe Note Edited: 0127114 View Revisions