2
0
mirror of https://sourceware.org/git/binutils-gdb.git synced 2024-12-27 04:52:05 +08:00
binutils-gdb/gdb/testsuite/gdb.base/fork-print-inferior-events.exp
Joel Brobecker b811d2c292 Update copyright year range in all GDB files.
gdb/ChangeLog:

        Update copyright year range in all GDB files.
2020-01-01 10:20:53 +04:00

93 lines
3.6 KiB
Plaintext

# This testcase is part of GDB, the GNU debugger.
# Copyright 2007-2020 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Test that the event messages printed when using 'set print
# inferior-events [on,off]', 'set follow-fork-mode [child,parent]' and
# 'set detach-on-fork [on,off]' are the correct ones.
# This test relies on "run", so it cannot run on target remote stubs.
if { [use_gdb_stub] } {
untested "not supported on target remote stubs"
return
}
# Test relies on checking follow-fork output. Do not run if gdb debug is
# enabled as it will be redirected to the log.
if [gdb_debug_enabled] {
untested "debug is enabled"
return 0
}
standard_testfile
if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
return -1
}
# This is the expected output for each of the test combinations
# below. The order here is important:
#
# inferior-events: on; follow-fork: child; detach-on-fork: on
# inferior-events: on; follow-fork: child; detach-on-fork: off
# inferior-events: on; follow-fork: parent; detach-on-fork: on
# inferior-events: on; follow-fork: parent; detach-on-fork: off
# inferior-events: off; follow-fork: child; detach-on-fork: on
# inferior-events: off; follow-fork: child; detach-on-fork: off
# inferior-events: off; follow-fork: parent; detach-on-fork: on
# inferior-events: off; follow-fork: parent; detach-on-fork: off
set reading_re "(Reading.*from remote target\\.\\.\\.\r\n)*"
set exited_normally_re "${reading_re}\\\[Inferior $decimal \\(.*\\) exited normally\\\]"
# gdbserver produces a slightly different message when attaching after
# a fork, so we have to tweak the regexp to accomodate that.
set attach_child_re "${reading_re}\\\[Attaching after .* fork to child .*\\\]\r\n"
set detach_child_re "${reading_re}\\\[Detaching after fork from child .*\\\]\r\n"
set detach_parent_re "${reading_re}\\\[Detaching after fork from parent .*\\\]\r\n"
set new_inf_re "${reading_re}\\\[New inferior $decimal \\(.*\\)\\\]\r\n"
set inf_detached_re "${reading_re}\\\[Inferior $decimal \\(.*\\) detached\\\]\r\n"
set expected_output [list \
"${attach_child_re}${new_inf_re}${detach_parent_re}${inf_detached_re}" \
"${attach_child_re}${new_inf_re}" \
"${detach_child_re}" \
"${new_inf_re}" \
"" \
"" \
"" \
"" \
]
set i 0
foreach_with_prefix print_inferior_events { "on" "off" } {
foreach_with_prefix follow_fork_mode { "child" "parent" } {
foreach_with_prefix detach_on_fork { "on" "off" } {
clean_restart $binfile
gdb_test_no_output "set print inferior-events $print_inferior_events"
gdb_test_no_output "set follow-fork-mode $follow_fork_mode"
gdb_test_no_output "set detach-on-fork $detach_on_fork"
set output [lindex $expected_output $i]
# Always add the "Starting program..." string so that we
# match exactly the lines we want.
set output "Starting program: $binfile\\s*\r\n${output}${exited_normally_re}"
set i [expr $i + 1]
gdb_test "run" $output
}
}
}