diff options
author | Lancelot SIX <lancelot.six@amd.com> | 2022-04-01 11:59:29 +0100 |
---|---|---|
committer | Lancelot SIX <lancelot.six@amd.com> | 2022-04-04 23:03:32 +0100 |
commit | 6109f7a39eb956a4121875630895669cece178e8 (patch) | |
tree | 9ed947e4bf5a59faa744137f4ccbf58bcf60d71f /gdb | |
parent | cc96ae7f8839bd63a943751d52af94db3b956c1f (diff) | |
download | gdb-6109f7a39eb956a4121875630895669cece178e8.zip gdb-6109f7a39eb956a4121875630895669cece178e8.tar.gz gdb-6109f7a39eb956a4121875630895669cece178e8.tar.bz2 |
gdb: Add maint set ignore-prologue-end-flag
The previous patch added support for the DWARF prologue-end flag in line
table. This flag can be used by DWARF producers to indicate where to
place breakpoints past a function prologue. However, this takes
precedence over prologue analyzers. So if we have to debug a program
with erroneous debug information, the overall debugging experience will
be degraded.
This commit proposes to add a maintenance command to instruct GDB to
ignore the prologue_end flag.
Tested on x86_64-gnu-linux.
Change-Id: Idda6d1b96ba887f4af555b43d9923261b9cc6f82
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/NEWS | 9 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 13 | ||||
-rw-r--r-- | gdb/symtab.c | 19 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp | 14 |
4 files changed, 54 insertions, 1 deletions
@@ -14,6 +14,15 @@ emit to indicate where a breakpoint should be placed to break in a function past its prologue. +* New commands + +maintenance set ignore-prologue-end-flag on|off +maintenance show ignore-prologue-end-flag + This setting, which is off by default, controls whether GDB ignores the + PROLOGUE-END flag from the line-table when skipping prologue. This can be + used to force GDB to use prologue analyzers if the line-table is constructed + from erroneous debug information. + * Changed commands maintenance info line-table diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 14d7581..b7da5e1 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -19857,6 +19857,19 @@ when collecting performance data. The command @code{maint flush-symbol-cache} is deprecated in favor of @code{maint flush symbol-cache}.. +@kindex maint set ignore-prologue-end-flag +@cindex prologue-end +@item maint set ignore-prologue-end-flag [on|off] +Enable or disable the use of the @samp{PROLOGUE-END} flag from the line-table. +When @samp{off} (the default), @value{GDBN} uses the @samp{PROLOGUE-END} flag +to place breakpoints past the end of a function prologue. When @samp{on}, +@value{GDBN} ignores the flag and relies on prologue analyzers to skip function +prologues. + +@kindex maint show ignore-prologue-end-flag +@item maint show ignore-prologue-end-flag +Show whether @value{GDBN} will ignore the @samp{PROLOGUE-END} flag. + @end table @node Altering diff --git a/gdb/symtab.c b/gdb/symtab.c index 57a55a5..4204423 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -288,6 +288,10 @@ static const char *const multiple_symbols_modes[] = }; static const char *multiple_symbols_mode = multiple_symbols_all; +/* When TRUE, ignore the prologue-end flag in linetable_entry when searching + for the SAL past a function prologue. */ +static bool ignore_prologue_end_flag = false; + /* Read-only accessor to AUTO_SELECT_MODE. */ const char * @@ -3941,7 +3945,7 @@ skip_prologue_sal (struct symtab_and_line *sal) /* Check if the compiler explicitly indicated where a breakpoint should be placed to skip the prologue. */ - if (skip) + if (!ignore_prologue_end_flag && skip) { gdb::optional<CORE_ADDR> linetable_pc = skip_prologue_using_linetable (pc); @@ -7113,6 +7117,19 @@ If zero then the symbol cache is disabled."), &maintenance_set_cmdlist, &maintenance_show_cmdlist); + add_setshow_boolean_cmd ("ignore-prologue-end-flag", no_class, + &ignore_prologue_end_flag, + _("Set if the PROLOGUE-END flag is ignored."), + _("Show if the PROLOGUE-END flag is ignored."), + _("\ +The PROLOGUE-END flag from the line-table entries is used to place \ +breakpoints past the prologue of functions. Disabeling its use use forces \ +the use of prologue scanners."), + nullptr, nullptr, + &maintenance_set_cmdlist, + &maintenance_show_cmdlist); + + add_cmd ("symbol-cache", class_maintenance, maintenance_print_symbol_cache, _("Dump the symbol cache for each program space."), &maintenanceprintlist); diff --git a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp index 0de13ae..b5f8bcc 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp @@ -89,3 +89,17 @@ if ![runto_main] { set prologue_end_line [gdb_get_line_number "main assign o"] gdb_test "frame" ".*main \\\(\\\) at \[^\r\n\]*:$prologue_end_line\r\n.*" + +with_test_prefix "ignore-prologue-end" { + clean_restart $binfile + gdb_test_no_output "maintenance set ignore-prologue-end-flag on" + + if ![runto_main] { + return -1 + } + + # If we ignore the prologue-end flag, we should stop at the first statement + # of main which assigns m. + set prologue_end_line [gdb_get_line_number "main assign m"] + gdb_test "frame" ".*main \\\(\\\) at \[^\r\n\]*:$prologue_end_line\r\n.*" +} |