gdb: add __repr__() implementation to a few Python types
authorMatheus Branco Borella <dark.ryu.550@gmail.com>
Thu, 18 May 2023 03:33:57 +0000 (00:33 -0300)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 4 Jul 2023 11:07:16 +0000 (12:07 +0100)
commitbb2bd584f31a25ba1cfe5bdac4d07d8cffe87c3d
tree8dac0966bc63e625f87af8e1a6a2243e15df3803
parentb8c2de06bcbc13a1a6b93163cf675272d7eada9f
gdb: add __repr__() implementation to a few Python types

Only a few types in the Python API currently have __repr__()
implementations.  This patch adds a few more of them. specifically: it
adds __repr__() implementations to gdb.Symbol, gdb.Architecture,
gdb.Block, gdb.Breakpoint, gdb.BreakpointLocation, and gdb.Type.

This makes it easier to play around the GDB Python API in the Python
interpreter session invoked with the 'pi' command in GDB, giving more
easily accessible tipe information to users.

An example of how this would look like:

  (gdb) pi
  >> gdb.lookup_type("char")
  <gdb.Type code=TYPE_CODE_INT name=char>
  >> gdb.lookup_global_symbol("main")
  <gdb.Symbol print_name=main>

The gdb.Block.__repr__() method shows the first 5 symbols from the
block, and then a message to show how many more were elided (if any).
12 files changed:
gdb/python/py-arch.c
gdb/python/py-block.c
gdb/python/py-breakpoint.c
gdb/python/py-symbol.c
gdb/python/py-type.c
gdb/testsuite/gdb.python/py-arch.exp
gdb/testsuite/gdb.python/py-block.c
gdb/testsuite/gdb.python/py-block.exp
gdb/testsuite/gdb.python/py-bp-locations.exp
gdb/testsuite/gdb.python/py-breakpoint.exp
gdb/testsuite/gdb.python/py-symbol.exp
gdb/testsuite/gdb.python/py-type.exp