[v4,0/6] Add python method gdb.InferiorThread.handle

Message ID 20190404165854.17343-1-kevinb@redhat.com
Headers show
Series
  • Add python method gdb.InferiorThread.handle
Related show

Message

Kevin Buettner April 4, 2019, 4:58 p.m.
This six part series adds a python method named "handle" which is used
to obtain the thread handle from a thread object.

It will eventually be used as part of the implementation of the
"thread parent" operation for the OpenMP work that I've been doing.

While thread handles are normally opaque, for my OpenMP work, it's
become necessary to convert a handle to a form upon which arithmetic
may be performed.  Via some simple arithmetic manipulations, it's
possible to find the handle associated with a GOMP thread.  If you want
details on this, see:

https://www.sourceware.org/ml/gdb-patches/2018-09/msg00719.html

This is version 3 of a series that I first posted in Sept, 2018.

In v1, InferiorThread.thread_handle was passed a type and returned
a gdb.Value object representing the handle (of the type passed in).

In v2, InferiorThread.thread_handle is a nullary method.  It returns
the thread handle represented as a Python bytes object.  If it's
necessary to pierce the opacity of this object, as it is for my use
case, the two argument form of the gdb.Value constructor may be used
to make an object of some suitable type.

In v3, the name has been changed to "handle" instead of
"thread_handle" at the suggestion of Tom Tromey.  I've also fixed a
few other small problems identified by Tom.  Also, in order to stay
consistent with the new naming, "thread_from_thread_handle", an
existing python method, has been renamed to "thread_from_handle".  The
old name may still be used, but is considered deprecated.

In v4, this version, patches 1 and 2 have been revised slightly to
address some additional problems found by Tom Tromey.  Patches 3-6
are unchanged, but are included for completeness.

Kevin


 gdb/doc/python.texi                       | 17 +++++-
 gdb/gdbthread.h                           |  4 +-
 gdb/linux-thread-db.c                     | 19 +++++++
 gdb/python/py-inferior.c                  | 37 ++++++++++--
 gdb/python/py-infthread.c                 | 34 ++++++++++++
 gdb/remote.c                              | 10 ++++
 gdb/target-debug.h                        |  2 +
 gdb/target-delegates.c                    | 28 ++++++++++
 gdb/target.c                              |  8 +++
 gdb/target.h                              |  9 +++
 gdb/testsuite/gdb.python/py-thrhandle.exp | 68 +++++++++++++++++------
 gdb/thread.c                              | 10 ++--
 12 files changed, 215 insertions(+), 31 deletions(-)

-- 
2.20.1

Comments

Tom Tromey April 8, 2019, 8:30 p.m. | #1
>>>>> "Kevin" == Kevin Buettner <kevinb@redhat.com> writes:


Kevin> In v4, this version, patches 1 and 2 have been revised slightly to
Kevin> address some additional problems found by Tom Tromey.  Patches 3-6
Kevin> are unchanged, but are included for completeness.

Thanks.  I looked at the updated patches and they look good to me.

Tom
Kevin Buettner April 9, 2019, 3:34 a.m. | #2
On Mon, 08 Apr 2019 14:30:00 -0600
Tom Tromey <tom@tromey.com> wrote:

> >>>>> "Kevin" == Kevin Buettner <kevinb@redhat.com> writes:  

> 

> Kevin> In v4, this version, patches 1 and 2 have been revised slightly to

> Kevin> address some additional problems found by Tom Tromey.  Patches 3-6

> Kevin> are unchanged, but are included for completeness.  

> 

> Thanks.  I looked at the updated patches and they look good to me.


Thanks for all of the reviews!

I've pushed this series (after fixing a TRY/CATCH build problem and
then retesting).

Kevin