aboutsummaryrefslogtreecommitdiff
path: root/gdb/NEWS
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2023-10-18 15:46:23 +0100
committerAndrew Burgess <aburgess@redhat.com>2023-10-26 18:27:17 +0100
commitef8cf9093dcf2f2320336f2d9bb9cca33f098189 (patch)
tree66d4ccc7058a6d05582e93c0ef4e782e4e549b70 /gdb/NEWS
parentfd492bf1e20a0410189307c5063acc444c4bd5d3 (diff)
downloadgdb-ef8cf9093dcf2f2320336f2d9bb9cca33f098189.zip
gdb-ef8cf9093dcf2f2320336f2d9bb9cca33f098189.tar.gz
gdb-ef8cf9093dcf2f2320336f2d9bb9cca33f098189.tar.bz2
gdb/python: Add new gdb.Value.bytes attribute
Add a gdb.Value.bytes attribute. This attribute contains the bytes of the value (assuming the complete bytes of the value are available). If the bytes of the gdb.Value are not available then accessing this attribute raises an exception. The bytes object returned from gdb.Value.bytes is cached within GDB so that the same bytes object is returned each time. The bytes object is created on-demand though to reduce unnecessary work. For some values we can of course obtain the same information by reading inferior memory based on gdb.Value.address and gdb.Value.type.sizeof, however, not every value is in memory, so we don't always have an address. The gdb.Value.bytes attribute will convert any value to a bytes object, so long as the contents are available. The value can be one created purely in Python code, the value could be in a register, or (of course) the value could be in memory. The Value.bytes attribute can also be assigned too. Assigning to this attribute is similar to calling Value.assign, the value of the underlying value is updated within the inferior. The value assigned to Value.bytes must be a buffer which contains exactly the correct number of bytes (i.e. unlike value creation, we don't allow oversized buffers). To support this assignment like behaviour I've factored out the core of valpy_assign. I've also updated convert_buffer_and_type_to_value so that it can (for my use case) check the exact buffer length. The restrictions for when the Value.bytes can or cannot be written too are exactly the same as for Value.assign. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=13267 Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/NEWS')
-rw-r--r--gdb/NEWS3
1 files changed, 3 insertions, 0 deletions
diff --git a/gdb/NEWS b/gdb/NEWS
index 30b8cad..6022def 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -11,6 +11,9 @@
** New function gdb.notify_mi(NAME, DATA), that emits custom
GDB/MI async notification.
+ ** New read/write attribute gdb.Value.bytes that contains a bytes
+ object holding the contents of this value.
+
*** Changes in GDB 14
* GDB now supports the AArch64 Scalable Matrix Extension 2 (SME2), which