1 # Copyright (C) 2010-2020 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 \
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\\."
120 gdb_test "continue" "Continuing.*infrun:.*infrun:.*Breakpoint \[0-9\]+, foo.*"
121 gdb_test "set debug infrun 0"
122 gdb_test "set logging off" "Done logging to /dev/null\\."
123 gdb_test "help" "List of classes of commands:.*"
126 with_test_prefix "redirect debugging" {
127 gdb_test_no_output "set logging debugredirect on"
128 gdb_test "set debug infrun 1"
129 gdb_test "set logging on" \
130 "Copying output to /dev/null.*Redirecting debug output to /dev/null\\."
131 gdb_test "continue" "Continuing.*((?!infrun).).*Breakpoint \[0-9\]+, bar.*"
132 gdb_test "set debug infrun 0"
133 gdb_test "set logging off" "Done logging to /dev/null\\."
134 gdb_test "help" "List of classes of commands:.*"