aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-02-14 11:35:45 +0000
committerPedro Alves <palves@redhat.com>2011-02-14 11:35:45 +0000
commit8af8e3bc815c464731924d121681ac73cae1ab1d (patch)
treeff401808e5259498226db71f707f4fdf7aa30c33 /gdb/testsuite
parent1b28d0b3beda72343ea25f135f17746340cae89c (diff)
downloadgdb-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/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog10
-rw-r--r--gdb/testsuite/gdb.trace/unavailable.cc33
-rw-r--r--gdb/testsuite/gdb.trace/unavailable.exp50
3 files changed, 91 insertions, 2 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 0fab274..eb00301 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,15 @@
2011-02-14 Pedro Alves <pedro@codesourcery.com>
+ * 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.
+
+2011-02-14 Pedro Alves <pedro@codesourcery.com>
+
* gdb.trace/unavailable.cc (a, b, c): New globals.
(main): Set and clear them.
* gdb.trace/unavailable.exp (gdb_collect_globals_test): Collect
diff --git a/gdb/testsuite/gdb.trace/unavailable.cc b/gdb/testsuite/gdb.trace/unavailable.cc
index 7b4a2b2..36b7455 100644
--- a/gdb/testsuite/gdb.trace/unavailable.cc
+++ b/gdb/testsuite/gdb.trace/unavailable.cc
@@ -133,13 +133,44 @@ struct StructA StructB::static_struct_a;
StructRef g_structref(0x12345678);
StructRef *g_structref_p = &g_structref;
+class Base
+{
+protected:
+ int x;
+
+public:
+ Base(void) { x = 2; };
+};
+
+class Middle: public virtual Base
+{
+protected:
+ int y;
+
+public:
+ Middle(void): Base() { y = 3; };
+};
+
+class Derived: public virtual Middle {
+protected:
+ int z;
+
+public:
+ Derived(void): Middle() { z = 4; };
+};
+
+Derived derived_unavail;
+Derived derived_partial;
+Derived derived_whole;
+
struct Virtual {
int z;
virtual ~Virtual() {}
};
-Virtual *virtualp;
+Virtual virtual_partial;
+Virtual *virtualp = &virtual_partial;
/* Test functions. */
diff --git a/gdb/testsuite/gdb.trace/unavailable.exp b/gdb/testsuite/gdb.trace/unavailable.exp
index 8ec6343..ab8fe97 100644
--- a/gdb/testsuite/gdb.trace/unavailable.exp
+++ b/gdb/testsuite/gdb.trace/unavailable.exp
@@ -87,6 +87,9 @@ proc gdb_collect_globals_test { } {
"Tracepoint \[0-9\]+ at .*" \
"set tracepoint"
+ # We collect the initial sizeof(pointer) bytes of derived_partial
+ # in an attempt of collecting the vptr. Not portable, but should
+ # work everywhere we need to care.
gdb_trace_setactions "define actions" \
"" \
"collect struct_b.struct_a.array\[2\]" "^$" \
@@ -106,7 +109,12 @@ proc gdb_collect_globals_test { } {
"collect g_string_partial\[1\]" "^$" \
"collect g_string_partial\[2\]" "^$" \
\
- "collect g_structref_p" "^$"
+ "collect g_structref_p" "^$" \
+ \
+ "collect *((char *)&derived_partial)@sizeof\(void *\)" "^$" \
+ "collect derived_whole" "^$" \
+ \
+ "collect virtual_partial.z" "^$"
# Begin the test.
run_trace_experiment globals_test_func
@@ -256,14 +264,54 @@ proc gdb_collect_globals_test { } {
gdb_test_no_output "set print object on"
+ set old_pf_prefix_2 $pf_prefix
+ set pf_prefix "$pf_prefix print object on:"
+
# With print object on, printing a pointer may need to fetch the
# pointed-to object, to check its run-time type. Make sure that
# fails gracefully and transparently when the pointer itself is
# unavailable.
gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>"
+ # no vtable pointer available
+ gdb_test "print derived_unavail" \
+ " = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <unavailable>}"
+
+ # vtable pointer available, but nothing else
+ gdb_test "print derived_partial" \
+ " = \\(Derived\\) {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex, z = <unavailable>}"
+
+ # whole object available
+ gdb_test "print derived_whole" \
+ " = \\(Derived\\) {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex, z = 4}"
+
+ set pf_prefix $old_pf_prefix_2
+
gdb_test_no_output "set print object off"
+ set pf_prefix "$pf_prefix print object off:"
+
+ gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>"
+
+ # no vtable pointer available
+ gdb_test "print derived_unavail" \
+ " = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <unavailable>}"
+
+ # vtable pointer available, but nothing else
+ gdb_test "print derived_partial" \
+ " = {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex, z = <unavailable>}"
+
+ # whole object available
+ gdb_test "print derived_whole" \
+ " = {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex, z = 4}"
+
+ set pf_prefix $old_pf_prefix_2
+
+ # An instance of a virtual class where we collected everything but
+ # the vptr.
+ gdb_test "print virtual_partial" \
+ " = {_vptr.Virtual = <unavailable>, z = 0}"
+
gdb_test "tfind none" \
"#0 end .*" \
"cease trace debugging"