gdb/python: add gdb.Frame.__repr__() method
authorAndrew Burgess <aburgess@redhat.com>
Thu, 4 Jan 2024 10:57:40 +0000 (10:57 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Fri, 12 Jan 2024 11:21:27 +0000 (11:21 +0000)
commitd6defe8761ca7db47e3c1e1168f7869ffbb7e087
tree0dc36d76c7de7e15445a0cb7f2185f23d4eb22b2
parent1925bba80edd37c2ef90ef1d2c599dfc2fc17f72
gdb/python: add gdb.Frame.__repr__() method

Add a gdb.Frame.__repr__() method.  Before this patch we would see
output like this:

  (gdb) pi
  >>> gdb.selected_frame()
  <gdb.Frame object at 0x7fa8cc2df270>

After this patch, we now see:

  (gdb) pi
  >>> gdb.selected_frame()
  <gdb.Frame level=0 frame-id={stack=0x7ffff7da0ed0,code=0x000000000040115d,!special}>

More verbose, but, I hope, more useful.

If the gdb.Frame becomes invalid, then we will see:

  (gdb) pi
  >>> invalid_frame_variable
  <gdb.Frame (invalid)>

which is inline with how other invalid objects are displayed.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/python/py-frame.c
gdb/testsuite/gdb.python/py-frame.exp