public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] [gdb/tdep] Two fixes for gdb.arch/pr25124.exp
@ 2024-11-29 16:09 Tom de Vries
  2024-11-29 16:09 ` [PATCH 1/2] [gdb/symtab] Apply workaround for PR gas/31115 a bit more Tom de Vries
  2024-11-29 16:09 ` [PATCH 2/2] [gdb/testsuite] Fix DUPLICATE in gdb.arch/pr25124.exp Tom de Vries
  0 siblings, 2 replies; 6+ messages in thread
From: Tom de Vries @ 2024-11-29 16:09 UTC (permalink / raw)
  To: gdb-patches

This series contains two patches for test-case gdb.arch/pr25124.exp on
arm-linux.

The first patch fixes a regression.

The second patch fixes a DUPLICATE.

Tom de Vries (2):
  [gdb/symtab] Apply workaround for PR gas/31115 a bit more
  [gdb/testsuite] Fix DUPLICATE in gdb.arch/pr25124.exp

 gdb/dwarf2/read.c                  | 41 ++++++++++++++++++++++--------
 gdb/testsuite/gdb.arch/pr25124.exp |  4 +--
 2 files changed, 33 insertions(+), 12 deletions(-)


base-commit: 2727c14ec4bc97c683fa07fab022d6d00410c963
-- 
2.35.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] [gdb/symtab] Apply workaround for PR gas/31115 a bit more
  2024-11-29 16:09 [PATCH 0/2] [gdb/tdep] Two fixes for gdb.arch/pr25124.exp Tom de Vries
@ 2024-11-29 16:09 ` Tom de Vries
  2024-12-02 12:09   ` Alexandra Petlanova Hajkova
  2024-11-29 16:09 ` [PATCH 2/2] [gdb/testsuite] Fix DUPLICATE in gdb.arch/pr25124.exp Tom de Vries
  1 sibling, 1 reply; 6+ messages in thread
From: Tom de Vries @ 2024-11-29 16:09 UTC (permalink / raw)
  To: gdb-patches

In commit 8a61ee551ce ("[gdb/symtab] Workaround PR gas/31115"), I applied a
workaround for PR gas/31115 in read_func_scope, fixing test-case
gdb.arch/pr25124.exp.

Recently I noticed that the test-case is failing again.

Fix this by factoring out the workaround into a new function fixup_low_high_pc
and applying it in dwarf2_die_base_address.

While we're at it, do the same in dwarf2_record_block_ranges.

Tested on arm-linux with target boards unix/-marm and unix/-mthumb.
---
 gdb/dwarf2/read.c | 41 +++++++++++++++++++++++++++++++----------
 1 file changed, 31 insertions(+), 10 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 5a284be1f90..2890799b761 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9989,6 +9989,30 @@ check_ada_pragma_import (struct die_info *die, struct dwarf2_cu *cu)
   return true;
 }
 
+/* Apply fixups to LOW_PC and HIGH_PC due to an incorrect DIE in CU.  */
+
+static void
+fixup_low_high_pc (struct dwarf2_cu *cu, struct die_info *die, CORE_ADDR *low_pc,
+		   CORE_ADDR *high_pc)
+{
+  if (die->tag != DW_TAG_subprogram)
+    return;
+
+  dwarf2_per_objfile *per_objfile = cu->per_objfile;
+  struct objfile *objfile = per_objfile->objfile;
+  struct gdbarch *gdbarch = objfile->arch ();
+
+  if (gdbarch_bfd_arch_info (gdbarch)->arch == bfd_arch_arm
+      && producer_is_gas_ge_2_39 (cu))
+    {
+      /* Gas version 2.39 produces DWARF for a Thumb subprogram with a low_pc
+	 attribute with the thumb bit set (PR gas/31115).  Work around this.  */
+      *low_pc = gdbarch_addr_bits_remove (gdbarch, *low_pc);
+      if (high_pc != nullptr)
+	*high_pc = gdbarch_addr_bits_remove (gdbarch, *high_pc);
+    }
+}
+
 static void
 read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
 {
@@ -10068,15 +10092,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
 
   lowpc = per_objfile->relocate (unrel_low);
   highpc = per_objfile->relocate (unrel_high);
-
-  if (gdbarch_bfd_arch_info (gdbarch)->arch == bfd_arch_arm
-      && producer_is_gas_ge_2_39 (cu))
-    {
-      /* Gas version 2.39 produces DWARF for a Thumb subprogram with a low_pc
-	 attribute with the thumb bit set (PR gas/31115).  Work around this.  */
-      lowpc = gdbarch_addr_bits_remove (gdbarch, lowpc);
-      highpc = gdbarch_addr_bits_remove (gdbarch, highpc);
-    }
+  fixup_low_high_pc (cu, die, &lowpc, &highpc);
 
   /* If we have any template arguments, then we must allocate a
      different sort of symbol.  */
@@ -11336,7 +11352,11 @@ dwarf2_die_base_address (struct die_info *die, struct block *block,
 
   struct attribute *attr = dwarf2_attr (die, DW_AT_low_pc, cu);
   if (attr != nullptr)
-    return per_objfile->relocate (attr->as_address ());
+    {
+      CORE_ADDR res = per_objfile->relocate (attr->as_address ());
+      fixup_low_high_pc (cu, die, &res, nullptr);
+      return res;
+    }
   else if (block->ranges ().size () > 0)
     return block->ranges ()[0].start ();
 
@@ -11443,6 +11463,7 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
 
 	  CORE_ADDR low = per_objfile->relocate (unrel_low);
 	  CORE_ADDR high = per_objfile->relocate (unrel_high);
+	  fixup_low_high_pc (cu, die, &low, &high);
 	  cu->get_builder ()->record_block_range (block, low, high - 1);
 	}
     }
-- 
2.35.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] [gdb/testsuite] Fix DUPLICATE in gdb.arch/pr25124.exp
  2024-11-29 16:09 [PATCH 0/2] [gdb/tdep] Two fixes for gdb.arch/pr25124.exp Tom de Vries
  2024-11-29 16:09 ` [PATCH 1/2] [gdb/symtab] Apply workaround for PR gas/31115 a bit more Tom de Vries
@ 2024-11-29 16:09 ` Tom de Vries
  2024-12-03 17:34   ` Tom Tromey
  1 sibling, 1 reply; 6+ messages in thread
From: Tom de Vries @ 2024-11-29 16:09 UTC (permalink / raw)
  To: gdb-patches

With test-case gdb.arch/pr25124.exp, I run into:
...
PASS: gdb.arch/pr25124.exp: disassemble thumb instruction (1st try)
PASS: gdb.arch/pr25124.exp: disassemble thumb instruction (2nd try)
DUPLICATE: gdb.arch/pr25124.exp: disassemble thumb instruction (2nd try)
...

Fix this by using a comma instead of parentheses.

Tested on arm-linux.
---
 gdb/testsuite/gdb.arch/pr25124.exp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/pr25124.exp b/gdb/testsuite/gdb.arch/pr25124.exp
index 3bf08a178ec..26cfc1368a0 100644
--- a/gdb/testsuite/gdb.arch/pr25124.exp
+++ b/gdb/testsuite/gdb.arch/pr25124.exp
@@ -30,7 +30,7 @@ clean_restart $binfile
 # Check if the disassemble ouput is correct.
 gdb_test "x /i main+8" \
 	"$hex <main\\+8>:\[ \t\]+bx\[ \t\]+lr" \
-	"disassemble thumb instruction (1st try)"
+	"disassemble thumb instruction, 1st try"
 
 # Reload the symbol file to trigger the bug.
 gdb_load ${binfile}
@@ -38,4 +38,4 @@ gdb_load ${binfile}
 # Check if the disassemble output is the same as above.
 gdb_test "x /i main+8" \
 	"$hex <main\\+8>:\[ \t\]+bx\[ \t\]+lr" \
-	"disassemble thumb instruction (2nd try)"
+	"disassemble thumb instruction, 2nd try"
-- 
2.35.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] [gdb/symtab] Apply workaround for PR gas/31115 a bit more
  2024-11-29 16:09 ` [PATCH 1/2] [gdb/symtab] Apply workaround for PR gas/31115 a bit more Tom de Vries
@ 2024-12-02 12:09   ` Alexandra Petlanova Hajkova
  2024-12-09 17:20     ` Tom de Vries
  0 siblings, 1 reply; 6+ messages in thread
From: Alexandra Petlanova Hajkova @ 2024-12-02 12:09 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 767 bytes --]

On Fri, Nov 29, 2024 at 5:08 PM Tom de Vries <tdevries@suse.de> wrote:

> In commit 8a61ee551ce ("[gdb/symtab] Workaround PR gas/31115"), I applied a
> workaround for PR gas/31115 in read_func_scope, fixing test-case
> gdb.arch/pr25124.exp.
>
> Recently I noticed that the test-case is failing again.
>
> Fix this by factoring out the workaround into a new function
> fixup_low_high_pc
> and applying it in dwarf2_die_base_address.
>
> While we're at it, do the same in dwarf2_record_block_ranges.
>
> Tested on arm-linux with target boards unix/-marm and unix/-mthumb.
> ---
>
> Hi,
great you fixed this. I've tried this doesn't add any regression on
ppc64le, Fedora Rawhide.

   Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] [gdb/testsuite] Fix DUPLICATE in gdb.arch/pr25124.exp
  2024-11-29 16:09 ` [PATCH 2/2] [gdb/testsuite] Fix DUPLICATE in gdb.arch/pr25124.exp Tom de Vries
@ 2024-12-03 17:34   ` Tom Tromey
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2024-12-03 17:34 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> With test-case gdb.arch/pr25124.exp, I run into:
Tom> ...
Tom> PASS: gdb.arch/pr25124.exp: disassemble thumb instruction (1st try)
Tom> PASS: gdb.arch/pr25124.exp: disassemble thumb instruction (2nd try)
Tom> DUPLICATE: gdb.arch/pr25124.exp: disassemble thumb instruction (2nd try)
Tom> ...

Tom> Fix this by using a comma instead of parentheses.

Seems obvious FWIW.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] [gdb/symtab] Apply workaround for PR gas/31115 a bit more
  2024-12-02 12:09   ` Alexandra Petlanova Hajkova
@ 2024-12-09 17:20     ` Tom de Vries
  0 siblings, 0 replies; 6+ messages in thread
From: Tom de Vries @ 2024-12-09 17:20 UTC (permalink / raw)
  To: Alexandra Petlanova Hajkova; +Cc: gdb-patches

On 12/2/24 13:09, Alexandra Petlanova Hajkova wrote:
> 
> 
> On Fri, Nov 29, 2024 at 5:08 PM Tom de Vries <tdevries@suse.de 
> <mailto:tdevries@suse.de>> wrote:
> 
>     In commit 8a61ee551ce ("[gdb/symtab] Workaround PR gas/31115"), I
>     applied a
>     workaround for PR gas/31115 in read_func_scope, fixing test-case
>     gdb.arch/pr25124.exp.
> 
>     Recently I noticed that the test-case is failing again.
> 
>     Fix this by factoring out the workaround into a new function
>     fixup_low_high_pc
>     and applying it in dwarf2_die_base_address.
> 
>     While we're at it, do the same in dwarf2_record_block_ranges.
> 
>     Tested on arm-linux with target boards unix/-marm and unix/-mthumb.
>     ---
> 
> Hi,
> great you fixed this. I've tried this doesn't add any regression on 
> ppc64le, Fedora Rawhide.
> 
>     Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com 
> <mailto:ahajkova@redhat.com>

Hi Alexandra,

thanks for the review, pushed.

- Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-12-09 17:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-29 16:09 [PATCH 0/2] [gdb/tdep] Two fixes for gdb.arch/pr25124.exp Tom de Vries
2024-11-29 16:09 ` [PATCH 1/2] [gdb/symtab] Apply workaround for PR gas/31115 a bit more Tom de Vries
2024-12-02 12:09   ` Alexandra Petlanova Hajkova
2024-12-09 17:20     ` Tom de Vries
2024-11-29 16:09 ` [PATCH 2/2] [gdb/testsuite] Fix DUPLICATE in gdb.arch/pr25124.exp Tom de Vries
2024-12-03 17:34   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).