OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [args.exp] - Blame information for rev 157

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
# Copyright 2003, 2007, 2008 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 .
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
 
21
if $tracelevel then {
22
    strace $tracelevel
23
}
24
 
25
 
26
global GDBFLAGS
27
 
28
# Skip test if target does not support argument passing.
29
if [target_info exists noargs] {
30
    return;
31
}
32
 
33
set testfile "args"
34
set srcfile ${testfile}.c
35
set binfile ${objdir}/${subdir}/${testfile}
36
 
37
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
38
    untested args.exp
39
    return -1
40
}
41
 
42
proc 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
 
73
#
74
# Test that the --args are processed correctly.
75
#
76
set old_gdbflags $GDBFLAGS
77
set GDBFLAGS "--args $binfile 1 3"
78
args_test basic {{1} {3}}
79
 
80
#
81
# Test that the --args are processed correctly even if one of them is empty.
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.
84
#
85
set GDBFLAGS "--args $binfile 1 {} 3"
86
args_test "one empty" {{1} {} {3}}
87
 
88
#
89
# try with 2 empty args
90
#
91
set GDBFLAGS "--args $binfile 1 {} {} 3"
92
args_test "two empty" {{1} {} {} 3}
93
 
94
# Try with arguments containing literal single quotes.
95
 
96
set GDBFLAGS "--args $binfile 1 '' 3"
97
args_test "one empty" {{1} {''} {3}}
98
 
99
set GDBFLAGS "--args $binfile 1 '' '' 3"
100
args_test "two empty" {{1} {''} {''} {3}}
101
 
102
set GDBFLAGS $old_gdbflags

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.