]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.guile/scm-section-script.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.guile / scm-section-script.exp
CommitLineData
213516ef 1# Copyright (C) 2010-2023 Free Software Foundation, Inc.
ed3ef339
DE
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# This file is part of the GDB testsuite. It tests automagic loading of
17# scripts specified in the .debug_gdb_scripts section.
18
19# This test can only be run on targets which support ELF and use gas.
20# For now pick a sampling of likely targets.
21if {![istarget *-*-linux*]
22 && ![istarget *-*-gnu*]
23 && ![istarget *-*-elf*]
24 && ![istarget *-*-openbsd*]
25 && ![istarget arm*-*-eabi*]
ed3ef339
DE
26 && ![istarget powerpc-*-eabi*]} {
27 verbose "Skipping scm-section-script.exp because of lack of support."
28 return
29}
30
31load_lib gdb-guile.exp
32
33standard_testfile
34
35# Make this available to gdb before the program starts, it is
36# automagically loaded by gdb.
ed3ef339
DE
37# We also need to do this before compiling the program because the name
38# of the script file is encoded in the binary.
ed3ef339 39set remote_guile_file [gdb_remote_download host \
df1b803a 40 ${srcdir}/${subdir}/${testfile}.scm]
ed3ef339
DE
41
42if {[build_executable $testfile.exp $testfile $srcfile \
43 [list debug "additional_flags=-I${srcdir}/../../include -DSCRIPT_FILE=\"$remote_guile_file\""]] == -1} {
44 return
45}
46
47# Start with a fresh gdb.
48gdb_exit
49gdb_start
50
51# Skip all tests if Guile scripting is not enabled.
52if { [skip_guile_tests] } { continue }
53
54gdb_reinitialize_dir $srcdir/$subdir
9f050062
DE
55
56# Try first with a restrictive safe-path.
57
58gdb_test_no_output "set auto-load safe-path /restricted" \
59 "set restricted auto-load safe-path"
60gdb_load ${binfile}
61
62# Verify gdb did not load the scripts.
63set test_name "verify scripts not loaded"
64gdb_test_multiple "info auto-load guile-scripts" "$test_name" {
65 -re "Yes.*${testfile}.scm.*Yes.*inlined-script.*$gdb_prompt $" {
66 fail "$test_name"
67 }
68 -re "No.*${testfile}.scm.*No.*inlined-script.*$gdb_prompt $" {
69 pass "$test_name"
70 }
71}
72
73# Try again with a working safe-path.
74
75gdb_exit
76gdb_start
77gdb_reinitialize_dir $srcdir/$subdir
78
79gdb_test_no_output "set auto-load safe-path ${remote_guile_file}:${binfile}" \
ed3ef339
DE
80 "set auto-load safe-path"
81gdb_load ${binfile}
82
9f050062
DE
83# Verify gdb loaded each script and they appear once in the list.
84set test_name "verify scripts loaded"
85gdb_test_multiple "info auto-load guile-scripts" "$test_name" {
86 -re "${testfile}.scm.*${testfile}.scm.*$gdb_prompt $" {
87 fail "$test_name"
88 }
89 -re "inlined-script.*inlined-script.*$gdb_prompt $" {
90 fail "$test_name"
91 }
92 -re "Yes.*${testfile}.scm.*Yes.*inlined-script.*$gdb_prompt $" {
93 pass "$test_name"
94 }
95}
96
ed3ef339
DE
97# Again, with a regexp this time.
98gdb_test "info auto-load guile-scripts ${testfile}" "Yes.*${testfile}.scm.*"
9f050062 99
ed3ef339
DE
100# Again, with a regexp that matches no scripts.
101gdb_test "info auto-load guile-scripts no-script-matches-this" \
102 "No auto-load scripts matching no-script-matches-this."
103
104if ![gdb_guile_runto_main] {
105 return
106}
107
108gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
109 ".*Breakpoint.*"
110gdb_test "continue" ".*Breakpoint.*"
111
112gdb_test "print ss" " = a=<1> b=<2>"
9f050062
DE
113
114gdb_test "test-cmd 1 2 3" "test-cmd output, arg = 1 2 3"