aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-valprint.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-02-14 11:33:24 +0000
committerPedro Alves <palves@redhat.com>2011-02-14 11:33:24 +0000
commitec0a52e16206a31867fdcc5535c42baca7bf8967 (patch)
tree3f8b2d7194b672c5c155f9931635fda2fa2fc142 /gdb/c-valprint.c
parent24e6bceefbdf681e3e4101a44835a29afe33f902 (diff)
downloadgdb-ec0a52e16206a31867fdcc5535c42baca7bf8967.zip
gdb-ec0a52e16206a31867fdcc5535c42baca7bf8967.tar.gz
gdb-ec0a52e16206a31867fdcc5535c42baca7bf8967.tar.bz2
gdb/testsuite/
* gdb.trace/unavailable.cc (struct Virtual): New. (virtualp): New global pointer. * gdb.trace/unavailable.exp (gdb_collect_globals_test): Test printing a pointer to an object whose type has a vtable, with print object on. gdb/ * value.h (value_entirely_available): Declare. * value.c (value_entirely_available): New function. * c-valprint.c (c_value_print): Don't try fetching the pointer's real type if the pointer is unavailable.
Diffstat (limited to 'gdb/c-valprint.c')
-rw-r--r--gdb/c-valprint.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 138aca6..8e4f932 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -686,29 +686,33 @@ c_value_print (struct value *val, struct ui_file *stream,
}
/* Pointer to class, check real type of object. */
fprintf_filtered (stream, "(");
- real_type = value_rtti_target_type (val, &full,
- &top, &using_enc);
- if (real_type)
- {
- /* RTTI entry found. */
- if (TYPE_CODE (type) == TYPE_CODE_PTR)
- {
- /* Create a pointer type pointing to the real
- type. */
- type = lookup_pointer_type (real_type);
- }
- else
- {
- /* Create a reference type referencing the real
- type. */
- type = lookup_reference_type (real_type);
- }
- /* JYG: Need to adjust pointer value. */
- val = value_from_pointer (type, value_as_address (val) - top);
-
- /* Note: When we look up RTTI entries, we don't get any
- information on const or volatile attributes. */
- }
+
+ if (value_entirely_available (val))
+ {
+ real_type = value_rtti_target_type (val, &full, &top, &using_enc);
+ if (real_type)
+ {
+ /* RTTI entry found. */
+ if (TYPE_CODE (type) == TYPE_CODE_PTR)
+ {
+ /* Create a pointer type pointing to the real
+ type. */
+ type = lookup_pointer_type (real_type);
+ }
+ else
+ {
+ /* Create a reference type referencing the real
+ type. */
+ type = lookup_reference_type (real_type);
+ }
+ /* Need to adjust pointer value. */
+ val = value_from_pointer (type, value_as_address (val) - top);
+
+ /* Note: When we look up RTTI entries, we don't get
+ any information on const or volatile
+ attributes. */
+ }
+ }
type_print (type, "", stream, -1);
fprintf_filtered (stream, ") ");
val_type = type;