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