aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/py-progspace.exp
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-05-22 11:40:10 -0600
committerTom Tromey <tromey@adacore.com>2023-07-21 12:05:30 -0600
commit27b2eff1b82f518254bec231650f1b67ee160200 (patch)
treef832c1d5c7b9628815f6a95a60df9c4a1b4356ab /gdb/testsuite/gdb.python/py-progspace.exp
parent672c55ddcf17d322dbc868d8465f0027d8210e73 (diff)
downloadgdb-27b2eff1b82f518254bec231650f1b67ee160200.zip
gdb-27b2eff1b82f518254bec231650f1b67ee160200.tar.gz
gdb-27b2eff1b82f518254bec231650f1b67ee160200.tar.bz2
Add Progspace.objfile_for_address
This adds a new objfile_for_address method to gdb.Progspace. This makes it easy to find the objfile for a given address. There's a related PR; and while this change would have been sufficient for my original need, it's not clear to me whether I should close the bug. Nevertheless I think it makes sense to at least mention it here. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=19288 Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Diffstat (limited to 'gdb/testsuite/gdb.python/py-progspace.exp')
-rw-r--r--gdb/testsuite/gdb.python/py-progspace.exp7
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-progspace.exp b/gdb/testsuite/gdb.python/py-progspace.exp
index 638b279..f0dc208 100644
--- a/gdb/testsuite/gdb.python/py-progspace.exp
+++ b/gdb/testsuite/gdb.python/py-progspace.exp
@@ -68,6 +68,13 @@ if ![is_address_zero_readable] {
gdb_test "python print (gdb.current_progspace ().block_for_pc (0))" "None"
}
+gdb_test "python print(gdb.current_progspace().objfile_for_address(${pc_val}).username)" \
+ ".*py-progspace" \
+ "objfile for pc"
+gdb_test "python print(gdb.current_progspace().objfile_for_address(0))" \
+ "None" \
+ "no objfile for 0"
+
# With a single inferior, progspace.objfiles () and gdb.objfiles () should
# be identical.
gdb_test "python print (progspace.objfiles () == gdb.objfiles ())" "True"