From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Use fully-qualified name in var_decl_name
Date: Thu, 23 Apr 2026 13:01:09 -0600 [thread overview]
Message-ID: <20260423190109.1274057-1-tromey@adacore.com> (raw)
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
next reply other threads:[~2026-04-23 19:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 19:01 Tom Tromey [this message]
2026-04-24 13:33 ` Andrew Burgess
2026-05-01 17:43 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260423190109.1274057-1-tromey@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox