]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright (C) 2010-2024 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 | 16 | # Do not run if gdb debug is enabled as it will interfere with log redirect. |
e5bf39c5 | 17 | require !gdb_debug_enabled |
81f47ac2 | 18 | |
5b362f04 | 19 | if { [prepare_for_testing "failed to prepare" ui-redirect start.c] } { |
14dba4b4 JK |
20 | return -1 |
21 | } | |
22 | ||
30331a6c | 23 | if ![runto_main] { |
30331a6c TV |
24 | return -1 |
25 | } | |
14dba4b4 JK |
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 | ||
ca1285d1 AH |
42 | gdb_breakpoint "foo" |
43 | gdb_breakpoint "bar" | |
44 | ||
30331a6c | 45 | set cmds [multi_line_input \ |
8abd8ee8 | 46 | "break -qualified main" \ |
30331a6c TV |
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 | ||
65d1cd5f TV |
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 | ||
f3a09c80 AH |
74 | with_test_prefix "logging" { |
75 | gdb_test_no_output "set logging file /dev/null" | |
6ff96754 | 76 | gdb_test "set logging enabled on" \ |
ca1285d1 | 77 | "Copying output to /dev/null.*Copying debug output to /dev/null\\." |
30331a6c TV |
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" | |
65d1cd5f | 81 | gdb_test "userdefined" "#0 main ().*" |
6ff96754 | 82 | gdb_test "set logging enabled off" "Done logging to /dev/null\\." |
f3a09c80 AH |
83 | gdb_test "help" "List of classes of commands:.*" |
84 | } | |
85 | ||
86 | with_test_prefix "redirect" { | |
87 | gdb_test "set logging redirect on" | |
6ff96754 | 88 | gdb_test "set logging enabled on" \ |
ca1285d1 | 89 | "Redirecting output to /dev/null.*Copying debug output to /dev/null\\." |
30331a6c TV |
90 | gdb_test_no_output "save breakpoints $cmds_file" "save breakpoints cmds.txt" |
91 | cmp_file_string "$cmds_file" "$cmds" "cmds.txt" | |
65d1cd5f | 92 | gdb_test_no_output "userdefined" |
6ff96754 | 93 | gdb_test "set logging enabled off" "Done logging to /dev/null\\." |
f3a09c80 | 94 | gdb_test "help" "List of classes of commands:.*" |
fdc3b978 | 95 | gdb_test_no_output "set logging redirect off" |
f3a09c80 AH |
96 | } |
97 | ||
98 | with_test_prefix "redirect while already logging" { | |
6ff96754 | 99 | gdb_test "set logging enabled on" \ |
ca1285d1 | 100 | "Copying output to /dev/null.*Copying debug output to /dev/null\\." |
f3a09c80 AH |
101 | gdb_test "set logging redirect on" \ |
102 | ".*warning: Currently logging .*Turn the logging off and on to make the new setting effective.*" | |
30331a6c TV |
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" | |
65d1cd5f | 106 | gdb_test "userdefined" "#0 main ().*" |
6ff96754 | 107 | gdb_test "set logging enabled off" "Done logging to /dev/null\\." |
f3a09c80 | 108 | gdb_test "help" "List of classes of commands:.*" |
ca1285d1 AH |
109 | gdb_test_no_output "set logging redirect off" |
110 | } | |
111 | ||
112 | with_test_prefix "debugging" { | |
113 | gdb_test "set debug infrun 1" | |
6ff96754 | 114 | gdb_test "set logging enabled on" \ |
ca1285d1 | 115 | "Copying output to /dev/null.*Copying debug output to /dev/null\\." |
3ec3145c | 116 | |
c76d61da PA |
117 | gdb_test \ |
118 | -prompt "$gdb_prompt \\\[infrun\\\] fetch_inferior_event: exit\r\n$" \ | |
119 | "continue" \ | |
120 | "Continuing.*\\\[infrun\\\] .*\\\[infrun\\\] .*Breakpoint \[0-9\]+, foo.*" | |
3ec3145c | 121 | |
ca1285d1 | 122 | gdb_test "set debug infrun 0" |
6ff96754 | 123 | gdb_test "set logging enabled off" "Done logging to /dev/null\\." |
ca1285d1 AH |
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" | |
6ff96754 | 130 | gdb_test "set logging enabled on" \ |
ca1285d1 AH |
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" | |
6ff96754 | 134 | gdb_test "set logging enabled off" "Done logging to /dev/null\\." |
ca1285d1 | 135 | gdb_test "help" "List of classes of commands:.*" |
f3a09c80 | 136 | } |
59b59f08 LS |
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" | |
6ff96754 | 141 | gdb_test "set logging enabled on" \ |
59b59f08 | 142 | "Redirecting output to /dev/null.*Redirecting debug output to /dev/null\\." |
6ff96754 | 143 | gdb_test "set logging enabled off" "Done logging to /dev/null\\." |
59b59f08 | 144 | } |