This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[commit] Fix some VALUE_EMBEDDED_OFFSET bugs
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sat, 21 Jun 2003 19:31:54 -0400
- Subject: [commit] Fix some VALUE_EMBEDDED_OFFSET bugs
This patch fixes PR c++/1210. In a couple places we were not consistent
about VALUE_OFFSET and VALUE_EMBEDDED_OFFSET. The rule appears to be: for
functions which take a memory buffer, an address, and an offset, the memory
buffer should begin at the address, and the offset should be used when
using the buffer or the address, to find the start of the inner object.
Roughly.
Test case posted under separate subject; patch checked in.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2003-06-21 Daniel Jacobowitz <drow@mvista.com>
* c-valprint.c (c_value_print): Add VALUE_OFFSET to the address
argument of val_print.
* cp-valprint.c (cp_print_value): Don't add the offset parameter
to the address argument of baseclass_offset or target_read_memory.
Do add it to the argument of cp_print_value_fields.
Index: c-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-valprint.c,v
retrieving revision 1.20
diff -u -p -r1.20 c-valprint.c
--- c-valprint.c 2 Jun 2003 18:08:16 -0000 1.20
+++ c-valprint.c 21 Jun 2003 23:22:58 -0000
@@ -592,7 +592,8 @@ c_value_print (struct value *val, struct
/* Otherwise, we end up at the return outside this "if" */
}
- return val_print (type, VALUE_CONTENTS_ALL (val), VALUE_EMBEDDED_OFFSET (val),
- VALUE_ADDRESS (val),
+ return val_print (type, VALUE_CONTENTS_ALL (val),
+ VALUE_EMBEDDED_OFFSET (val),
+ VALUE_ADDRESS (val) + VALUE_OFFSET (val),
stream, format, 1, 0, pretty);
}
Index: cp-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-valprint.c,v
retrieving revision 1.21
diff -u -p -r1.21 cp-valprint.c
--- cp-valprint.c 15 May 2003 22:18:42 -0000 1.21
+++ cp-valprint.c 21 Jun 2003 23:22:59 -0000
@@ -554,7 +554,7 @@ cp_print_value (struct type *type, struc
{
boffset = baseclass_offset (type, i,
valaddr + offset,
- address + offset);
+ address);
skip = ((boffset == -1) || (boffset + offset) < 0) ? 1 : -1;
if (BASETYPE_VIA_VIRTUAL (type, i))
@@ -569,9 +569,10 @@ cp_print_value (struct type *type, struc
{
/* FIXME (alloca): unsafe if baseclass is really really large. */
base_valaddr = (char *) alloca (TYPE_LENGTH (baseclass));
- if (target_read_memory (address + offset + boffset, base_valaddr,
+ if (target_read_memory (address + boffset, base_valaddr,
TYPE_LENGTH (baseclass)) != 0)
skip = 1;
+ address = address + boffset;
thisoffset = 0;
boffset = 0;
thistype = baseclass;
@@ -600,7 +601,8 @@ cp_print_value (struct type *type, struc
fprintf_filtered (stream, "<invalid address>");
else
cp_print_value_fields (baseclass, thistype, base_valaddr,
- thisoffset + boffset, address, stream, format,
+ thisoffset + boffset, address + boffset,
+ stream, format,
recurse, pretty,
((struct type **)
obstack_base (&dont_print_vb_obstack)),