This is the mail archive of the archer@sourceware.org mailing list for the Archer 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]

[python] fix crash when manipulating string in internal variable


This fixes the following crash:

(gdb) set $blah = "whatever"
(gdb) set $blah[4] = 0
*CRASH*

which was introduced by:

commit b5cdb6e5cfc537b99173fe981e81a87d1ebe4566
Author: Tom Tromey <tromey@redhat.com>
Date:   Fri Oct 17 10:50:26 2008 -0600

The problem is that value_subscripted_rvalue tries to set the address of
an internalvar_component value, which trips a gdb_assert in
set_value_address. The underlying thinko is also present in upstream
GDB, but the code works there because it uses the VALUE_ADDRESS macro
which happens to work.

I won't submit this patch upstream because I'm not sure it's right,
since I don't know much about the implementation of internal variables.


2008-11-23  Thiago Jung Bauermann  <bauerman@br.ibm.com>

	* valarith.c (value_subscripted_rvalue,
	value_bitstring_subscript): Fix internal error when given a value
	for an internal variable.

diff --git a/gdb/valarith.c b/gdb/valarith.c
index 1c114f6..36100c1 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -234,10 +234,15 @@ value_subscripted_rvalue (struct value *array, struct value *idx, int lowerbound
 	    value_contents (array) + elt_offs, elt_size);
 
   if (VALUE_LVAL (array) == lval_internalvar)
-    VALUE_LVAL (v) = lval_internalvar_component;
+    {
+      VALUE_LVAL (v) = lval_internalvar_component;
+      VALUE_INTERNALVAR (v) = VALUE_INTERNALVAR (array);
+    }
   else
-    VALUE_LVAL (v) = VALUE_LVAL (array);
-  set_value_address (v, value_raw_address (array));
+    {
+      VALUE_LVAL (v) = VALUE_LVAL (array);
+      set_value_address (v, value_raw_address (array));
+    }
   VALUE_REGNUM (v) = VALUE_REGNUM (array);
   VALUE_FRAME_ID (v) = VALUE_FRAME_ID (array);
   set_value_offset (v, value_offset (array) + elt_offs);
@@ -280,8 +285,12 @@ value_bitstring_subscript (struct type *type,
 
   VALUE_LVAL (v) = VALUE_LVAL (bitstring);
   if (VALUE_LVAL (bitstring) == lval_internalvar)
-    VALUE_LVAL (v) = lval_internalvar_component;
-  set_value_address (v, value_raw_address (bitstring));
+    {
+      VALUE_LVAL (v) = lval_internalvar_component;
+      VALUE_INTERNALVAR (v) = VALUE_INTERNALVAR (bitstring);
+    }
+  else
+    set_value_address (v, value_raw_address (bitstring));
   VALUE_FRAME_ID (v) = VALUE_FRAME_ID (bitstring);
 
   set_value_offset (v, offset + value_offset (bitstring));
-- 
1.5.6.5



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