I want to get the address from a value in the same way that the x
examine command works. Internally, this seems to use value_as_address
, which turns any gdb expression into a core address. I have not managed to find a binding for this anywhere in the Python API surface. Further, the workarounds I've seen so far don't seem to accomplish this:
It is not reasonable to cast the type to a void pointer because this is language dependent (will not work in Rust executables, for instance):
some_Value.cast(gdb.lookup_type('void').pointer())
will fail if there is no "void" type, as in the case of Rust.
I want to accept integers, which should come out unchanged.
In particular, I want a function that takes strings such as "0x5555555740a0"
, "main"
, etc and turns them into an integer containing their address.