python - GDB pretty-printer: printing an array when the size is known by the parent struct -
i have struct in c++ this:
struct heapblock { char* data; } struct datablock { int size; heapblock hb; } these part of framework , have several other members, helpers , on, these are of import parts. show in python gdb pretty-printer this:
name type value datablock: datablock "size 2000 @ 0x445343" |--->size int 2000 |--->data heapblock {...} |--->[0] char 0x34 |--->[1] char 0x45 .... <more values> so far, have failed @ getting heapblock shown separate child. have abused iterator produce:
name type value datablock: datablock |--->size int 2000 |--->[0] char 0x34 |--->[1] char 0x45 .... <more values> this done returning db["size"] in first result iterator returned datablockprinter's children() method, , db["hb"]["data"] next size results.
i have tried utilize separate printer heapblocks, problem there heapblock has no thought how big is: stored in parent (datablock), heapblock printer doesn't know when stop iterating.
is possible size field heapblock pretty printer when printed part of datablock here?
unfortunately there no built-in way this. believe there bug open in gdb bugzilla.
it might possible hack: in datablock printer, record address , size of heapblock in hash table. heapblock printer up. of course of study problem becomes 1 of deciding how invalidate cache. offhand can't think of way :-( maybe it's ok not invalidate it. might seek invalidating when datablock printer destroyed; gdb doesn't guarantee work, might ok in practice.
python debugging gdb pretty-print gdb-python
No comments:
Post a Comment