aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/py-infthread.exp
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2024-01-09 17:29:24 +0000
committerAndrew Burgess <aburgess@redhat.com>2024-01-12 09:22:25 +0000
commit76118e1675f5eaf3fc44524ec435981705572629 (patch)
tree4f4351eece10850ac947757b538a795a72e43491 /gdb/testsuite/gdb.python/py-infthread.exp
parent322ffd247e4e95a0d5a1b11ad1ef91f3378e6174 (diff)
downloadgdb-76118e1675f5eaf3fc44524ec435981705572629.zip
gdb-76118e1675f5eaf3fc44524ec435981705572629.tar.gz
gdb-76118e1675f5eaf3fc44524ec435981705572629.tar.bz2
gdb/python: New InferiorThread.ptid_string attribute
This commit adds a new InferiorThread.ptid_string attribute. This read-only attribute contains the string returned by target_pid_to_str, which actually converts a ptid (not pid) to a string. This is the string that appears (at least in part) in the output of 'info threads' in the 'Target Id' column, but also in the thread exited message that GDB prints. Having access to this string from Python is useful for allowing extensions identify threads in a similar way to how GDB core would identify the thread. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/testsuite/gdb.python/py-infthread.exp')
-rw-r--r--gdb/testsuite/gdb.python/py-infthread.exp8
1 files changed, 8 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-infthread.exp b/gdb/testsuite/gdb.python/py-infthread.exp
index 0b10ce9..3b07d84 100644
--- a/gdb/testsuite/gdb.python/py-infthread.exp
+++ b/gdb/testsuite/gdb.python/py-infthread.exp
@@ -62,6 +62,14 @@ gdb_test "python print ('result = %s' % t0.num)" " = 1" "test InferiorThread.num
gdb_test "python print ('result = %s' % t0.global_num)" " = 1" "test InferiorThread.global_num"
gdb_test "python print ('result = %s' % str (t0.ptid))" " = \\(\[0-9\]+, \[0-9\]+, \[0-9\]+\\)" "test InferiorThread.ptid"
+# Test the InferiorThread.ptid_string attribute. We don't test the
+# actual string contents as they vary based on target, but we check
+# that we get back a non-empty string.
+gdb_test "python print(type(t0.ptid_string))" "<class 'str'>" \
+ "check that InferiorThread.ptid_string is a string"
+gdb_test "python print(t0.ptid_string)" ".+" \
+ "check that InferiorThread.ptid_string is non-empty"
+
gdb_py_test_silent_cmd "python i0 = t0.inferior" "test InferiorThread.inferior" 1
gdb_test "python print ('result = %s' % i0.num)" " = 1" "test Inferior.num"