xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.python/py-event-load.exp (revision 4439cfd0acf9c7dc90625e5cd83b2317a9ab8967)
1# Copyright 2022-2023 Free Software Foundation, Inc.
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
17# Test the Python free_objfile event.
18
19load_lib gdb-python.exp
20
21if {[skip_shlib_tests]} {
22    untested "skipping shared library tests"
23    return -1
24}
25
26if {[get_compiler_info]} {
27    warning "Could not get compiler info"
28    untested "no compiler info"
29    return -1
30}
31
32standard_testfile .c
33if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
34	 executable {debug shlib_load}] != ""} {
35    untested "failed to compile"
36    return -1
37}
38
39set testfile2 py-events-shlib
40set srcfile2 ${testfile2}.c
41set binfile2 [standard_output_file ${testfile2}.so]
42set binfile2_dlopen [shlib_target_file ${testfile2}.so]
43if {[gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" \
44	 ${binfile2} {debug}] != ""} {
45    untested "failed to compile shared library"
46    return -1
47}
48
49clean_restart $testfile
50
51if {![runto_main]} {
52    return
53}
54
55if { [skip_python_tests] } { return }
56
57gdb_test_no_output "set var libname = \"$binfile2_dlopen\""
58
59set pyfile [gdb_remote_download host ${srcdir}/${subdir}/py-event-load.py]
60gdb_test_no_output "source ${pyfile}" "load python file"
61
62gdb_breakpoint [gdb_get_line_number "final breakpoint here"]
63
64gdb_continue_to_breakpoint "run to final breakpoint"
65
66gdb_test "python print(freed_objfile)" [string_to_regexp $binfile2_dlopen] \
67    "print name of unloaded objfile"
68