This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
RFA: Check for corruption of cv_type chain
- From: Jim Blandy <jimb at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 3 May 2002 16:54:23 -0500 (EST)
- Subject: RFA: Check for corruption of cv_type chain
This extends hang.exp to test for both of the bugs described in its
comments.
2002-05-03 Jim Blandy <jimb@redhat.com>
* gdb.c++/hang.exp: Check for corruption of the cv_type chain.
If we're compiling with GCC, pass the -gstabs+ flag, to get
the stabs needed to trigger the bug.
* gdb.c++/hang3.C: New file.
Index: gdb/testsuite/gdb.c++/hang.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.c++/hang.exp,v
retrieving revision 1.1
diff -c -r1.1 hang.exp
*** gdb/testsuite/gdb.c++/hang.exp 2 May 2002 07:03:53 -0000 1.1
--- gdb/testsuite/gdb.c++/hang.exp 3 May 2002 18:23:49 -0000
***************
*** 29,41 ****
set testfile hang
set binfile ${objdir}/${subdir}/${testfile}
! foreach file {hang1 hang2} {
! if { [gdb_compile "${srcdir}/${subdir}/${file}.C" "${file}.o" object {debug c++}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
}
! if {[gdb_compile "hang1.o hang2.o" ${binfile} executable {debug c++}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
--- 29,61 ----
set testfile hang
set binfile ${objdir}/${subdir}/${testfile}
! if [get_compiler_info ${binfile} "c++"] {
! return -1;
! }
!
! # These tests are intended to catch problems in the STABS reader, so I
! # think it's okay to override the preference the user expressed in
! # their $DEJAGNU file or whatever, and explicitly request extended
! # stabs debugging information. But, if we don't know how to do that,
! # these tests still should pass just fine if the executable uses some
! # other format.
! #
! # Plain old -gstabs isn't enough, by the way. See the notes for
! # "doesn't corrupt cv_type chain", below.
! if {$gcc_compiled} {
! set debug_option additional_flags=-gstabs+
! } else {
! set debug_option debug
! }
! set options [list c++ $debug_option]
!
! foreach file {hang1 hang2 hang3} {
! if {[gdb_compile "${srcdir}/${subdir}/${file}.C" "${file}.o" object $options] != ""} {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
}
! if {[gdb_compile "hang1.o hang2.o hang3.o" ${binfile} executable $options] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
***************
*** 110,113 ****
# in `cleanup_undefined_types' corrupted the target type's `cv_type'
# ring, `finish_cv_type' enters an infinite loop.
! gdb_test "print var_in_b" " = 1729" "can read debug info"
--- 130,148 ----
# in `cleanup_undefined_types' corrupted the target type's `cv_type'
# ring, `finish_cv_type' enters an infinite loop.
! # This checks that GDB recognizes when a structure is about to be
! # overwritten, and refuses, with a complaint.
! gdb_test "print var_in_hang2" " = 1729" "doesn't overwrite struct type"
!
! # This checks that cleanup_undefined_types doesn't create corrupt
! # cv_type chains. Note that var_in_hang3 does need to be declared in
! # a separate compilation unit, whose psymtab depends on hang1.o's
! # psymtab. Otherwise, GDB won't call cleanup_undefined_types (as it
! # finishes hang1.o's symbols) before it calls make_cv_type (while
! # reading hang3.o's symbols).
! #
! # The bug only happens when you compile with -gstabs+; Otherwise, GCC
! # won't include the `const' qualifier on `const_B_ptr' in `hang3.o''s
! # STABS, so GDB won't try to create a const variant of the smashed
! # struct type, and get caught by the corrupted cv_type chain.
! gdb_test "print var_in_hang3" " = 42" "doesn't corrupt cv_type chain"
Index: gdb/testsuite/gdb.c++/hang2.C
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.c++/hang2.C,v
retrieving revision 1.1
diff -c -r1.1 hang2.C
*** gdb/testsuite/gdb.c++/hang2.C 2 May 2002 07:03:53 -0000 1.1
--- gdb/testsuite/gdb.c++/hang2.C 3 May 2002 18:23:49 -0000
***************
*** 5,8 ****
int member_of_B;
};
! int var_in_b = 1729;
--- 5,8 ----
int member_of_B;
};
! int var_in_hang2 = 1729;
Index: gdb/testsuite/gdb.c++/hang3.C
===================================================================
RCS file: gdb/testsuite/gdb.c++/hang3.C
diff -N gdb/testsuite/gdb.c++/hang3.C
*** gdb/testsuite/gdb.c++/hang3.C 1 Jan 1970 00:00:00 -0000
--- gdb/testsuite/gdb.c++/hang3.C 3 May 2002 18:23:49 -0000
***************
*** 0 ****
--- 1,4 ----
+ #include "hang.H"
+
+ const struct B *const_B_ptr;
+ int var_in_hang3 = 42;