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