Automatic date update in version.in
[binutils-gdb.git] / gdb / testsuite / gdb.guile / scm-section-script.exp
blobfb46ad7ee1f9dedf9dd243b9e7b9a5ce88c90939
1 # Copyright (C) 2010-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file is part of the GDB testsuite.  It tests automagic loading of
17 # scripts specified in the .debug_gdb_scripts section.
19 # This test can only be run on targets which support ELF and use gas.
20 # For now pick a sampling of likely targets.
21 if {![istarget *-*-linux*]
22     && ![istarget *-*-gnu*]
23     && ![istarget *-*-elf*]
24     && ![istarget *-*-openbsd*]
25     && ![istarget arm*-*-eabi*]
26     && ![istarget powerpc-*-eabi*]} {
27     verbose "Skipping scm-section-script.exp because of lack of support."
28     return
31 load_lib gdb-guile.exp
33 require allow_guile_tests
35 standard_testfile
37 # Make this available to gdb before the program starts, it is
38 # automagically loaded by gdb.
39 # We also need to do this before compiling the program because the name
40 # of the script file is encoded in the binary.
41 set remote_guile_file [gdb_remote_download host \
42                            ${srcdir}/${subdir}/${testfile}.scm]
44 if {[build_executable $testfile.exp $testfile $srcfile \
45         [list debug "additional_flags=-I${srcdir}/../../include -DSCRIPT_FILE=\"$remote_guile_file\""]] == -1} {
46     return
49 clean_restart
51 # Try first with a restrictive safe-path.
53 gdb_test_no_output "set auto-load safe-path /restricted" \
54     "set restricted auto-load safe-path"
55 gdb_load ${binfile}
57 # Verify gdb did not load the scripts.
58 set test_name "verify scripts not loaded"
59 gdb_test_multiple "info auto-load guile-scripts" "$test_name" {
60     -re "Yes.*${testfile}.scm.*Yes.*inlined-script.*$gdb_prompt $" {
61         fail "$test_name"
62     }
63     -re "No.*${testfile}.scm.*No.*inlined-script.*$gdb_prompt $" {
64         pass "$test_name"
65     }
68 # Try again with a working safe-path.
70 clean_restart
72 gdb_test_no_output "set auto-load safe-path ${remote_guile_file}:${binfile}" \
73     "set auto-load safe-path"
74 gdb_load ${binfile}
76 # Verify gdb loaded each script and they appear once in the list.
77 set test_name "verify scripts loaded"
78 gdb_test_multiple "info auto-load guile-scripts" "$test_name" {
79     -re "${testfile}.scm.*${testfile}.scm.*$gdb_prompt $" {
80         fail "$test_name"
81     }
82     -re "inlined-script.*inlined-script.*$gdb_prompt $" {
83         fail "$test_name"
84     }
85     -re "Yes.*${testfile}.scm.*Yes.*inlined-script.*$gdb_prompt $" {
86         pass "$test_name"
87     }
90 # Again, with a regexp this time.
91 gdb_test "info auto-load guile-scripts ${testfile}" "Yes.*${testfile}.scm.*"
93 # Again, with a regexp that matches no scripts.
94 gdb_test "info auto-load guile-scripts no-script-matches-this" \
95   "No auto-load scripts matching no-script-matches-this."
97 if ![gdb_guile_runto_main] {
98     return
101 gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
102     ".*Breakpoint.*"
103 gdb_test "continue" ".*Breakpoint.*"
105 gdb_test "print ss" " = a=<1> b=<2>"
107 gdb_test "test-cmd 1 2 3" "test-cmd output, arg = 1 2 3"