Bug 13267 - python: gdb.Value needs a method to get raw memory as a string
Summary: python: gdb.Value needs a method to get raw memory as a string
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: python (show other bugs)
Version: 7.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2011-10-05 20:42 UTC by S Boucher
Modified: 2022-06-05 16:29 UTC (History)
2 users (show)

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description S Boucher 2011-10-05 20:42:14 UTC
gdb.Value provides a way to get a textual string (gdb.Value.string(...)), but there's no way to get it as a raw sequence of bytes.  Maybe this could be done with an encoding argument of None?


v = gdb.parse_and_eval("var")
data = v.string(None, length=64)
Comment 1 Tom Tromey 2018-09-15 06:18:27 UTC
A method on Value would be fine, but there's also
Comment 2 Tom Tromey 2022-06-05 16:29:00 UTC
It seems to me that there are two different things we might
want to expose.

One thing is access to the underlying bytes of a Value.
This is maybe a little tricky because a Value might not have
all the bytes available.

The other thing is using a pointer value to fetch memory.
This can be done via read_memory, though it might be
nice to also have a convenience method on Value.