aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorJan Vrany <jan.vrany@labware.com>2025-03-19 21:12:53 +0000
committerJan Vrany <jan.vrany@labware.com>2025-03-19 21:12:53 +0000
commit14b8ef758c634e0c1460010f2125799d0588a194 (patch)
tree43aad567be78863c54339271b7d0b2615e72fe24 /gdb/testsuite
parent35ad2b260d39da9990bdff8695eee218b9aa6ead (diff)
downloadbinutils-14b8ef758c634e0c1460010f2125799d0588a194.zip
binutils-14b8ef758c634e0c1460010f2125799d0588a194.tar.gz
binutils-14b8ef758c634e0c1460010f2125799d0588a194.tar.bz2
gdb/python: preserve identity for gdb.Symtab objects
This commit changes symtab_to_symtab_object() so that each it is called with a particular struct symtab * it returns the very same gdb.Symtab object. This is done by searching per-objfile linked list of instances and - if found - return it rather than creating new gdb.Symtab. Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.python/py-symtab.exp28
1 files changed, 28 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-symtab.exp b/gdb/testsuite/gdb.python/py-symtab.exp
index 4765ef5..18d77a0 100644
--- a/gdb/testsuite/gdb.python/py-symtab.exp
+++ b/gdb/testsuite/gdb.python/py-symtab.exp
@@ -90,6 +90,34 @@ gdb_test_multiple "python print (\"simple_struct\" in static_symbols)" \
}
}
+# Test symtab identity
+gdb_test "python print (symtab is symtab)"\
+ "True" \
+ "test symtab identity 1"
+gdb_test "python print (symtab is gdb.selected_frame().find_sal().symtab)"\
+ "True" \
+ "test symtab identity 2"
+gdb_test "python print (sal.symtab is gdb.selected_frame().find_sal().symtab)"\
+ "True" \
+ "test symtab identity 3"
+gdb_test "python print (symtab is not \"xxx\")"\
+ "True" \
+ "test symtab non-identity with non-symtab"
+
+# Test symtab equality
+gdb_test "python print (symtab == symtab)"\
+ "True" \
+ "test symtab equality 1"
+gdb_test "python print (symtab == gdb.selected_frame().find_sal().symtab)"\
+ "True" \
+ "test symtab equality 2"
+gdb_test "python print (sal.symtab == gdb.selected_frame().find_sal().symtab)"\
+ "True" \
+ "test symtab equality 3"
+gdb_test "python print (symtab != \"xxx\")"\
+ "True" \
+ "test symtab non-equality with non-symtab"
+
# Test is_valid when the objfile is unloaded. This must be the last
# test as it unloads the object file in GDB.
gdb_unload