]>
Commit | Line | Data |
---|---|---|
9b4ff276 AC |
1 | /* OBSOLETE /* Remote debugging interface for AMD 29000 EBMON on IBM PC, for GDB. */ |
2 | /* OBSOLETE Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001 */ | |
3 | /* OBSOLETE Free Software Foundation, Inc. */ | |
4 | /* OBSOLETE Contributed by Cygnus Support. Written by Jim Kingdon for Cygnus. */ | |
5 | /* OBSOLETE */ | |
6 | /* OBSOLETE This file is part of GDB. */ | |
7 | /* OBSOLETE */ | |
8 | /* OBSOLETE This program is free software; you can redistribute it and/or modify */ | |
9 | /* OBSOLETE it under the terms of the GNU General Public License as published by */ | |
10 | /* OBSOLETE the Free Software Foundation; either version 2 of the License, or */ | |
11 | /* OBSOLETE (at your option) any later version. */ | |
12 | /* OBSOLETE */ | |
13 | /* OBSOLETE This program is distributed in the hope that it will be useful, */ | |
14 | /* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */ | |
15 | /* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | |
16 | /* OBSOLETE GNU General Public License for more details. */ | |
17 | /* OBSOLETE */ | |
18 | /* OBSOLETE You should have received a copy of the GNU General Public License */ | |
19 | /* OBSOLETE along with this program; if not, write to the Free Software */ | |
20 | /* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, */ | |
21 | /* OBSOLETE Boston, MA 02111-1307, USA. */ */ | |
22 | /* OBSOLETE */ | |
23 | /* OBSOLETE /* This is like remote.c but is for an esoteric situation-- */ | |
24 | /* OBSOLETE having a a29k board in a PC hooked up to a unix machine with */ | |
25 | /* OBSOLETE a serial line, and running ctty com1 on the PC, through which */ | |
26 | /* OBSOLETE the unix machine can run ebmon. Not to mention that the PC */ | |
27 | /* OBSOLETE has PC/NFS, so it can access the same executables that gdb can, */ | |
28 | /* OBSOLETE over the net in real time. */ */ | |
29 | /* OBSOLETE */ | |
30 | /* OBSOLETE #include "defs.h" */ | |
31 | /* OBSOLETE #include "gdb_string.h" */ | |
32 | /* OBSOLETE #include "regcache.h" */ | |
33 | /* OBSOLETE */ | |
34 | /* OBSOLETE #include "inferior.h" */ | |
35 | /* OBSOLETE #include "bfd.h" */ | |
36 | /* OBSOLETE #include "symfile.h" */ | |
37 | /* OBSOLETE #include "value.h" */ | |
38 | /* OBSOLETE #include <ctype.h> */ | |
39 | /* OBSOLETE #include <fcntl.h> */ | |
40 | /* OBSOLETE #include <signal.h> */ | |
41 | /* OBSOLETE #include <errno.h> */ | |
42 | /* OBSOLETE #include "terminal.h" */ | |
43 | /* OBSOLETE #include "target.h" */ | |
44 | /* OBSOLETE #include "gdbcore.h" */ | |
45 | /* OBSOLETE */ | |
46 | /* OBSOLETE extern struct target_ops eb_ops; /* Forward declaration */ */ | |
47 | /* OBSOLETE */ | |
48 | /* OBSOLETE static void eb_close (); */ | |
49 | /* OBSOLETE */ | |
50 | /* OBSOLETE #define LOG_FILE "eb.log" */ | |
51 | /* OBSOLETE #if defined (LOG_FILE) */ | |
52 | /* OBSOLETE FILE *log_file; */ | |
53 | /* OBSOLETE #endif */ | |
54 | /* OBSOLETE */ | |
55 | /* OBSOLETE static int timeout = 24; */ | |
56 | /* OBSOLETE */ | |
57 | /* OBSOLETE /* Descriptor for I/O to remote machine. Initialize it to -1 so that */ | |
58 | /* OBSOLETE eb_open knows that we don't have a file open when the program */ | |
59 | /* OBSOLETE starts. */ */ | |
60 | /* OBSOLETE int eb_desc = -1; */ | |
61 | /* OBSOLETE */ | |
62 | /* OBSOLETE /* stream which is fdopen'd from eb_desc. Only valid when */ | |
63 | /* OBSOLETE eb_desc != -1. */ */ | |
64 | /* OBSOLETE FILE *eb_stream; */ | |
65 | /* OBSOLETE */ | |
66 | /* OBSOLETE /* Read a character from the remote system, doing all the fancy */ | |
67 | /* OBSOLETE timeout stuff. */ */ | |
68 | /* OBSOLETE static int */ | |
69 | /* OBSOLETE readchar (void) */ | |
70 | /* OBSOLETE { */ | |
71 | /* OBSOLETE char buf; */ | |
72 | /* OBSOLETE */ | |
73 | /* OBSOLETE buf = '\0'; */ | |
74 | /* OBSOLETE #ifdef HAVE_TERMIO */ | |
75 | /* OBSOLETE /* termio does the timeout for us. */ */ | |
76 | /* OBSOLETE read (eb_desc, &buf, 1); */ | |
77 | /* OBSOLETE #else */ | |
78 | /* OBSOLETE alarm (timeout); */ | |
79 | /* OBSOLETE if (read (eb_desc, &buf, 1) < 0) */ | |
80 | /* OBSOLETE { */ | |
81 | /* OBSOLETE if (errno == EINTR) */ | |
82 | /* OBSOLETE error ("Timeout reading from remote system."); */ | |
83 | /* OBSOLETE else */ | |
84 | /* OBSOLETE perror_with_name ("remote"); */ | |
85 | /* OBSOLETE } */ | |
86 | /* OBSOLETE alarm (0); */ | |
87 | /* OBSOLETE #endif */ | |
88 | /* OBSOLETE */ | |
89 | /* OBSOLETE if (buf == '\0') */ | |
90 | /* OBSOLETE error ("Timeout reading from remote system."); */ | |
91 | /* OBSOLETE #if defined (LOG_FILE) */ | |
92 | /* OBSOLETE putc (buf & 0x7f, log_file); */ | |
93 | /* OBSOLETE #endif */ | |
94 | /* OBSOLETE return buf & 0x7f; */ | |
95 | /* OBSOLETE } */ | |
96 | /* OBSOLETE */ | |
97 | /* OBSOLETE /* Keep discarding input from the remote system, until STRING is found. */ | |
98 | /* OBSOLETE Let the user break out immediately. */ */ | |
99 | /* OBSOLETE static void */ | |
100 | /* OBSOLETE expect (char *string) */ | |
101 | /* OBSOLETE { */ | |
102 | /* OBSOLETE char *p = string; */ | |
103 | /* OBSOLETE */ | |
104 | /* OBSOLETE immediate_quit++; */ | |
105 | /* OBSOLETE while (1) */ | |
106 | /* OBSOLETE { */ | |
107 | /* OBSOLETE if (readchar () == *p) */ | |
108 | /* OBSOLETE { */ | |
109 | /* OBSOLETE p++; */ | |
110 | /* OBSOLETE if (*p == '\0') */ | |
111 | /* OBSOLETE { */ | |
112 | /* OBSOLETE immediate_quit--; */ | |
113 | /* OBSOLETE return; */ | |
114 | /* OBSOLETE } */ | |
115 | /* OBSOLETE } */ | |
116 | /* OBSOLETE else */ | |
117 | /* OBSOLETE p = string; */ | |
118 | /* OBSOLETE } */ | |
119 | /* OBSOLETE } */ | |
120 | /* OBSOLETE */ | |
121 | /* OBSOLETE /* Keep discarding input until we see the ebmon prompt. */ | |
122 | /* OBSOLETE */ | |
123 | /* OBSOLETE The convention for dealing with the prompt is that you */ | |
124 | /* OBSOLETE o give your command */ | |
125 | /* OBSOLETE o *then* wait for the prompt. */ | |
126 | /* OBSOLETE */ | |
127 | /* OBSOLETE Thus the last thing that a procedure does with the serial line */ | |
128 | /* OBSOLETE will be an expect_prompt(). Exception: eb_resume does not */ | |
129 | /* OBSOLETE wait for the prompt, because the terminal is being handed over */ | |
130 | /* OBSOLETE to the inferior. However, the next thing which happens after that */ | |
131 | /* OBSOLETE is a eb_wait which does wait for the prompt. */ | |
132 | /* OBSOLETE Note that this includes abnormal exit, e.g. error(). This is */ | |
133 | /* OBSOLETE necessary to prevent getting into states from which we can't */ | |
134 | /* OBSOLETE recover. */ */ | |
135 | /* OBSOLETE static void */ | |
136 | /* OBSOLETE expect_prompt (void) */ | |
137 | /* OBSOLETE { */ | |
138 | /* OBSOLETE #if defined (LOG_FILE) */ | |
139 | /* OBSOLETE /* This is a convenient place to do this. The idea is to do it often */ | |
140 | /* OBSOLETE enough that we never lose much data if we terminate abnormally. */ */ | |
141 | /* OBSOLETE fflush (log_file); */ | |
142 | /* OBSOLETE #endif */ | |
143 | /* OBSOLETE expect ("\n# "); */ | |
144 | /* OBSOLETE } */ | |
145 | /* OBSOLETE */ | |
146 | /* OBSOLETE /* Get a hex digit from the remote system & return its value. */ | |
147 | /* OBSOLETE If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */ */ | |
148 | /* OBSOLETE static int */ | |
149 | /* OBSOLETE get_hex_digit (int ignore_space) */ | |
150 | /* OBSOLETE { */ | |
151 | /* OBSOLETE int ch; */ | |
152 | /* OBSOLETE while (1) */ | |
153 | /* OBSOLETE { */ | |
154 | /* OBSOLETE ch = readchar (); */ | |
155 | /* OBSOLETE if (ch >= '0' && ch <= '9') */ | |
156 | /* OBSOLETE return ch - '0'; */ | |
157 | /* OBSOLETE else if (ch >= 'A' && ch <= 'F') */ | |
158 | /* OBSOLETE return ch - 'A' + 10; */ | |
159 | /* OBSOLETE else if (ch >= 'a' && ch <= 'f') */ | |
160 | /* OBSOLETE return ch - 'a' + 10; */ | |
161 | /* OBSOLETE else if (ch == ' ' && ignore_space) */ | |
162 | /* OBSOLETE ; */ | |
163 | /* OBSOLETE else */ | |
164 | /* OBSOLETE { */ | |
165 | /* OBSOLETE expect_prompt (); */ | |
166 | /* OBSOLETE error ("Invalid hex digit from remote system."); */ | |
167 | /* OBSOLETE } */ | |
168 | /* OBSOLETE } */ | |
169 | /* OBSOLETE } */ | |
170 | /* OBSOLETE */ | |
171 | /* OBSOLETE /* Get a byte from eb_desc and put it in *BYT. Accept any number */ | |
172 | /* OBSOLETE leading spaces. */ */ | |
173 | /* OBSOLETE static void */ | |
174 | /* OBSOLETE get_hex_byte (char *byt) */ | |
175 | /* OBSOLETE { */ | |
176 | /* OBSOLETE int val; */ | |
177 | /* OBSOLETE */ | |
178 | /* OBSOLETE val = get_hex_digit (1) << 4; */ | |
179 | /* OBSOLETE val |= get_hex_digit (0); */ | |
180 | /* OBSOLETE *byt = val; */ | |
181 | /* OBSOLETE } */ | |
182 | /* OBSOLETE */ | |
183 | /* OBSOLETE /* Get N 32-bit words from remote, each preceded by a space, */ | |
184 | /* OBSOLETE and put them in registers starting at REGNO. */ */ | |
185 | /* OBSOLETE static void */ | |
186 | /* OBSOLETE get_hex_regs (int n, int regno) */ | |
187 | /* OBSOLETE { */ | |
188 | /* OBSOLETE long val; */ | |
189 | /* OBSOLETE int i; */ | |
190 | /* OBSOLETE */ | |
191 | /* OBSOLETE for (i = 0; i < n; i++) */ | |
192 | /* OBSOLETE { */ | |
193 | /* OBSOLETE int j; */ | |
194 | /* OBSOLETE */ | |
195 | /* OBSOLETE val = 0; */ | |
196 | /* OBSOLETE for (j = 0; j < 8; j++) */ | |
197 | /* OBSOLETE val = (val << 4) + get_hex_digit (j == 0); */ | |
198 | /* OBSOLETE supply_register (regno++, (char *) &val); */ | |
199 | /* OBSOLETE } */ | |
200 | /* OBSOLETE } */ | |
201 | /* OBSOLETE */ | |
202 | /* OBSOLETE /* Called when SIGALRM signal sent due to alarm() timeout. */ */ | |
203 | /* OBSOLETE #ifndef HAVE_TERMIO */ | |
204 | /* OBSOLETE */ | |
205 | /* OBSOLETE volatile int n_alarms; */ | |
206 | /* OBSOLETE */ | |
207 | /* OBSOLETE void */ | |
208 | /* OBSOLETE eb_timer (void) */ | |
209 | /* OBSOLETE { */ | |
210 | /* OBSOLETE #if 0 */ | |
211 | /* OBSOLETE if (kiodebug) */ | |
212 | /* OBSOLETE printf ("eb_timer called\n"); */ | |
213 | /* OBSOLETE #endif */ | |
214 | /* OBSOLETE n_alarms++; */ | |
215 | /* OBSOLETE } */ | |
216 | /* OBSOLETE #endif */ | |
217 | /* OBSOLETE */ | |
218 | /* OBSOLETE /* malloc'd name of the program on the remote system. */ */ | |
219 | /* OBSOLETE static char *prog_name = NULL; */ | |
220 | /* OBSOLETE */ | |
221 | /* OBSOLETE /* Nonzero if we have loaded the file ("yc") and not yet issued a "gi" */ | |
222 | /* OBSOLETE command. "gi" is supposed to happen exactly once for each "yc". */ */ | |
223 | /* OBSOLETE static int need_gi = 0; */ | |
224 | /* OBSOLETE */ | |
225 | /* OBSOLETE /* Number of SIGTRAPs we need to simulate. That is, the next */ | |
226 | /* OBSOLETE NEED_ARTIFICIAL_TRAP calls to eb_wait should just return */ | |
227 | /* OBSOLETE SIGTRAP without actually waiting for anything. */ */ | |
228 | /* OBSOLETE */ | |
229 | /* OBSOLETE static int need_artificial_trap = 0; */ | |
230 | /* OBSOLETE */ | |
231 | /* OBSOLETE /* This is called not only when we first attach, but also when the */ | |
232 | /* OBSOLETE user types "run" after having attached. */ */ | |
233 | /* OBSOLETE static void */ | |
234 | /* OBSOLETE eb_create_inferior (char *execfile, char *args, char **env) */ | |
235 | /* OBSOLETE { */ | |
236 | /* OBSOLETE int entry_pt; */ | |
237 | /* OBSOLETE */ | |
238 | /* OBSOLETE if (args && *args) */ | |
239 | /* OBSOLETE error ("Can't pass arguments to remote EBMON process"); */ | |
240 | /* OBSOLETE */ | |
241 | /* OBSOLETE if (execfile == 0 || exec_bfd == 0) */ | |
242 | /* OBSOLETE error ("No executable file specified"); */ | |
243 | /* OBSOLETE */ | |
244 | /* OBSOLETE entry_pt = (int) bfd_get_start_address (exec_bfd); */ | |
245 | /* OBSOLETE */ | |
246 | /* OBSOLETE { */ | |
247 | /* OBSOLETE /* OK, now read in the file. Y=read, C=COFF, D=no symbols */ | |
248 | /* OBSOLETE 0=start address, %s=filename. */ */ | |
249 | /* OBSOLETE */ | |
250 | /* OBSOLETE fprintf (eb_stream, "YC D,0:%s", prog_name); */ | |
251 | /* OBSOLETE */ | |
252 | /* OBSOLETE if (args != NULL) */ | |
253 | /* OBSOLETE fprintf (eb_stream, " %s", args); */ | |
254 | /* OBSOLETE */ | |
255 | /* OBSOLETE fprintf (eb_stream, "\n"); */ | |
256 | /* OBSOLETE fflush (eb_stream); */ | |
257 | /* OBSOLETE */ | |
258 | /* OBSOLETE expect_prompt (); */ | |
259 | /* OBSOLETE */ | |
260 | /* OBSOLETE need_gi = 1; */ | |
261 | /* OBSOLETE } */ | |
262 | /* OBSOLETE */ | |
263 | /* OBSOLETE /* The "process" (board) is already stopped awaiting our commands, and */ | |
264 | /* OBSOLETE the program is already downloaded. We just set its PC and go. */ */ | |
265 | /* OBSOLETE */ | |
266 | /* OBSOLETE clear_proceed_status (); */ | |
267 | /* OBSOLETE */ | |
268 | /* OBSOLETE /* Tell wait_for_inferior that we've started a new process. */ */ | |
269 | /* OBSOLETE init_wait_for_inferior (); */ | |
270 | /* OBSOLETE */ | |
271 | /* OBSOLETE /* Set up the "saved terminal modes" of the inferior */ | |
272 | /* OBSOLETE based on what modes we are starting it with. */ */ | |
273 | /* OBSOLETE target_terminal_init (); */ | |
274 | /* OBSOLETE */ | |
275 | /* OBSOLETE /* Install inferior's terminal modes. */ */ | |
276 | /* OBSOLETE target_terminal_inferior (); */ | |
277 | /* OBSOLETE */ | |
278 | /* OBSOLETE /* insert_step_breakpoint (); FIXME, do we need this? */ */ | |
279 | /* OBSOLETE proceed ((CORE_ADDR) entry_pt, TARGET_SIGNAL_DEFAULT, 0); /* Let 'er rip... */ */ | |
280 | /* OBSOLETE } */ | |
281 | /* OBSOLETE */ | |
282 | /* OBSOLETE /* Translate baud rates from integers to damn B_codes. Unix should */ | |
283 | /* OBSOLETE have outgrown this crap years ago, but even POSIX wouldn't buck it. */ */ | |
284 | /* OBSOLETE */ | |
285 | /* OBSOLETE #ifndef B19200 */ | |
286 | /* OBSOLETE #define B19200 EXTA */ | |
287 | /* OBSOLETE #endif */ | |
288 | /* OBSOLETE #ifndef B38400 */ | |
289 | /* OBSOLETE #define B38400 EXTB */ | |
290 | /* OBSOLETE #endif */ | |
291 | /* OBSOLETE */ | |
292 | /* OBSOLETE struct */ | |
293 | /* OBSOLETE { */ | |
294 | /* OBSOLETE int rate, damn_b; */ | |
295 | /* OBSOLETE } */ | |
296 | /* OBSOLETE baudtab[] = */ | |
297 | /* OBSOLETE { */ | |
298 | /* OBSOLETE { */ | |
299 | /* OBSOLETE 0, B0 */ | |
300 | /* OBSOLETE } */ | |
301 | /* OBSOLETE , */ | |
302 | /* OBSOLETE { */ | |
303 | /* OBSOLETE 50, B50 */ | |
304 | /* OBSOLETE } */ | |
305 | /* OBSOLETE , */ | |
306 | /* OBSOLETE { */ | |
307 | /* OBSOLETE 75, B75 */ | |
308 | /* OBSOLETE } */ | |
309 | /* OBSOLETE , */ | |
310 | /* OBSOLETE { */ | |
311 | /* OBSOLETE 110, B110 */ | |
312 | /* OBSOLETE } */ | |
313 | /* OBSOLETE , */ | |
314 | /* OBSOLETE { */ | |
315 | /* OBSOLETE 134, B134 */ | |
316 | /* OBSOLETE } */ | |
317 | /* OBSOLETE , */ | |
318 | /* OBSOLETE { */ | |
319 | /* OBSOLETE 150, B150 */ | |
320 | /* OBSOLETE } */ | |
321 | /* OBSOLETE , */ | |
322 | /* OBSOLETE { */ | |
323 | /* OBSOLETE 200, B200 */ | |
324 | /* OBSOLETE } */ | |
325 | /* OBSOLETE , */ | |
326 | /* OBSOLETE { */ | |
327 | /* OBSOLETE 300, B300 */ | |
328 | /* OBSOLETE } */ | |
329 | /* OBSOLETE , */ | |
330 | /* OBSOLETE { */ | |
331 | /* OBSOLETE 600, B600 */ | |
332 | /* OBSOLETE } */ | |
333 | /* OBSOLETE , */ | |
334 | /* OBSOLETE { */ | |
335 | /* OBSOLETE 1200, B1200 */ | |
336 | /* OBSOLETE } */ | |
337 | /* OBSOLETE , */ | |
338 | /* OBSOLETE { */ | |
339 | /* OBSOLETE 1800, B1800 */ | |
340 | /* OBSOLETE } */ | |
341 | /* OBSOLETE , */ | |
342 | /* OBSOLETE { */ | |
343 | /* OBSOLETE 2400, B2400 */ | |
344 | /* OBSOLETE } */ | |
345 | /* OBSOLETE , */ | |
346 | /* OBSOLETE { */ | |
347 | /* OBSOLETE 4800, B4800 */ | |
348 | /* OBSOLETE } */ | |
349 | /* OBSOLETE , */ | |
350 | /* OBSOLETE { */ | |
351 | /* OBSOLETE 9600, B9600 */ | |
352 | /* OBSOLETE } */ | |
353 | /* OBSOLETE , */ | |
354 | /* OBSOLETE { */ | |
355 | /* OBSOLETE 19200, B19200 */ | |
356 | /* OBSOLETE } */ | |
357 | /* OBSOLETE , */ | |
358 | /* OBSOLETE { */ | |
359 | /* OBSOLETE 38400, B38400 */ | |
360 | /* OBSOLETE } */ | |
361 | /* OBSOLETE , */ | |
362 | /* OBSOLETE { */ | |
363 | /* OBSOLETE -1, -1 */ | |
364 | /* OBSOLETE } */ | |
365 | /* OBSOLETE , */ | |
366 | /* OBSOLETE }; */ | |
367 | /* OBSOLETE */ | |
368 | /* OBSOLETE int */ | |
369 | /* OBSOLETE damn_b (int rate) */ | |
370 | /* OBSOLETE { */ | |
371 | /* OBSOLETE int i; */ | |
372 | /* OBSOLETE */ | |
373 | /* OBSOLETE for (i = 0; baudtab[i].rate != -1; i++) */ | |
374 | /* OBSOLETE if (rate == baudtab[i].rate) */ | |
375 | /* OBSOLETE return baudtab[i].damn_b; */ | |
376 | /* OBSOLETE return B38400; /* Random */ */ | |
377 | /* OBSOLETE } */ | |
378 | /* OBSOLETE */ | |
379 | /* OBSOLETE */ | |
380 | /* OBSOLETE /* Open a connection to a remote debugger. */ | |
381 | /* OBSOLETE NAME is the filename used for communication, then a space, */ | |
382 | /* OBSOLETE then the name of the program as we should name it to EBMON. */ */ | |
383 | /* OBSOLETE */ | |
384 | /* OBSOLETE static int baudrate = 9600; */ | |
385 | /* OBSOLETE static char *dev_name; */ | |
386 | /* OBSOLETE void */ | |
387 | /* OBSOLETE eb_open (char *name, int from_tty) */ | |
388 | /* OBSOLETE { */ | |
389 | /* OBSOLETE TERMINAL sg; */ | |
390 | /* OBSOLETE */ | |
391 | /* OBSOLETE char *p; */ | |
392 | /* OBSOLETE */ | |
393 | /* OBSOLETE target_preopen (from_tty); */ | |
394 | /* OBSOLETE */ | |
395 | /* OBSOLETE /* Find the first whitespace character, it separates dev_name from */ | |
396 | /* OBSOLETE prog_name. */ */ | |
397 | /* OBSOLETE if (name == 0) */ | |
398 | /* OBSOLETE goto erroid; */ | |
399 | /* OBSOLETE */ | |
400 | /* OBSOLETE for (p = name; */ | |
401 | /* OBSOLETE *p != '\0' && !isspace (*p); p++) */ | |
402 | /* OBSOLETE ; */ | |
403 | /* OBSOLETE if (*p == '\0') */ | |
404 | /* OBSOLETE erroid: */ | |
405 | /* OBSOLETE error ("\ */ | |
406 | /* OBSOLETE Please include the name of the device for the serial port,\n\ */ | |
407 | /* OBSOLETE the baud rate, and the name of the program to run on the remote system."); */ | |
408 | /* OBSOLETE dev_name = alloca (p - name + 1); */ | |
409 | /* OBSOLETE strncpy (dev_name, name, p - name); */ | |
410 | /* OBSOLETE dev_name[p - name] = '\0'; */ | |
411 | /* OBSOLETE */ | |
412 | /* OBSOLETE /* Skip over the whitespace after dev_name */ */ | |
413 | /* OBSOLETE for (; isspace (*p); p++) */ | |
414 | /* OBSOLETE /*EMPTY */ ; */ | |
415 | /* OBSOLETE */ | |
416 | /* OBSOLETE if (1 != sscanf (p, "%d ", &baudrate)) */ | |
417 | /* OBSOLETE goto erroid; */ | |
418 | /* OBSOLETE */ | |
419 | /* OBSOLETE /* Skip the number and then the spaces */ */ | |
420 | /* OBSOLETE for (; isdigit (*p); p++) */ | |
421 | /* OBSOLETE /*EMPTY */ ; */ | |
422 | /* OBSOLETE for (; isspace (*p); p++) */ | |
423 | /* OBSOLETE /*EMPTY */ ; */ | |
424 | /* OBSOLETE */ | |
425 | /* OBSOLETE if (prog_name != NULL) */ | |
426 | /* OBSOLETE xfree (prog_name); */ | |
427 | /* OBSOLETE prog_name = savestring (p, strlen (p)); */ | |
428 | /* OBSOLETE */ | |
429 | /* OBSOLETE eb_close (0); */ | |
430 | /* OBSOLETE */ | |
431 | /* OBSOLETE eb_desc = open (dev_name, O_RDWR); */ | |
432 | /* OBSOLETE if (eb_desc < 0) */ | |
433 | /* OBSOLETE perror_with_name (dev_name); */ | |
434 | /* OBSOLETE ioctl (eb_desc, TIOCGETP, &sg); */ | |
435 | /* OBSOLETE #ifdef HAVE_TERMIO */ | |
436 | /* OBSOLETE sg.c_cc[VMIN] = 0; /* read with timeout. */ */ | |
437 | /* OBSOLETE sg.c_cc[VTIME] = timeout * 10; */ | |
438 | /* OBSOLETE sg.c_lflag &= ~(ICANON | ECHO); */ | |
439 | /* OBSOLETE sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate); */ | |
440 | /* OBSOLETE #else */ | |
441 | /* OBSOLETE sg.sg_ispeed = damn_b (baudrate); */ | |
442 | /* OBSOLETE sg.sg_ospeed = damn_b (baudrate); */ | |
443 | /* OBSOLETE sg.sg_flags |= RAW | ANYP; */ | |
444 | /* OBSOLETE sg.sg_flags &= ~ECHO; */ | |
445 | /* OBSOLETE #endif */ | |
446 | /* OBSOLETE */ | |
447 | /* OBSOLETE ioctl (eb_desc, TIOCSETP, &sg); */ | |
448 | /* OBSOLETE eb_stream = fdopen (eb_desc, "r+"); */ | |
449 | /* OBSOLETE */ | |
450 | /* OBSOLETE push_target (&eb_ops); */ | |
451 | /* OBSOLETE if (from_tty) */ | |
452 | /* OBSOLETE printf ("Remote %s debugging %s using %s\n", target_shortname, */ | |
453 | /* OBSOLETE prog_name, dev_name); */ | |
454 | /* OBSOLETE */ | |
455 | /* OBSOLETE #ifndef HAVE_TERMIO */ | |
456 | /* OBSOLETE #ifndef NO_SIGINTERRUPT */ | |
457 | /* OBSOLETE /* Cause SIGALRM's to make reads fail with EINTR instead of resuming */ | |
458 | /* OBSOLETE the read. */ */ | |
459 | /* OBSOLETE if (siginterrupt (SIGALRM, 1) != 0) */ | |
460 | /* OBSOLETE perror ("eb_open: error in siginterrupt"); */ | |
461 | /* OBSOLETE #endif */ | |
462 | /* OBSOLETE */ | |
463 | /* OBSOLETE /* Set up read timeout timer. */ */ | |
464 | /* OBSOLETE if ((void (*)) signal (SIGALRM, eb_timer) == (void (*)) -1) */ | |
465 | /* OBSOLETE perror ("eb_open: error in signal"); */ | |
466 | /* OBSOLETE #endif */ | |
467 | /* OBSOLETE */ | |
468 | /* OBSOLETE #if defined (LOG_FILE) */ | |
469 | /* OBSOLETE log_file = fopen (LOG_FILE, "w"); */ | |
470 | /* OBSOLETE if (log_file == NULL) */ | |
471 | /* OBSOLETE perror_with_name (LOG_FILE); */ | |
472 | /* OBSOLETE #endif */ | |
473 | /* OBSOLETE */ | |
474 | /* OBSOLETE /* Hello? Are you there? */ */ | |
475 | /* OBSOLETE write (eb_desc, "\n", 1); */ | |
476 | /* OBSOLETE */ | |
477 | /* OBSOLETE expect_prompt (); */ | |
478 | /* OBSOLETE } */ | |
479 | /* OBSOLETE */ | |
480 | /* OBSOLETE /* Close out all files and local state before this target loses control. */ */ | |
481 | /* OBSOLETE */ | |
482 | /* OBSOLETE static void */ | |
483 | /* OBSOLETE eb_close (int quitting) */ | |
484 | /* OBSOLETE { */ | |
485 | /* OBSOLETE */ | |
486 | /* OBSOLETE /* Due to a bug in Unix, fclose closes not only the stdio stream, */ | |
487 | /* OBSOLETE but also the file descriptor. So we don't actually close */ | |
488 | /* OBSOLETE eb_desc. */ */ | |
489 | /* OBSOLETE if (eb_stream) */ | |
490 | /* OBSOLETE fclose (eb_stream); /* This also closes eb_desc */ */ | |
491 | /* OBSOLETE if (eb_desc >= 0) */ | |
492 | /* OBSOLETE /* close (eb_desc); */ */ | |
493 | /* OBSOLETE */ | |
494 | /* OBSOLETE /* Do not try to close eb_desc again, later in the program. */ */ | |
495 | /* OBSOLETE eb_stream = NULL; */ | |
496 | /* OBSOLETE eb_desc = -1; */ | |
497 | /* OBSOLETE */ | |
498 | /* OBSOLETE #if defined (LOG_FILE) */ | |
499 | /* OBSOLETE if (log_file) */ | |
500 | /* OBSOLETE { */ | |
501 | /* OBSOLETE if (ferror (log_file)) */ | |
502 | /* OBSOLETE printf ("Error writing log file.\n"); */ | |
503 | /* OBSOLETE if (fclose (log_file) != 0) */ | |
504 | /* OBSOLETE printf ("Error closing log file.\n"); */ | |
505 | /* OBSOLETE } */ | |
506 | /* OBSOLETE #endif */ | |
507 | /* OBSOLETE } */ | |
508 | /* OBSOLETE */ | |
509 | /* OBSOLETE /* Terminate the open connection to the remote debugger. */ | |
510 | /* OBSOLETE Use this when you want to detach and do something else */ | |
511 | /* OBSOLETE with your gdb. */ */ | |
512 | /* OBSOLETE void */ | |
513 | /* OBSOLETE eb_detach (int from_tty) */ | |
514 | /* OBSOLETE { */ | |
515 | /* OBSOLETE pop_target (); /* calls eb_close to do the real work */ */ | |
516 | /* OBSOLETE if (from_tty) */ | |
517 | /* OBSOLETE printf ("Ending remote %s debugging\n", target_shortname); */ | |
518 | /* OBSOLETE } */ | |
519 | /* OBSOLETE */ | |
520 | /* OBSOLETE /* Tell the remote machine to resume. */ */ | |
521 | /* OBSOLETE */ | |
522 | /* OBSOLETE void */ | |
523 | /* OBSOLETE eb_resume (ptid_t ptid, int step, enum target_signal sig) */ | |
524 | /* OBSOLETE { */ | |
525 | /* OBSOLETE if (step) */ | |
526 | /* OBSOLETE { */ | |
527 | /* OBSOLETE write (eb_desc, "t 1,s\n", 6); */ | |
528 | /* OBSOLETE /* Wait for the echo. */ */ | |
529 | /* OBSOLETE expect ("t 1,s\r"); */ | |
530 | /* OBSOLETE /* Then comes a line containing the instruction we stepped to. */ */ | |
531 | /* OBSOLETE expect ("\n@"); */ | |
532 | /* OBSOLETE /* Then we get the prompt. */ */ | |
533 | /* OBSOLETE expect_prompt (); */ | |
534 | /* OBSOLETE */ | |
535 | /* OBSOLETE /* Force the next eb_wait to return a trap. Not doing anything */ | |
536 | /* OBSOLETE about I/O from the target means that the user has to type */ | |
537 | /* OBSOLETE "continue" to see any. This should be fixed. */ */ | |
538 | /* OBSOLETE need_artificial_trap = 1; */ | |
539 | /* OBSOLETE } */ | |
540 | /* OBSOLETE else */ | |
541 | /* OBSOLETE { */ | |
542 | /* OBSOLETE if (need_gi) */ | |
543 | /* OBSOLETE { */ | |
544 | /* OBSOLETE need_gi = 0; */ | |
545 | /* OBSOLETE write (eb_desc, "gi\n", 3); */ | |
546 | /* OBSOLETE */ | |
547 | /* OBSOLETE /* Swallow the echo of "gi". */ */ | |
548 | /* OBSOLETE expect ("gi\r"); */ | |
549 | /* OBSOLETE } */ | |
550 | /* OBSOLETE else */ | |
551 | /* OBSOLETE { */ | |
552 | /* OBSOLETE write (eb_desc, "GR\n", 3); */ | |
553 | /* OBSOLETE /* Swallow the echo. */ */ | |
554 | /* OBSOLETE expect ("GR\r"); */ | |
555 | /* OBSOLETE } */ | |
556 | /* OBSOLETE } */ | |
557 | /* OBSOLETE } */ | |
558 | /* OBSOLETE */ | |
559 | /* OBSOLETE /* Wait until the remote machine stops, then return, */ | |
560 | /* OBSOLETE storing status in STATUS just as `wait' would. */ */ | |
561 | /* OBSOLETE */ | |
562 | /* OBSOLETE ptid_t */ | |
563 | /* OBSOLETE eb_wait (ptid_t ptid, struct target_waitstatus *status) */ | |
564 | /* OBSOLETE { */ | |
565 | /* OBSOLETE /* Strings to look for. '?' means match any single character. */ | |
566 | /* OBSOLETE Note that with the algorithm we use, the initial character */ | |
567 | /* OBSOLETE of the string cannot recur in the string, or we will not */ | |
568 | /* OBSOLETE find some cases of the string in the input. */ */ | |
569 | /* OBSOLETE */ | |
570 | /* OBSOLETE static char bpt[] = "Invalid interrupt taken - #0x50 - "; */ | |
571 | /* OBSOLETE /* It would be tempting to look for "\n[__exit + 0x8]\n" */ | |
572 | /* OBSOLETE but that requires loading symbols with "yc i" and even if */ | |
573 | /* OBSOLETE we did do that we don't know that the file has symbols. */ */ | |
574 | /* OBSOLETE static char exitmsg[] = "\n@????????I JMPTI GR121,LR0"; */ | |
575 | /* OBSOLETE char *bp = bpt; */ | |
576 | /* OBSOLETE char *ep = exitmsg; */ | |
577 | /* OBSOLETE */ | |
578 | /* OBSOLETE /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars. */ */ | |
579 | /* OBSOLETE char swallowed[50]; */ | |
580 | /* OBSOLETE /* Current position in swallowed. */ */ | |
581 | /* OBSOLETE char *swallowed_p = swallowed; */ | |
582 | /* OBSOLETE */ | |
583 | /* OBSOLETE int ch; */ | |
584 | /* OBSOLETE int ch_handled; */ | |
585 | /* OBSOLETE */ | |
586 | /* OBSOLETE int old_timeout = timeout; */ | |
587 | /* OBSOLETE */ | |
588 | /* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */ | |
589 | /* OBSOLETE status->value.integer = 0; */ | |
590 | /* OBSOLETE */ | |
591 | /* OBSOLETE if (need_artificial_trap != 0) */ | |
592 | /* OBSOLETE { */ | |
593 | /* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */ | |
594 | /* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */ | |
595 | /* OBSOLETE need_artificial_trap--; */ | |
596 | /* OBSOLETE return 0; */ | |
597 | /* OBSOLETE } */ | |
598 | /* OBSOLETE */ | |
599 | /* OBSOLETE timeout = 0; /* Don't time out -- user program is running. */ */ | |
600 | /* OBSOLETE while (1) */ | |
601 | /* OBSOLETE { */ | |
602 | /* OBSOLETE ch_handled = 0; */ | |
603 | /* OBSOLETE ch = readchar (); */ | |
604 | /* OBSOLETE if (ch == *bp) */ | |
605 | /* OBSOLETE { */ | |
606 | /* OBSOLETE bp++; */ | |
607 | /* OBSOLETE if (*bp == '\0') */ | |
608 | /* OBSOLETE break; */ | |
609 | /* OBSOLETE ch_handled = 1; */ | |
610 | /* OBSOLETE */ | |
611 | /* OBSOLETE *swallowed_p++ = ch; */ | |
612 | /* OBSOLETE } */ | |
613 | /* OBSOLETE else */ | |
614 | /* OBSOLETE bp = bpt; */ | |
615 | /* OBSOLETE */ | |
616 | /* OBSOLETE if (ch == *ep || *ep == '?') */ | |
617 | /* OBSOLETE { */ | |
618 | /* OBSOLETE ep++; */ | |
619 | /* OBSOLETE if (*ep == '\0') */ | |
620 | /* OBSOLETE break; */ | |
621 | /* OBSOLETE */ | |
622 | /* OBSOLETE if (!ch_handled) */ | |
623 | /* OBSOLETE *swallowed_p++ = ch; */ | |
624 | /* OBSOLETE ch_handled = 1; */ | |
625 | /* OBSOLETE } */ | |
626 | /* OBSOLETE else */ | |
627 | /* OBSOLETE ep = exitmsg; */ | |
628 | /* OBSOLETE */ | |
629 | /* OBSOLETE if (!ch_handled) */ | |
630 | /* OBSOLETE { */ | |
631 | /* OBSOLETE char *p; */ | |
632 | /* OBSOLETE */ | |
633 | /* OBSOLETE /* Print out any characters which have been swallowed. */ */ | |
634 | /* OBSOLETE for (p = swallowed; p < swallowed_p; ++p) */ | |
635 | /* OBSOLETE putc (*p, stdout); */ | |
636 | /* OBSOLETE swallowed_p = swallowed; */ | |
637 | /* OBSOLETE */ | |
638 | /* OBSOLETE putc (ch, stdout); */ | |
639 | /* OBSOLETE } */ | |
640 | /* OBSOLETE } */ | |
641 | /* OBSOLETE expect_prompt (); */ | |
642 | /* OBSOLETE if (*bp == '\0') */ | |
643 | /* OBSOLETE { */ | |
644 | /* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */ | |
645 | /* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */ | |
646 | /* OBSOLETE } */ | |
647 | /* OBSOLETE else */ | |
648 | /* OBSOLETE { */ | |
649 | /* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */ | |
650 | /* OBSOLETE status->value.integer = 0; */ | |
651 | /* OBSOLETE } */ | |
652 | /* OBSOLETE timeout = old_timeout; */ | |
653 | /* OBSOLETE */ | |
654 | /* OBSOLETE return 0; */ | |
655 | /* OBSOLETE } */ | |
656 | /* OBSOLETE */ | |
657 | /* OBSOLETE /* Return the name of register number REGNO */ | |
658 | /* OBSOLETE in the form input and output by EBMON. */ | |
659 | /* OBSOLETE */ | |
660 | /* OBSOLETE Returns a pointer to a static buffer containing the answer. */ */ | |
661 | /* OBSOLETE static char * */ | |
662 | /* OBSOLETE get_reg_name (int regno) */ | |
663 | /* OBSOLETE { */ | |
664 | /* OBSOLETE static char buf[80]; */ | |
665 | /* OBSOLETE if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) */ | |
666 | /* OBSOLETE sprintf (buf, "GR%03d", regno - GR96_REGNUM + 96); */ | |
667 | /* OBSOLETE else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) */ | |
668 | /* OBSOLETE sprintf (buf, "LR%03d", regno - LR0_REGNUM); */ | |
669 | /* OBSOLETE else if (regno == Q_REGNUM) */ | |
670 | /* OBSOLETE strcpy (buf, "SR131"); */ | |
671 | /* OBSOLETE else if (regno >= BP_REGNUM && regno <= CR_REGNUM) */ | |
672 | /* OBSOLETE sprintf (buf, "SR%03d", regno - BP_REGNUM + 133); */ | |
673 | /* OBSOLETE else if (regno == ALU_REGNUM) */ | |
674 | /* OBSOLETE strcpy (buf, "SR132"); */ | |
675 | /* OBSOLETE else if (regno >= IPC_REGNUM && regno <= IPB_REGNUM) */ | |
676 | /* OBSOLETE sprintf (buf, "SR%03d", regno - IPC_REGNUM + 128); */ | |
677 | /* OBSOLETE else if (regno >= VAB_REGNUM && regno <= LRU_REGNUM) */ | |
678 | /* OBSOLETE sprintf (buf, "SR%03d", regno - VAB_REGNUM); */ | |
679 | /* OBSOLETE else if (regno == GR1_REGNUM) */ | |
680 | /* OBSOLETE strcpy (buf, "GR001"); */ | |
681 | /* OBSOLETE return buf; */ | |
682 | /* OBSOLETE } */ | |
683 | /* OBSOLETE */ | |
684 | /* OBSOLETE /* Read the remote registers into the block REGS. */ */ | |
685 | /* OBSOLETE */ | |
686 | /* OBSOLETE static void */ | |
687 | /* OBSOLETE eb_fetch_registers (void) */ | |
688 | /* OBSOLETE { */ | |
689 | /* OBSOLETE int reg_index; */ | |
690 | /* OBSOLETE int regnum_index; */ | |
691 | /* OBSOLETE char tempbuf[10]; */ | |
692 | /* OBSOLETE int i; */ | |
693 | /* OBSOLETE */ | |
694 | /* OBSOLETE #if 0 */ | |
695 | /* OBSOLETE /* This should not be necessary, because one is supposed to read the */ | |
696 | /* OBSOLETE registers only when the inferior is stopped (at least with */ | |
697 | /* OBSOLETE ptrace() and why not make it the same for remote?). */ */ | |
698 | /* OBSOLETE /* ^A is the "normal character" used to make sure we are talking to EBMON */ | |
699 | /* OBSOLETE and not to the program being debugged. */ */ | |
700 | /* OBSOLETE write (eb_desc, "\001\n"); */ | |
701 | /* OBSOLETE expect_prompt (); */ | |
702 | /* OBSOLETE #endif */ | |
703 | /* OBSOLETE */ | |
704 | /* OBSOLETE write (eb_desc, "dw gr96,gr127\n", 14); */ | |
705 | /* OBSOLETE for (reg_index = 96, regnum_index = GR96_REGNUM; */ | |
706 | /* OBSOLETE reg_index < 128; */ | |
707 | /* OBSOLETE reg_index += 4, regnum_index += 4) */ | |
708 | /* OBSOLETE { */ | |
709 | /* OBSOLETE sprintf (tempbuf, "GR%03d ", reg_index); */ | |
710 | /* OBSOLETE expect (tempbuf); */ | |
711 | /* OBSOLETE get_hex_regs (4, regnum_index); */ | |
712 | /* OBSOLETE expect ("\n"); */ | |
713 | /* OBSOLETE } */ | |
714 | /* OBSOLETE */ | |
715 | /* OBSOLETE for (i = 0; i < 128; i += 32) */ | |
716 | /* OBSOLETE { */ | |
717 | /* OBSOLETE /* The PC has a tendency to hang if we get these */ | |
718 | /* OBSOLETE all in one fell swoop ("dw lr0,lr127"). */ */ | |
719 | /* OBSOLETE sprintf (tempbuf, "dw lr%d\n", i); */ | |
720 | /* OBSOLETE write (eb_desc, tempbuf, strlen (tempbuf)); */ | |
721 | /* OBSOLETE for (reg_index = i, regnum_index = LR0_REGNUM + i; */ | |
722 | /* OBSOLETE reg_index < i + 32; */ | |
723 | /* OBSOLETE reg_index += 4, regnum_index += 4) */ | |
724 | /* OBSOLETE { */ | |
725 | /* OBSOLETE sprintf (tempbuf, "LR%03d ", reg_index); */ | |
726 | /* OBSOLETE expect (tempbuf); */ | |
727 | /* OBSOLETE get_hex_regs (4, regnum_index); */ | |
728 | /* OBSOLETE expect ("\n"); */ | |
729 | /* OBSOLETE } */ | |
730 | /* OBSOLETE } */ | |
731 | /* OBSOLETE */ | |
732 | /* OBSOLETE write (eb_desc, "dw sr133,sr133\n", 15); */ | |
733 | /* OBSOLETE expect ("SR133 "); */ | |
734 | /* OBSOLETE get_hex_regs (1, BP_REGNUM); */ | |
735 | /* OBSOLETE expect ("\n"); */ | |
736 | /* OBSOLETE */ | |
737 | /* OBSOLETE write (eb_desc, "dw sr134,sr134\n", 15); */ | |
738 | /* OBSOLETE expect ("SR134 "); */ | |
739 | /* OBSOLETE get_hex_regs (1, FC_REGNUM); */ | |
740 | /* OBSOLETE expect ("\n"); */ | |
741 | /* OBSOLETE */ | |
742 | /* OBSOLETE write (eb_desc, "dw sr135,sr135\n", 15); */ | |
743 | /* OBSOLETE expect ("SR135 "); */ | |
744 | /* OBSOLETE get_hex_regs (1, CR_REGNUM); */ | |
745 | /* OBSOLETE expect ("\n"); */ | |
746 | /* OBSOLETE */ | |
747 | /* OBSOLETE write (eb_desc, "dw sr131,sr131\n", 15); */ | |
748 | /* OBSOLETE expect ("SR131 "); */ | |
749 | /* OBSOLETE get_hex_regs (1, Q_REGNUM); */ | |
750 | /* OBSOLETE expect ("\n"); */ | |
751 | /* OBSOLETE */ | |
752 | /* OBSOLETE write (eb_desc, "dw sr0,sr14\n", 12); */ | |
753 | /* OBSOLETE for (reg_index = 0, regnum_index = VAB_REGNUM; */ | |
754 | /* OBSOLETE regnum_index <= LRU_REGNUM; */ | |
755 | /* OBSOLETE regnum_index += 4, reg_index += 4) */ | |
756 | /* OBSOLETE { */ | |
757 | /* OBSOLETE sprintf (tempbuf, "SR%03d ", reg_index); */ | |
758 | /* OBSOLETE expect (tempbuf); */ | |
759 | /* OBSOLETE get_hex_regs (reg_index == 12 ? 3 : 4, regnum_index); */ | |
760 | /* OBSOLETE expect ("\n"); */ | |
761 | /* OBSOLETE } */ | |
762 | /* OBSOLETE */ | |
763 | /* OBSOLETE /* There doesn't seem to be any way to get these. */ */ | |
764 | /* OBSOLETE { */ | |
765 | /* OBSOLETE int val = -1; */ | |
766 | /* OBSOLETE supply_register (FPE_REGNUM, (char *) &val); */ | |
767 | /* OBSOLETE supply_register (INTE_REGNUM, (char *) &val); */ | |
768 | /* OBSOLETE supply_register (FPS_REGNUM, (char *) &val); */ | |
769 | /* OBSOLETE supply_register (EXO_REGNUM, (char *) &val); */ | |
770 | /* OBSOLETE } */ | |
771 | /* OBSOLETE */ | |
772 | /* OBSOLETE write (eb_desc, "dw gr1,gr1\n", 11); */ | |
773 | /* OBSOLETE expect ("GR001 "); */ | |
774 | /* OBSOLETE get_hex_regs (1, GR1_REGNUM); */ | |
775 | /* OBSOLETE expect_prompt (); */ | |
776 | /* OBSOLETE } */ | |
777 | /* OBSOLETE */ | |
778 | /* OBSOLETE /* Fetch register REGNO, or all registers if REGNO is -1. */ | |
779 | /* OBSOLETE Returns errno value. */ */ | |
780 | /* OBSOLETE void */ | |
781 | /* OBSOLETE eb_fetch_register (int regno) */ | |
782 | /* OBSOLETE { */ | |
783 | /* OBSOLETE if (regno == -1) */ | |
784 | /* OBSOLETE eb_fetch_registers (); */ | |
785 | /* OBSOLETE else */ | |
786 | /* OBSOLETE { */ | |
787 | /* OBSOLETE char *name = get_reg_name (regno); */ | |
788 | /* OBSOLETE fprintf (eb_stream, "dw %s,%s\n", name, name); */ | |
789 | /* OBSOLETE expect (name); */ | |
790 | /* OBSOLETE expect (" "); */ | |
791 | /* OBSOLETE get_hex_regs (1, regno); */ | |
792 | /* OBSOLETE expect_prompt (); */ | |
793 | /* OBSOLETE } */ | |
794 | /* OBSOLETE return; */ | |
795 | /* OBSOLETE } */ | |
796 | /* OBSOLETE */ | |
797 | /* OBSOLETE /* Store the remote registers from the contents of the block REGS. */ */ | |
798 | /* OBSOLETE */ | |
799 | /* OBSOLETE static void */ | |
800 | /* OBSOLETE eb_store_registers (void) */ | |
801 | /* OBSOLETE { */ | |
802 | /* OBSOLETE int i, j; */ | |
803 | /* OBSOLETE fprintf (eb_stream, "s gr1,%x\n", read_register (GR1_REGNUM)); */ | |
804 | /* OBSOLETE expect_prompt (); */ | |
805 | /* OBSOLETE */ | |
806 | /* OBSOLETE for (j = 0; j < 32; j += 16) */ | |
807 | /* OBSOLETE { */ | |
808 | /* OBSOLETE fprintf (eb_stream, "s gr%d,", j + 96); */ | |
809 | /* OBSOLETE for (i = 0; i < 15; ++i) */ | |
810 | /* OBSOLETE fprintf (eb_stream, "%x,", read_register (GR96_REGNUM + j + i)); */ | |
811 | /* OBSOLETE fprintf (eb_stream, "%x\n", read_register (GR96_REGNUM + j + 15)); */ | |
812 | /* OBSOLETE expect_prompt (); */ | |
813 | /* OBSOLETE } */ | |
814 | /* OBSOLETE */ | |
815 | /* OBSOLETE for (j = 0; j < 128; j += 16) */ | |
816 | /* OBSOLETE { */ | |
817 | /* OBSOLETE fprintf (eb_stream, "s lr%d,", j); */ | |
818 | /* OBSOLETE for (i = 0; i < 15; ++i) */ | |
819 | /* OBSOLETE fprintf (eb_stream, "%x,", read_register (LR0_REGNUM + j + i)); */ | |
820 | /* OBSOLETE fprintf (eb_stream, "%x\n", read_register (LR0_REGNUM + j + 15)); */ | |
821 | /* OBSOLETE expect_prompt (); */ | |
822 | /* OBSOLETE } */ | |
823 | /* OBSOLETE */ | |
824 | /* OBSOLETE fprintf (eb_stream, "s sr133,%x,%x,%x\n", read_register (BP_REGNUM), */ | |
825 | /* OBSOLETE read_register (FC_REGNUM), read_register (CR_REGNUM)); */ | |
826 | /* OBSOLETE expect_prompt (); */ | |
827 | /* OBSOLETE fprintf (eb_stream, "s sr131,%x\n", read_register (Q_REGNUM)); */ | |
828 | /* OBSOLETE expect_prompt (); */ | |
829 | /* OBSOLETE fprintf (eb_stream, "s sr0,"); */ | |
830 | /* OBSOLETE for (i = 0; i < 11; ++i) */ | |
831 | /* OBSOLETE fprintf (eb_stream, "%x,", read_register (VAB_REGNUM + i)); */ | |
832 | /* OBSOLETE fprintf (eb_stream, "%x\n", read_register (VAB_REGNUM + 11)); */ | |
833 | /* OBSOLETE expect_prompt (); */ | |
834 | /* OBSOLETE } */ | |
835 | /* OBSOLETE */ | |
836 | /* OBSOLETE /* Store register REGNO, or all if REGNO == 0. */ | |
837 | /* OBSOLETE Return errno value. */ */ | |
838 | /* OBSOLETE void */ | |
839 | /* OBSOLETE eb_store_register (int regno) */ | |
840 | /* OBSOLETE { */ | |
841 | /* OBSOLETE if (regno == -1) */ | |
842 | /* OBSOLETE eb_store_registers (); */ | |
843 | /* OBSOLETE else */ | |
844 | /* OBSOLETE { */ | |
845 | /* OBSOLETE char *name = get_reg_name (regno); */ | |
846 | /* OBSOLETE fprintf (eb_stream, "s %s,%x\n", name, read_register (regno)); */ | |
847 | /* OBSOLETE /* Setting GR1 changes the numbers of all the locals, so */ | |
848 | /* OBSOLETE invalidate the register cache. Do this *after* calling */ | |
849 | /* OBSOLETE read_register, because we want read_register to return the */ | |
850 | /* OBSOLETE value that write_register has just stuffed into the registers */ | |
851 | /* OBSOLETE array, not the value of the register fetched from the */ | |
852 | /* OBSOLETE inferior. */ */ | |
853 | /* OBSOLETE if (regno == GR1_REGNUM) */ | |
854 | /* OBSOLETE registers_changed (); */ | |
855 | /* OBSOLETE expect_prompt (); */ | |
856 | /* OBSOLETE } */ | |
857 | /* OBSOLETE } */ | |
858 | /* OBSOLETE */ | |
859 | /* OBSOLETE /* Get ready to modify the registers array. On machines which store */ | |
860 | /* OBSOLETE individual registers, this doesn't need to do anything. On machines */ | |
861 | /* OBSOLETE which store all the registers in one fell swoop, this makes sure */ | |
862 | /* OBSOLETE that registers contains all the registers from the program being */ | |
863 | /* OBSOLETE debugged. */ */ | |
864 | /* OBSOLETE */ | |
865 | /* OBSOLETE void */ | |
866 | /* OBSOLETE eb_prepare_to_store (void) */ | |
867 | /* OBSOLETE { */ | |
868 | /* OBSOLETE /* Do nothing, since we can store individual regs */ */ | |
869 | /* OBSOLETE } */ | |
870 | /* OBSOLETE */ | |
871 | /* OBSOLETE /* Transfer LEN bytes between GDB address MYADDR and target address */ | |
872 | /* OBSOLETE MEMADDR. If WRITE is non-zero, transfer them to the target, */ | |
873 | /* OBSOLETE otherwise transfer them from the target. TARGET is unused. */ | |
874 | /* OBSOLETE */ | |
875 | /* OBSOLETE Returns the number of bytes transferred. */ */ | |
876 | /* OBSOLETE */ | |
877 | /* OBSOLETE int */ | |
878 | /* OBSOLETE eb_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, */ | |
879 | /* OBSOLETE struct mem_attrib *attrib ATTRIBUTE_UNUSED, */ | |
880 | /* OBSOLETE struct target_ops *target ATTRIBUTE_UNUSED) */ | |
881 | /* OBSOLETE { */ | |
882 | /* OBSOLETE if (write) */ | |
883 | /* OBSOLETE return eb_write_inferior_memory (memaddr, myaddr, len); */ | |
884 | /* OBSOLETE else */ | |
885 | /* OBSOLETE return eb_read_inferior_memory (memaddr, myaddr, len); */ | |
886 | /* OBSOLETE } */ | |
887 | /* OBSOLETE */ | |
888 | /* OBSOLETE void */ | |
889 | /* OBSOLETE eb_files_info (void) */ | |
890 | /* OBSOLETE { */ | |
891 | /* OBSOLETE printf ("\tAttached to %s at %d baud and running program %s.\n", */ | |
892 | /* OBSOLETE dev_name, baudrate, prog_name); */ | |
893 | /* OBSOLETE } */ | |
894 | /* OBSOLETE */ | |
895 | /* OBSOLETE /* Copy LEN bytes of data from debugger memory at MYADDR */ | |
896 | /* OBSOLETE to inferior's memory at MEMADDR. Returns length moved. */ */ | |
897 | /* OBSOLETE int */ | |
898 | /* OBSOLETE eb_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */ | |
899 | /* OBSOLETE { */ | |
900 | /* OBSOLETE int i; */ | |
901 | /* OBSOLETE */ | |
902 | /* OBSOLETE for (i = 0; i < len; i++) */ | |
903 | /* OBSOLETE { */ | |
904 | /* OBSOLETE if ((i % 16) == 0) */ | |
905 | /* OBSOLETE fprintf (eb_stream, "sb %x,", memaddr + i); */ | |
906 | /* OBSOLETE if ((i % 16) == 15 || i == len - 1) */ | |
907 | /* OBSOLETE { */ | |
908 | /* OBSOLETE fprintf (eb_stream, "%x\n", ((unsigned char *) myaddr)[i]); */ | |
909 | /* OBSOLETE expect_prompt (); */ | |
910 | /* OBSOLETE } */ | |
911 | /* OBSOLETE else */ | |
912 | /* OBSOLETE fprintf (eb_stream, "%x,", ((unsigned char *) myaddr)[i]); */ | |
913 | /* OBSOLETE } */ | |
914 | /* OBSOLETE return len; */ | |
915 | /* OBSOLETE } */ | |
916 | /* OBSOLETE */ | |
917 | /* OBSOLETE /* Read LEN bytes from inferior memory at MEMADDR. Put the result */ | |
918 | /* OBSOLETE at debugger address MYADDR. Returns length moved. */ */ | |
919 | /* OBSOLETE int */ | |
920 | /* OBSOLETE eb_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */ | |
921 | /* OBSOLETE { */ | |
922 | /* OBSOLETE int i; */ | |
923 | /* OBSOLETE */ | |
924 | /* OBSOLETE /* Number of bytes read so far. */ */ | |
925 | /* OBSOLETE int count; */ | |
926 | /* OBSOLETE */ | |
927 | /* OBSOLETE /* Starting address of this pass. */ */ | |
928 | /* OBSOLETE unsigned long startaddr; */ | |
929 | /* OBSOLETE */ | |
930 | /* OBSOLETE /* Number of bytes to read in this pass. */ */ | |
931 | /* OBSOLETE int len_this_pass; */ | |
932 | /* OBSOLETE */ | |
933 | /* OBSOLETE /* Note that this code works correctly if startaddr is just less */ | |
934 | /* OBSOLETE than UINT_MAX (well, really CORE_ADDR_MAX if there was such a */ | |
935 | /* OBSOLETE thing). That is, something like */ | |
936 | /* OBSOLETE eb_read_bytes (CORE_ADDR_MAX - 4, foo, 4) */ | |
937 | /* OBSOLETE works--it never adds len to memaddr and gets 0. */ */ | |
938 | /* OBSOLETE /* However, something like */ | |
939 | /* OBSOLETE eb_read_bytes (CORE_ADDR_MAX - 3, foo, 4) */ | |
940 | /* OBSOLETE doesn't need to work. Detect it and give up if there's an attempt */ | |
941 | /* OBSOLETE to do that. */ */ | |
942 | /* OBSOLETE if (((memaddr - 1) + len) < memaddr) */ | |
943 | /* OBSOLETE { */ | |
944 | /* OBSOLETE errno = EIO; */ | |
945 | /* OBSOLETE return 0; */ | |
946 | /* OBSOLETE } */ | |
947 | /* OBSOLETE */ | |
948 | /* OBSOLETE startaddr = memaddr; */ | |
949 | /* OBSOLETE count = 0; */ | |
950 | /* OBSOLETE while (count < len) */ | |
951 | /* OBSOLETE { */ | |
952 | /* OBSOLETE len_this_pass = 16; */ | |
953 | /* OBSOLETE if ((startaddr % 16) != 0) */ | |
954 | /* OBSOLETE len_this_pass -= startaddr % 16; */ | |
955 | /* OBSOLETE if (len_this_pass > (len - count)) */ | |
956 | /* OBSOLETE len_this_pass = (len - count); */ | |
957 | /* OBSOLETE */ | |
958 | /* OBSOLETE fprintf (eb_stream, "db %x,%x\n", startaddr, */ | |
959 | /* OBSOLETE (startaddr - 1) + len_this_pass); */ | |
960 | /* OBSOLETE expect ("\n"); */ | |
961 | /* OBSOLETE */ | |
962 | /* OBSOLETE /* Look for 8 hex digits. */ */ | |
963 | /* OBSOLETE i = 0; */ | |
964 | /* OBSOLETE while (1) */ | |
965 | /* OBSOLETE { */ | |
966 | /* OBSOLETE if (isxdigit (readchar ())) */ | |
967 | /* OBSOLETE ++i; */ | |
968 | /* OBSOLETE else */ | |
969 | /* OBSOLETE { */ | |
970 | /* OBSOLETE expect_prompt (); */ | |
971 | /* OBSOLETE error ("Hex digit expected from remote system."); */ | |
972 | /* OBSOLETE } */ | |
973 | /* OBSOLETE if (i >= 8) */ | |
974 | /* OBSOLETE break; */ | |
975 | /* OBSOLETE } */ | |
976 | /* OBSOLETE */ | |
977 | /* OBSOLETE expect (" "); */ | |
978 | /* OBSOLETE */ | |
979 | /* OBSOLETE for (i = 0; i < len_this_pass; i++) */ | |
980 | /* OBSOLETE get_hex_byte (&myaddr[count++]); */ | |
981 | /* OBSOLETE */ | |
982 | /* OBSOLETE expect_prompt (); */ | |
983 | /* OBSOLETE */ | |
984 | /* OBSOLETE startaddr += len_this_pass; */ | |
985 | /* OBSOLETE } */ | |
986 | /* OBSOLETE return len; */ | |
987 | /* OBSOLETE } */ | |
988 | /* OBSOLETE */ | |
989 | /* OBSOLETE static void */ | |
990 | /* OBSOLETE eb_kill (char *args, int from_tty) */ | |
991 | /* OBSOLETE { */ | |
992 | /* OBSOLETE return; /* Ignore attempts to kill target system */ */ | |
993 | /* OBSOLETE } */ | |
994 | /* OBSOLETE */ | |
995 | /* OBSOLETE /* Clean up when a program exits. */ | |
996 | /* OBSOLETE */ | |
997 | /* OBSOLETE The program actually lives on in the remote processor's RAM, and may be */ | |
998 | /* OBSOLETE run again without a download. Don't leave it full of breakpoint */ | |
999 | /* OBSOLETE instructions. */ */ | |
1000 | /* OBSOLETE */ | |
1001 | /* OBSOLETE void */ | |
1002 | /* OBSOLETE eb_mourn_inferior (void) */ | |
1003 | /* OBSOLETE { */ | |
1004 | /* OBSOLETE remove_breakpoints (); */ | |
1005 | /* OBSOLETE unpush_target (&eb_ops); */ | |
1006 | /* OBSOLETE generic_mourn_inferior (); /* Do all the proper things now */ */ | |
1007 | /* OBSOLETE } */ | |
1008 | /* OBSOLETE /* Define the target subroutine names */ */ | |
1009 | /* OBSOLETE */ | |
1010 | /* OBSOLETE struct target_ops eb_ops; */ | |
1011 | /* OBSOLETE */ | |
1012 | /* OBSOLETE static void */ | |
1013 | /* OBSOLETE init_eb_ops (void) */ | |
1014 | /* OBSOLETE { */ | |
1015 | /* OBSOLETE eb_ops.to_shortname = "amd-eb"; */ | |
1016 | /* OBSOLETE eb_ops.to_longname = "Remote serial AMD EBMON target"; */ | |
1017 | /* OBSOLETE eb_ops.to_doc = "Use a remote computer running EBMON connected by a serial line.\n\ */ | |
1018 | /* OBSOLETE Arguments are the name of the device for the serial line,\n\ */ | |
1019 | /* OBSOLETE the speed to connect at in bits per second, and the filename of the\n\ */ | |
1020 | /* OBSOLETE executable as it exists on the remote computer. For example,\n\ */ | |
1021 | /* OBSOLETE target amd-eb /dev/ttya 9600 demo", */ | |
1022 | /* OBSOLETE eb_ops.to_open = eb_open; */ | |
1023 | /* OBSOLETE eb_ops.to_close = eb_close; */ | |
1024 | /* OBSOLETE eb_ops.to_attach = 0; */ | |
1025 | /* OBSOLETE eb_ops.to_post_attach = NULL; */ | |
1026 | /* OBSOLETE eb_ops.to_require_attach = NULL; */ | |
1027 | /* OBSOLETE eb_ops.to_detach = eb_detach; */ | |
1028 | /* OBSOLETE eb_ops.to_require_detach = NULL; */ | |
1029 | /* OBSOLETE eb_ops.to_resume = eb_resume; */ | |
1030 | /* OBSOLETE eb_ops.to_wait = eb_wait; */ | |
1031 | /* OBSOLETE eb_ops.to_post_wait = NULL; */ | |
1032 | /* OBSOLETE eb_ops.to_fetch_registers = eb_fetch_register; */ | |
1033 | /* OBSOLETE eb_ops.to_store_registers = eb_store_register; */ | |
1034 | /* OBSOLETE eb_ops.to_prepare_to_store = eb_prepare_to_store; */ | |
1035 | /* OBSOLETE eb_ops.to_xfer_memory = eb_xfer_inferior_memory; */ | |
1036 | /* OBSOLETE eb_ops.to_files_info = eb_files_info; */ | |
1037 | /* OBSOLETE eb_ops.to_insert_breakpoint = 0; */ | |
1038 | /* OBSOLETE eb_ops.to_remove_breakpoint = 0; /* Breakpoints */ */ | |
1039 | /* OBSOLETE eb_ops.to_terminal_init = 0; */ | |
1040 | /* OBSOLETE eb_ops.to_terminal_inferior = 0; */ | |
1041 | /* OBSOLETE eb_ops.to_terminal_ours_for_output = 0; */ | |
1042 | /* OBSOLETE eb_ops.to_terminal_ours = 0; */ | |
1043 | /* OBSOLETE eb_ops.to_terminal_info = 0; /* Terminal handling */ */ | |
1044 | /* OBSOLETE eb_ops.to_kill = eb_kill; */ | |
1045 | /* OBSOLETE eb_ops.to_load = generic_load; /* load */ */ | |
1046 | /* OBSOLETE eb_ops.to_lookup_symbol = 0; /* lookup_symbol */ */ | |
1047 | /* OBSOLETE eb_ops.to_create_inferior = eb_create_inferior; */ | |
1048 | /* OBSOLETE eb_ops.to_post_startup_inferior = NULL; */ | |
1049 | /* OBSOLETE eb_ops.to_acknowledge_created_inferior = NULL; */ | |
1050 | /* OBSOLETE eb_ops.to_clone_and_follow_inferior = NULL; */ | |
1051 | /* OBSOLETE eb_ops.to_post_follow_inferior_by_clone = NULL; */ | |
1052 | /* OBSOLETE eb_ops.to_insert_fork_catchpoint = NULL; */ | |
1053 | /* OBSOLETE eb_ops.to_remove_fork_catchpoint = NULL; */ | |
1054 | /* OBSOLETE eb_ops.to_insert_vfork_catchpoint = NULL; */ | |
1055 | /* OBSOLETE eb_ops.to_remove_vfork_catchpoint = NULL; */ | |
1056 | /* OBSOLETE eb_ops.to_has_forked = NULL; */ | |
1057 | /* OBSOLETE eb_ops.to_has_vforked = NULL; */ | |
1058 | /* OBSOLETE eb_ops.to_can_follow_vfork_prior_to_exec = NULL; */ | |
1059 | /* OBSOLETE eb_ops.to_post_follow_vfork = NULL; */ | |
1060 | /* OBSOLETE eb_ops.to_insert_exec_catchpoint = NULL; */ | |
1061 | /* OBSOLETE eb_ops.to_remove_exec_catchpoint = NULL; */ | |
1062 | /* OBSOLETE eb_ops.to_has_execd = NULL; */ | |
1063 | /* OBSOLETE eb_ops.to_reported_exec_events_per_exec_call = NULL; */ | |
1064 | /* OBSOLETE eb_ops.to_has_exited = NULL; */ | |
1065 | /* OBSOLETE eb_ops.to_mourn_inferior = eb_mourn_inferior; */ | |
1066 | /* OBSOLETE eb_ops.to_can_run = 0; /* can_run */ */ | |
1067 | /* OBSOLETE eb_ops.to_notice_signals = 0; /* notice_signals */ */ | |
1068 | /* OBSOLETE eb_ops.to_thread_alive = 0; /* thread-alive */ */ | |
1069 | /* OBSOLETE eb_ops.to_stop = 0; /* to_stop */ */ | |
1070 | /* OBSOLETE eb_ops.to_pid_to_exec_file = NULL; */ | |
1071 | /* OBSOLETE eb_ops.to_stratum = process_stratum; */ | |
1072 | /* OBSOLETE eb_ops.DONT_USE = 0; /* next */ */ | |
1073 | /* OBSOLETE eb_ops.to_has_all_memory = 1; */ | |
1074 | /* OBSOLETE eb_ops.to_has_memory = 1; */ | |
1075 | /* OBSOLETE eb_ops.to_has_stack = 1; */ | |
1076 | /* OBSOLETE eb_ops.to_has_registers = 1; */ | |
1077 | /* OBSOLETE eb_ops.to_has_execution = 1; /* all mem, mem, stack, regs, exec */ */ | |
1078 | /* OBSOLETE eb_ops.to_sections = 0; /* sections */ */ | |
1079 | /* OBSOLETE eb_ops.to_sections_end = 0; /* sections end */ */ | |
1080 | /* OBSOLETE eb_ops.to_magic = OPS_MAGIC; /* Always the last thing */ */ | |
1081 | /* OBSOLETE }; */ | |
1082 | /* OBSOLETE */ | |
1083 | /* OBSOLETE void */ | |
1084 | /* OBSOLETE _initialize_remote_eb (void) */ | |
1085 | /* OBSOLETE { */ | |
1086 | /* OBSOLETE init_eb_ops (); */ | |
1087 | /* OBSOLETE add_target (&eb_ops); */ | |
1088 | /* OBSOLETE } */ |