binutils-gdb/gdb/testsuite/gdb.python/py-connection-removed.exp
Andrew Burgess 1d506c26d9 Update copyright year range in header of all files managed by GDB
This commit is the result of the following actions:

  - Running gdb/copyright.py to update all of the copyright headers to
    include 2024,

  - Manually updating a few files the copyright.py script told me to
    update, these files had copyright headers embedded within the
    file,

  - Regenerating gdbsupport/Makefile.in to refresh it's copyright
    date,

  - Using grep to find other files that still mentioned 2023.  If
    these files were updated last year from 2022 to 2023 then I've
    updated them this year to 2024.

I'm sure I've probably missed some dates.  Feel free to fix them up as
you spot them.
2024-01-12 15:49:57 +00:00

91 lines
3.2 KiB
Text

# Copyright (C) 2022-2024 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/>.
# Check that the gdb.connect_removed event triggers when we expect it
# too.
#
# Checking this event has wider implications that simply some corner
# of the Python API working or not. The connection_removed event
# triggers when the reference count of a process_stratum_target
# reaches zero. If these events stop triggering when expected then
# GDB might be getting the reference counting on target_ops objects
# wrong.
load_lib gdb-python.exp
require allow_python_tests
standard_testfile py-connection.c
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
if ![runto_main] then {
return 0
}
# Register a callback that will trigger when a connection is removed
# (deleted) within GDB.
gdb_test_multiline "Add connection_removed event" \
"python" "" \
"def connection_removed_handler(event):" "" \
" num = event.connection.num" "" \
" type = event.connection.type" "" \
" print('Connection %d (%s) removed' % (num, type))" "" \
"gdb.events.connection_removed.connect (connection_removed_handler)" "" \
"end" ""
if { [target_info exists gdb_protocol] } {
if { [target_info gdb_protocol] == "extended-remote" } {
set connection_type "extended-remote"
} else {
set connection_type "remote"
}
} else {
set connection_type "native"
}
# Add an inferior that shares a connection with inferior 1.
gdb_test "add-inferior" "Added inferior 2 on connection 1 \[^\r\n\]+"
# Add an inferior with no connection.
gdb_test "add-inferior -no-connection" "Added inferior 3"
# Kill the first inferior. If we are using the plain 'remote' protocol then
# it as this point that the remote target connection is removed. For the
# 'extended-remote' and 'native' targets the connection is removed later.
if { $connection_type == "remote" } {
gdb_test "with confirm off -- kill" \
"Connection 1 \\(remote\\) removed\r\n.*" "kill inferior"
} else {
gdb_test "with confirm off -- kill" "" "kill inferior"
}
# Switch to inferior 3 (the one with no connection).
gdb_test "inferior 3"
# Remove inferior 1, not expecting anything interesting at this point.
gdb_test_no_output "remove-inferiors 1"
# Now removed inferior 2. For the 'remote' target the connection has
# already been removed (see above), but for 'extended-remote' and 'native'
# targets, it is at this point that the connection is removed.
if { $connection_type == "remote" } {
gdb_test_no_output "remove-inferiors 2"
} else {
gdb_test "remove-inferiors 2" \
"Connection 1 \\(${connection_type}\\) removed"
}