aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Pluzhnikov <ppluzhnikov@google.com>2008-07-14 18:28:57 +0000
committerPaul Pluzhnikov <ppluzhnikov@google.com>2008-07-14 18:28:57 +0000
commit7093c834d701edb312386d6953c47c50924a2628 (patch)
tree55141ad44cc3308fbd2546024b55d1da61ea8db1
parent5651477109e89a1a78c5c28cfac55c6141000754 (diff)
downloadgdb-7093c834d701edb312386d6953c47c50924a2628.zip
gdb-7093c834d701edb312386d6953c47c50924a2628.tar.gz
gdb-7093c834d701edb312386d6953c47c50924a2628.tar.bz2
Fix for PR gdb/2477
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/Makefile.in2
-rw-r--r--gdb/cp-abi.c11
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.cp/class2.cc11
-rw-r--r--gdb/testsuite/gdb.cp/class2.exp7
6 files changed, 37 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bb12239..8741bbc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2008-07-14 Paul Pluzhnikov <ppluzhnikov@google.com>
+
+ PR gdb/2477
+ * cp-abi.c (value_virtual_fn_field): Handle invalid pointers.
+
2008-07-14 Pedro Alves <pedro@codesourcery.com>
* i386-dicos-tdep.c (i386_dicos_frame_align): Delete.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 013d444..3e82b92 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2022,7 +2022,7 @@ corelow.o: corelow.c $(defs_h) $(arch_utils_h) $(gdb_string_h) $(frame_h) \
core-regset.o: core-regset.c $(defs_h) $(command_h) $(gdbcore_h) \
$(inferior_h) $(target_h) $(regcache_h) $(gdb_string_h) $(gregset_h)
cp-abi.o: cp-abi.c $(defs_h) $(value_h) $(cp_abi_h) $(command_h) $(gdbcmd_h) \
- $(ui_out_h) $(gdb_string_h)
+ $(ui_out_h) $(gdb_string_h) $(exceptions_h)
cp-name-parser.o: cp-name-parser.c $(safe_ctype_h) $(libiberty_h) $(demangle_h)
cp-namespace.o: cp-namespace.c $(defs_h) $(cp_support_h) $(gdb_obstack_h) \
$(symtab_h) $(symfile_h) $(gdb_assert_h) $(block_h) $(objfiles_h) \
diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
index 6e200ff..250f64b 100644
--- a/gdb/cp-abi.c
+++ b/gdb/cp-abi.c
@@ -22,6 +22,7 @@
#include "value.h"
#include "cp-abi.h"
#include "command.h"
+#include "exceptions.h"
#include "gdbcmd.h"
#include "ui-out.h"
@@ -89,9 +90,17 @@ value_virtual_fn_field (struct value **arg1p, struct fn_field *f, int j,
struct type *
value_rtti_type (struct value *v, int *full, int *top, int *using_enc)
{
+ struct type *ret = NULL;
+ struct gdb_exception e;
if ((current_cp_abi.rtti_type) == NULL)
return NULL;
- return (*current_cp_abi.rtti_type) (v, full, top, using_enc);
+ TRY_CATCH (e, RETURN_MASK_ERROR)
+ {
+ ret = (*current_cp_abi.rtti_type) (v, full, top, using_enc);
+ }
+ if (e.reason < 0)
+ return NULL;
+ return ret;
}
void
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 4aacf9b..51b55bb 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2008-07-14 Paul Pluzhnikov <ppluzhnikov@google.com>
+
+ * gdb.cp/class2.exp, gdb.cp/class2.cc: Test for PR2477.
+
2008-07-13 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/randomize.exp: Catch non-Linux targets as untested.
diff --git a/gdb/testsuite/gdb.cp/class2.cc b/gdb/testsuite/gdb.cp/class2.cc
index 8aba5c3..9a34309 100644
--- a/gdb/testsuite/gdb.cp/class2.cc
+++ b/gdb/testsuite/gdb.cp/class2.cc
@@ -41,6 +41,12 @@ B::~B()
b2 = 902;
}
+struct C : public B
+{
+ A *c1;
+ A *c2;
+};
+
// Stop the compiler from optimizing away data.
void refer (A *)
{
@@ -57,16 +63,19 @@ void refer (empty *)
int main (void)
{
- A alpha, *aap, *abp;
+ A alpha, *aap, *abp, *acp;
B beta, *bbp;
+ C gamma;
empty e;
alpha.a1 = 100;
beta.a1 = 200; beta.b1 = 201; beta.b2 = 202;
+ gamma.c1 = 0; gamma.c2 = (A *) ~0UL;
aap = &alpha; refer (aap);
abp = &beta; refer (abp);
bbp = &beta; refer (bbp);
+ acp = &gamma; refer (acp);
refer (&e);
return 0; // marker return 0
diff --git a/gdb/testsuite/gdb.cp/class2.exp b/gdb/testsuite/gdb.cp/class2.exp
index 4ae0947..d39130d 100644
--- a/gdb/testsuite/gdb.cp/class2.exp
+++ b/gdb/testsuite/gdb.cp/class2.exp
@@ -117,3 +117,10 @@ gdb_test "print * (B *) abp" \
# Printing the value of an object containing no data fields:
gdb_test "p e" "= \{<No data fields>\}" "print object with no data fields"
+
+# Printing NULL pointers with "set print object on"
+
+gdb_test "set print object on" ""
+gdb_test "p acp" "= \\(C \\*\\) 0x\[a-f0-9\]+"
+gdb_test "p acp->c1" "\\(A \\*\\) 0x0"
+gdb_test "p acp->c2" "\\(A \\*\\) 0xf+"