Commit | Line | Data |
---|---|---|
3aa3c593 | 1 | # Copyright (C) 1988, 1990, 1991, 1992, 1995 Free Software Foundation, Inc. |
19fa4a0a MW |
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 2 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, write to the Free Software | |
6c9638b4 | 15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
19fa4a0a MW |
16 | |
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # DejaGnu@cygnus.com | |
19 | ||
20 | # This file was written by Rob Savoye. (rob@cygnus.com) | |
21 | ||
22 | # | |
23 | # load support libraries | |
24 | # | |
25 | load_lib remote.exp | |
7e7cb02f RS |
26 | load_lib gdb.exp |
27 | load_lib vxworks.exp | |
28 | ||
19fa4a0a | 29 | set shell_prompt "->" |
8c7ab5da | 30 | set prompt "\\(vxgdb\\)" |
19fa4a0a MW |
31 | |
32 | # | |
33 | # gdb_version -- extract and print the version number of gcc | |
34 | # | |
35 | proc gdb_version {} { | |
1c65406f | 36 | default_gdb_version |
19fa4a0a MW |
37 | } |
38 | ||
39 | # | |
40 | # gdb_load -- load a file into the debugger. | |
41 | # We have to stop and start gdb each time we do this, because when | |
42 | # vxgdb loads two files in a row, the symbols in the first file loaded | |
2a1bb527 | 43 | # take precedence. Returns -1 on error, else 0. |
19fa4a0a MW |
44 | # |
45 | proc gdb_load { arg } { | |
46 | global shell_id | |
2a1bb527 RS |
47 | |
48 | # gdb_exit | |
49 | # spawn_vxgdb | |
50 | set result 0 | |
51 | ||
11c54b4f | 52 | if { [vxworks_ld $shell_id $arg] != 0 } { |
983bfa63 | 53 | perror "Couldn't load $arg" |
2a1bb527 | 54 | return -1 |
19fa4a0a | 55 | } |
2a1bb527 RS |
56 | |
57 | return [gdb_file_cmd $arg] | |
19fa4a0a MW |
58 | } |
59 | ||
19fa4a0a MW |
60 | # |
61 | # gdb_start -- start gdb running and | |
62 | # | |
63 | proc gdb_start { } { | |
19fa4a0a MW |
64 | global prompt |
65 | global verbose | |
66 | global targetname | |
67 | global connectmode | |
68 | global reboot | |
69 | global shell_id | |
70 | ||
71 | # get a connection to the board | |
72 | set shell_id [ eval $connectmode "$targetname" ] | |
73 | if $shell_id<0 then { | |
8f07e537 | 74 | perror "Couldn't connect to $targetname." |
19fa4a0a MW |
75 | return -1 |
76 | } | |
2a1bb527 | 77 | verbose "Spawn id for remote shell is $shell_id" |
19fa4a0a MW |
78 | |
79 | # reboot vxworks to get a clean start | |
80 | if $reboot then { | |
7e7cb02f | 81 | verbose "Rebooting VxWorks, Please wait...\n" |
19fa4a0a | 82 | |
cc5be366 | 83 | send -i $shell_id "\030" |
19fa4a0a MW |
84 | set timeout 120 |
85 | expect { | |
86 | -i $shell_id -re "Connection closed.*$" { | |
7e7cb02f | 87 | verbose "\nVxWorks has closed the shell" |
19fa4a0a | 88 | } |
7e7cb02f | 89 | -i $shell_id eof { |
8f07e537 | 90 | perror "(eof) never disconnected from VxWorks shell." |
7e7cb02f RS |
91 | return -1 |
92 | } | |
93 | -i $shell_id timeout { | |
8f07e537 | 94 | perror "(timeout) never disconnected from VxWorks shell." |
7e7cb02f RS |
95 | return -1 |
96 | } | |
19fa4a0a | 97 | } |
7e7cb02f RS |
98 | catch "close -i $shell_id" tmp |
99 | wait -i $shell_id | |
19fa4a0a MW |
100 | } |
101 | set timeout 10 | |
102 | ||
62148952 | 103 | catch "spawn_vxgdb" |
19fa4a0a MW |
104 | } |
105 | ||
106 | proc spawn_vxgdb { } { | |
19fa4a0a MW |
107 | global prompt |
108 | global verbose | |
109 | global targetname | |
110 | ||
983bfa63 | 111 | default_gdb_start |
19fa4a0a | 112 | |
19fa4a0a MW |
113 | # set the default arguments to "main", so that "run" with no |
114 | # arguments will work correctly. | |
115 | send "set args main\n" | |
116 | expect -re ".*$prompt $" {} | |
117 | ||
2a1bb527 | 118 | verbose "Setting up target, Please wait..." |
19fa4a0a MW |
119 | # set targets hostname |
120 | send "target vxworks $targetname\n" | |
121 | set timeout 60 | |
122 | expect { | |
123 | -re "Done\..*$prompt $" { | |
62148952 | 124 | verbose "Set target to $targetname" 1 |
19fa4a0a MW |
125 | } |
126 | -re "net_connect: RPC: Program not registered.*$" { | |
8f07e537 | 127 | perror "Couldn't set GDB to target $targetname." |
19fa4a0a MW |
128 | exit 1 |
129 | } | |
130 | timeout { | |
8f07e537 | 131 | perror "Couldn't set target for vxworks." |
19fa4a0a | 132 | set timeout 10 |
05a291bb | 133 | return -1 |
19fa4a0a MW |
134 | } |
135 | } | |
136 | set timeout 10 | |
137 | } | |
138 | ||
7e7cb02f RS |
139 | proc gdb_exit { } { |
140 | global shell_id | |
2a1bb527 RS |
141 | if [info exists shell_id] then { |
142 | exit_remote_shell $shell_id | |
143 | } | |
fd69a916 | 144 | catch default_gdb_exit |
7e7cb02f RS |
145 | } |
146 | ||
62148952 | 147 | #expect_after { |
8f07e537 BC |
148 | # "<return>" { send "\n"; perror "Window too small." } |
149 | # -re "\(y or n\) " { send "n\n"; perror "Got interactive prompt." } | |
150 | # buffer_full { perror "internal buffer is full." } | |
151 | # eof { perror "eof -- pty is hosed." } | |
152 | # timeout { perror "timeout." } | |
153 | # "virtual memory exhausted" { perror "virtual memory exhausted." } | |
154 | # "Undefined command" { perror "send string probably wrong." } | |
62148952 | 155 | #} |
19fa4a0a | 156 | |
19fa4a0a MW |
157 | gdb_start |
158 |