aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2010-04-22 23:15:43 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2010-04-22 23:15:43 +0000
commitc0201579c8cd0c319fa851c98b0adf21ac013489 (patch)
tree16da9856639cf50456ca57f90fa738059ead5304 /gdb/testsuite
parent793b0ff8d7126cf5ec1631fc07ffec5b5664b226 (diff)
downloadgdb-c0201579c8cd0c319fa851c98b0adf21ac013489.zip
gdb-c0201579c8cd0c319fa851c98b0adf21ac013489.tar.gz
gdb-c0201579c8cd0c319fa851c98b0adf21ac013489.tar.bz2
gdb/
Fix crashes on dangling display expressions. * ada-lang.c (ada_operator_check): New function. (ada_exp_descriptor): Fill-in the field operator_check. * c-lang.c (exp_descriptor_c): Fill-in the field operator_check. * jv-lang.c (exp_descriptor_java): Likewise. * m2-lang.c (exp_descriptor_modula2): Likewise. * scm-lang.c (exp_descriptor_scm): Likewise. * parse.c (exp_descriptor_standard): Likewise. (operator_check_standard): New function. (exp_iterate, exp_uses_objfile_iter, exp_uses_objfile): New functions. * parser-defs.h (struct exp_descriptor): New field operator_check. (operator_check_standard, exp_uses_objfile): New declarations. * printcmd.c: Remove the inclusion of solib.h. (display_uses_solib_p): Remove the function. (clear_dangling_display_expressions): Call lookup_objfile_from_block and exp_uses_objfile instead of display_uses_solib_p. * solist.h (struct so_list) <objfile>: New comment. * symtab.c (lookup_objfile_from_block): Remove the static qualifier. * symtab.h (lookup_objfile_from_block): New declaration. (struct general_symbol_info) <obj_section>: Extend the comment. gdb/testsuite/ Fix crashes on dangling display expressions. * gdb.base/solib-display.exp: Call gdb_gnu_strip_debug if LIBSEPDEBUG is SEP. (lib_flags): Remove the "debug" keyword. (libsepdebug): New variable for iterating new loop. (save_pf_prefix): New variable wrapping the loop. (sep_lib_flags): New variable derived from LIB_FLAGS. Use it. * lib/gdb.exp (gdb_gnu_strip_debug): Document the return code.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog11
-rw-r--r--gdb/testsuite/gdb.base/solib-display.exp146
-rw-r--r--gdb/testsuite/lib/gdb.exp3
3 files changed, 103 insertions, 57 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 6bbacf0..025e50d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2010-04-22 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix crashes on dangling display expressions.
+ * gdb.base/solib-display.exp: Call gdb_gnu_strip_debug if LIBSEPDEBUG
+ is SEP.
+ (lib_flags): Remove the "debug" keyword.
+ (libsepdebug): New variable for iterating new loop.
+ (save_pf_prefix): New variable wrapping the loop.
+ (sep_lib_flags): New variable derived from LIB_FLAGS. Use it.
+ * lib/gdb.exp (gdb_gnu_strip_debug): Document the return code.
+
2010-04-22 Pierre Muller <muller@ics.u-strasbg.fr>
* gdb.threads/watchthreads.exp: Change to obtain consistent output.
diff --git a/gdb/testsuite/gdb.base/solib-display.exp b/gdb/testsuite/gdb.base/solib-display.exp
index 42a48d0..9ee2633 100644
--- a/gdb/testsuite/gdb.base/solib-display.exp
+++ b/gdb/testsuite/gdb.base/solib-display.exp
@@ -36,7 +36,7 @@ if { [skip_shlib_tests] || [is_remote target] } {
set libname "solib-display-lib"
set srcfile_lib ${srcdir}/${subdir}/${libname}.c
set binfile_lib ${objdir}/${subdir}/${libname}.so
-set lib_flags [list debug]
+set lib_flags {}
# Binary file.
set testfile "solib-display-main"
set srcfile ${srcdir}/${subdir}/${testfile}.c
@@ -48,60 +48,92 @@ if [get_compiler_info ${binfile}] {
return -1
}
-if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
- || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
- untested "Could not compile $binfile_lib or $binfile."
- return -1
+set save_pf_prefix $pf_prefix
+# SEP must be last for the possible `unsupported' error path.
+foreach libsepdebug {NO IN SEP} {
+
+ set pf_prefix $save_pf_prefix
+ lappend pf_prefix "$libsepdebug:"
+
+ set sep_lib_flags $lib_flags
+ if {$libsepdebug != "NO"} {
+ lappend sep_lib_flags {debug}
+ }
+ if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $sep_lib_flags] != ""
+ || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
+ untested "Could not compile $binfile_lib or $binfile."
+ return -1
+ }
+
+ if {$libsepdebug == "SEP"} {
+ if {[gdb_gnu_strip_debug $binfile_lib] != 0} {
+ unsupported "Could not split debug of $binfile_lib."
+ return
+ } else {
+ pass "split solib"
+ }
+ }
+
+ clean_restart $executable
+
+ if ![runto_main] then {
+ fail "Can't run to main"
+ return 0
+ }
+
+ gdb_test "display a_global" "1: a_global = 41"
+ gdb_test "display b_global" "2: b_global = 42"
+ gdb_test "display c_global" "3: c_global = 43"
+
+ if { [gdb_start_cmd] < 0 } {
+ fail "Can't run to main (2)"
+ continue
+ }
+
+ gdb_test "" "3: c_global = 43\\r\\n2: b_global = 42\\r\\n1: a_global = 41" "after rerun"
+
+ # Now rebuild the library without b_global
+ if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} \
+ "$sep_lib_flags additional_flags=-DNO_B_GLOBAL"] != ""} {
+ fail "Can't rebuild $binfile_lib"
+ }
+
+ if {$libsepdebug == "SEP"} {
+ set test "split solib second time"
+ if {[gdb_gnu_strip_debug $binfile_lib] != 0} {
+ fail $test
+ continue
+ } else {
+ pass $test
+ }
+ }
+
+ if { [gdb_start_cmd] < 0 } {
+ fail "Can't run to main (3)"
+ continue
+ }
+
+ gdb_test "" "3: c_global = 43\\r\\nwarning: .*b_global.*\\r\\n1: a_global = 41" "after rerun (2)"
+
+ # Now verify that displays which are not in the shared library
+ # are not cleared permaturely.
+
+ gdb_test "break [gdb_get_line_number "break here" ${testfile}.c]" \
+ ".*Breakpoint.* at .*"
+
+ gdb_test "continue"
+ gdb_test "display main_global" "4: main_global = 44"
+ gdb_test "display a_local" "5: a_local = 45"
+ gdb_test "display a_static" "6: a_static = 46"
+
+ if { [gdb_start_cmd] < 0 } {
+ fail "Can't run to main (4)"
+ continue
+ }
+
+ gdb_test "" "6: a_static = 46\\r\\n4: main_global = 44\\r\\n.*"
+ gdb_test "break [gdb_get_line_number "break here" ${testfile}.c]" \
+ ".*Breakpoint.* at .*"
+ gdb_test "continue" "6: a_static = 46\\r\\n5: a_local = 45\\r\\n4: main_global = 44\\r\\n.*"
}
-
-clean_restart ${executable}
-
-if ![runto_main] then {
- fail "Can't run to main"
- return 0
-}
-
-gdb_test "display a_global" "1: a_global = 41"
-gdb_test "display b_global" "2: b_global = 42"
-gdb_test "display c_global" "3: c_global = 43"
-
-if { [gdb_start_cmd] < 0 } {
- fail "Can't run to main (2)"
- return 0
-}
-
-gdb_test "" "3: c_global = 43\\r\\n2: b_global = 42\\r\\n1: a_global = 41" "after rerun"
-
-# Now rebuild the library without b_global
-if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} \
- "$lib_flags additional_flags=-DNO_B_GLOBAL"] != ""} {
- fail "Can't rebuild $binfile_lib"
-}
-
-if { [gdb_start_cmd] < 0 } {
- fail "Can't run to main (3)"
- return 0
-}
-
-gdb_test "" "3: c_global = 43\\r\\nwarning: .*b_global.*\\r\\n1: a_global = 41" "after rerun"
-
-# Now verify that displays which are not in the shared library
-# are not cleared permaturely.
-
-gdb_test "break [gdb_get_line_number "break here" ${testfile}.c]" \
- ".*Breakpoint.* at .*"
-
-gdb_test "continue"
-gdb_test "display main_global" "4: main_global = 44"
-gdb_test "display a_local" "5: a_local = 45"
-gdb_test "display a_static" "6: a_static = 46"
-
-if { [gdb_start_cmd] < 0 } {
- fail "Can't run to main (4)"
- return 0
-}
-
-gdb_test "" "6: a_static = 46\\r\\n4: main_global = 44\\r\\n.*"
-gdb_test "break [gdb_get_line_number "break here" ${testfile}.c]" \
- ".*Breakpoint.* at .*"
-gdb_test "continue" "6: a_static = 46\\r\\n5: a_local = 45\\r\\n4: main_global = 44\\r\\n.*"
+set pf_prefix $save_pf_prefix
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 19126a4..3a1fad3 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2896,6 +2896,9 @@ proc build_id_debug_filename_get { exec } {
# Create stripped files for DEST, replacing it. If ARGS is passed, it is a
# list of optional flags. The only currently supported flag is no-main,
# which removes the symbol entry for main from the separate debug file.
+#
+# Function returns zero on success. Function will return non-zero failure code
+# on some targets not supporting separate debug info (such as i386-msdos).
proc gdb_gnu_strip_debug { dest args } {