[PATCHv3 0/2] Add __repr__() implementation to a few Python types

Andrew Burgess aburgess@redhat.com
Fri May 19 21:27:56 GMT 2023


Matheus,

Thanks for moving this forward.

I took a look through, and I think this looks great.  I noticed a few
whitespace issues with the patch, so I fixed all of them.  But during
testing I ended up making a few more changes, so I figured I'd just
post what I ended up with.

The biggest change you'll see is a whole extra patch.  It turns out
that the way you were using mdict_size wasn't correct -- mdict_size
doesn't always return the number of symbols!  As a result the symbol
list for block_func (in the py-block.exp test) would end up printed
without comma's between the symbols.  Anyway, the new first patch
fixes this.

While we're in py-block.c, I changed the output format.  Rather than
displaying the symbols one per line, they are now listed all on one
line.  The multi-line format looks great if all you are displaying is
the one object's repr, but if the repr is printed as part of a larger
string then I think the multi-line layout doesn't look as good.  Now
we're only printing a few symbols I figure we can afford to go with a
one line layout.

On the testing side I've tightened the patterns in py-block.exp, and
extended the test to check the ouptut in block_func -- this exposes
the mdict_size issue.

I've added some tests for gdb.BreakpointLocation, which were missing.

And I've made the patterns in py-breakpoint.exp more precise, and
added some additional tests to catch more cases.

Would be great to hear your thoughts on the updates,

Thanks,
Andrew

---

Andrew Burgess (1):
  gdb: have mdict_size always return a symbol count

Matheus Branco Borella via Gdb-patches (1):
  gdb: add __repr__() implementation to a few Python types

 gdb/dictionary.c                             | 13 +++-
 gdb/dictionary.h                             |  3 +-
 gdb/python/py-arch.c                         | 17 ++++-
 gdb/python/py-block.c                        | 37 ++++++++++-
 gdb/python/py-breakpoint.c                   | 67 ++++++++++++++++++-
 gdb/python/py-symbol.c                       | 15 ++++-
 gdb/python/py-type.c                         | 30 ++++++++-
 gdb/symmisc.c                                |  2 +-
 gdb/testsuite/gdb.python/py-arch.exp         |  6 ++
 gdb/testsuite/gdb.python/py-block.c          | 31 +++++++++
 gdb/testsuite/gdb.python/py-block.exp        | 38 ++++++++++-
 gdb/testsuite/gdb.python/py-bp-locations.exp | 32 +++++++++
 gdb/testsuite/gdb.python/py-breakpoint.exp   | 69 +++++++++++++++++---
 gdb/testsuite/gdb.python/py-symbol.exp       |  2 +
 gdb/testsuite/gdb.python/py-type.exp         |  4 ++
 15 files changed, 343 insertions(+), 23 deletions(-)


base-commit: e84060b489746d031ed1ec9e7b6b39fdf4b6cfe3
-- 
2.25.4



More information about the Gdb-patches mailing list