]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/python: Add gdb.Inferior.__dict__ attribute
authorAndrew Burgess <aburgess@redhat.com>
Thu, 4 Jan 2024 16:46:40 +0000 (16:46 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Fri, 12 Jan 2024 11:21:30 +0000 (11:21 +0000)
commit13cd9bceea3c3a3081c463597146a11ade765e39
tree8c2a7b96be594b13b55b320d17d89468303016a2
parent2f47f48fe55eb72bfe4d3c5291a74f4a53121c5e
gdb/python: Add gdb.Inferior.__dict__ attribute

The gdb.Objfile, gdb.Progspace, and gdb.Type Python types already have
a __dict__ attribute, which allows users to create user defined
attributes within the objects.  This is useful if the user wants to
cache information within an object.

This commit adds the same functionality to the gdb.Inferior type.

After this commit there is a new gdb.Inferior.__dict__ attribute,
which is a dictionary.  A user can, for example, do this:

  (gdb) pi
  >>> i = gdb.selected_inferior()
  >>> i._user_attribute = 123
  >>> i._user_attribute
  123
  >>>

There's a new test included.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
gdb/NEWS
gdb/doc/python.texi
gdb/python/py-inferior.c
gdb/testsuite/gdb.python/py-inferior.exp