1 # Copyright (C) 2010-2021 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # Do not run if gdb debug is enabled as it will interfere with log redirect.
17 if [gdb_debug_enabled] {
18 untested "debug is enabled"
22 if { [prepare_for_testing "failed to prepare" ui-redirect start.c] } {
27 fail "can't run to main"
32 gdb_test_multiple $test $test {
33 -re "End with a line saying just \"end\"\\.\r\n>$" {
39 gdb_test_multiple $test $test {
44 gdb_test_no_output "end"
49 set cmds [multi_line_input \
50 "break -qualified main" \
57 set outdir [standard_output_file {}]
58 set cmds_file "$outdir/cmds.txt"
60 with_test_prefix "userdefined" {
61 set test "define userdefined"
62 gdb_test_multiple $test $test {
63 -re "End with a line saying just \"end\"\\.\r\n>$" {
69 gdb_test_multiple $test $test {
75 gdb_test_no_output "end"
78 with_test_prefix "logging" {
79 gdb_test_no_output "set logging file /dev/null"
80 gdb_test "set logging on" \
81 "Copying output to /dev/null.*Copying debug output to /dev/null\\."
82 gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \
83 "save breakpoints cmds.txt"
84 cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
85 gdb_test "userdefined" "#0 main ().*"
86 gdb_test "set logging off" "Done logging to /dev/null\\."
87 gdb_test "help" "List of classes of commands:.*"
90 with_test_prefix "redirect" {
91 gdb_test "set logging redirect on"
92 gdb_test "set logging on" \
93 "Redirecting output to /dev/null.*Copying debug output to /dev/null\\."
94 gdb_test_no_output "save breakpoints $cmds_file" "save breakpoints cmds.txt"
95 cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
96 gdb_test_no_output "userdefined"
97 gdb_test "set logging off" "Done logging to /dev/null\\."
98 gdb_test "help" "List of classes of commands:.*"
101 with_test_prefix "redirect while already logging" {
102 gdb_test_no_output "set logging redirect off"
103 gdb_test "set logging on" \
104 "Copying output to /dev/null.*Copying debug output to /dev/null\\."
105 gdb_test "set logging redirect on" \
106 ".*warning: Currently logging .*Turn the logging off and on to make the new setting effective.*"
107 gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \
108 "save breakpoints cmds.txt"
109 cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
110 gdb_test "userdefined" "#0 main ().*"
111 gdb_test "set logging off" "Done logging to /dev/null\\."
112 gdb_test "help" "List of classes of commands:.*"
113 gdb_test_no_output "set logging redirect off"
116 with_test_prefix "debugging" {
117 gdb_test "set debug infrun 1"
118 gdb_test "set logging on" \
119 "Copying output to /dev/null.*Copying debug output to /dev/null\\."
121 set prompt "$gdb_prompt \\\[infrun\\\] fetch_inferior_event: exit\r\n$"
122 gdb_test_multiple "continue" "continue" -prompt $prompt {
123 -re "Continuing.*\\\[infrun\\\] .*\\\[infrun\\\] .*Breakpoint \[0-9\]+, foo.*$prompt$" {
128 gdb_test "set debug infrun 0"
129 gdb_test "set logging off" "Done logging to /dev/null\\."
130 gdb_test "help" "List of classes of commands:.*"
133 with_test_prefix "redirect debugging" {
134 gdb_test_no_output "set logging debugredirect on"
135 gdb_test "set debug infrun 1"
136 gdb_test "set logging on" \
137 "Copying output to /dev/null.*Redirecting debug output to /dev/null\\."
138 gdb_test "continue" "Continuing.*((?!infrun).).*Breakpoint \[0-9\]+, bar.*"
139 gdb_test "set debug infrun 0"
140 gdb_test "set logging off" "Done logging to /dev/null\\."
141 gdb_test "help" "List of classes of commands:.*"
144 with_test_prefix "redirect logging and debuging" {
145 gdb_test_no_output "set logging redirect on"
146 gdb_test_no_output "set logging debugredirect on"
147 gdb_test "set logging on" \
148 "Redirecting output to /dev/null.*Redirecting debug output to /dev/null\\."
149 gdb_test "set logging off" "Done logging to /dev/null\\."