aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-11-12 08:47:09 -0700
committerTom Tromey <tom@tromey.com>2020-11-12 08:47:09 -0700
commit1f2624a35413c31c317e5da8ce7401b59ecfbfa5 (patch)
treede75c4db6e08432ce1bf00fae7a2855593e5dab5
parent9e74f0aef6a73dba185161558cebace2ed9a54e5 (diff)
downloadgdb-1f2624a35413c31c317e5da8ce7401b59ecfbfa5.zip
gdb-1f2624a35413c31c317e5da8ce7401b59ecfbfa5.tar.gz
gdb-1f2624a35413c31c317e5da8ce7401b59ecfbfa5.tar.bz2
Fix Rust regression with -readnow
PR rust/26799 points out that a certain test case fails with -readnow. This happens because, with -readnow, there are no partial symtabs; but find_symbol_at_address requires these. This patch fixes this problem by searching all of an objfile's compunit symtabs if it does not have partial symbols. Note that this test will still fail with .gdb_index. I don't think that is readily fixable. gdb/ChangeLog 2020-11-12 Tom Tromey <tom@tromey.com> PR rust/26799: * symtab.c (find_symbol_at_address): Search symtabs if no psymtabs exist. gdb/testsuite/ChangeLog 2020-11-12 Tom Tromey <tom@tromey.com> PR rust/26799: * gdb.rust/traits.exp: Remove kfails.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/symtab.c59
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.rust/traits.exp6
4 files changed, 52 insertions, 24 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b24fdb5..038d45f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2020-11-12 Tom Tromey <tom@tromey.com>
+
+ PR rust/26799:
+ * symtab.c (find_symbol_at_address): Search symtabs if no psymtabs
+ exist.
+
2020-11-12 Andrew Burgess <andrew.burgess@embecosm.com>
* features/Makefile (XMLTOC): Add rx.xml.
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 5cc875f..dccc3d1 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3024,30 +3024,53 @@ find_pc_compunit_symtab (CORE_ADDR pc)
struct symbol *
find_symbol_at_address (CORE_ADDR address)
{
- for (objfile *objfile : current_program_space->objfiles ())
+ /* A helper function to search a given symtab for a symbol matching
+ ADDR. */
+ auto search_symtab = [] (compunit_symtab *symtab, CORE_ADDR addr) -> symbol *
{
- if (objfile->sf == NULL
- || objfile->sf->qf->find_compunit_symtab_by_address == NULL)
- continue;
+ const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (symtab);
- struct compunit_symtab *symtab
- = objfile->sf->qf->find_compunit_symtab_by_address (objfile, address);
- if (symtab != NULL)
+ for (int i = GLOBAL_BLOCK; i <= STATIC_BLOCK; ++i)
{
- const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (symtab);
+ const struct block *b = BLOCKVECTOR_BLOCK (bv, i);
+ struct block_iterator iter;
+ struct symbol *sym;
- for (int i = GLOBAL_BLOCK; i <= STATIC_BLOCK; ++i)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
- const struct block *b = BLOCKVECTOR_BLOCK (bv, i);
- struct block_iterator iter;
- struct symbol *sym;
+ if (SYMBOL_CLASS (sym) == LOC_STATIC
+ && SYMBOL_VALUE_ADDRESS (sym) == addr)
+ return sym;
+ }
+ }
+ return nullptr;
+ };
- ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- if (SYMBOL_CLASS (sym) == LOC_STATIC
- && SYMBOL_VALUE_ADDRESS (sym) == address)
- return sym;
- }
+ for (objfile *objfile : current_program_space->objfiles ())
+ {
+ /* If this objfile doesn't have "quick" functions, then it may
+ have been read with -readnow, in which case we need to search
+ the symtabs directly. */
+ if (objfile->sf == NULL
+ || objfile->sf->qf->find_compunit_symtab_by_address == NULL)
+ {
+ for (compunit_symtab *symtab : objfile->compunits ())
+ {
+ struct symbol *sym = search_symtab (symtab, address);
+ if (sym != nullptr)
+ return sym;
+ }
+ }
+ else
+ {
+ struct compunit_symtab *symtab
+ = objfile->sf->qf->find_compunit_symtab_by_address (objfile,
+ address);
+ if (symtab != NULL)
+ {
+ struct symbol *sym = search_symtab (symtab, address);
+ if (sym != nullptr)
+ return sym;
}
}
}
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ecac8bb..f23721e 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-11-12 Tom Tromey <tom@tromey.com>
+
+ PR rust/26799:
+ * gdb.rust/traits.exp: Remove kfails.
+
2020-11-12 Gary Benson <gbenson@redhat.com>
* gdb.threads/tls-so_extern_main.c (tls_ptr): Add missing return
diff --git a/gdb/testsuite/gdb.rust/traits.exp b/gdb/testsuite/gdb.rust/traits.exp
index d237b92..73a75b0 100644
--- a/gdb/testsuite/gdb.rust/traits.exp
+++ b/gdb/testsuite/gdb.rust/traits.exp
@@ -45,11 +45,5 @@ if {![runto ${srcfile}:$line]} {
set readnow_p [readnow $binfile]
-if { $readnow_p } {
- setup_kfail "gdb/26799" *-*-*
-}
gdb_test "print *td" " = 23.5"
-if { $readnow_p } {
- setup_kfail "gdb/26799" *-*-*
-}
gdb_test "print *tu" " = 23"