From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 4/5] Tests for gdb.InferiorThread.thread_handle
Date: Thu, 28 Feb 2019 02:34:00 -0000 [thread overview]
Message-ID: <20190227193410.25a300f7@f29-4.lan> (raw)
In-Reply-To: <20190227192416.613752c8@f29-4.lan>
gdb/testsuite/ChangeLog:
* gdb.python/py-thrhandle.exp: Add tests for
gdb.InferiorThread.thread_handle.
---
gdb/testsuite/gdb.python/py-thrhandle.exp | 42 ++++++++++++++++++++++++++++---
1 file changed, 39 insertions(+), 3 deletions(-)
diff --git a/gdb/testsuite/gdb.python/py-thrhandle.exp b/gdb/testsuite/gdb.python/py-thrhandle.exp
index 2c905b444f..ec6852b333 100644
--- a/gdb/testsuite/gdb.python/py-thrhandle.exp
+++ b/gdb/testsuite/gdb.python/py-thrhandle.exp
@@ -16,11 +16,12 @@
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@gnu.org
-# This file verifies that gdb.Inferior.thread_from_thread_handle works
-# as expected.
+# This file verifies that methods Inferior.thread_from_thread_handle
+# and InferiorThread.thread_handle work as expected.
-standard_testfile
+load_lib gdb-python.exp
+standard_testfile
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug] != "" } {
return -1
@@ -104,3 +105,38 @@ gdb_test "python print(gdb.selected_inferior().thread_from_thread_handle(gdb.par
gdb_test "python print(gdb.selected_inferior().thread_from_thread_handle(gdb.parse_and_eval('\"S\"')))" \
".*Thread handle size mismatch.*" \
"Pass too small of an object to thread_from_thread_handle"
+
+# Test the thread_handle method
+
+gdb_py_test_silent_cmd "python tp=gdb.lookup_type('pthread_t')" \
+ "Get pthread_t type" 0
+gdb_py_test_silent_cmd "python inf=gdb.selected_inferior()" "Get inferior" 0
+
+foreach thrN {0 1 2} {
+ with_test_prefix "thread $thrN" {
+
+ gdb_py_test_silent_cmd \
+ "python hand = gdb.parse_and_eval('thrs\[$thrN\]')" \
+ "fetch thread handle from inferior" \
+ 1
+
+ gdb_py_test_silent_cmd \
+ "python hand_bytes = inf.thread_from_thread_handle(hand).thread_handle()" \
+ "fetch thread handle from thread" \
+ 1
+
+
+ # It'd be nice to be able to use this comparison expression:
+ #
+ # hand == hand_bytes
+ #
+ # But this won't work because hand is a gdb.Value and hand_bytes
+ # is a Python bytes object. Therefore, we convert the bytes
+ # object into a gdb.value by calling the two argument form of
+ # its constructor.
+
+ gdb_test "python print(gdb.Value(hand_bytes, tp) == hand)" \
+ "True" \
+ "verify that handles are the same"
+ }
+}
next prev parent reply other threads:[~2019-02-28 2:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-28 2:24 [PATCH v2 0/5] Add python method gdb.InferiorThread.thread_handle Kevin Buettner
2019-02-28 2:30 ` [PATCH v2 1/5] Introduce target_ops method thread_info_to_thread_handle Kevin Buettner
2019-03-05 21:44 ` Tom Tromey
2019-02-28 2:31 ` [PATCH v2 2/5] Add python method InferiorThread.thread_handle Kevin Buettner
2019-03-05 21:48 ` Tom Tromey
2019-03-20 20:24 ` Kevin Buettner
2019-03-20 20:39 ` Tom Tromey
2019-03-20 20:48 ` Kevin Buettner
2019-02-28 2:32 ` [PATCH v2 3/5] Support buffer objects as handles in Inferior.thread_from_thread_handle() Kevin Buettner
2019-03-05 21:51 ` Tom Tromey
2019-02-28 2:34 ` Kevin Buettner [this message]
2019-03-05 21:54 ` [PATCH v2 4/5] Tests for gdb.InferiorThread.thread_handle Tom Tromey
2019-02-28 2:35 ` [PATCH v2 5/5] Documentation for python method InferiorThread.thread_handle Kevin Buettner
2019-02-28 18:06 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190227193410.25a300f7@f29-4.lan \
--to=kevinb@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox