1# Copyright (C) 2014-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
16load_lib gdb-python.exp
17
18standard_testfile amd64-py-framefilter-invalidarg.S
19
20if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
21    verbose "Skipping py-framefilter-invalidarg."
22    return
23}
24
25# We cannot use prepare_for_testing as we have to set the safe-patch
26# to check objfile and progspace printers.
27if {[build_executable $testfile.exp $testfile $srcfile {}] == -1} {
28    return -1
29}
30
31# Start with a fresh gdb.
32gdb_exit
33gdb_start
34
35# Skip all tests if Python scripting is not enabled.
36if { [skip_python_tests] } { continue }
37
38# Make the -gdb.py script available to gdb, it is automagically loaded by gdb.
39# Care is taken to put it in the same directory as the binary so that
40# gdb will find it.
41set remote_obj_python_file \
42    [remote_download \
43	 host ${srcdir}/${subdir}/${testfile}-gdb.py \
44	 [standard_output_file ${testfile}-gdb.py]]
45
46gdb_reinitialize_dir $srcdir/$subdir
47gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
48    "set auto-load safe-path"
49gdb_load ${binfile}
50# Verify gdb loaded the script.
51gdb_test "info auto-load python-scripts" "Yes.*${testfile}-gdb.py.*" \
52    "Test auto-load had loaded python scripts"
53
54if {![runto_main]} {
55    return
56}
57gdb_test_no_output "set python print-stack full" \
58    "set python print-stack to full"
59
60# Load global frame-filters
61set remote_python_file [gdb_remote_download host \
62			    ${srcdir}/${subdir}/${testfile}.py]
63gdb_test_no_output "source ${remote_python_file}" "load python file"
64
65gdb_test "bt" "niam \\(argc=<error reading variable: dwarf expression stack underflow>, argv=0x\[0-9a-f\]+\\) at py-framefilter-invalidarg.c:\[0-9\]+" "bt full with filters"
66