This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

should gdb.Value implement __hash__()?


Hi,

i have a problem with gdb.Value. I'm working on formating buffers, that
are usually given as pointers. The format, how to interprete the data
behind the pointer is given in a tree-like structure - inner nodes save
offsets, leafs save the datatype for an special address (buffer+offsets).
>From inferior context i know, how to format the buffers address - and
following the tree how to format the whole buffer - but from context i
don't know how to format buffer+offset.
for example:
format: {
         +0x12:{int},
         +0x36:{double},
         +0x5a:{ +0x00:{int},
                 +0x08:{double}}}
buffer=0x1000
should print as:
(gdb) p buffer
$1 = { *((int*) 0x1000+0x12),
       *((double*) 0x1000+0x36),
       { *((int*) 0x1000+0x5a+0x00),
         *((double*) 0x1000+0x5a+0x08)}}


As you see, the way i want to display the content of this buffer is this
tree-like structure as given in format. The print-handler would return
"array" as display_hint and the address+offsets as children -- or casted
value for leafs. To know how to format the children i would create a
print-handler for this new address and collect it like this:
dict[address]=pointer_printer(address, format)
The intention is to lookup the address in the dict and return the listed
printer as handler.

The problem is, that gdb.Value is hashable, but the hash does not depend
on the value of gdb.Value. Also repr(gdb.Value) is not usable as key.
str(gdb.Value) triggers the lookup_function, which tries to find
str(gdb.Value) in dict - resulting in endless recursion.

Is there a way to get a stringrepresentation of the content of gdb.Value
bypassing the prettyprinting mechanism? Or is it possible to provide a
__hash__, that represents the content of the value? Or to provide the raw
string as __repr__()?

Thanks
- Joachim


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]