OSDN Git Service

30a3c2b16956ec8d731e51874aa68a891e04c9e9
[pf3gnuchains/pf3gnuchains3x.git] / gdb / testsuite / config / sim.exp
1 # Test Framework Driver for GDB driving a builtin simulator
2 #   Copyright 1994, 1997, 1998, 2004, 2007 Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 load_lib gdb.exp
18
19 #
20 # gdb_target_sim
21 # Set gdb to target the simulator
22 #
23 proc gdb_target_sim { } {
24     global gdb_prompt
25     
26     set target_sim_options "[board_info target gdb,target_sim_options]";
27
28     send_gdb "target sim $target_sim_options\n"
29     set timeout 60
30     verbose "Timeout is now $timeout seconds" 2
31     gdb_expect {
32         -re "Connected to the simulator.*$gdb_prompt $" {
33             verbose "Set target to sim"
34         }
35         timeout { 
36             perror "Couldn't set target for simulator."
37             cleanup
38             return -1
39         }
40     }
41     set timeout 10
42     verbose "Timeout is now $timeout seconds" 2
43     return 0
44 }
45
46 #
47 # gdb_load -- load a file into the debugger.
48 #             return a -1 if anything goes wrong.
49 #
50 proc gdb_load { arg } {
51     global verbose
52     global loadpath
53     global loadfile
54     global GDB
55     global gdb_prompt
56
57     if { $arg != "" } {
58         if [gdb_file_cmd $arg] then { return -1 }
59     }
60
61     if [gdb_target_sim] then { return -1 }
62
63     send_gdb "load\n"
64     set timeout 2400
65     verbose "Timeout is now $timeout seconds" 2
66     gdb_expect {
67         -re ".*$gdb_prompt $" {
68             if $verbose>1 then {
69                 send_user "Loaded $arg into $GDB\n"
70             }
71             set timeout 30
72             verbose "Timeout is now $timeout seconds" 2
73             return 0
74         }
75         -re "$gdb_prompt $"     {
76             if $verbose>1 then {
77                 perror "GDB couldn't load."
78             }
79         }
80         timeout {
81             if $verbose>1 then {
82                 perror "Timed out trying to load $arg."
83             }
84         }
85     }
86     return -1
87 }