Remove unused support for target-based exception catching.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / args.exp
CommitLineData
6aba47ca 1# Copyright 2003, 2007 Free Software Foundation, Inc.
8f9ab801
EZ
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
8f9ab801
EZ
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
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
8f9ab801
EZ
15
16# Please email any bugs, comments, and/or additions to this file to:
17# bug-gdb@prep.ai.mit.edu
18
19# This is a test for the gdb invocation option --args.
20
21if $tracelevel then {
22 strace $tracelevel
23}
24
25
26global GDBFLAGS
27
19ea9e73
MS
28# Skip test if target does not support argument passing.
29if [target_info exists noargs] {
30 return;
31}
32
8f9ab801
EZ
33set testfile "args"
34set srcfile ${testfile}.c
35set binfile ${objdir}/${subdir}/${testfile}
36
fc91c6c2 37if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
b60f0898
JB
38 untested args.exp
39 return -1
8f9ab801
EZ
40}
41
ae018d1a
DJ
42proc args_test { name arglist } {
43 global srcdir
44 global subdir
45 global binfile
46 global hex
47 global decimal
48
49 gdb_exit
50 gdb_start
51 gdb_reinitialize_dir $srcdir/$subdir
52
53 # No loading needs to be done when the target is `exec'. Some targets
54 # require that the program be loaded, however, and it doesn't hurt
55 # for `exec'.
56 gdb_load $binfile
57
58 runto_main
59 gdb_breakpoint [gdb_get_line_number "set breakpoint here"]
60 gdb_continue_to_breakpoint "breakpoint for $name"
61
62 set expected_len [expr 1 + [llength $arglist]]
63 gdb_test "print argc" "\\\$$decimal = $expected_len" "argc for $name"
64
65 set i 1
66 foreach arg $arglist {
67 gdb_test "print argv\[$i\]" "\\\$$decimal = $hex \"$arg\"" \
68 "argv\[$i\] for $name"
69 set i [expr $i + 1]
70 }
71}
72
8f9ab801
EZ
73#
74# Test that the --args are processed correctly.
75#
c362c33a 76set old_gdbflags $GDBFLAGS
8f9ab801 77set GDBFLAGS "--args $binfile 1 3"
ae018d1a 78args_test basic {{1} {3}}
8f9ab801
EZ
79
80#
81# Test that the --args are processed correctly even if one of them is empty.
ae018d1a
DJ
82# The syntax needed is a little peculiar; DejaGNU treats the arguments as a
83# list and expands them itself, since no shell redirection is involved.
8f9ab801 84#
ae018d1a
DJ
85set GDBFLAGS "--args $binfile 1 {} 3"
86args_test "one empty" {{1} {} {3}}
8f9ab801
EZ
87
88#
89# try with 2 empty args
90#
ae018d1a
DJ
91set GDBFLAGS "--args $binfile 1 {} {} 3"
92args_test "two empty" {{1} {} {} 3}
93
94# Try with arguments containing literal single quotes.
95
96set GDBFLAGS "--args $binfile 1 '' 3"
97args_test "one empty" {{1} {''} {3}}
98
8f9ab801 99set GDBFLAGS "--args $binfile 1 '' '' 3"
ae018d1a 100args_test "two empty" {{1} {''} {''} {3}}
8f9ab801 101
c362c33a 102set GDBFLAGS $old_gdbflags
This page took 0.933434 seconds and 4 git commands to generate.