984f4beabbb06c0d2b66b347ff33f69be7680b58
[deliverable/binutils-gdb.git] / gdb / testsuite / config / vx-gdb.exp
1 # Copyright (C) 1988, 1990, 1991, 1992, 1995 Free Software Foundation, Inc.
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
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
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
26 load_lib gdb.exp
27 load_lib vxworks.exp
28
29 set shell_prompt "->"
30 set prompt "\\(vxgdb\\)"
31
32 #
33 # gdb_version -- extract and print the version number of gcc
34 #
35 proc gdb_version {} {
36 default_gdb_version
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
43 # take precedence. Returns -1 on error, else 0.
44 #
45 proc gdb_load { arg } {
46 global shell_id
47
48 # gdb_exit
49 # spawn_vxgdb
50 set result 0
51
52 if { [vxworks_ld $shell_id $arg] != 0 } {
53 perror "Couldn't load $arg"
54 return -1
55 }
56
57 return [gdb_file_cmd $arg]
58 }
59
60 #
61 # gdb_start -- start gdb running and
62 #
63 proc gdb_start { } {
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 {
74 perror "Couldn't connect to $targetname."
75 return -1
76 }
77 verbose "Spawn id for remote shell is $shell_id"
78
79 # reboot vxworks to get a clean start
80 if $reboot then {
81 verbose "Rebooting VxWorks, Please wait...\n"
82
83 send -i $shell_id "\030"
84 set timeout 120
85 verbose "Timeout is now $timeout seconds" 2
86 expect {
87 -i $shell_id -re "Connection closed.*$" {
88 verbose "\nVxWorks has closed the shell"
89 }
90 -i $shell_id eof {
91 perror "(eof) never disconnected from VxWorks shell."
92 return -1
93 }
94 -i $shell_id timeout {
95 perror "(timeout) never disconnected from VxWorks shell."
96 return -1
97 }
98 }
99 catch "close -i $shell_id" tmp
100 wait -i $shell_id
101 }
102 set timeout 10
103 verbose "Timeout is now $timeout seconds" 2
104
105 catch "spawn_vxgdb"
106 }
107
108 proc spawn_vxgdb { } {
109 global prompt
110 global verbose
111 global targetname
112
113 default_gdb_start
114
115 # set the default arguments to "main", so that "run" with no
116 # arguments will work correctly.
117 send "set args main\n"
118 expect -re ".*$prompt $" {}
119
120 verbose "Setting up target, Please wait..."
121 # set targets hostname
122 send "target vxworks $targetname\n"
123 set timeout 60
124 verbose "Timeout is now $timeout seconds" 2
125 expect {
126 -re "Done\..*$prompt $" {
127 verbose "Set target to $targetname" 1
128 }
129 -re "net_connect: RPC: Program not registered.*$" {
130 perror "Couldn't set GDB to target $targetname."
131 exit 1
132 }
133 timeout {
134 perror "Couldn't set target for vxworks."
135 set timeout 10
136 verbose "Timeout is now $timeout seconds" 2
137 return -1
138 }
139 }
140 set timeout 10
141 verbose "Timeout is now $timeout seconds" 2
142 }
143
144 proc gdb_exit { } {
145 global shell_id
146 if [info exists shell_id] then {
147 exit_remote_shell $shell_id
148 }
149 catch default_gdb_exit
150 }
151
152 #expect_after {
153 # "<return>" { send "\n"; perror "Window too small." }
154 # -re "\(y or n\) " { send "n\n"; perror "Got interactive prompt." }
155 # buffer_full { perror "internal buffer is full." }
156 # eof { perror "eof -- pty is hosed." }
157 # timeout { perror "timeout." }
158 # "virtual memory exhausted" { perror "virtual memory exhausted." }
159 # "Undefined command" { perror "send string probably wrong." }
160 #}
161
162 gdb_start
163
This page took 0.0346 seconds and 4 git commands to generate.