This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/2] Check for line notes on GCC as well as Clang
- From: Alan Hayward <Alan dot Hayward at arm dot com>
- To: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Cc: nd <nd at arm dot com>, Alan Hayward <Alan dot Hayward at arm dot com>
- Date: Wed, 24 Oct 2018 09:04:39 +0000
- Subject: [PATCH 2/2] Check for line notes on GCC as well as Clang
- References: <20181024090427.22721-1-alan.hayward@arm.com>
i386 and amd64 only skip the prologue using line notes if the compiler is
Clang. Also allow this for GCC.
With this change we can revert ovldbreak.exp back to only allowing line 49
as the breakpoint for main.
Fixes over 50 tests on Ubuntu x86_64.
Note: Many other targets do NOT have any Clang/GNU check - they allow any
valid result from skip_prologue_using_sal. Maybe that is the better fix
here. However, I was erring on the side of caution.
gdb/ChangeLog:
2018-10-24 Alan Hayward <alan.hayward@arm.com>
* amd64-tdep.c (amd64_skip_prologue): Add GNU check.
* i386-tdep.c (i386_skip_prologue): Likewise.
gdb/testsuite/ChangeLog:
2018-10-24 Alan Hayward <alan.hayward@arm.com>
* gdb.cp/ovldbreak.exp: Only allow line 49 for main breakpoint.
---
gdb/amd64-tdep.c | 7 ++++---
gdb/i386-tdep.c | 7 ++++---
gdb/testsuite/gdb.cp/ovldbreak.exp | 2 +-
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 088542d72b..cda462b5d8 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -2474,12 +2474,13 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
= skip_prologue_using_sal (gdbarch, func_addr);
struct compunit_symtab *cust = find_pc_compunit_symtab (func_addr);
- /* Clang always emits a line note before the prologue and another
- one after. We trust clang to emit usable line notes. */
+ /* Clang/GCC always emits a line note before the prologue and another
+ one after. We trust Clang/GCC to emit usable line notes. */
if (post_prologue_pc
&& (cust != NULL
&& COMPUNIT_PRODUCER (cust) != NULL
- && startswith (COMPUNIT_PRODUCER (cust), "clang ")))
+ && (startswith (COMPUNIT_PRODUCER (cust), "clang ")
+ || startswith (COMPUNIT_PRODUCER (cust), "GNU "))))
return std::max (start_pc, post_prologue_pc);
}
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index a6994aaf12..73e1c6c420 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -1844,12 +1844,13 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
= skip_prologue_using_sal (gdbarch, func_addr);
struct compunit_symtab *cust = find_pc_compunit_symtab (func_addr);
- /* Clang always emits a line note before the prologue and another
- one after. We trust clang to emit usable line notes. */
+ /* Clang/GCC always emits a line note before the prologue and another
+ one after. We trust Clang/GCC to emit usable line notes. */
if (post_prologue_pc
&& (cust != NULL
&& COMPUNIT_PRODUCER (cust) != NULL
- && startswith (COMPUNIT_PRODUCER (cust), "clang ")))
+ && (startswith (COMPUNIT_PRODUCER (cust), "clang ")
+ || startswith (COMPUNIT_PRODUCER (cust), "GNU "))))
return std::max (start_pc, post_prologue_pc);
}
diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp
index f3f329d293..a2f5620ca8 100644
--- a/gdb/testsuite/gdb.cp/ovldbreak.exp
+++ b/gdb/testsuite/gdb.cp/ovldbreak.exp
@@ -209,7 +209,7 @@ for {set idx 0} {$idx < [llength $overloads]} {incr idx} {
# Verify the breakpoints.
set bptable "Num\[\t \]+Type\[\t \]+Disp Enb Address\[\t \]+What.*\[\r\n]+"
-append bptable "\[0-9\]+\[\t \]+breakpoint\[\t \]+keep\[\t \]y\[\t \]+$hex\[\t \]+in main(\\((|void)\\))? at.*$srcfile:4\[89\]\[\r\n\]+"
+append bptable "\[0-9\]+\[\t \]+breakpoint\[\t \]+keep\[\t \]y\[\t \]+$hex\[\t \]+in main(\\((|void)\\))? at.*$srcfile:49\[\r\n\]+"
append bptable "\[\t \]+breakpoint already hit 1 time\[\r\n\]+."
foreach ovld $overloads {
append bptable [format "\[0-9\]+\[\t \]+breakpoint\[\t \]+keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(%s\\) at.*$srcfile:%d\[\r\n\]+" $ovld \
--
2.17.1 (Apple Git-112)