0c5e4898cc29cc295f66f4291fedf63c43e010ed
[platform/upstream/gdb.git] / gdb / testsuite / gdb.guile / scm-section-script.exp
1 # Copyright (C) 2010-2014 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 # 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.
21 if {![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
32 load_lib gdb-guile.exp
33
34 standard_testfile
35
36 # Make this available to gdb before the program starts, it is
37 # automagically loaded by gdb.
38 # Give the file a new name so we don't clobber the real one if
39 # objfile == srcdir.
40 # We also need to do this before compiling the program because the name
41 # of the script file is encoded in the binary.
42 # FIXME: Can we get gdb_remote_download to call standard_output_file for us?
43 set remote_guile_file [gdb_remote_download host \
44                            ${srcdir}/${subdir}/${testfile}.scm \
45                            ${subdir}/t-${testfile}.scm]
46
47 if {[build_executable $testfile.exp $testfile $srcfile \
48         [list debug "additional_flags=-I${srcdir}/../../include -DSCRIPT_FILE=\"$remote_guile_file\""]] == -1} {
49     return
50 }
51
52 # Start with a fresh gdb.
53 gdb_exit
54 gdb_start
55
56 # Skip all tests if Guile scripting is not enabled.
57 if { [skip_guile_tests] } { continue }
58
59 gdb_reinitialize_dir $srcdir/$subdir
60 gdb_test_no_output "set auto-load safe-path ${remote_guile_file}" \
61     "set auto-load safe-path"
62 gdb_load ${binfile}
63
64 # Verify gdb loaded the script.
65 gdb_test "info auto-load guile-scripts" "Yes.*${testfile}.scm.*"
66 # Again, with a regexp this time.
67 gdb_test "info auto-load guile-scripts ${testfile}" "Yes.*${testfile}.scm.*"
68 # Again, with a regexp that matches no scripts.
69 gdb_test "info auto-load guile-scripts no-script-matches-this" \
70   "No auto-load scripts matching no-script-matches-this."
71
72 if ![gdb_guile_runto_main] {
73     return
74 }
75
76 gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
77     ".*Breakpoint.*"
78 gdb_test "continue" ".*Breakpoint.*"
79
80 gdb_test "print ss" " = a=<1> b=<2>"