Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright (C) 2010-2022 Free Software Foundation, Inc. |
14dba4b4 JK |
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 | ||
81f47ac2 AH |
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" | |
19 | return 0 | |
20 | } | |
21 | ||
5b362f04 | 22 | if { [prepare_for_testing "failed to prepare" ui-redirect start.c] } { |
14dba4b4 JK |
23 | return -1 |
24 | } | |
25 | ||
30331a6c TV |
26 | if ![runto_main] { |
27 | fail "can't run to main" | |
28 | return -1 | |
29 | } | |
14dba4b4 JK |
30 | |
31 | set test "commands" | |
32 | gdb_test_multiple $test $test { | |
33 | -re "End with a line saying just \"end\"\\.\r\n>$" { | |
34 | pass $test | |
35 | } | |
36 | } | |
37 | ||
38 | set test "print 1" | |
39 | gdb_test_multiple $test $test { | |
40 | -re "\r\n>$" { | |
41 | pass $test | |
42 | } | |
43 | } | |
44 | gdb_test_no_output "end" | |
45 | ||
ca1285d1 AH |
46 | gdb_breakpoint "foo" |
47 | gdb_breakpoint "bar" | |
48 | ||
30331a6c | 49 | set cmds [multi_line_input \ |
8abd8ee8 | 50 | "break -qualified main" \ |
30331a6c TV |
51 | " commands" \ |
52 | " print 1" \ | |
53 | " end" \ | |
54 | "break foo" \ | |
55 | "break bar"] | |
56 | set cmds "$cmds\n" | |
57 | set outdir [standard_output_file {}] | |
58 | set cmds_file "$outdir/cmds.txt" | |
59 | ||
65d1cd5f TV |
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>$" { | |
64 | pass $test | |
65 | } | |
66 | } | |
67 | ||
68 | set test "bt" | |
69 | gdb_test_multiple $test $test { | |
70 | -re "\r\n>$" { | |
71 | pass $test | |
72 | } | |
73 | } | |
74 | ||
75 | gdb_test_no_output "end" | |
76 | } | |
77 | ||
f3a09c80 AH |
78 | with_test_prefix "logging" { |
79 | gdb_test_no_output "set logging file /dev/null" | |
ca1285d1 AH |
80 | gdb_test "set logging on" \ |
81 | "Copying output to /dev/null.*Copying debug output to /dev/null\\." | |
30331a6c TV |
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" | |
65d1cd5f | 85 | gdb_test "userdefined" "#0 main ().*" |
f3a09c80 AH |
86 | gdb_test "set logging off" "Done logging to /dev/null\\." |
87 | gdb_test "help" "List of classes of commands:.*" | |
88 | } | |
89 | ||
90 | with_test_prefix "redirect" { | |
91 | gdb_test "set logging redirect on" | |
ca1285d1 AH |
92 | gdb_test "set logging on" \ |
93 | "Redirecting output to /dev/null.*Copying debug output to /dev/null\\." | |
30331a6c TV |
94 | gdb_test_no_output "save breakpoints $cmds_file" "save breakpoints cmds.txt" |
95 | cmp_file_string "$cmds_file" "$cmds" "cmds.txt" | |
65d1cd5f | 96 | gdb_test_no_output "userdefined" |
f3a09c80 AH |
97 | gdb_test "set logging off" "Done logging to /dev/null\\." |
98 | gdb_test "help" "List of classes of commands:.*" | |
99 | } | |
100 | ||
101 | with_test_prefix "redirect while already logging" { | |
102 | gdb_test_no_output "set logging redirect off" | |
ca1285d1 AH |
103 | gdb_test "set logging on" \ |
104 | "Copying output to /dev/null.*Copying debug output to /dev/null\\." | |
f3a09c80 AH |
105 | gdb_test "set logging redirect on" \ |
106 | ".*warning: Currently logging .*Turn the logging off and on to make the new setting effective.*" | |
30331a6c TV |
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" | |
65d1cd5f | 110 | gdb_test "userdefined" "#0 main ().*" |
f3a09c80 AH |
111 | gdb_test "set logging off" "Done logging to /dev/null\\." |
112 | gdb_test "help" "List of classes of commands:.*" | |
ca1285d1 AH |
113 | gdb_test_no_output "set logging redirect off" |
114 | } | |
115 | ||
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\\." | |
3ec3145c SM |
120 | |
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$" { | |
124 | pass $gdb_test_name | |
125 | } | |
126 | } | |
127 | ||
ca1285d1 AH |
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:.*" | |
131 | } | |
132 | ||
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:.*" | |
f3a09c80 | 142 | } |
59b59f08 LS |
143 | |
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\\." | |
150 | } |