The prologue-end line record must be emitted after the last instruction that is part of the function frame setup code and before the instruction that marks the beginning of the function body.
For the below test:
1 extern int get_arg(); 2 extern void func(int x); 3 4 int main() 5 { 6 int a; 7 func(get_arg()); 8 } 9
The prologue-end line record is emitted with an incorrect associated address, which causes a debugger to show the beginning of function body to be inside the prologue.
This can be seen in the following trimmed assembler output:
main: ... .loc 1 7 0 prologue_end pushq %rax .Lcfi0: .cfi_def_cfa_offset 16 callq _Z7get_argv ... retq
The instruction 'pushq %rax' is part of the frame setup code.
The correct location for the prologue-end line information is just before the call to '_Z7get_argv', as illustrated in the following trimmed assembler output:
main: ... pushq %rax .Lcfi0: .cfi_def_cfa_offset 16 .loc 1 7 0 prologue_end callq _Z7get_argv ... retq
Notes:
- This patch does not change the LLDB test cases that were failing with a previous patch.
- As per reference, there are 2 previous related revisions:
https://reviews.llvm.org/D37625
Closed by commit rL313047
Reverted in rL313057 as it was causing buildbot failure (lldb inline stepping tests).
https://reviews.llvm.org/D39283
Patch with the required changes to the failing tests.
After some discussions with Tamas, it was clear that changing the test cases was not an optimal solution.
This revision should be abandoned.
Can you explain why this is necessary / convince me that this is also true for shrink-wrapped code? I could imagine that for shrink-wrapped code, where the frame setup is sunk to the latest possible point it would still be useful to know accurate line numbers for code before the frame setup.