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