This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] gdb.python: Do all C testing before any C++ testing.
- From: dje at google dot com (Doug Evans)
- To: gdb-patches at sourceware dot org
- Date: Mon, 14 May 2012 22:35:56 -0700 (PDT)
- Subject: [patch] gdb.python: Do all C testing before any C++ testing.
Hi.
One of the properties of Fission is that the output of the compiler
is now two files: foo.o and foo.dwo.
So if we compile foo.c as C and then as C++, the C++ compile
will clobber the C foo.dwo and the tests will fail.
This changes the tests to avoid this.
I will commit this in a few days if there are no objections.
2012-05-14 Doug Evans <dje@google.com>
* gdb.python/py-prettyprint.exp: Do all C testing before any C++
testing.
* gdb.python/py-symbol.exp: Ditto.
* gdb.python/py-value.exp: Ditto.
Index: testsuite/gdb.python/py-prettyprint.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-prettyprint.exp,v
retrieving revision 1.25
diff -u -p -r1.25 py-prettyprint.exp
--- testsuite/gdb.python/py-prettyprint.exp 16 Jan 2012 16:21:52 -0000 1.25
+++ testsuite/gdb.python/py-prettyprint.exp 15 May 2012 05:29:13 -0000
@@ -110,7 +110,6 @@ proc run_lang_tests {exefile lang} {
}
run_lang_tests "${binfile}" "c"
-run_lang_tests "${binfile}-cxx" "c++"
# Run various other tests.
@@ -147,3 +146,11 @@ gdb_test "print ss" " = a=< a=<1> b=<$he
"print ss enabled #2"
remote_file host delete ${remote_python_file}
+
+# Now that we're done with C testing, test C++.
+# Note: This build must be done after all C testing because the .o file
+# used by the C and C++ versions are the same, and thus if we're testing
+# Fission then the .dwo files will be the same, and building the c++ file
+# will clobber the C .dwo file.
+
+run_lang_tests "${binfile}-cxx" "c++"
Index: testsuite/gdb.python/py-symbol.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-symbol.exp,v
retrieving revision 1.14
diff -u -p -r1.14 py-symbol.exp
--- testsuite/gdb.python/py-symbol.exp 8 Feb 2012 19:58:25 -0000 1.14
+++ testsuite/gdb.python/py-symbol.exp 15 May 2012 05:29:13 -0000
@@ -121,8 +122,31 @@ gdb_test "python print t\[0\].type" "enu
# Test symtab attribute.
gdb_test "python print t\[0\].symtab" "gdb.python/py-symbol.c.*" "Get symtab"
+# Test is_valid when the objfile is unloaded.
+# This must be the last C test as it unloads the object file in GDB.
+# Start with a fresh gdb.
+clean_restart ${testfile}
+if ![runto_main] then {
+ fail "Cannot run to main."
+ return 0
+}
+gdb_breakpoint [gdb_get_line_number "Break at end."]
+gdb_continue_to_breakpoint "Break at end."
+gdb_py_test_silent_cmd "python a = gdb.lookup_symbol(\'a\')" "Get variable a" 0
+gdb_test "python print a\[0\].is_valid()" "True" "Test symbol validity"
+delete_breakpoints
+gdb_unload
+gdb_test "python print a\[0\].is_valid()" "False" "Test symbol validity"
+
+# WARNING: At this point the objfile is unloaded.
+# For any further testing, restart GDB.
+
# C++ tests
# Recompile binary.
+# Note: This build must be done after all C testing because the .o file
+# used by the C and C++ versions are the same, and thus if we're testing
+# Fission then the .dwo files will be the same, and building the c++ file
+# will clobber the C .dwo file.
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}-cxx" executable "debug c++"] != "" } {
untested "Couldn't compile ${srcfile} in c++ mode"
return -1
@@ -152,19 +176,3 @@ gdb_test "python print cplusfunc.name" "
gdb_test "python print cplusfunc.print_name" "SimpleClass::valueofi().*" "Test func.print_name"
gdb_test "python print cplusfunc.linkage_name" "SimpleClass::valueofi().*" "Test func.linkage_name"
gdb_test "python print cplusfunc.addr_class == gdb.SYMBOL_LOC_BLOCK" "True" "Test func.addr_class"
-
-# Test is_valid when the objfile is unloaded. This must be the last
-# test as it unloads the object file in GDB.
-# Start with a fresh gdb.
-clean_restart ${testfile}
-if ![runto_main] then {
- fail "Cannot run to main."
- return 0
-}
-gdb_breakpoint [gdb_get_line_number "Break at end."]
-gdb_continue_to_breakpoint "Break at end."
-gdb_py_test_silent_cmd "python a = gdb.lookup_symbol(\'a\')" "Get variable a" 0
-gdb_test "python print a\[0\].is_valid()" "True" "Test symbol validity"
-delete_breakpoints
-gdb_unload
-gdb_test "python print a\[0\].is_valid()" "False" "Test symbol validity"
Index: testsuite/gdb.python/py-value.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-value.exp,v
retrieving revision 1.27
diff -u -p -r1.27 py-value.exp
--- testsuite/gdb.python/py-value.exp 16 Jan 2012 16:21:52 -0000 1.27
+++ testsuite/gdb.python/py-value.exp 15 May 2012 05:29:13 -0000
@@ -20,11 +20,13 @@ load_lib gdb-python.exp
set testfile "py-value"
set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+set binfile ${testfile}
# Build inferior to language specification.
-proc build_inferior {exefile lang} {
- global srcdir subdir srcfile testfile hex
+proc build_inferior {binfile lang} {
+ global srcdir objdir subdir srcfile testfile hex
+
+ set exefile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${exefile}" executable "debug $lang"] != "" } {
untested "Couldn't compile ${srcfile} in $lang mode"
@@ -364,15 +366,9 @@ proc test_value_after_death {} {
# the type of the value was not being checked before allowing a
# subscript operation to proceed.
-proc test_subscript_regression {exefile lang} {
-
- global srcdir subdir
-
+proc test_subscript_regression {binfile lang} {
# Start with a fresh gdb.
- gdb_exit
- gdb_start
- gdb_reinitialize_dir $srcdir/$subdir
- gdb_load ${exefile}
+ clean_restart ${binfile}
if ![runto_main ] then {
perror "couldn't run to breakpoint"
@@ -465,14 +461,9 @@ proc test_value_hash {} {
# Build C and C++ versions of executable
build_inferior "${binfile}" "c"
-build_inferior "${binfile}-cxx" "c++"
# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
@@ -499,4 +490,10 @@ test_value_after_death
# Test either C or C++ values.
test_subscript_regression "${binfile}" "c"
+
+# Note: This build must be done after all C testing because the .o file
+# used by the C and C++ versions are the same, and thus if we're testing
+# Fission then the .dwo files will be the same, and building the c++ file
+# will clobber the C .dwo file.
+build_inferior "${binfile}-cxx" "c++"
test_subscript_regression "${binfile}-cxx" "c++"