From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 6F70E385C6DD for ; Mon, 23 Oct 2023 17:55:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F70E385C6DD Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6F70E385C6DD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698083754; cv=none; b=DV4UZLiXslGJAeaai9Np1B4h1sOBeSbqCUPtPct/YzSePPLMne4uiTQQfhVC6RLfwu7p2KKnmmGOeEobM9rPXE3rso8MonY/bvmyZN92CRIPWFuH302hC5x9h95wPWHYHB5rJOgnxfebRcfl7hOcRWkdzkA2DqXcEALUtZcOVnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698083754; c=relaxed/simple; bh=6dZ5+ahLuLAifgDGWSj+BcPQIy6ROXulRe1ED6+Rk6c=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=kbuPGfYaMVsMHssuUny1QIlTGGD079PMcEG+daJ+AYAIXUOm3HwXoZS1e8Le/vkoR3YTF7wKZvFue/cxszNNHANXiA5HKg3UkPDIt3vBlHp2QAMByBVd3F6+p95fznUHh3hlqe4yp3A3Vn15/c1nyMbo3nTLRM7cC7vTKZ5hzG4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698083751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+q5T9KeqDVShy01UN3d4GFyUqrucoY8mkirQRheS81s=; b=hDMqMs9EvGG8U4/mxdGZ9PJaxq2JcfVYNLmphrlw2XzA4BsYy0MHEgL0t6sUe97jx/Wn4q BE4cj0BI39BXFdUcgwj245Vv38DIJDpBwItwTYEtz3KV3Uw4C5ldM7qBNGBbrTfzUpQpeF Mp4DrzxNdCfz1UHDu9DtJ2dDQvPm/NE= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-576-HdPe4gyBMS6ZLtmM2aXBYw-1; Mon, 23 Oct 2023 13:55:49 -0400 X-MC-Unique: HdPe4gyBMS6ZLtmM2aXBYw-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-53df4385dccso2317941a12.0 for ; Mon, 23 Oct 2023 10:55:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698083748; x=1698688548; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+q5T9KeqDVShy01UN3d4GFyUqrucoY8mkirQRheS81s=; b=Y9Spt+MbYpKYsKUTWQphQZEszT57HwPYa5EdacQj3EMkExhDifGHaPqnpfD2Ju+mq4 lvwc2ivISGpPoU3kHtzd0g38w8NHw3PXAQB3wuowacpqZN2xLT35/6lFotJ72BwLPyFc ySV6HyNPk1SU/cnEyTpfXnoxKhtJ4y6DNJ7vKZlRy1mv53GW/N/C1rNmmbIfqCDPLxlg i2fwfqIq+FuYotISv+AGKJepu/5yXDZabjhkywtKMrCuJ0nWVKyVojB2Z9QDYIz8Mr5x YsBLr85SwVB52O+oLYpvX2Aen7k9ik07SV1HyM+92JJMNEuVpzrh6dwdqH3ynw9boDnZ SeAQ== X-Gm-Message-State: AOJu0Yyu5eVBbEcX4Q5lOr/rRzQybqt7Nt9OoxE6hTMd/KW/qErbvD5f XMAYeJlOa84xNHVfYWTeQ4K/JVmYX9plZPLj6THT84VVHXLbFdhN5YoDnEWfxJVK8ILyNHgu5Iy RBgSzTOf3eKjXAzNnlzzn7YNfrBGLJEqgudwNWlXn37FSCAukUaf8DAA2gsV9Mxd7SQfqvHnlFt a1my7kEw== X-Received: by 2002:a05:6402:518a:b0:53d:b3c3:57fc with SMTP id q10-20020a056402518a00b0053db3c357fcmr7213234edd.3.1698083748123; Mon, 23 Oct 2023 10:55:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvEkO6BRDZl6CMYw7RUTIuzMmkiJYHsC/v6qAW9TC+/Bfr07wHkw16CLu12zLZyEERKXwiug== X-Received: by 2002:a05:6402:518a:b0:53d:b3c3:57fc with SMTP id q10-20020a056402518a00b0053db3c357fcmr7213210edd.3.1698083747504; Mon, 23 Oct 2023 10:55:47 -0700 (PDT) Received: from localhost ([31.111.84.209]) by smtp.gmail.com with ESMTPSA id c21-20020a50d655000000b00537963f692esm6819311edj.0.2023.10.23.10.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 10:55:47 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess , Eli Zaretskii , Tom Tromey Subject: [PATCHv2] gdb/python: Add new gdb.Value.bytes attribute Date: Mon, 23 Oct 2023 18:55:44 +0100 Message-Id: <2584da63766489b4a98467942a916b2de3331fba.1698083522.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <9cefc82f3c5d6619bca1f04a783e48ea5639a841.1697641024.git.aburgess@redhat.com> References: <9cefc82f3c5d6619bca1f04a783e48ea5639a841.1697641024.git.aburgess@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Thanks for the feedback on V1. In V2: - Docs have been updated to be more explicit about the byte ordering, but have also been extended to cover the new functionality I've added in this update, - The cached value is now cleared correctly during Value.assign calls as Tom pointed out, - The Value.bytes attribute can now be assigned too. This is similar to how Value.assign works. --- 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 --- gdb/NEWS | 3 + gdb/doc/python.texi | 16 ++++ gdb/python/py-value.c | 122 ++++++++++++++++++++++---- gdb/testsuite/gdb.python/py-value.exp | 109 ++++++++++++++++++++++- 4 files changed, 230 insertions(+), 20 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 08d779010f0..e54554dc044 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 diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index 546b4d4b962..8cc3f92cbfe 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -916,6 +916,21 @@ method is invoked. @end defvar +@defvar Value.bytes +The value of this attribute is a @code{bytes} object containing the +bytes that make up this @code{Value}'s complete value in little endian +order. If the complete contents of this value are not available then +accessing this attribute will raise an exception. + +This attribute can also be assigned to. The new value should be a +buffer object (e.g.@: a @code{bytes} object), the length of the new +buffer must exactly match the length of this @code{Value}'s type. The +bytes values in the new buffer should be in little endian order. + +As with @code{Value.assign} (@pxref{Value.assign}), if this value +cannot be assigned to, then an exception will be thrown. +@end defvar + The following methods are provided: @defun Value.__init__ (val) @@ -966,6 +981,7 @@ behaves as though @var{type} was not passed at all. @end defun +@anchor{Value.assign} @defun Value.assign (rhs) Assign @var{rhs} to this value, and return @code{None}. If this value cannot be assigned to, or if the assignment is invalid for some reason diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 0bf1d6e0dae..f360f849ce6 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -63,6 +63,7 @@ struct value_object { PyObject *address; PyObject *type; PyObject *dynamic_type; + PyObject *content_bytes; }; /* List of all values which are currently exposed to Python. It is @@ -86,6 +87,7 @@ valpy_clear_value (value_object *self) Py_CLEAR (self->address); Py_CLEAR (self->type); Py_CLEAR (self->dynamic_type); + Py_CLEAR (self->content_bytes); } /* Called by the Python interpreter when deallocating a value object. */ @@ -135,10 +137,14 @@ note_value (value_object *value_obj) /* Convert a python object OBJ with type TYPE to a gdb value. The python object in question must conform to the python buffer protocol. On success, return the converted value, otherwise - nullptr. */ + nullptr. When REQUIRE_EXACT_SIZE_P is true the buffer OBJ must be the + exact length of TYPE. When REQUIRE_EXACT_SIZE_P is false then the + buffer OBJ can be longer than TYPE, in which case only the least + significant bytes from the buffer are used. */ static struct value * -convert_buffer_and_type_to_value (PyObject *obj, struct type *type) +convert_buffer_and_type_to_value (PyObject *obj, struct type *type, + bool require_exact_size_p) { Py_buffer_up buffer_up; Py_buffer py_buf; @@ -157,7 +163,13 @@ convert_buffer_and_type_to_value (PyObject *obj, struct type *type) return nullptr; } - if (type->length () > py_buf.len) + if (require_exact_size_p && type->length () != py_buf.len) + { + PyErr_SetString (PyExc_ValueError, + _("Size of type is not equal to that of buffer object.")); + return nullptr; + } + else if (!require_exact_size_p && type->length () > py_buf.len) { PyErr_SetString (PyExc_ValueError, _("Size of type is larger than that of buffer object.")); @@ -196,7 +208,7 @@ valpy_init (PyObject *self, PyObject *args, PyObject *kwds) if (type == nullptr) value = convert_value_from_python (val_obj); else - value = convert_buffer_and_type_to_value (val_obj, type); + value = convert_buffer_and_type_to_value (val_obj, type, false); if (value == nullptr) { gdb_assert (PyErr_Occurred ()); @@ -888,36 +900,53 @@ valpy_reinterpret_cast (PyObject *self, PyObject *args) return valpy_do_cast (self, args, UNOP_REINTERPRET_CAST); } -/* Implementation of the "assign" method. */ +/* Assign NEW_VALUE into SELF, handles 'struct value' reference counting, + and also clearing the bytes data cached within SELF. Return true if + the assignment was successful, otherwise return false, in which case a + Python exception will be set. */ -static PyObject * -valpy_assign (PyObject *self_obj, PyObject *args) +static bool +valpy_assign_core (value_object *self, struct value *new_value) { - PyObject *val_obj; - - if (! PyArg_ParseTuple (args, "O", &val_obj)) - return nullptr; - - struct value *val = convert_value_from_python (val_obj); - if (val == nullptr) - return nullptr; - try { - value_object *self = (value_object *) self_obj; - value *new_value = value_assign (self->value, val); + new_value = value_assign (self->value, new_value); + /* value_as_address returns a new value with the same location as the old one. Ensure that this gdb.Value is updated to reflect the new value. */ new_value->incref (); self->value->decref (); + Py_CLEAR (self->content_bytes); self->value = new_value; } catch (const gdb_exception &except) { - GDB_PY_HANDLE_EXCEPTION (except); + gdbpy_convert_exception (except); + return false; } + return true; +} + +/* Implementation of the "assign" method. */ + +static PyObject * +valpy_assign (PyObject *self_obj, PyObject *args) +{ + PyObject *val_obj; + + if (! PyArg_ParseTuple (args, "O", &val_obj)) + return nullptr; + + struct value *val = convert_value_from_python (val_obj); + if (val == nullptr) + return nullptr; + + value_object *self = (value_object *) self_obj; + if (!valpy_assign_core (self, val)) + return nullptr; + Py_RETURN_NONE; } @@ -1304,6 +1333,58 @@ valpy_get_is_lazy (PyObject *self, void *closure) Py_RETURN_FALSE; } +/* Get gdb.Value.bytes attribute. */ + +static PyObject * +valpy_get_bytes (PyObject *self, void *closure) +{ + value_object *value_obj = (value_object *) self; + struct value *value = value_obj->value; + + if (value_obj->content_bytes != nullptr) + { + Py_INCREF (value_obj->content_bytes); + return value_obj->content_bytes; + } + + gdb::array_view contents; + try + { + contents = value->contents (); + } + catch (const gdb_exception &except) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + + value_obj->content_bytes + = PyBytes_FromStringAndSize ((const char *) contents.data (), + contents.size ()); + Py_XINCREF (value_obj->content_bytes); + return value_obj->content_bytes; +} + +/* Set gdb.Value.bytes attribute. */ + +static int +valpy_set_bytes (PyObject *self_obj, PyObject *new_value_obj, void *closure) +{ + value_object *self = (value_object *) self_obj; + + /* Create a new value from the buffer NEW_VALUE_OBJ. We pass true here + to indicate that NEW_VALUE_OBJ must match exactly the type length. */ + struct value *new_value + = convert_buffer_and_type_to_value (new_value_obj, self->value->type (), + true); + if (new_value == nullptr) + return -1; + + if (!valpy_assign_core (self, new_value)) + return -1; + + return 0; +} + /* Implements gdb.Value.fetch_lazy (). */ static PyObject * valpy_fetch_lazy (PyObject *self, PyObject *args) @@ -1865,6 +1946,7 @@ value_to_value_object (struct value *val) val_obj->address = NULL; val_obj->type = NULL; val_obj->dynamic_type = NULL; + val_obj->content_bytes = nullptr; note_value (val_obj); } @@ -2152,6 +2234,8 @@ static gdb_PyGetSetDef value_object_getset[] = { "Boolean telling whether the value is lazy (not fetched yet\n\ from the inferior). A lazy value is fetched when needed, or when\n\ the \"fetch_lazy()\" method is called.", NULL }, + { "bytes", valpy_get_bytes, valpy_set_bytes, + "Return a bytearray containing the bytes of this value.", nullptr }, {NULL} /* Sentinel */ }; diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp index cdfcd414cd4..4b826f2d6ca 100644 --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp @@ -66,7 +66,8 @@ proc test_value_creation {} { gdb_test "python print ('result = %s' % i.address)" "= None" "test address attribute in non-addressable value" # Test creating / printing an optimized out value - gdb_test "python print(gdb.Value(gdb.Value(5).type.optimized_out()))" + gdb_test "python print(gdb.Value(gdb.Value(5).type.optimized_out()))" \ + "" } # Check that we can call gdb.Value.__init__ to change a value. @@ -542,13 +543,30 @@ proc prepare_type_and_buffer {} { proc test_value_from_buffer {} { global gdb_prompt + # A Python helper function. Create a bytes object from inferior + # memory LEN bytes starting at ADDR, and compare this to the bytes + # obtained from VAL.bytes. Assert that the two bytes object match. + gdb_test_multiline "Create another function to check Value.bytes" \ + "python" "" \ + "def compare_value_bytes_to_mem(val, addr, len):" "" \ + " mem = gdb.selected_inferior().read_memory(addr, len)" "" \ + " mem_bytes = mem.tobytes()" "" \ + " val_bytes = val.bytes" "" \ + " assert mem_bytes == val_bytes" "" \ + "end" "" + prepare_type_and_buffer gdb_test "python v=gdb.Value(b,tp); print(v)" "1" \ "construct value from buffer" + gdb_test_no_output { python compare_value_bytes_to_mem(v, addr, size_a0) } gdb_test "python v=gdb.Value(b\[size_a0:\],tp); print(v)" "2" \ "convert 2nd elem of buffer to value" + gdb_test_no_output \ + { python compare_value_bytes_to_mem(v, (int(addr) + size_a0), size_a0) } gdb_test "python v=gdb.Value(b\[2*size_a0:\],tp); print(v)" "3" \ "convert 3rd elem of buffer to value" + gdb_test_no_output \ + { python compare_value_bytes_to_mem(v, (int(addr) + (2 * size_a0)), size_a0) } gdb_test "python v=gdb.Value(b\[2*size_a0+1:\],tp); print(v)" \ "ValueError: Size of type is larger than that of buffer object\..*" \ "attempt to convert smaller buffer than size of type" @@ -556,6 +574,8 @@ proc test_value_from_buffer {} { "make array type" 0 gdb_py_test_silent_cmd "python va=gdb.Value(b,atp)" \ "construct array value from buffer" 0 + gdb_test_no_output \ + { python compare_value_bytes_to_mem(va, addr, size_a0 * 3) } gdb_test "python print(va)" "\\{1, 2, 3\\}" "print array value" gdb_test "python print(va\[0\])" "1" "print first array element" gdb_test "python print(va\[1\])" "2" "print second array element" @@ -633,6 +653,92 @@ proc test_history_count {} { } } +# Test the gdb.Value.bytes API. +proc_with_prefix test_value_bytes { } { + # Test accessing the bytes of an optimised out value. + gdb_test "python print(gdb.Value(gdb.Value(5).type.optimized_out()).bytes)" \ + [multi_line \ + "gdb\\.error: value has been optimized out" \ + "Error while executing Python code\\."] + + # A Python helper function. Fetch VAR_NAME from the inferior as a + # gdb.Value. Read the bytes of the value based on its address, and + # the size of its type. The compare these bytes to the value + # obtained from gdb.Value.bytes. Assert that the two bytes objects + # match. + gdb_test_multiline "Create a function to check Value.bytes" \ + "python" "" \ + "def check_value_bytes(var_name):" "" \ + " val = gdb.parse_and_eval(var_name)" "" \ + " addr = val.address" "" \ + " len = val.type.sizeof" "" \ + " mem = gdb.selected_inferior().read_memory(addr, len)" "" \ + " mem_bytes = mem.tobytes()" "" \ + " val_bytes = val.bytes" "" \ + " assert mem_bytes == val_bytes" "" \ + "end" "" + + gdb_test_no_output { python check_value_bytes("a") } + gdb_test_no_output { python check_value_bytes("p") } + gdb_test_no_output { python check_value_bytes("i") } + gdb_test_no_output { python check_value_bytes("ptr_i") } + gdb_test_no_output { python check_value_bytes("embed") } + gdb_test_no_output { python check_value_bytes("fp1") } + gdb_test_no_output { python check_value_bytes("nullst") } + gdb_test_no_output { python check_value_bytes("st") } + gdb_test_no_output { python check_value_bytes("s") } + gdb_test_no_output { python check_value_bytes("u") } + + # Check that gdb.Value.bytes changes after calling + # gdb.Value.assign(). The bytes value is cached within the Value + # object, so calling assign should clear the cache. + with_test_prefix "assign clears bytes cache" { + gdb_test_no_output "python v = gdb.parse_and_eval(\"i\")" + gdb_test_no_output "python bytes_before = v.bytes" + gdb_test_no_output "python v.assign(9)" + gdb_test_no_output "python bytes_after = v.bytes" + gdb_test_no_output "python assert(bytes_after != bytes_before)" + } + + # Check that if we re-init a gdb.Value object the cached bytes for + # the Value are cleared. + with_test_prefix "re-init clears bytes cache" { + gdb_test_no_output "python w = gdb.Value(1)" + gdb_test_no_output "python bytes_before = w.bytes" + gdb_test_no_output "python w.__init__(3)" + gdb_test_no_output "python bytes_after = w.bytes" + gdb_test_no_output "python assert(bytes_after != bytes_before)" + } + + # Check that we can assign to the Value.bytes field. + gdb_test_no_output "python i_value = gdb.parse_and_eval('i')" \ + "evaluate i" + gdb_test_no_output "python i_bytes = i_value.bytes" + gdb_test_no_output "python i_bytes = bytes(\[b if b != 9 else 5 for b in i_bytes\])" + gdb_test_no_output "python i_value.bytes = i_bytes" + gdb_test "print i" " = 5" + + # Check we get an exception if attempting to assign a buffer that is + # too big, or too small. + gdb_test_no_output "python bytes_as_int = \[x for x in i_bytes\]" + gdb_test_no_output "python bytes_as_int.append(0)" + gdb_test_no_output "python too_many_bytes = bytes(bytes_as_int)" + gdb_test "python i_value.bytes = too_many_bytes" \ + "ValueError: Size of type is not equal to that of buffer object\\..*" + gdb_test_no_output "python bytes_as_int = bytes_as_int\[0:-2\]" + gdb_test_no_output "python too_few_bytes = bytes(bytes_as_int)" + gdb_test "python i_value.bytes = too_few_bytes" \ + "ValueError: Size of type is not equal to that of buffer object\\..*" + + # Check we get an exception writing to a not_lval. + gdb_test_no_output "python i_value = gdb.Value(9)" \ + "reset i_value" + gdb_test_no_output "python i_bytes = i_value.bytes" \ + "grab new value bytes" + gdb_test "python i_value.bytes = i_bytes" "not an lvalue.*" \ + "cannot assign to not_lval value" +} + # Test Value.assign. proc test_assign {} { gdb_test_no_output "python i_value = gdb.parse_and_eval('i')" \ @@ -677,6 +783,7 @@ test_value_from_buffer test_value_sub_classes test_inferior_function_call test_assign +test_value_bytes test_value_after_death # Test either C or C++ values. base-commit: 29736fc507c7a9c6e797b7f83e8df4be73d37767 -- 2.25.4