diff options
author | Pedro Alves <palves@redhat.com> | 2011-02-14 11:35:45 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2011-02-14 11:35:45 +0000 |
commit | 8af8e3bc815c464731924d121681ac73cae1ab1d (patch) | |
tree | ff401808e5259498226db71f707f4fdf7aa30c33 /gdb/cp-valprint.c | |
parent | 1b28d0b3beda72343ea25f135f17746340cae89c (diff) | |
download | gdb-8af8e3bc815c464731924d121681ac73cae1ab1d.zip gdb-8af8e3bc815c464731924d121681ac73cae1ab1d.tar.gz gdb-8af8e3bc815c464731924d121681ac73cae1ab1d.tar.bz2 |
gdb/
* exceptions.h (NOT_AVAILABLE_ERROR): New error.
* value.c: Include "exceptions.h".
(require_available): Throw NOT_AVAILABLE_ERROR instead of a
generic error.
* cp-abi.c: Include gdb_assert.h.
(baseclass_offset): Add `embedded_offset' and `val' parameters.
Assert the method is implemented. Wrap NOT_AVAILABLE_ERROR
errors.
* cp-abi.h (baseclass_offset): Add `embedded_offset' and `val'
parameters. No longer returns -1 on error.
(struct cp_abi_ops) <baseclass_offset>: Add `embedded_offset' and
`val' parameters.
* cp-valprint.c: Include exceptions.h.
(cp_print_value): Handle NOT_AVAILABLE_ERROR errors when fetching
the baseclass_offset. Handle unavailable base classes. Use
val_print_invalid_address.
* p-valprint.c: Include exceptions.h.
(pascal_object_print_value): Handle NOT_AVAILABLE_ERROR errors
when fetching the baseclass_offset. No longer expect
baseclass_offset returning -1. Handle unavailable base classes.
Use val_print_invalid_address.
* valops.c (dynamic_cast_check_1): Rename `contents' parameter to
`valaddr' parameter, and change its type to gdb_byte pointer. Add
`embedded_offset' and `val' parameters. Adjust.
(dynamic_cast_check_2): Rename `contents' parameter to `valaddr'
parameter, and change its type to gdb_byte pointer. Add
`embedded_offset' and `val' parameters. Adjust. No longer expect
baseclass_offset returning -1.
(value_dynamic_cast): Use value_contents_for_printing rather than
value_contents. Adjust.
(search_struct_field): No longer expect baseclass_offset returning
-1.
(search_struct_method): If reading memory from the target is
necessary, wrap it in a new value to pass to baseclass_offset. No
longer expect baseclass_offset returning -1.
(find_method_list): No longer expect baseclass_offset returning
-1. Use value_contents_for_printing rather than value_contents.
* valprint.c (val_print_invalid_address): New function.
* valprint.h (val_print_invalid_address): Declare.
* gdbtypes.c (is_unique_ancestor_worker): New `embedded_offset'
and `val' parameters. No longer expect baseclass_offset returning
-1. Adjust.
* gnu-v2-abi.c: Include "exceptions.h".
(gnuv2_baseclass_offset): Add `embedded_offset' and `val'
parameters. Handle unavailable memory. Recurse through
gnuv2_baseclass_offset directly, rather than through
baseclass_offset. No longer returns -1 on not found, instead
throw an error.
* gnu-v3-abi.c (gnuv3_baseclass_offset): Add `embedded_offset' and
`val' parameters. Adjust.
gdb/testsuite/
* gdb.trace/unavailable.cc (class Base, class Middle, class
Derived): New types.
(derived_unavail, derived_partial, derived_whole): New globals.
(virtual_partial): New global.
(virtualp): Point at virtual_partial.
* gdb.trace/unavailable.exp (gdb_collect_globals_test): Add tests
related to unavailable vptr.
Diffstat (limited to 'gdb/cp-valprint.c')
-rw-r--r-- | gdb/cp-valprint.c | 83 |
1 files changed, 47 insertions, 36 deletions
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 1a171ea..255e9ce 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -37,6 +37,7 @@ #include "cp-support.h" #include "language.h" #include "python/python.h" +#include "exceptions.h" /* Controls printing of vtbl's. */ static void @@ -482,12 +483,13 @@ cp_print_value (struct type *type, struct type *real_type, for (i = 0; i < n_baseclasses; i++) { - int boffset; + int boffset = 0; int skip; struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i)); char *basename = TYPE_NAME (baseclass); - const gdb_byte *base_valaddr; - const struct value *base_val; + const gdb_byte *base_valaddr = NULL; + const struct value *base_val = NULL; + volatile struct gdb_exception ex; if (BASETYPE_VIA_VIRTUAL (type, i)) { @@ -507,34 +509,47 @@ cp_print_value (struct type *type, struct type *real_type, thisoffset = offset; thistype = real_type; - boffset = baseclass_offset (type, i, valaddr + offset, - address + offset); - skip = ((boffset == -1) || (boffset + offset) < 0); - - if (BASETYPE_VIA_VIRTUAL (type, i)) + TRY_CATCH (ex, RETURN_MASK_ERROR) { - /* The virtual base class pointer might have been clobbered - by the user program. Make sure that it still points to a - valid memory location. */ + boffset = baseclass_offset (type, i, valaddr, offset, address, val); + } + if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR) + skip = -1; + else if (ex.reason < 0) + skip = 1; + else + { + skip = 0; - if (boffset != -1 - && ((boffset + offset) < 0 - || (boffset + offset) >= TYPE_LENGTH (real_type))) + if (BASETYPE_VIA_VIRTUAL (type, i)) { - /* FIXME (alloca): unsafe if baseclass is really really - large. */ - gdb_byte *buf = alloca (TYPE_LENGTH (baseclass)); - - if (target_read_memory (address + boffset, buf, - TYPE_LENGTH (baseclass)) != 0) - skip = 1; - 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); + /* The virtual base class pointer might have been + clobbered by the user program. Make sure that it + still points to a valid memory location. */ + + if ((boffset + offset) < 0 + || (boffset + offset) >= TYPE_LENGTH (real_type)) + { + /* FIXME (alloca): unsafe if baseclass is really + really large. */ + gdb_byte *buf = alloca (TYPE_LENGTH (baseclass)); + + if (target_read_memory (address + boffset, buf, + TYPE_LENGTH (baseclass)) != 0) + skip = 1; + 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_val = val; + } } else { @@ -542,11 +557,6 @@ cp_print_value (struct type *type, struct type *real_type, base_val = val; } } - else - { - base_valaddr = valaddr; - base_val = val; - } /* Now do the printing. */ if (options->pretty) @@ -560,9 +570,10 @@ cp_print_value (struct type *type, struct type *real_type, fputs_filtered (basename ? basename : "", stream); fputs_filtered ("> = ", stream); - - if (skip) - fprintf_filtered (stream, "<invalid address>"); + if (skip < 0) + val_print_unavailable (stream); + else if (skip > 0) + val_print_invalid_address (stream); else { int result = 0; |