Commit | Line | Data |
---|---|---|
c906108c | 1 | # Test Framework Driver for GDB driving a builtin simulator |
e2882c85 | 2 | # Copyright 1994-2018 Free Software Foundation, Inc. |
c906108c SS |
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 | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
c906108c SS |
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. | |
e22f8b7c | 13 | # |
c906108c | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c SS |
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 | |
c906108c | 25 | |
4ec70201 | 26 | set target_sim_options "[board_info target gdb,target_sim_options]" |
c906108c SS |
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 | |
b7b73cae | 38 | return -1 |
c906108c SS |
39 | } |
40 | } | |
41 | set timeout 10 | |
42 | verbose "Timeout is now $timeout seconds" 2 | |
b7b73cae | 43 | return 0 |
c906108c SS |
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 | ||
83f66e8f DJ |
57 | if { $arg != "" } { |
58 | if [gdb_file_cmd $arg] then { return -1 } | |
59 | } | |
c906108c | 60 | |
b7b73cae | 61 | if [gdb_target_sim] then { return -1 } |
c906108c SS |
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 | |
954269c2 | 73 | return 0 |
c906108c SS |
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 | } | |
954269c2 | 86 | return -1 |
c906108c | 87 | } |