aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-01-25 15:18:36 +0000
committerPedro Alves <palves@redhat.com>2011-01-25 15:18:36 +0000
commitde4127a3b22abd0e9e69f61f6e52b5f891050ffd (patch)
treee9c7badb2302c3e663e392770e7f01d355cb5d03 /gdb
parentee99023e123b99f55fdf9a99e54e03fea21d3882 (diff)
downloadgdb-de4127a3b22abd0e9e69f61f6e52b5f891050ffd.zip
gdb-de4127a3b22abd0e9e69f61f6e52b5f891050ffd.tar.gz
gdb-de4127a3b22abd0e9e69f61f6e52b5f891050ffd.tar.bz2
* cp-valprint.c (cp_print_value): Treat the 'skip' local as
boolean. Make sure to always pass a value that matches the contents buffer to callees. Preserve `address' for following iterations. * value.c (value_contents_for_printing_const): New. (value_address): Constify value argument. * value.h (value_contents_for_printing_const): Declare. (value_address): Constify value argument.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/cp-valprint.c35
-rw-r--r--gdb/value.c9
-rw-r--r--gdb/value.h8
4 files changed, 49 insertions, 14 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 245ace6..be7b9c1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
2011-01-25 Pedro Alves <pedro@codesourcery.com>
+ * cp-valprint.c (cp_print_value): Treat the 'skip' local as
+ boolean. Make sure to always pass a value that matches the
+ contents buffer to callees. Preserve `address' for following
+ iterations.
+ * value.c (value_contents_for_printing_const): New.
+ (value_address): Constify value argument.
+ * value.h (value_contents_for_printing_const): Declare.
+ (value_address): Constify value argument.
+
+2011-01-25 Pedro Alves <pedro@codesourcery.com>
+
* regcache.c (struct regcache_descr): Rename
sizeof_raw_register_valid_p field to sizeof_raw_register_status,
and sizeof_cooked_register_valid_p to
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 23e42c1..ff3908d 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -488,6 +488,7 @@ cp_print_value (struct type *type, struct type *real_type,
struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
char *basename = TYPE_NAME (baseclass);
const gdb_byte *base_valaddr;
+ const struct value *base_val;
if (BASETYPE_VIA_VIRTUAL (type, i))
{
@@ -509,7 +510,7 @@ cp_print_value (struct type *type, struct type *real_type,
boffset = baseclass_offset (type, i, valaddr + offset,
address + offset);
- skip = ((boffset == -1) || (boffset + offset) < 0) ? 1 : -1;
+ skip = ((boffset == -1) || (boffset + offset) < 0);
if (BASETYPE_VIA_VIRTUAL (type, i))
{
@@ -525,20 +526,28 @@ cp_print_value (struct type *type, struct type *real_type,
large. */
gdb_byte *buf = alloca (TYPE_LENGTH (baseclass));
- base_valaddr = buf;
if (target_read_memory (address + boffset, buf,
TYPE_LENGTH (baseclass)) != 0)
skip = 1;
- address = address + boffset;
+ base_val = value_from_contents_and_address (baseclass,
+ buf,
+ address + boffset);
thisoffset = 0;
boffset = 0;
thistype = baseclass;
+ base_valaddr = value_contents_for_printing_const (base_val);
}
else
- base_valaddr = valaddr;
+ {
+ base_valaddr = valaddr;
+ base_val = val;
+ }
}
else
- base_valaddr = valaddr;
+ {
+ base_valaddr = valaddr;
+ base_val = val;
+ }
/* Now do the printing. */
if (options->pretty)
@@ -553,7 +562,7 @@ cp_print_value (struct type *type, struct type *real_type,
fputs_filtered ("> = ", stream);
- if (skip >= 1)
+ if (skip)
fprintf_filtered (stream, "<invalid address>");
else
{
@@ -564,15 +573,17 @@ cp_print_value (struct type *type, struct type *real_type,
if (!options->raw)
result = apply_val_pretty_printer (baseclass, base_valaddr,
thisoffset + boffset,
- address,
- stream, recurse,
- val, options,
- current_language);
+ value_address (base_val),
+ stream, recurse, base_val,
+ options, current_language);
+
+
if (!result)
cp_print_value_fields (baseclass, thistype, base_valaddr,
- thisoffset + boffset, address,
- stream, recurse, val, options,
+ thisoffset + boffset,
+ value_address (base_val),
+ stream, recurse, base_val, options,
((struct type **)
obstack_base (&dont_print_vb_obstack)),
0);
diff --git a/gdb/value.c b/gdb/value.c
index db83ea2..e26270c 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -435,6 +435,13 @@ value_contents_for_printing (struct value *value)
}
const gdb_byte *
+value_contents_for_printing_const (const struct value *value)
+{
+ gdb_assert (!value->lazy);
+ return value->contents;
+}
+
+const gdb_byte *
value_contents_all (struct value *value)
{
const gdb_byte *result = value_contents_for_printing (value);
@@ -596,7 +603,7 @@ deprecated_value_lval_hack (struct value *value)
}
CORE_ADDR
-value_address (struct value *value)
+value_address (const struct value *value)
{
if (value->lval == lval_internalvar
|| value->lval == lval_internalvar_component)
diff --git a/gdb/value.h b/gdb/value.h
index 16f4646..aa8ff3c 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -273,6 +273,12 @@ extern const gdb_byte *value_contents_all (struct value *);
plan to check the validity manually. */
extern const gdb_byte *value_contents_for_printing (struct value *value);
+/* Like value_contents_for_printing, but accepts a constant value
+ pointer. Unlike value_contents_for_printing however, the pointed
+ value must _not_ be lazy. */
+extern const gdb_byte *
+ value_contents_for_printing_const (const struct value *value);
+
extern int value_fetch_lazy (struct value *val);
extern int value_contents_equal (struct value *val1, struct value *val2);
@@ -308,7 +314,7 @@ extern enum lval_type *deprecated_value_lval_hack (struct value *);
lval == lval_register, return the byte offset into the registers
structure. Otherwise, return 0. The returned address
includes the offset, if any. */
-extern CORE_ADDR value_address (struct value *);
+extern CORE_ADDR value_address (const struct value *);
/* Like value_address, except the result does not include value's
offset. */