1 # Copyright
2012-2022 Free Software Foundation
, Inc.
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.
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.
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
/>.
16 load_lib mi
-support.exp
19 standard_testfile basics.c
22 if [build_executable $testfile.exp $testfile $srcfile $opts
] {
23 untested
"failed to compile"
27 mi_clean_restart $binfile
29 if {[mi_runto_main
] < 0} {
33 set milogfile
[standard_output_file
"milog.txt"]
35 mi_gdb_test
"-gdb-set logging file $milogfile" "\\^done" \
36 "-gdb-set logging file"
38 mi_gdb_test
"-gdb-set logging overwrite on" ".*"
40 mi_gdb_test
"-gdb-set logging enabled on" ".*" "logging on"
46 mi_gdb_test
"-gdb-set logging enabled off" ".*" "logging off"
48 set chan
[open $milogfile
]
49 set logcontent
[read $chan
]
52 set mi_log_prompt
"\[(\]gdb\[)\] \[\r\n\]+"
54 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] {
55 pass
"log file contents"
57 fail
"log file contents"
60 # Now try the redirect
, which writes into the file only.
62 mi_gdb_test
"-gdb-set logging redirect on" ".*" "redirect logging on"
64 # Since all output will be going into the file
, just keep sending commands
65 # and don
't expect anything to appear until logging is turned off.
67 send_gdb "1001-gdb-set logging enabled on\n"
68 send_gdb "1002-exec-step\n"
69 send_gdb "1003-exec-next\n"
71 mi_gdb_test "1004-gdb-set logging enabled off" ".*" "redirect logging off"
73 set chan [open $milogfile]
74 set logcontent [read $chan]
77 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] {
78 pass "redirect log file contents"
80 fail "redirect log file contents"
83 # Now try enabling a redirect while GDB is already logging. This used
85 with_test_prefix "redirect while already logging" {
86 mi_gdb_test "-gdb-set logging redirect off" ".*" \
87 "logging redirect off"
88 mi_gdb_test "-gdb-set logging enabled on" ".*" \
90 mi_gdb_test "-gdb-set logging redirect on" \
91 ".*warning: Currently logging .*Turn the logging off and on to make the new setting effective.*" \
93 mi_gdb_test "-gdb-set logging enabled off" ".*" \
99 remote_file host delete $milogfile