Fix crash printing classes (BZ 849357, Tom Tromey).

This commit is contained in:
Jan Kratochvil 2012-09-27 20:50:35 +02:00
parent a7d7affa1c
commit 60a99dfbcf
2 changed files with 118 additions and 1 deletions

110
gdb-print-class.patch Normal file
View File

@ -0,0 +1,110 @@
http://sourceware.org/ml/gdb-cvs/2012-09/msg00169.html
### src/gdb/ChangeLog 2012/09/27 12:53:57 1.14718
### src/gdb/ChangeLog 2012/09/27 16:04:18 1.14719
## -1,3 +1,8 @@
+2012-09-27 Tom Tromey <tromey@redhat.com>
+
+ Fix https://bugzilla.redhat.com/show_bug.cgi?id=849357
+ * cp-valprint.c (cp_print_value_fields): Use get_vptr_fieldno.
+
2012-09-27 Joel Brobecker <brobecker@adacore.com>
* sol-thread.c (sol_thread_fetch_registers)
--- src/gdb/cp-valprint.c 2012/07/06 05:36:07 1.85
+++ src/gdb/cp-valprint.c 2012/09/27 16:04:22 1.86
@@ -210,7 +210,9 @@
{
int statmem_obstack_initial_size = 0;
int stat_array_obstack_initial_size = 0;
-
+ struct type *vptr_basetype = NULL;
+ int vptr_fieldno;
+
if (dont_print_statmem == 0)
{
statmem_obstack_initial_size =
@@ -225,6 +227,7 @@
}
}
+ vptr_fieldno = get_vptr_fieldno (type, &vptr_basetype);
for (i = n_baseclasses; i < len; i++)
{
/* If requested, skip printing of static fields. */
@@ -358,7 +361,7 @@
v, stream, recurse + 1,
options);
}
- else if (i == TYPE_VPTR_FIELDNO (type))
+ else if (i == vptr_fieldno && type == vptr_basetype)
{
int i_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8;
struct type *i_type = TYPE_FIELD_TYPE (type, i);
### src/gdb/testsuite/ChangeLog 2012/09/26 19:50:12 1.3396
### src/gdb/testsuite/ChangeLog 2012/09/27 16:04:22 1.3397
## -1,3 +1,10 @@
+2012-09-27 Tom Tromey <tromey@redhat.com>
+
+ * gdb.cp/derivation.exp: Add regression test.
+ * gdb.cp/derivation.cc (class V_base, class V_inter, class
+ V_derived): New.
+ (vderived): New global.
+
2012-09-26 Tom Tromey <tromey@redhat.com>
* gdb.dwarf2/dw2-common-block.S: New file.
--- src/gdb/testsuite/gdb.cp/derivation.cc 2011/12/13 17:22:08 1.2
+++ src/gdb/testsuite/gdb.cp/derivation.cc 2012/09/27 16:04:23 1.3
@@ -118,8 +118,37 @@
};
+class V_base
+{
+public:
+ virtual void m();
+ int base;
+};
+void
+V_base::m()
+{
+}
+
+class V_inter : public virtual V_base
+{
+public:
+ virtual void f();
+ int inter;
+};
+
+void
+V_inter::f()
+{
+}
+
+class V_derived : public V_inter
+{
+public:
+ double x;
+};
+V_derived vderived;
int A::afoo() {
return 1;
--- src/gdb/testsuite/gdb.cp/derivation.exp 2012/07/10 15:18:18 1.19
+++ src/gdb/testsuite/gdb.cp/derivation.exp 2012/09/27 16:04:23 1.20
@@ -176,3 +176,11 @@
gdb_test "print g_instance.bfoo()" "\\$\[0-9\]+ = 2" "print value of g_instance.bfoo()"
gdb_test "print g_instance.cfoo()" "\\$\[0-9\]+ = 3" "print value of g_instance.cfoo()"
+
+# This is a regression test for a bug that caused a crash when trying
+# to print the vtbl pointer. We don't care about the output so much
+# here (it is tested elsewhere), just that gdb doesn't crash. We test
+# "ptype" first because, before the gdb fix, that was the only code
+# path calling get_vptr_fieldno.
+gdb_test "ptype vderived" "type = .*"
+gdb_test "print vderived" " = {.* inter = 0.*x = 0}"

View File

@ -34,7 +34,7 @@ Version: 7.5.0.20120926
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 22%{?dist}
Release: 23%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain
Group: Development/Debuggers
@ -568,6 +568,9 @@ Patch716: gdb-minidebuginfo.patch
# [ppc32] Fix stepping over symbol-less code crash regression (BZ 860696).
Patch725: gdb-step-symless.patch
# Fix crash printing classes (BZ 849357, Tom Tromey).
Patch726: gdb-print-class.patch
%if 0%{!?rhel:1} || 0%{?rhel} > 6
# RL_STATE_FEDORA_GDB would not be found for:
# Patch642: gdb-readline62-ask-more-rh.patch
@ -877,6 +880,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c gdb/go-exp.c
%patch703 -p1
%patch716 -p1
%patch725 -p1
%patch726 -p1
%patch393 -p1
%if 0%{!?el5:1} || 0%{?scl:1}
@ -1373,6 +1377,9 @@ fi
%endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch"
%changelog
* Thu Sep 27 2012 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.5-23.fc18
- Fix crash printing classes (BZ 849357, Tom Tromey).
* Wed Sep 26 2012 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.5-22.fc18
- Fix .spec 'bundled' Provides for the stable branch rebase.