Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Use fully-qualified name in var_decl_name
@ 2026-04-23 19:01 Tom Tromey
  2026-04-24 13:33 ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2026-04-23 19:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

While testing gdb against a version of gnat-llvm that emits
unqualified names (in a hierarchical structure), I found that
gdb.ada/array_of_symbolic_length.exp would fail.

The DWARF in question looks like this:

 <1><11a1>: Abbrev Number: 2 (DW_TAG_module)
    <11a2>   DW_AT_name        : (indirect string, offset: 0xe65): pck
 <2><11a6>: Abbrev Number: 3 (DW_TAG_variable)
    <11a7>   DW_AT_name        : (indirect string, offset: 0xe69): my_length_LAST
[...]
 <3><11df>: Abbrev Number: 5 (DW_TAG_subrange_type)
    <11e0>   DW_AT_type        : <0x12ab>
    <11e4>   DW_AT_upper_bound : <0x11a6>

That is, an array's upper bound refers to my_length_LAST.  gdb
represents this as a PROP_VARIABLE_NAME -- but only the local name of
the variable was used in this case.

This patch changes var_decl_name to use the correct full name for the
variable.
---
 gdb/dwarf2/read.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index bc7b8b46d87..9fa8b704182 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -13397,10 +13397,7 @@ var_decl_name (struct die_info *die, struct dwarf2_cu *cu)
   if (attr == nullptr || !attr->as_boolean ())
     return nullptr;
 
-  attr = dwarf2_attr (die, DW_AT_name, cu);
-  if (attr == nullptr)
-    return nullptr;
-  return attr->as_string ();
+  return dwarf2_full_name (nullptr, die, cu);
 }
 
 /* Parse dwarf attribute if it's a block, reference or constant and put the

base-commit: f797b25fdc7ca4a48c09802082426b71e56898aa
-- 
2.53.0


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

end of thread, other threads:[~2026-05-01 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-23 19:01 [PATCH] Use fully-qualified name in var_decl_name Tom Tromey
2026-04-24 13:33 ` Andrew Burgess
2026-05-01 17:43   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox