Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 2/5] Add python method InferiorThread.thread_handle
Date: Thu, 28 Feb 2019 02:31:00 -0000	[thread overview]
Message-ID: <20190227193107.5c55cc03@f29-4.lan> (raw)
In-Reply-To: <20190227192416.613752c8@f29-4.lan>

gdb/ChangeLog:

	* python/py-infthread.c (thpy_thread_handle): New function.
	(thread_object_methods): Register thpy_thread_handle.
---
 gdb/python/py-infthread.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index bf90d08ae6..13e11b16e1 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -257,6 +257,24 @@ thpy_is_valid (PyObject *self, PyObject *args)
   Py_RETURN_TRUE;
 }
 
+/* Implementation of gdb.InferiorThread.thread_handle (self) -> handle. */
+
+static PyObject *
+thpy_thread_handle (PyObject *self, PyObject *args)
+{
+  thread_object *thread_obj = (thread_object *) self;
+  THPY_REQUIRE_VALID (thread_obj);
+
+  gdb::byte_vector hv = target_thread_info_to_thread_handle (thread_obj->thread);
+
+  if (hv.size () == 0)
+    return NULL;
+
+  PyObject *object = PyBytes_FromStringAndSize ((const char *) hv.data (),
+				                hv.size());
+  return object;
+}
+
 /* Return a reference to a new Python object representing a ptid_t.
    The object is a tuple containing (pid, lwp, tid). */
 PyObject *
@@ -336,6 +354,9 @@ Return whether the thread is running." },
   { "is_exited", thpy_is_exited, METH_NOARGS,
     "is_exited () -> Boolean\n\
 Return whether the thread is exited." },
+  { "thread_handle", thpy_thread_handle, METH_NOARGS,
+    "thread_handle  () -> handle\n\
+Return thread handle for thread." },
 
   { NULL }
 };


  parent reply	other threads:[~2019-02-28  2:31 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 ` Kevin Buettner [this message]
2019-03-05 21:48   ` [PATCH v2 2/5] Add python method InferiorThread.thread_handle 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 ` [PATCH v2 4/5] Tests for gdb.InferiorThread.thread_handle Kevin Buettner
2019-03-05 21:54   ` 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=20190227193107.5c55cc03@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