diff options
author | Lancelot SIX <lancelot.six@amd.com> | 2022-02-25 23:41:47 +0000 |
---|---|---|
committer | Lancelot SIX <lancelot.six@amd.com> | 2022-04-04 23:03:32 +0100 |
commit | cc96ae7f8839bd63a943751d52af94db3b956c1f (patch) | |
tree | 52e84b6b5ac798fdc470e8011bc8bb050804bf46 /gdb/doc | |
parent | 6cacd78ba5bb705e127d60478c71955b37914c53 (diff) | |
download | gdb-cc96ae7f8839bd63a943751d52af94db3b956c1f.zip gdb-cc96ae7f8839bd63a943751d52af94db3b956c1f.tar.gz gdb-cc96ae7f8839bd63a943751d52af94db3b956c1f.tar.bz2 |
gdb: Add support for DW_LNS_set_prologue_end in line-table
Add support for DW_LNS_set_prologue_end when building line-tables. This
attribute can be set by the compiler to indicate that an instruction is
an adequate place to set a breakpoint just after the prologue of a
function.
The compiler might set multiple prologue_end, but considering how
current skip_prologue_using_sal works, this commit modifies it to accept
the first instruction with this marker (if any) to be the place where a
breakpoint should be placed to be at the end of the prologue.
The need for this support came from a problematic usecase generated by
hipcc (i.e. clang). The problem is as follows: There's a function
(lets call it foo) which covers PC from 0xa800 to 0xa950. The body of
foo begins with a call to an inlined function, covering from 0xa800 to
0xa94c. The issue is that when placing a breakpoint at 'foo', GDB
inserts the breakpoint at 0xa818. The 0x18 offset is what GDB thinks is
foo's first address past the prologue.
Later, when hitting the breakpoint, GDB reports the stop within the
inlined function because the PC falls in its range while the user
expects to stop in FOO.
Looking at the line-table for this location, we have:
INDEX LINE ADDRESS IS-STMT
[...]
14 293 0x000000000000a66c Y
15 END 0x000000000000a6e0 Y
16 287 0x000000000000a800 Y
17 END 0x000000000000a818 Y
18 287 0x000000000000a824 Y
[...]
For comparison, let's look at llvm-dwarfdump's output for this CU:
Address Line Column File ISA Discriminator Flags
------------------ ------ ------ ------ --- ------------- -------------
[...]
0x000000000000a66c 293 12 2 0 0 is_stmt
0x000000000000a6e0 96 43 82 0 0 is_stmt
0x000000000000a6f8 102 18 82 0 0 is_stmt
0x000000000000a70c 102 24 82 0 0
0x000000000000a710 102 18 82 0 0
0x000000000000a72c 101 16 82 0 0 is_stmt
0x000000000000a73c 2915 50 83 0 0 is_stmt
0x000000000000a74c 110 1 1 0 0 is_stmt
0x000000000000a750 110 1 1 0 0 is_stmt end_sequence
0x000000000000a800 107 0 1 0 0 is_stmt
0x000000000000a800 287 12 2 0 0 is_stmt prologue_end
0x000000000000a818 114 59 81 0 0 is_stmt
0x000000000000a824 287 12 2 0 0 is_stmt
0x000000000000a828 100 58 82 0 0 is_stmt
[...]
The main difference we are interested in here is that llvm-dwarfdump's
output tells us that 0xa800 is an adequate place to place a breakpoint
past a function prologue. Since we know that foo covers from 0xa800 to
0xa94c, 0xa800 is the address at which the breakpoint should be placed
if the user wants to break in foo.
This commit proposes to add support for the prologue_end flag in the
line-program processing.
The processing of this prologue_end flag is made in skip_prologue_sal,
before it calls gdbarch_skip_prologue_noexcept. The intent is that if
the compiler gave information on where the prologue ends, we should use
this information and not try to rely on architecture dependent logic to
guess it.
The testsuite have been executed using this patch on GNU/Linux x86_64.
Testcases have been compiled with both gcc/g++ (verison 9.4.0) and
clang/clang++ (version 10.0.0) since at the time of writing GCC does not
set the prologue_end marker. Tests done with GCC 11.2.0 (not over the
entire testsuite) show that it does not emit this flag either.
No regression have been observed with GCC or Clang. Note that when
using Clang, this patch fixes a failure in
gdb.opt/inline-small-func.exp.
Change-Id: I720449a8a9b2e1fb45b54c6095d3b1e9da9152f8
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/gdb.texinfo | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index af02517..14d7581 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -19794,6 +19794,33 @@ line 1574. List the @code{struct linetable} from all @code{struct symtab} instances whose name matches @var{regexp}. If @var{regexp} is not given, list the @code{struct linetable} from all @code{struct symtab}. +For example: + +@smallexample +(@value{GDBP}) maint info line-table +objfile: /home/gnu/build/a.out ((struct objfile *) 0x6120000e0d40) +compunit_symtab: simple.cpp ((struct compunit_symtab *) 0x6210000ff450) +symtab: /home/gnu/src/simple.cpp ((struct symtab *) 0x6210000ff4d0) +linetable: ((struct linetable *) 0x62100012b760): +INDEX LINE ADDRESS IS-STMT PROLOGUE-END +0 3 0x0000000000401110 Y +1 4 0x0000000000401114 Y Y +2 9 0x0000000000401120 Y +3 10 0x0000000000401124 Y Y +4 10 0x0000000000401129 +5 15 0x0000000000401130 Y +6 16 0x0000000000401134 Y Y +7 16 0x0000000000401139 +8 21 0x0000000000401140 Y +9 22 0x000000000040114f Y Y +10 22 0x0000000000401154 +11 END 0x000000000040115a Y +@end smallexample +@noindent +The @samp{IS-STMT} column indicates if the address is a recommended breakpoint +location to represent a line or a statement. The @samp{PROLOGUE-END} column +indicates that a given address is an adequate place to set a breakpoint at the +first instruction following a function prologue. @kindex maint set symbol-cache-size @cindex symbol cache size |