aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r--gdb/testsuite/gdb.base/filename-completion.exp14
-rw-r--r--gdb/testsuite/gdb.base/gstack.exp6
-rw-r--r--gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp148
-rw-r--r--gdb/testsuite/gdb.base/options.exp17
-rw-r--r--gdb/testsuite/gdb.base/shlib-unload.exp69
5 files changed, 171 insertions, 83 deletions
diff --git a/gdb/testsuite/gdb.base/filename-completion.exp b/gdb/testsuite/gdb.base/filename-completion.exp
index 03ead59..a1dd974 100644
--- a/gdb/testsuite/gdb.base/filename-completion.exp
+++ b/gdb/testsuite/gdb.base/filename-completion.exp
@@ -381,11 +381,15 @@ proc run_mid_line_completion_tests { root cmd } {
proc run_quoting_and_escaping_tests { root } {
# Test all the commands which allow quoting of filenames, and
# which require whitespace to be escaped in unquoted filenames.
- foreach_with_prefix cmd { file exec-file symbol-file add-symbol-file \
- remove-symbol-file \
- "target core" "target exec" "target tfile" \
- "maint print c-tdesc" "compile file" \
- "save gdb-index" "save gdb-index -dwarf-5" } {
+ set all_cmds { file exec-file symbol-file add-symbol-file \
+ remove-symbol-file \
+ "target core" "target exec" "target tfile" \
+ "maint print c-tdesc" "save gdb-index"
+ "save gdb-index -dwarf-5" }
+ if { [allow_compile_tests] } {
+ lappend all_cmds "compile file"
+ }
+ foreach_with_prefix cmd $all_cmds {
# Try each test placing the filename as the first argument
# then again with a quoted string immediately after the
# command. This works because the filename completer will
diff --git a/gdb/testsuite/gdb.base/gstack.exp b/gdb/testsuite/gdb.base/gstack.exp
index 8df36b1..89be676 100644
--- a/gdb/testsuite/gdb.base/gstack.exp
+++ b/gdb/testsuite/gdb.base/gstack.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2024 Free Software Foundation, Inc.
+# Copyright (C) 2024-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -62,8 +62,10 @@ if { ![gdb_assert { ![expr {$res < 0 || $res == ""}] } $test] } {
set test "got backtrace"
set saw_backtrace false
set no_awk false
+set location_re ${srcfile}:${decimal}
+
gdb_expect {
- -i "$res" -re "#0 +(0x\[0-9a-f\]+ in )?main \(\).*\r\nGSTACK-END\r\n\$" {
+ -i "$res" -re "#0 +(0x\[0-9a-f\]+ in )?main \(\).*$location_re.*\r\nGSTACK-END\r\n\$" {
set saw_backtrace true
pass $test
exp_continue
diff --git a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
index 45086f6..46561a9 100644
--- a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
+++ b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
@@ -72,77 +72,89 @@ gdb_continue_to_breakpoint "stop at test breakpoint"
gdb_test_no_output "source ${pyfile}"\
"import python scripts"
-# Check the unbroken stack.
-gdb_test_sequence "bt" "backtrace when the unwind is left unbroken" {
- "\\r\\n#0 \[^\r\n\]* inline_func \\(\\) at "
- "\\r\\n#1 \[^\r\n\]* normal_func \\(\\) at "
- "\\r\\n#2 \[^\r\n\]* inline_func \\(\\) at "
- "\\r\\n#3 \[^\r\n\]* normal_func \\(\\) at "
- "\\r\\n#4 \[^\r\n\]* inline_func \\(\\) at "
- "\\r\\n#5 \[^\r\n\]* normal_func \\(\\) at "
- "\\r\\n#6 \[^\r\n\]* main \\(\\) at "
-}
+# Test with and without filters.
+foreach bt_cmd { "bt" "bt -no-filters" } {
+ with_test_prefix "$bt_cmd" {
-with_test_prefix "cycle at level 5" {
- # Arrange to introduce a stack cycle at frame 5.
- gdb_test_no_output "python stop_at_level=5"
- gdb_test "maint flush register-cache" \
- "Register cache flushed\\."
- gdb_test_lines "bt" "backtrace when the unwind is broken at frame 5" \
- [multi_line \
- "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
- "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
- "#2 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
- "#3 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
- "#4 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
- "#5 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
- "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"]
-}
+ # Check the unbroken stack.
+ gdb_test_sequence "$bt_cmd" "backtrace when the unwind is left unbroken" {
+ "\\r\\n#0 \[^\r\n\]* inline_func \\(\\) at "
+ "\\r\\n#1 \[^\r\n\]* normal_func \\(\\) at "
+ "\\r\\n#2 \[^\r\n\]* inline_func \\(\\) at "
+ "\\r\\n#3 \[^\r\n\]* normal_func \\(\\) at "
+ "\\r\\n#4 \[^\r\n\]* inline_func \\(\\) at "
+ "\\r\\n#5 \[^\r\n\]* normal_func \\(\\) at "
+ "\\r\\n#6 \[^\r\n\]* main \\(\\) at "
+ }
-with_test_prefix "cycle at level 3" {
- # Arrange to introduce a stack cycle at frame 3.
- gdb_test_no_output "python stop_at_level=3"
- gdb_test "maint flush register-cache" \
- "Register cache flushed\\."
- gdb_test_lines "bt" "backtrace when the unwind is broken at frame 3" \
- [multi_line \
- "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
- "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
- "#2 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
- "#3 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
- "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"]
-}
+ with_test_prefix "cycle at level 5" {
+ # Arrange to introduce a stack cycle at frame 5.
+ gdb_test_no_output "python stop_at_level=5"
+ gdb_test "maint flush register-cache" \
+ "Register cache flushed\\."
+ gdb_test_lines "$bt_cmd" "backtrace when the unwind is broken at frame 5" \
+ [multi_line \
+ "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
+ "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
+ "#2 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
+ "#3 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
+ "#4 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
+ "#5 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
+ "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"]
+ }
-with_test_prefix "cycle at level 1" {
- # Arrange to introduce a stack cycle at frame 1.
- gdb_test_no_output "python stop_at_level=1"
- gdb_test "maint flush register-cache" \
- "Register cache flushed\\."
- gdb_test_lines "bt" "backtrace when the unwind is broken at frame 1" \
- [multi_line \
- "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
- "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
- "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"]
-}
+ with_test_prefix "cycle at level 3" {
+ # Arrange to introduce a stack cycle at frame 3.
+ gdb_test_no_output "python stop_at_level=3"
+ gdb_test "maint flush register-cache" \
+ "Register cache flushed\\."
+ gdb_test_lines "$bt_cmd" "backtrace when the unwind is broken at frame 3" \
+ [multi_line \
+ "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
+ "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
+ "#2 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
+ "#3 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
+ "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"]
+ }
-# Flush the register cache (which also flushes the frame cache) so we
-# get a full backtrace again, then switch on frame debugging and try
-# to back trace. At one point this triggered an assertion.
-gdb_test "maint flush register-cache" \
- "Register cache flushed\\." ""
-gdb_test_no_output "set debug frame 1"
-set ok 1
-gdb_test_multiple "bt" "backtrace with debugging on" {
- -re "^$gdb_prompt $" {
- gdb_assert { $ok } $gdb_test_name
- }
- -re "Python Exception <class 'gdb.error'>: \[^\r\n\]*\r\n" {
- set ok 0
- exp_continue
- }
- -re "\[^\r\n\]+\r\n" {
- exp_continue
+ with_test_prefix "cycle at level 1" {
+ # Arrange to introduce a stack cycle at frame 1.
+ gdb_test_no_output "python stop_at_level=1"
+ gdb_test "maint flush register-cache" \
+ "Register cache flushed\\."
+ gdb_test_lines "$bt_cmd" "backtrace when the unwind is broken at frame 1" \
+ [multi_line \
+ "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
+ "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
+ "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"]
+ }
+
+ # Flush the register cache (which also flushes the frame cache) so we
+ # get a full backtrace again, then switch on frame debugging and try
+ # to back trace. At one point this triggered an assertion.
+ gdb_test "maint flush register-cache" \
+ "Register cache flushed\\." ""
+ gdb_test_no_output "set debug frame 1"
+ set ok 1
+ gdb_test_multiple "$bt_cmd" "backtrace with debugging on" {
+ -re "^$gdb_prompt $" {
+ gdb_assert { $ok } $gdb_test_name
+ }
+ -re "Python Exception <class 'gdb.error'>: \[^\r\n\]*\r\n" {
+ set ok 0
+ exp_continue
+ }
+ -re "\[^\r\n\]+\r\n" {
+ exp_continue
+ }
+ }
+ gdb_test "p 1 + 2 + 3" " = 6" \
+ "ensure GDB is still alive"
+
+ # Prepare for the next iteration of the test loop
+ gdb_test_no_output "set debug frame 0"
+ gdb_test_no_output "python stop_at_level=None"
+ gdb_test "maint flush register-cache" \
+ "Register cache flushed\\." "maint flush register-cache at (loop end)"
}
}
-gdb_test "p 1 + 2 + 3" " = 6" \
- "ensure GDB is still alive"
diff --git a/gdb/testsuite/gdb.base/options.exp b/gdb/testsuite/gdb.base/options.exp
index a1ca39e..8760a91 100644
--- a/gdb/testsuite/gdb.base/options.exp
+++ b/gdb/testsuite/gdb.base/options.exp
@@ -99,21 +99,21 @@ proc make_cmd {variant} {
# operand.
proc expect_none {operand} {
return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\
- -string '' -filename '' -- $operand"
+ -string '' -filename '' -color magenta -- $operand"
}
# Return a string for the expected result of running "maint
# test-options xxx", with -flag set. OPERAND is the expected operand.
proc expect_flag {operand} {
return "-flag 1 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\
- -string '' -filename '' -- $operand"
+ -string '' -filename '' -color magenta -- $operand"
}
# Return a string for the expected result of running "maint
# test-options xxx", with -bool set. OPERAND is the expected operand.
proc expect_bool {operand} {
return "-flag 0 -xx1 0 -xx2 0 -bool 1 -enum xxx -uint-unl 0 -pint-unl 0\
- -string '' -filename '' -- $operand"
+ -string '' -filename '' -color magenta -- $operand"
}
# Return a string for the expected result of running "maint
@@ -123,10 +123,10 @@ proc expect_bool {operand} {
proc expect_integer {option val operand} {
if {$option == "uinteger-unlimited"} {
return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl $val\
- -pint-unl 0 -string '' -filename '' -- $operand"
+ -pint-unl 0 -string '' -filename '' -color magenta -- $operand"
} elseif {$option == "pinteger-unlimited"} {
return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0\
- -pint-unl $val -string '' -filename '' -- $operand"
+ -pint-unl $val -string '' -filename '' -color magenta -- $operand"
} else {
error "unsupported option: $option"
}
@@ -144,7 +144,7 @@ proc expect_string {str operand} {
set str [string range $str 1 end-1]
}
return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\
- -string '$str' -filename '' -- $operand"
+ -string '$str' -filename '' -color magenta -- $operand"
}
# Return a string for the expected result of running "maint
@@ -159,11 +159,12 @@ proc expect_filename {str operand} {
set str [string range $str 1 end-1]
}
return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\
- -string '' -filename '$str' -- $operand"
+ -string '' -filename '$str' -color magenta -- $operand"
}
set all_options {
"-bool"
+ "-color"
"-enum"
"-filename"
"-flag"
@@ -628,7 +629,7 @@ proc_with_prefix test-flag {variant} {
# Extract twice the same flag, separated by one space.
gdb_test "$cmd -xx1 -xx2 -xx1 -xx2 -xx1 -- non flags args" \
"-flag 0 -xx1 1 -xx2 1 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\
- -string '' -filename '' -- non flags args"
+ -string '' -filename '' -color magenta -- non flags args"
# Extract 2 known flags in front of unknown flags.
gdb_test "$cmd -xx1 -xx2 -a -b -c -xx1 --" \
diff --git a/gdb/testsuite/gdb.base/shlib-unload.exp b/gdb/testsuite/gdb.base/shlib-unload.exp
index f3e8cce..9d47416 100644
--- a/gdb/testsuite/gdb.base/shlib-unload.exp
+++ b/gdb/testsuite/gdb.base/shlib-unload.exp
@@ -225,6 +225,75 @@ proc_with_prefix test_dprintf_with_rerun {} {
"dprintf is non-pending after restart"
}
+# Check that we see breakpoint modified events (where appropriate)
+# when the 'nosharedlibrary' command is used to unload all shared
+# libraries.
+#
+# Also check that the 'nosharedlibrary' doesn't trigger a warning
+# about shared library breakpoints being disabled.
+proc_with_prefix test_silent_nosharedlib {} {
+ if { ![allow_python_tests] } {
+ unsupported "python support needed"
+ return
+ }
+
+ foreach_with_prefix type { breakpoint dprintf } {
+ clean_restart $::binfile
+
+ if {![runto_main]} {
+ return
+ }
+
+ gdb_breakpoint $::srcfile:$::bp_line
+ gdb_continue_to_breakpoint "stop before dlclose"
+
+ # Setup a dprintf or breakpoint in the shared library.
+ if { $type eq "breakpoint" } {
+ gdb_test "break foo"
+ } else {
+ gdb_test "dprintf foo,\"In foo\""
+ }
+
+ # Record the number of the b/p (or dprintf) we just inserted.
+ set bp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*" \
+ "get b/p number"]
+
+ # Load Python library to track b/p modifications.
+ gdb_test_no_output "source $::pyfile" "import python scripts"
+
+ # Initialise the b/p modified hash. Currently dprintf style
+ # breakpoints are not visible from Python, so the modification
+ # count will remain unchanged in that case.
+ gdb_test_no_output "python bp_modified_counts\[$bp_num\] = 0"
+
+ # Discard symbols from all loaded shared libraries.
+ gdb_test_no_output "nosharedlibrary"
+
+ # Check that our b/p is now showing as disabled.
+ if { $type eq "breakpoint" } {
+ set re \
+ [list "$bp_num\\s+breakpoint\\s+keep\\s+y\\s+<PENDING>\\s+foo"]
+ set count 1
+ } else {
+ set re \
+ [list \
+ "$bp_num\\s+dprintf\\s+keep\\s+y\\s+<PENDING>\\s+foo" \
+ "\\s+printf \"In foo\""]
+ set count 0
+ }
+
+ gdb_test "info breakpoints $bp_num" \
+ [multi_line "^Num\\s+Type\\s+Disp\\s+Enb\\s+Address\\s+What" \
+ {*}$re]
+
+ # Check we've seen the expected number of breakpoint modified
+ # events. Currently dprintf breakpoints are not visible from
+ # Python, so we will not see an event in that case.
+ gdb_test "python print(bp_modified_counts\[$bp_num\])" "^$count"
+ }
+}
+
test_bp_modified_events
test_dprintf_after_unload
test_dprintf_with_rerun
+test_silent_nosharedlib