]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi-logging.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-logging.exp
CommitLineData
213516ef 1# Copyright 2012-2023 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
16load_lib mi-support.exp
17set MIFLAGS "-i=mi"
18
298a9cf0 19standard_testfile basics.c
37ce89eb
SS
20set opts {debug}
21
298a9cf0 22if [build_executable $testfile.exp $testfile $srcfile $opts] {
5b362f04 23 untested "failed to compile"
ae59b1da 24 return -1
37ce89eb
SS
25}
26
b75d55d4
PA
27mi_clean_restart $binfile
28
29if {[mi_runto_main] < 0} {
37ce89eb
SS
30 return -1
31}
32
84741506 33set milogfile [standard_output_file "milog.txt"]
37ce89eb 34
e36788d1
TV
35mi_gdb_test "-gdb-set logging file $milogfile" "\\^done" \
36 "-gdb-set logging file"
37ce89eb
SS
37
38mi_gdb_test "-gdb-set logging overwrite on" ".*"
39
6ff96754 40mi_gdb_test "-gdb-set logging enabled on" ".*" "logging on"
37ce89eb
SS
41
42mi_step "logged step"
43
44mi_next "logged next"
45
6ff96754 46mi_gdb_test "-gdb-set logging enabled off" ".*" "logging off"
37ce89eb
SS
47
48set chan [open $milogfile]
49set logcontent [read $chan]
50close $chan
51
52set mi_log_prompt "\[(\]gdb\[)\] \[\r\n\]+"
53
54if [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 55 pass "log file contents"
37ce89eb 56} else {
bc6c7af4 57 fail "log file contents"
37ce89eb
SS
58}
59
60# Now try the redirect, which writes into the file only.
61
62mi_gdb_test "-gdb-set logging redirect on" ".*" "redirect logging on"
63
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.
66
6ff96754 67send_gdb "1001-gdb-set logging enabled on\n"
37ce89eb
SS
68send_gdb "1002-exec-step\n"
69send_gdb "1003-exec-next\n"
70
6ff96754 71mi_gdb_test "1004-gdb-set logging enabled off" ".*" "redirect logging off"
37ce89eb
SS
72
73set chan [open $milogfile]
74set logcontent [read $chan]
75close $chan
76
77if [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 78 pass "redirect log file contents"
37ce89eb 79} else {
bc6c7af4 80 fail "redirect log file contents"
37ce89eb
SS
81}
82
5be5dbf0
PA
83# Now try enabling a redirect while GDB is already logging. This used
84# to crash GDB.
85with_test_prefix "redirect while already logging" {
86 mi_gdb_test "-gdb-set logging redirect off" ".*" \
87 "logging redirect off"
6ff96754 88 mi_gdb_test "-gdb-set logging enabled on" ".*" \
5be5dbf0
PA
89 "logging 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.*" \
92 "logging redirect on"
6ff96754 93 mi_gdb_test "-gdb-set logging enabled off" ".*" \
5be5dbf0
PA
94 "logging off"
95}
96
37ce89eb
SS
97mi_gdb_exit
98
99remote_file host delete $milogfile