Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2012-2020 Free Software Foundation, Inc. |
37ce89eb SS |
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 | load_lib mi-support.exp | |
17 | set MIFLAGS "-i=mi" | |
18 | ||
19 | gdb_exit | |
20 | if [mi_gdb_start] { | |
21 | continue | |
22 | } | |
23 | ||
298a9cf0 | 24 | standard_testfile basics.c |
37ce89eb SS |
25 | set opts {debug} |
26 | ||
298a9cf0 | 27 | if [build_executable $testfile.exp $testfile $srcfile $opts] { |
5b362f04 | 28 | untested "failed to compile" |
ae59b1da | 29 | return -1 |
37ce89eb SS |
30 | } |
31 | ||
32 | if {[mi_run_to_main] < 0} { | |
33 | return -1 | |
34 | } | |
35 | ||
84741506 | 36 | set milogfile [standard_output_file "milog.txt"] |
37ce89eb SS |
37 | |
38 | mi_gdb_test "-gdb-set logging file $milogfile" ".*" | |
39 | ||
40 | mi_gdb_test "-gdb-set logging overwrite on" ".*" | |
41 | ||
42 | mi_gdb_test "-gdb-set logging on" ".*" "logging on" | |
43 | ||
44 | mi_step "logged step" | |
45 | ||
46 | mi_next "logged next" | |
47 | ||
48 | mi_gdb_test "-gdb-set logging off" ".*" "logging off" | |
49 | ||
50 | set chan [open $milogfile] | |
51 | set logcontent [read $chan] | |
52 | close $chan | |
53 | ||
54 | set mi_log_prompt "\[(\]gdb\[)\] \[\r\n\]+" | |
55 | ||
56 | if [regexp "\\^done\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] { | |
bc6c7af4 | 57 | pass "log file contents" |
37ce89eb | 58 | } else { |
bc6c7af4 | 59 | fail "log file contents" |
37ce89eb SS |
60 | } |
61 | ||
62 | # Now try the redirect, which writes into the file only. | |
63 | ||
64 | mi_gdb_test "-gdb-set logging redirect on" ".*" "redirect logging on" | |
65 | ||
66 | # Since all output will be going into the file, just keep sending commands | |
67 | # and don't expect anything to appear until logging is turned off. | |
68 | ||
69 | send_gdb "1001-gdb-set logging on\n" | |
70 | send_gdb "1002-exec-step\n" | |
71 | send_gdb "1003-exec-next\n" | |
72 | ||
73 | mi_gdb_test "1004-gdb-set logging off" ".*" "redirect logging off" | |
74 | ||
75 | set chan [open $milogfile] | |
76 | set logcontent [read $chan] | |
77 | close $chan | |
78 | ||
79 | if [regexp "1001\\^done\[\r\n\]+$mi_log_prompt.*1002\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt.*1003\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] { | |
bc6c7af4 | 80 | pass "redirect log file contents" |
37ce89eb | 81 | } else { |
bc6c7af4 | 82 | fail "redirect log file contents" |
37ce89eb SS |
83 | } |
84 | ||
5be5dbf0 PA |
85 | # Now try enabling a redirect while GDB is already logging. This used |
86 | # to crash GDB. | |
87 | with_test_prefix "redirect while already logging" { | |
88 | mi_gdb_test "-gdb-set logging redirect off" ".*" \ | |
89 | "logging redirect off" | |
90 | mi_gdb_test "-gdb-set logging on" ".*" \ | |
91 | "logging on" | |
92 | mi_gdb_test "-gdb-set logging redirect on" \ | |
93 | ".*warning: Currently logging .*Turn the logging off and on to make the new setting effective.*" \ | |
94 | "logging redirect on" | |
95 | mi_gdb_test "-gdb-set logging off" ".*" \ | |
96 | "logging off" | |
97 | } | |
98 | ||
37ce89eb SS |
99 | mi_gdb_exit |
100 | ||
101 | remote_file host delete $milogfile |