aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog24
-rw-r--r--gdb/c-valprint.c16
-rw-r--r--gdb/cp-valprint.c9
-rw-r--r--gdb/dwarf2loc.c11
-rw-r--r--gdb/f-valprint.c11
-rw-r--r--gdb/jv-valprint.c14
-rw-r--r--gdb/p-valprint.c34
-rw-r--r--gdb/scm-valprint.c3
-rw-r--r--gdb/stack.c4
-rw-r--r--gdb/valprint.c59
-rw-r--r--gdb/value.h5
-rw-r--r--gdb/varobj.c6
12 files changed, 119 insertions, 77 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 984ed26..9babafb 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,27 @@
+2005-02-28 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * dwarf2loc.c (loclist_read_variable): Set optimized_out
+ instead of reporting an error.
+ * valprint.c (value_check_printable): New function.
+ (common_val_print): New function. Use value_check_printable.
+ (value_print): Use value_check_printable.
+ * value.h (common_val_print): Add prototype.
+
+ * c-valprint.c (c_val_print): Use common_val_print.
+ * cp-valprint.c (cp_print_value_fields): Likewise.
+ (cp_print_hpacc_virtual_table_entries): Likewise.
+ * f-valprint.c (f_val_print): Likewise.
+ * jv-valprint.c (java_value_print, java_print_value_fields):
+ Likewise.
+ * scm-valprint.c (scm_value_print): Likewise.
+ * stack.c (print_frame_args): Likewise.
+ * varobj.c (c_value_of_variable): Likewise.
+ * p-valprint.c (pascal_val_print, pascal_value_print): Likewise.
+ (pascal_object_print_value_fields): Likewise. Update call to
+ pascal_object_print_static_field.
+ (pascal_object_print_static_field): Remove TYPE argument. Use
+ common_val_print.
+
2005-02-25 Mark Kettenis <kettenis@gnu.org>
Committed by Elena Zannoni <ezannoni@redhat.com>
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 89a68e3..0e06ca6 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -233,9 +233,8 @@ c_val_print (struct type *type, const bfd_byte *valaddr, int embedded_offset,
wtype = TYPE_TARGET_TYPE (type);
}
vt_val = value_at (wtype, vt_address);
- val_print (value_type (vt_val), value_contents (vt_val), 0,
- VALUE_ADDRESS (vt_val), stream, format,
- deref_ref, recurse + 1, pretty);
+ common_val_print (vt_val, stream, format,
+ deref_ref, recurse + 1, pretty);
if (pretty)
{
fprintf_filtered (stream, "\n");
@@ -283,15 +282,8 @@ c_val_print (struct type *type, const bfd_byte *valaddr, int embedded_offset,
(TYPE_TARGET_TYPE (type),
unpack_pointer (lookup_pointer_type (builtin_type_void),
valaddr + embedded_offset));
- val_print (value_type (deref_val),
- value_contents (deref_val),
- 0,
- VALUE_ADDRESS (deref_val),
- stream,
- format,
- deref_ref,
- recurse,
- pretty);
+ common_val_print (deref_val, stream, format, deref_ref,
+ recurse, pretty);
}
else
fputs_filtered ("???", stream);
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index bec0e57..cc481b4 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -389,8 +389,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
(TYPE_FIELD_TYPE (type, i),
unpack_field_as_long (type, valaddr + offset, i));
- val_print (TYPE_FIELD_TYPE (type, i), value_contents (v),
- 0, 0, stream, format, 0, recurse + 1, pretty);
+ common_val_print (v, stream, format, 0, recurse + 1, pretty);
}
}
else
@@ -454,8 +453,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
v = value_from_pointer (lookup_pointer_type (builtin_type_unsigned_long),
*(unsigned long *) (valaddr + offset));
- val_print (value_type (v), value_contents (v), 0, 0,
- stream, format, 0, recurse + 1, pretty);
+ common_val_print (v, stream, format, 0, recurse + 1, pretty);
fields_seen = 1;
if (vtblprint)
@@ -822,8 +820,7 @@ cp_print_hpacc_virtual_table_entries (struct type *type, int *vfuncs,
deprecated_set_value_type (vf, value_type (v));
/* print out the entry */
- val_print (value_type (vf), value_contents (vf), 0, 0,
- stream, format, 0, recurse + 1, pretty);
+ common_val_print (vf, stream, format, 0, recurse + 1, pretty);
field_physname
= TYPE_FN_FIELD_PHYSNAME (TYPE_FN_FIELDLIST1 (type, fn), oi);
/* pai: (temp) FIXME Maybe this should be DMGL_ANSI */
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 203ebdd..b715ae2 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -512,9 +512,14 @@ loclist_read_variable (struct symbol *symbol, struct frame_info *frame)
data = find_location_expression (dlbaton, &size,
frame ? get_frame_pc (frame) : 0);
if (data == NULL)
- error (_("Variable \"%s\" is not available."), SYMBOL_NATURAL_NAME (symbol));
-
- val = dwarf2_evaluate_loc_desc (symbol, frame, data, size, dlbaton->objfile);
+ {
+ val = allocate_value (SYMBOL_TYPE (symbol));
+ VALUE_LVAL (val) = not_lval;
+ set_value_optimized_out (val, 1);
+ }
+ else
+ val = dwarf2_evaluate_loc_desc (symbol, frame, data, size,
+ dlbaton->objfile);
return val;
}
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index a4f2161..5d86798 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -440,15 +440,8 @@ f_val_print (struct type *type, const bfd_byte *valaddr, int embedded_offset,
(TYPE_TARGET_TYPE (type),
unpack_pointer (lookup_pointer_type (builtin_type_void),
valaddr + embedded_offset));
- val_print (value_type (deref_val),
- value_contents (deref_val),
- 0,
- VALUE_ADDRESS (deref_val),
- stream,
- format,
- deref_ref,
- recurse,
- pretty);
+ common_val_print (deref_val, stream, format, deref_ref, recurse,
+ pretty);
}
else
fputs_filtered ("???", stream);
diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c
index 51ba6fb..5ca94b5 100644
--- a/gdb/jv-valprint.c
+++ b/gdb/jv-valprint.c
@@ -182,8 +182,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
else
fprintf_filtered (stream, "%d..%d: ", i, i + reps - 1);
- val_print (value_type (v), value_contents (v), 0, 0,
- stream, format, 2, 1, pretty);
+ common_val_print (v, stream, format, 2, 1, pretty);
things_printed++;
i += reps;
@@ -235,8 +234,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
return 0;
}
- return (val_print (type, value_contents (val), 0, address,
- stream, format, 1, 0, pretty));
+ return common_val_print (val, stream, format, 1, 0, pretty);
}
/* TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and PRETTY have the
@@ -384,8 +382,7 @@ java_print_value_fields (struct type *type, const bfd_byte *valaddr,
v = value_from_longest (TYPE_FIELD_TYPE (type, i),
unpack_field_as_long (type, valaddr, i));
- val_print (TYPE_FIELD_TYPE (type, i), value_contents (v), 0,
- 0, stream, format, 0, recurse + 1, pretty);
+ common_val_print (v, stream, format, 0, recurse + 1, pretty);
}
}
else
@@ -404,9 +401,8 @@ java_print_value_fields (struct type *type, const bfd_byte *valaddr,
struct type *t = check_typedef (value_type (v));
if (TYPE_CODE (t) == TYPE_CODE_STRUCT)
v = value_addr (v);
- val_print (value_type (v),
- value_contents (v), 0, VALUE_ADDRESS (v),
- stream, format, 0, recurse + 1, pretty);
+ common_val_print (v, stream, format, 0, recurse + 1,
+ pretty);
}
}
else if (TYPE_FIELD_TYPE (type, i) == NULL)
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 46e40e0..e2105eb 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -240,9 +240,8 @@ pascal_val_print (struct type *type, const bfd_byte *valaddr,
wtype = TYPE_TARGET_TYPE (type);
}
vt_val = value_at (wtype, vt_address);
- val_print (value_type (vt_val), value_contents (vt_val), 0,
- VALUE_ADDRESS (vt_val), stream, format,
- deref_ref, recurse + 1, pretty);
+ common_val_print (vt_val, stream, format, deref_ref,
+ recurse + 1, pretty);
if (pretty)
{
fprintf_filtered (stream, "\n");
@@ -292,10 +291,8 @@ pascal_val_print (struct type *type, const bfd_byte *valaddr,
(TYPE_TARGET_TYPE (type),
unpack_pointer (lookup_pointer_type (builtin_type_void),
valaddr + embedded_offset));
- val_print (value_type (deref_val),
- value_contents (deref_val), 0,
- VALUE_ADDRESS (deref_val), stream, format,
- deref_ref, recurse + 1, pretty);
+ common_val_print (deref_val, stream, format, deref_ref,
+ recurse + 1, pretty);
}
else
fputs_filtered ("???", stream);
@@ -566,9 +563,7 @@ pascal_value_print (struct value *val, struct ui_file *stream, int format,
fprintf_filtered (stream, ") ");
}
}
- return val_print (type, value_contents (val), value_embedded_offset (val),
- VALUE_ADDRESS (val) + value_offset (val),
- stream, format, 1, 0, pretty);
+ return common_val_print (val, stream, format, 1, 0, pretty);
}
@@ -591,7 +586,7 @@ show_pascal_static_field_print (struct ui_file *file, int from_tty,
static struct obstack dont_print_vb_obstack;
static struct obstack dont_print_statmem_obstack;
-static void pascal_object_print_static_field (struct type *, struct value *,
+static void pascal_object_print_static_field (struct value *,
struct ui_file *, int, int,
enum val_prettyprint);
@@ -854,8 +849,7 @@ pascal_object_print_value_fields (struct type *type, const bfd_byte *valaddr,
v = value_from_longest (TYPE_FIELD_TYPE (type, i),
unpack_field_as_long (type, valaddr, i));
- val_print (TYPE_FIELD_TYPE (type, i), value_contents (v), 0, 0,
- stream, format, 0, recurse + 1, pretty);
+ common_val_print (v, stream, format, 0, recurse + 1, pretty);
}
}
else
@@ -874,9 +868,8 @@ pascal_object_print_value_fields (struct type *type, const bfd_byte *valaddr,
if (v == NULL)
fputs_filtered ("<optimized out>", stream);
else
- pascal_object_print_static_field (TYPE_FIELD_TYPE (type, i), v,
- stream, format, recurse + 1,
- pretty);
+ pascal_object_print_static_field (v, stream, format,
+ recurse + 1, pretty);
}
else
{
@@ -1017,14 +1010,16 @@ pascal_object_print_value (struct type *type, const bfd_byte *valaddr,
static member classes in an obstack and refuse to print them more
than once.
- VAL contains the value to print, TYPE, STREAM, RECURSE, and PRETTY
+ VAL contains the value to print, STREAM, RECURSE, and PRETTY
have the same meanings as in c_val_print. */
static void
-pascal_object_print_static_field (struct type *type, struct value *val,
+pascal_object_print_static_field (struct value *val,
struct ui_file *stream, int format,
int recurse, enum val_prettyprint pretty)
{
+ struct type *type = value_type (val);
+
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
{
CORE_ADDR *first_dont_print;
@@ -1053,8 +1048,7 @@ pascal_object_print_static_field (struct type *type, struct value *val,
stream, format, recurse, pretty, NULL, 1);
return;
}
- val_print (type, value_contents (val), 0, VALUE_ADDRESS (val),
- stream, format, 0, recurse, pretty);
+ common_val_print (val, stream, format, 0, recurse, pretty);
}
void
diff --git a/gdb/scm-valprint.c b/gdb/scm-valprint.c
index b7b3e10..fccedca 100644
--- a/gdb/scm-valprint.c
+++ b/gdb/scm-valprint.c
@@ -391,6 +391,5 @@ int
scm_value_print (struct value *val, struct ui_file *stream, int format,
enum val_prettyprint pretty)
{
- return (val_print (value_type (val), value_contents (val), 0,
- VALUE_ADDRESS (val), stream, format, 1, 0, pretty));
+ return (common_val_print (val, stream, format, 1, 0, pretty));
}
diff --git a/gdb/stack.c b/gdb/stack.c
index 6570d67..80f86bf 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -354,9 +354,7 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num,
if (val)
{
- val_print (value_type (val), value_contents (val), 0,
- VALUE_ADDRESS (val),
- stb->stream, 0, 0, 2, Val_no_prettyprint);
+ common_val_print (val, stb->stream, 0, 0, 2, Val_no_prettyprint);
ui_out_field_stream (uiout, "value", stb);
}
else
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 044ed21..bda75ef 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -217,25 +217,66 @@ val_print (struct type *type, const bfd_byte *valaddr, int embedded_offset,
stream, format, deref_ref, recurse, pretty));
}
-/* Print the value VAL in C-ish syntax on stream STREAM.
- FORMAT is a format-letter, or 0 for print in natural format of data type.
- If the object printed is a string pointer, returns
- the number of string bytes printed. */
+/* Check whether the value VAL is printable. Return 1 if it is;
+ return 0 and print an appropriate error message to STREAM if it
+ is not. */
-int
-value_print (struct value *val, struct ui_file *stream, int format,
- enum val_prettyprint pretty)
+static int
+value_check_printable (struct value *val, struct ui_file *stream)
{
if (val == 0)
{
- printf_filtered (_("<address of value unknown>"));
+ fprintf_filtered (stream, _("<address of value unknown>"));
return 0;
}
+
if (value_optimized_out (val))
{
- printf_filtered (_("<value optimized out>"));
+ fprintf_filtered (stream, _("<value optimized out>"));
return 0;
}
+
+ return 1;
+}
+
+/* Print the value VAL onto stream STREAM according to FORMAT (a
+ letter, or 0 for natural format using TYPE).
+
+ If DEREF_REF is nonzero, then dereference references, otherwise just print
+ them like pointers.
+
+ The PRETTY parameter controls prettyprinting.
+
+ If the data are a string pointer, returns the number of string characters
+ printed.
+
+ This is a preferable interface to val_print, above, because it uses
+ GDB's value mechanism. */
+
+int
+common_val_print (struct value *val, struct ui_file *stream, int format,
+ int deref_ref, int recurse, enum val_prettyprint pretty)
+{
+ if (!value_check_printable (val, stream))
+ return 0;
+
+ return val_print (value_type (val), value_contents_all (val),
+ value_embedded_offset (val), VALUE_ADDRESS (val),
+ stream, format, deref_ref, recurse, pretty);
+}
+
+/* Print the value VAL in C-ish syntax on stream STREAM.
+ FORMAT is a format-letter, or 0 for print in natural format of data type.
+ If the object printed is a string pointer, returns
+ the number of string bytes printed. */
+
+int
+value_print (struct value *val, struct ui_file *stream, int format,
+ enum val_prettyprint pretty)
+{
+ if (!value_check_printable (val, stream))
+ return 0;
+
return LA_VALUE_PRINT (val, stream, format, pretty);
}
diff --git a/gdb/value.h b/gdb/value.h
index 8e31c86..6688d96 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -479,6 +479,11 @@ extern int val_print (struct type *type, const bfd_byte *valaddr,
int deref_ref, int recurse,
enum val_prettyprint pretty);
+extern int common_val_print (struct value *val,
+ struct ui_file *stream, int format,
+ int deref_ref, int recurse,
+ enum val_prettyprint pretty);
+
extern int val_print_string (CORE_ADDR addr, int len, int width,
struct ui_file *stream);
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 8532a7c..019af9e 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2080,10 +2080,8 @@ c_value_of_variable (struct varobj *var)
if (value_lazy (var->value))
gdb_value_fetch_lazy (var->value);
- val_print (value_type (var->value),
- value_contents_raw (var->value), 0,
- VALUE_ADDRESS (var->value), stb,
- format_code[(int) var->format], 1, 0, 0);
+ common_val_print (var->value, stb,
+ format_code[(int) var->format], 1, 0, 0);
thevalue = ui_file_xstrdup (stb, &dummy);
do_cleanups (old_chain);
return thevalue;