]>
Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 1988, 1990, 1991, 1992, 1995, 1997, 2007 |
b6ba6518 | 2 | # 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 | |
6 | # the Free Software Foundation; either version 2 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, write to the Free Software | |
16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | ||
c906108c SS |
18 | # This file was written by Rob Savoye. (rob@cygnus.com) |
19 | ||
20 | # | |
21 | # load support libraries | |
22 | # | |
23 | load_lib remote.exp | |
24 | load_lib gdb.exp | |
25 | ||
26 | set shell_prompt "->" | |
27 | set gdb_prompt "\\(vxgdb\\)" | |
28 | ||
29 | # | |
30 | # gdb_version -- extract and print the version number of gcc | |
31 | # | |
32 | proc gdb_version {} { | |
33 | default_gdb_version | |
34 | } | |
35 | ||
36 | # | |
37 | # gdb_load -- load a file into the debugger. | |
38 | # We have to stop and start gdb each time we do this, because when | |
39 | # vxgdb loads two files in a row, the symbols in the first file loaded | |
40 | # take precedence. Returns -1 on error, else 0. | |
41 | # | |
42 | proc gdb_load { arg } { | |
43 | set result 0 | |
44 | ||
45 | if { [remote_ld target $arg] != 0 } { | |
46 | perror "Couldn't load $arg" | |
47 | return -1 | |
48 | } | |
49 | ||
50 | return [gdb_file_cmd $arg] | |
51 | } | |
52 | ||
53 | # | |
54 | # gdb_start -- start gdb running | |
55 | # | |
56 | proc gdb_start { } { | |
57 | global gdb_prompt | |
58 | global verbose | |
59 | global connectmode | |
60 | global reboot | |
61 | ||
62 | # get a connection to the board | |
63 | for { set x 0; } { $x < 3 } { incr x } { | |
64 | set shell_id [remote_open target] | |
65 | if { $shell_id > 0 } { | |
66 | verbose "Spawn id for remote shell is $shell_id" | |
67 | ||
68 | set timeout 10 | |
69 | verbose "Timeout is now $timeout seconds" 2 | |
70 | ||
71 | set state [spawn_vxgdb]; | |
72 | if { $state == "pass" } { | |
73 | return 0; | |
74 | } | |
75 | if { $state == "fail" } { | |
76 | return -1; | |
77 | } | |
78 | } | |
79 | remote_reboot target; | |
80 | } | |
81 | } | |
82 | ||
83 | proc spawn_vxgdb { } { | |
84 | global gdb_prompt | |
85 | ||
86 | default_gdb_start | |
87 | ||
88 | # set the default arguments to "main", so that "run" with no | |
89 | # arguments will work correctly. | |
90 | send_gdb "set args main\n" | |
91 | gdb_expect -re ".*$gdb_prompt $" {} | |
92 | ||
93 | verbose "Setting up target, Please wait..." | |
94 | # set targets hostname | |
95 | send_gdb "target vxworks [target_info hostname]\n" | |
96 | set timeout 60 | |
97 | verbose "Timeout is now $timeout seconds" 2 | |
98 | gdb_expect { | |
99 | -re "Done\..*$gdb_prompt $" { | |
100 | verbose "Set target to [target_info hostname]" 1 | |
101 | set timeout 10; | |
102 | return "pass"; | |
103 | } | |
104 | -re "net_connect: RPC: (Program not registered|.*Timed out).*$" { | |
105 | warning "Couldn't set GDB to target [target_info netport]." | |
106 | } | |
107 | timeout { | |
108 | warning "Couldn't set target for vxworks." | |
109 | } | |
110 | } | |
111 | return "retry"; | |
112 | } | |
113 | ||
114 | proc gdb_exit { } { | |
115 | remote_close target; | |
116 | catch default_gdb_exit | |
117 | } | |
118 | ||
119 | #expect_after { | |
120 | # "<return>" { send "\n"; perror "Window too small." } | |
121 | # -re "\(y or n\) " { send "n\n"; perror "Got interactive prompt." } | |
122 | # buffer_full { perror "internal buffer is full." } | |
123 | # eof { perror "eof -- pty is hosed." } | |
124 | # timeout { perror "timeout." } | |
125 | # "virtual memory exhausted" { perror "virtual memory exhausted." } | |
126 | # "Undefined command" { perror "send string probably wrong." } | |
127 | #} | |
128 |