Index: c-valprint.c =================================================================== RCS file: /cvs/src/src/gdb/c-valprint.c,v retrieving revision 1.39 diff -u -p -r1.39 c-valprint.c --- c-valprint.c 18 Jan 2006 21:24:19 -0000 1.39 +++ c-valprint.c 6 Apr 2006 08:28:55 -0000 @@ -277,13 +277,16 @@ c_val_print (struct type *type, const gd { if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF) { - struct value *deref_val = - value_at - (TYPE_TARGET_TYPE (type), - unpack_pointer (lookup_pointer_type (builtin_type_void), - valaddr + embedded_offset)); - common_val_print (deref_val, stream, format, deref_ref, - recurse, pretty); + CORE_ADDR addr = unpack_pointer ( + lookup_pointer_type (builtin_type_void), + valaddr + embedded_offset); + struct value *deref_val = value_at_maybe(TYPE_TARGET_TYPE(type), + addr); + if (deref_val) + common_val_print (deref_val, stream, format, deref_ref, + recurse, pretty); + else + fputs_filtered("memory not accessible", stream); } else fputs_filtered ("???", stream); Index: valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.163 diff -u -p -r1.163 valops.c --- valops.c 17 Dec 2005 22:34:03 -0000 1.163 +++ valops.c 6 Apr 2006 08:28:55 -0000 @@ -472,6 +472,36 @@ value_at (struct type *type, CORE_ADDR a return val; } + +/* Same as 'value_at', but returns NULL when memory can't be read + instead of throwing. +*/ +struct value* +value_at_maybe (struct type *type, CORE_ADDR addr) +{ + struct value *val; + int status; + + if (TYPE_CODE (check_typedef (type)) == TYPE_CODE_VOID) + error (_("Attempt to dereference a generic pointer.")); + + + val = allocate_value (type); + status = target_read_memory (addr, value_contents_all_raw(val), + TYPE_LENGTH (type)); + if (status == 0) + { + VALUE_LVAL (val) = lval_memory; + VALUE_ADDRESS (val) = addr; + return val; + } + else + { + return 0; + } +} + + /* Return a lazy value with type TYPE located at ADDR (cf. value_at). */ struct value * Index: value.h =================================================================== RCS file: /cvs/src/src/gdb/value.h,v retrieving revision 1.90 diff -u -p -r1.90 value.h --- value.h 1 Feb 2006 23:14:10 -0000 1.90 +++ value.h 6 Apr 2006 08:28:56 -0000 @@ -277,6 +277,8 @@ extern struct value *value_from_string ( extern struct value *value_at (struct type *type, CORE_ADDR addr); extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr); +extern struct value *value_at_maybe (struct type *type, CORE_ADDR addr); + extern struct value *value_from_register (struct type *type, int regnum, struct frame_info *frame); Index: mi/mi-cmd-stack.c =================================================================== RCS file: /cvs/src/src/gdb/mi/mi-cmd-stack.c,v retrieving revision 1.29 diff -u -p -r1.29 mi-cmd-stack.c --- mi/mi-cmd-stack.c 23 Dec 2005 18:57:46 -0000 1.29 +++ mi/mi-cmd-stack.c 6 Apr 2006 08:28:56 -0000 @@ -278,6 +278,8 @@ list_args_or_locals (int locals, int val { struct cleanup *cleanup_tuple = NULL; struct symbol *sym2; + struct value *val; + int print_it = 0; if (values != PRINT_NO_VALUES) cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); @@ -300,17 +302,24 @@ list_args_or_locals (int locals, int val && TYPE_CODE (type) != TYPE_CODE_STRUCT && TYPE_CODE (type) != TYPE_CODE_UNION) { - print_variable_value (sym2, fi, stb->stream); - ui_out_field_stream (uiout, "value", stb); + print_it = 1; } do_cleanups (cleanup_tuple); break; case PRINT_ALL_VALUES: - print_variable_value (sym2, fi, stb->stream); - ui_out_field_stream (uiout, "value", stb); - do_cleanups (cleanup_tuple); + print_it = 1; break; } + + if (print_it) + { + val = read_var_value (sym2, fi); + common_val_print + (val, stb->stream, 0, 1 /*deref refs*/, 2, Val_no_prettyprint); + ui_out_field_stream (uiout, "value", stb); + do_cleanups (cleanup_tuple); + } + } } if (BLOCK_FUNCTION (block))