* [PATCH] [gdb/symtab] Don't deduplicate variables in gdb-index
@ 2023-08-04 17:35 Tom de Vries
2023-08-13 4:11 ` Kevin Buettner
0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2023-08-04 17:35 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
When running test-case gdb.python/py-symbol.exp with target board
cc-with-gdb-index, we run into:
...
(gdb) python print (len (gdb.lookup_static_symbols ('rr')))^M
1^M
(gdb) FAIL: gdb.python/py-symbol.exp: print (len (gdb.lookup_static_symbols ('rr')))
...
[ Note that the test-case contains rr in both py-symtab.c:
...
static int __attribute__ ((used)) rr = 42; /* line of rr */
...
and py-symtab-2.c:
...
static int __attribute__ ((used)) rr = 99; /* line of other rr */
... ]
This passes with gdb-12-branch, and fails with gdb-13-branch.
AFAIU the current code in symtab_index_entry::minimize makes the assumption
that it's fine to store only one copy of rr in the gdb-index, because
"print rr" will only ever print one, and always the same.
But that fails to recognize that gdb supports gdb.lookup_static_symbols, which
returns a list of variables rather than the first one.
In other words, the current approach break feature parity between cooked index
and gdb-index.
Note btw that also debug-names has both instances:
...
[ 5] #00597969 rr:
<4> DW_TAG_variable DW_IDX_compile_unit=3 DW_IDX_GNU_internal=1
<4> DW_TAG_variable DW_IDX_compile_unit=4 DW_IDX_GNU_internal=1
...
Fix this in symtab_index_entry::minimize, by not deduplicating variables.
Tested on x86_64-linux, with target boards unix and cc-with-gdb-index.
PR symtab/30720
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30720
---
gdb/dwarf2/index-write.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index 66c5378d677..c3bc537521e 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -294,7 +294,7 @@ symtab_index_entry::minimize ()
auto from = std::unique (cu_indices.begin (), cu_indices.end ());
cu_indices.erase (from, cu_indices.end ());
- /* We don't want to enter a variable or type more than once, so
+ /* We don't want to enter a variable more than once, so
remove any such duplicates from the list as well. When doing
this, we want to keep the entry from the first CU -- but this is
implicit due to the sort. This choice is done because it's
@@ -304,8 +304,7 @@ symtab_index_entry::minimize ()
[&] (offset_type val)
{
gdb_index_symbol_kind kind = GDB_INDEX_SYMBOL_KIND_VALUE (val);
- if (kind != GDB_INDEX_SYMBOL_KIND_TYPE
- && kind != GDB_INDEX_SYMBOL_KIND_VARIABLE)
+ if (kind != GDB_INDEX_SYMBOL_KIND_TYPE)
return false;
val &= ~GDB_INDEX_CU_MASK;
base-commit: 0133072f87b7ac0791413870876a0769ca7d44e0
--
2.35.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [gdb/symtab] Don't deduplicate variables in gdb-index
2023-08-04 17:35 [PATCH] [gdb/symtab] Don't deduplicate variables in gdb-index Tom de Vries
@ 2023-08-13 4:11 ` Kevin Buettner
2023-08-13 21:29 ` Tom de Vries
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2023-08-13 4:11 UTC (permalink / raw)
To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries, Tom Tromey
On Fri, 4 Aug 2023 19:35:42 +0200
Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> wrote:
> Fix this in symtab_index_entry::minimize, by not deduplicating variables.
>
> Tested on x86_64-linux, with target boards unix and cc-with-gdb-index.
LGTM.
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [gdb/symtab] Don't deduplicate variables in gdb-index
2023-08-13 4:11 ` Kevin Buettner
@ 2023-08-13 21:29 ` Tom de Vries
0 siblings, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2023-08-13 21:29 UTC (permalink / raw)
To: Kevin Buettner, Tom de Vries via Gdb-patches; +Cc: Tom Tromey
On 8/13/23 06:11, Kevin Buettner wrote:
> On Fri, 4 Aug 2023 19:35:42 +0200
> Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> wrote:
>
>> Fix this in symtab_index_entry::minimize, by not deduplicating variables.
>>
>> Tested on x86_64-linux, with target boards unix and cc-with-gdb-index.
>
> LGTM.
>
Hi Kevin,
thanks for the review, I've pushed this after fixing a typo in the log
message and a nit the updated comment.
Thanks,
- Tom
> Reviewed-by: Kevin Buettner <kevinb@redhat.com>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-13 21:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-04 17:35 [PATCH] [gdb/symtab] Don't deduplicate variables in gdb-index Tom de Vries
2023-08-13 4:11 ` Kevin Buettner
2023-08-13 21:29 ` Tom de Vries
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).