]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.python/py-event-load.exp
gdb/testsuite: format some Python files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.python / py-event-load.exp
1 # Copyright 2022-2024 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
19 load_lib gdb-python.exp
20
21 require allow_shlib_tests allow_python_tests
22
23 if {[get_compiler_info]} {
24 warning "Could not get compiler info"
25 untested "no compiler info"
26 return -1
27 }
28
29 standard_testfile .c
30 if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
31 executable {debug shlib_load}] != ""} {
32 untested "failed to compile"
33 return -1
34 }
35
36 set testfile2 py-events-shlib
37 set srcfile2 ${testfile2}.c
38 set binfile2 [standard_output_file ${testfile2}.so]
39 if {[gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" \
40 ${binfile2} {debug}] != ""} {
41 untested "failed to compile shared library"
42 return -1
43 }
44
45 set binfile2_dlopen [gdb_download_shlib $binfile2]
46
47 clean_restart $testfile
48
49 if {![runto_main]} {
50 return
51 }
52
53 gdb_test_no_output "set var libname = \"$binfile2_dlopen\"" "set var libname"
54
55 set pyfile [gdb_remote_download host ${srcdir}/${subdir}/py-event-load.py]
56 gdb_test_no_output "source ${pyfile}" "load python file"
57
58 gdb_breakpoint [gdb_get_line_number "final breakpoint here"]
59
60 gdb_continue_to_breakpoint "run to final breakpoint"
61
62 gdb_test "python print(freed_objfile)" [string_to_regexp $binfile2_dlopen] \
63 "print name of unloaded objfile"