]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/ui-redirect.exp
x86: Add -z isa-level-report=[none|all|needed|used]
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / ui-redirect.exp
1 # Copyright (C) 2010-2024 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15
16 # Do not run if gdb debug is enabled as it will interfere with log redirect.
17 require !gdb_debug_enabled
18
19 if { [prepare_for_testing "failed to prepare" ui-redirect start.c] } {
20 return -1
21 }
22
23 if ![runto_main] {
24 return -1
25 }
26
27 set test "commands"
28 gdb_test_multiple $test $test {
29 -re "End with a line saying just \"end\"\\.\r\n>$" {
30 pass $test
31 }
32 }
33
34 set test "print 1"
35 gdb_test_multiple $test $test {
36 -re "\r\n>$" {
37 pass $test
38 }
39 }
40 gdb_test_no_output "end"
41
42 gdb_breakpoint "foo"
43 gdb_breakpoint "bar"
44
45 set cmds [multi_line_input \
46 "break -qualified main" \
47 " commands" \
48 " print 1" \
49 " end" \
50 "break foo" \
51 "break bar"]
52 set cmds "$cmds\n"
53 set outdir [standard_output_file {}]
54 set cmds_file "$outdir/cmds.txt"
55
56 with_test_prefix "userdefined" {
57 set test "define userdefined"
58 gdb_test_multiple $test $test {
59 -re "End with a line saying just \"end\"\\.\r\n>$" {
60 pass $test
61 }
62 }
63
64 set test "bt"
65 gdb_test_multiple $test $test {
66 -re "\r\n>$" {
67 pass $test
68 }
69 }
70
71 gdb_test_no_output "end"
72 }
73
74 with_test_prefix "logging" {
75 gdb_test_no_output "set logging file /dev/null"
76 gdb_test "set logging enabled on" \
77 "Copying output to /dev/null.*Copying debug output to /dev/null\\."
78 gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \
79 "save breakpoints cmds.txt"
80 cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
81 gdb_test "userdefined" "#0 main ().*"
82 gdb_test "set logging enabled off" "Done logging to /dev/null\\."
83 gdb_test "help" "List of classes of commands:.*"
84 }
85
86 with_test_prefix "redirect" {
87 gdb_test "set logging redirect on"
88 gdb_test "set logging enabled on" \
89 "Redirecting output to /dev/null.*Copying debug output to /dev/null\\."
90 gdb_test_no_output "save breakpoints $cmds_file" "save breakpoints cmds.txt"
91 cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
92 gdb_test_no_output "userdefined"
93 gdb_test "set logging enabled off" "Done logging to /dev/null\\."
94 gdb_test "help" "List of classes of commands:.*"
95 gdb_test_no_output "set logging redirect off"
96 }
97
98 with_test_prefix "redirect while already logging" {
99 gdb_test "set logging enabled on" \
100 "Copying output to /dev/null.*Copying debug output to /dev/null\\."
101 gdb_test "set logging redirect on" \
102 ".*warning: Currently logging .*Turn the logging off and on to make the new setting effective.*"
103 gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \
104 "save breakpoints cmds.txt"
105 cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
106 gdb_test "userdefined" "#0 main ().*"
107 gdb_test "set logging enabled off" "Done logging to /dev/null\\."
108 gdb_test "help" "List of classes of commands:.*"
109 gdb_test_no_output "set logging redirect off"
110 }
111
112 with_test_prefix "debugging" {
113 gdb_test "set debug infrun 1"
114 gdb_test "set logging enabled on" \
115 "Copying output to /dev/null.*Copying debug output to /dev/null\\."
116
117 gdb_test \
118 -prompt "$gdb_prompt \\\[infrun\\\] fetch_inferior_event: exit\r\n$" \
119 "continue" \
120 "Continuing.*\\\[infrun\\\] .*\\\[infrun\\\] .*Breakpoint \[0-9\]+, foo.*"
121
122 gdb_test "set debug infrun 0"
123 gdb_test "set logging enabled off" "Done logging to /dev/null\\."
124 gdb_test "help" "List of classes of commands:.*"
125 }
126
127 with_test_prefix "redirect debugging" {
128 gdb_test_no_output "set logging debugredirect on"
129 gdb_test "set debug infrun 1"
130 gdb_test "set logging enabled on" \
131 "Copying output to /dev/null.*Redirecting debug output to /dev/null\\."
132 gdb_test "continue" "Continuing.*((?!infrun).).*Breakpoint \[0-9\]+, bar.*"
133 gdb_test "set debug infrun 0"
134 gdb_test "set logging enabled off" "Done logging to /dev/null\\."
135 gdb_test "help" "List of classes of commands:.*"
136 }
137
138 with_test_prefix "redirect logging and debuging" {
139 gdb_test_no_output "set logging redirect on"
140 gdb_test_no_output "set logging debugredirect on"
141 gdb_test "set logging enabled on" \
142 "Redirecting output to /dev/null.*Redirecting debug output to /dev/null\\."
143 gdb_test "set logging enabled off" "Done logging to /dev/null\\."
144 }