gdb/gdb-symtab-fix-too-many-symbols-in-gdbpy_lookup_stat.patch
Tom de Vries 7cb3ecbb8b - Patches added (manual import from fedora rawhide @ 52a4dab):
* gdb-rhbz1773651-gdb-index-internal-error.patch
- Patches added (backport from master):
  * gdb-support-rseq-auxvs.patch
  * gdb-symtab-fix-line-number-of-static-const-class-mem.patch
  * gdb-symtab-fix-too-many-symbols-in-gdbpy_lookup_stat.patch
  * gdb-symtab-handle-pu-in-iterate_over_some_symtabs.patch
  * gdb-symtab-work-around-pr-gas-29517.patch
  * gdb-testsuite-add-kfail-for-pr-ada-30908.patch
  * gdb-testsuite-add-xfail-for-gdb-29965-in-gdb.threads.patch
  * gdb-testsuite-fix-gdb.ada-mi_task_arg.exp-with-newer.patch
  * gdb-testsuite-fix-gdb.arch-i386-signal.exp-on-x86_64.patch
  * gdb-testsuite-fix-gdb.cp-m-static.exp-regression-on-.patch
  * gdb-testsuite-fix-gdb.dwarf2-nullptr_t.exp-with-cc-w.patch
  * gdb-testsuite-fix-regexps-in-gdb.base-step-over-sysc.patch
  * gdb-symtab-find-main-language-without-symtab-expansi.patch
  * gdb-testsuite-add-wait-for-index-cache-in-gdb.dwarf2.patch
- Patches moved (from "Backport from gdb-patches" to
  "Backports from master, available in next release"):
  * gdb-cli-handle-pending-c-after-rl_callback_read_char.patch
  * gdb-testsuite-add-have_host_locale.patch
- Maintenance script qa.sh:
  * Remove PR28463, PR28108, PR29247 and PR29160 kfails.
  * Remove PR30540, PR30908, PR29965 kfails.
  * Remove gdb.ada/mi_task_arg.exp kfail.
- Limit "Suggests: %{python}-Pygments" to SLE-15 and later.

OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=365
2023-10-26 08:58:08 +00:00

67 lines
2.0 KiB
Diff

From 1362bc937bd54dbd22dd7b3c7ae9d8ab6ca7bbfc Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Wed, 6 Sep 2023 11:00:01 +0200
Subject: [PATCH 10/12] [gdb/symtab] Fix too many symbols in
gdbpy_lookup_static_symbols
When running test-case gdb.python/py-symbol.exp with target board
cc-with-dwz-m, we run into:
...
(gdb) python print (len (gdb.lookup_static_symbols ('rr')))^M
4^M
(gdb) FAIL: gdb.python/py-symbol.exp: \
print (len (gdb.lookup_static_symbols ('rr')))
...
while with target board unix we have instead:
...
(gdb) python print (len (gdb.lookup_static_symbols ('rr')))^M
2^M
(gdb) PASS: gdb.python/py-symbol.exp: \
print (len (gdb.lookup_static_symbols ('rr')))
...
The problem is that the loop in gdbpy_lookup_static_symbols loops over compunits
representing both CUs and PUs:
...
for (compunit_symtab *cust : objfile->compunits ())
...
When doing a lookup on a PU, the user link is followed until we end up at a CU,
and the lookup is done in that CU.
In other words, when doing a lookup in the loop for a PU we duplicate the
lookup for a CU that is already handled by the loop.
Fix this by skipping PUs in the loop in gdb.lookup_static_symbols.
Tested on x86_64-linux.
PR symtab/25261
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=25261
---
gdb/python/py-symbol.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index b8777966c47..ed4250bc2c7 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -582,9 +582,12 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
{
for (compunit_symtab *cust : objfile->compunits ())
{
- const struct blockvector *bv;
+ /* Skip included compunits to prevent including compunits from
+ being searched twice. */
+ if (cust->user != nullptr)
+ continue;
- bv = cust->blockvector ();
+ const struct blockvector *bv = cust->blockvector ();
const struct block *block = bv->static_block ();
if (block != nullptr)
--
2.35.3