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. */
6 /* OBSOLETE This file is part of GDB. */
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. */
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. */
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. */ */
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. */ */
30 /* OBSOLETE #include "defs.h" */
31 /* OBSOLETE #include "gdb_string.h" */
32 /* OBSOLETE #include "regcache.h" */
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" */
46 /* OBSOLETE extern struct target_ops eb_ops; /* Forward declaration */ */
48 /* OBSOLETE static void eb_close (); */
50 /* OBSOLETE #define LOG_FILE "eb.log" */
51 /* OBSOLETE #if defined (LOG_FILE) */
52 /* OBSOLETE FILE *log_file; */
55 /* OBSOLETE static int timeout = 24; */
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; */
62 /* OBSOLETE /* stream which is fdopen'd from eb_desc. Only valid when */
63 /* OBSOLETE eb_desc != -1. */ */
64 /* OBSOLETE FILE *eb_stream; */
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) */
71 /* OBSOLETE char buf; */
73 /* OBSOLETE buf = '\0'; */
74 /* OBSOLETE #ifdef HAVE_TERMIO */
75 /* OBSOLETE /* termio does the timeout for us. */ */
76 /* OBSOLETE read (eb_desc, &buf, 1); */
78 /* OBSOLETE alarm (timeout); */
79 /* OBSOLETE if (read (eb_desc, &buf, 1) < 0) */
81 /* OBSOLETE if (errno == EINTR) */
82 /* OBSOLETE error ("Timeout reading from remote system."); */
84 /* OBSOLETE perror_with_name ("remote"); */
86 /* OBSOLETE alarm (0); */
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); */
94 /* OBSOLETE return buf & 0x7f; */
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) */
102 /* OBSOLETE char *p = string; */
104 /* OBSOLETE immediate_quit++; */
105 /* OBSOLETE while (1) */
107 /* OBSOLETE if (readchar () == *p) */
110 /* OBSOLETE if (*p == '\0') */
112 /* OBSOLETE immediate_quit--; */
113 /* OBSOLETE return; */
117 /* OBSOLETE p = string; */
121 /* OBSOLETE /* Keep discarding input until we see the ebmon prompt. */
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. */
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) */
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# "); */
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) */
151 /* OBSOLETE int ch; */
152 /* OBSOLETE while (1) */
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) */
165 /* OBSOLETE expect_prompt (); */
166 /* OBSOLETE error ("Invalid hex digit from remote system."); */
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) */
176 /* OBSOLETE int val; */
178 /* OBSOLETE val = get_hex_digit (1) << 4; */
179 /* OBSOLETE val |= get_hex_digit (0); */
180 /* OBSOLETE *byt = val; */
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) */
188 /* OBSOLETE long val; */
189 /* OBSOLETE int i; */
191 /* OBSOLETE for (i = 0; i < n; i++) */
193 /* OBSOLETE int j; */
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); */
202 /* OBSOLETE /* Called when SIGALRM signal sent due to alarm() timeout. */ */
203 /* OBSOLETE #ifndef HAVE_TERMIO */
205 /* OBSOLETE volatile int n_alarms; */
208 /* OBSOLETE eb_timer (void) */
211 /* OBSOLETE if (kiodebug) */
212 /* OBSOLETE printf ("eb_timer called\n"); */
213 /* OBSOLETE #endif */
214 /* OBSOLETE n_alarms++; */
216 /* OBSOLETE #endif */
218 /* OBSOLETE /* malloc'd name of the program on the remote system. */ */
219 /* OBSOLETE static char *prog_name = NULL; */
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; */
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. */ */
229 /* OBSOLETE static int need_artificial_trap = 0; */
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) */
236 /* OBSOLETE int entry_pt; */
238 /* OBSOLETE if (args && *args) */
239 /* OBSOLETE error ("Can't pass arguments to remote EBMON process"); */
241 /* OBSOLETE if (execfile == 0 || exec_bfd == 0) */
242 /* OBSOLETE error ("No executable file specified"); */
244 /* OBSOLETE entry_pt = (int) bfd_get_start_address (exec_bfd); */
247 /* OBSOLETE /* OK, now read in the file. Y=read, C=COFF, D=no symbols */
248 /* OBSOLETE 0=start address, %s=filename. */ */
250 /* OBSOLETE fprintf (eb_stream, "YC D,0:%s", prog_name); */
252 /* OBSOLETE if (args != NULL) */
253 /* OBSOLETE fprintf (eb_stream, " %s", args); */
255 /* OBSOLETE fprintf (eb_stream, "\n"); */
256 /* OBSOLETE fflush (eb_stream); */
258 /* OBSOLETE expect_prompt (); */
260 /* OBSOLETE need_gi = 1; */
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. */ */
266 /* OBSOLETE clear_proceed_status (); */
268 /* OBSOLETE /* Tell wait_for_inferior that we've started a new process. */ */
269 /* OBSOLETE init_wait_for_inferior (); */
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 (); */
275 /* OBSOLETE /* Install inferior's terminal modes. */ */
276 /* OBSOLETE target_terminal_inferior (); */
278 /* OBSOLETE /* insert_step_breakpoint (); FIXME, do we need this? */ */
279 /* OBSOLETE proceed ((CORE_ADDR) entry_pt, TARGET_SIGNAL_DEFAULT, 0); /* Let 'er rip... */ */
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. */ */
285 /* OBSOLETE #ifndef B19200 */
286 /* OBSOLETE #define B19200 EXTA */
287 /* OBSOLETE #endif */
288 /* OBSOLETE #ifndef B38400 */
289 /* OBSOLETE #define B38400 EXTB */
290 /* OBSOLETE #endif */
292 /* OBSOLETE struct */
294 /* OBSOLETE int rate, damn_b; */
296 /* OBSOLETE baudtab[] = */
303 /* OBSOLETE 50, B50 */
307 /* OBSOLETE 75, B75 */
311 /* OBSOLETE 110, B110 */
315 /* OBSOLETE 134, B134 */
319 /* OBSOLETE 150, B150 */
323 /* OBSOLETE 200, B200 */
327 /* OBSOLETE 300, B300 */
331 /* OBSOLETE 600, B600 */
335 /* OBSOLETE 1200, B1200 */
339 /* OBSOLETE 1800, B1800 */
343 /* OBSOLETE 2400, B2400 */
347 /* OBSOLETE 4800, B4800 */
351 /* OBSOLETE 9600, B9600 */
355 /* OBSOLETE 19200, B19200 */
359 /* OBSOLETE 38400, B38400 */
363 /* OBSOLETE -1, -1 */
369 /* OBSOLETE damn_b (int rate) */
371 /* OBSOLETE int i; */
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 */ */
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. */ */
384 /* OBSOLETE static int baudrate = 9600; */
385 /* OBSOLETE static char *dev_name; */
387 /* OBSOLETE eb_open (char *name, int from_tty) */
389 /* OBSOLETE TERMINAL sg; */
391 /* OBSOLETE char *p; */
393 /* OBSOLETE target_preopen (from_tty); */
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; */
400 /* OBSOLETE for (p = name; */
401 /* OBSOLETE *p != '\0' && !isspace (*p); p++) */
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'; */
412 /* OBSOLETE /* Skip over the whitespace after dev_name */ */
413 /* OBSOLETE for (; isspace (*p); p++) */
414 /* OBSOLETE /*EMPTY */ ; */
416 /* OBSOLETE if (1 != sscanf (p, "%d ", &baudrate)) */
417 /* OBSOLETE goto erroid; */
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 */ ; */
425 /* OBSOLETE if (prog_name != NULL) */
426 /* OBSOLETE xfree (prog_name); */
427 /* OBSOLETE prog_name = savestring (p, strlen (p)); */
429 /* OBSOLETE eb_close (0); */
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); */
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 */
447 /* OBSOLETE ioctl (eb_desc, TIOCSETP, &sg); */
448 /* OBSOLETE eb_stream = fdopen (eb_desc, "r+"); */
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); */
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 */
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 */
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 */
474 /* OBSOLETE /* Hello? Are you there? */ */
475 /* OBSOLETE write (eb_desc, "\n", 1); */
477 /* OBSOLETE expect_prompt (); */
480 /* OBSOLETE /* Close out all files and local state before this target loses control. */ */
482 /* OBSOLETE static void */
483 /* OBSOLETE eb_close (int quitting) */
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); */ */
494 /* OBSOLETE /* Do not try to close eb_desc again, later in the program. */ */
495 /* OBSOLETE eb_stream = NULL; */
496 /* OBSOLETE eb_desc = -1; */
498 /* OBSOLETE #if defined (LOG_FILE) */
499 /* OBSOLETE if (log_file) */
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"); */
506 /* OBSOLETE #endif */
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. */ */
513 /* OBSOLETE eb_detach (int from_tty) */
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); */
520 /* OBSOLETE /* Tell the remote machine to resume. */ */
523 /* OBSOLETE eb_resume (ptid_t ptid, int step, enum target_signal sig) */
525 /* OBSOLETE if (step) */
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 (); */
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; */
542 /* OBSOLETE if (need_gi) */
544 /* OBSOLETE need_gi = 0; */
545 /* OBSOLETE write (eb_desc, "gi\n", 3); */
547 /* OBSOLETE /* Swallow the echo of "gi". */ */
548 /* OBSOLETE expect ("gi\r"); */
552 /* OBSOLETE write (eb_desc, "GR\n", 3); */
553 /* OBSOLETE /* Swallow the echo. */ */
554 /* OBSOLETE expect ("GR\r"); */
559 /* OBSOLETE /* Wait until the remote machine stops, then return, */
560 /* OBSOLETE storing status in STATUS just as `wait' would. */ */
562 /* OBSOLETE ptid_t */
563 /* OBSOLETE eb_wait (ptid_t ptid, struct target_waitstatus *status) */
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. */ */
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; */
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; */
583 /* OBSOLETE int ch; */
584 /* OBSOLETE int ch_handled; */
586 /* OBSOLETE int old_timeout = timeout; */
588 /* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */
589 /* OBSOLETE status->value.integer = 0; */
591 /* OBSOLETE if (need_artificial_trap != 0) */
593 /* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
594 /* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
595 /* OBSOLETE need_artificial_trap--; */
596 /* OBSOLETE return 0; */
599 /* OBSOLETE timeout = 0; /* Don't time out -- user program is running. */ */
600 /* OBSOLETE while (1) */
602 /* OBSOLETE ch_handled = 0; */
603 /* OBSOLETE ch = readchar (); */
604 /* OBSOLETE if (ch == *bp) */
607 /* OBSOLETE if (*bp == '\0') */
608 /* OBSOLETE break; */
609 /* OBSOLETE ch_handled = 1; */
611 /* OBSOLETE *swallowed_p++ = ch; */
614 /* OBSOLETE bp = bpt; */
616 /* OBSOLETE if (ch == *ep || *ep == '?') */
619 /* OBSOLETE if (*ep == '\0') */
620 /* OBSOLETE break; */
622 /* OBSOLETE if (!ch_handled) */
623 /* OBSOLETE *swallowed_p++ = ch; */
624 /* OBSOLETE ch_handled = 1; */
627 /* OBSOLETE ep = exitmsg; */
629 /* OBSOLETE if (!ch_handled) */
631 /* OBSOLETE char *p; */
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; */
638 /* OBSOLETE putc (ch, stdout); */
641 /* OBSOLETE expect_prompt (); */
642 /* OBSOLETE if (*bp == '\0') */
644 /* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
645 /* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
649 /* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */
650 /* OBSOLETE status->value.integer = 0; */
652 /* OBSOLETE timeout = old_timeout; */
654 /* OBSOLETE return 0; */
657 /* OBSOLETE /* Return the name of register number REGNO */
658 /* OBSOLETE in the form input and output by EBMON. */
660 /* OBSOLETE Returns a pointer to a static buffer containing the answer. */ */
661 /* OBSOLETE static char * */
662 /* OBSOLETE get_reg_name (int regno) */
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; */
684 /* OBSOLETE /* Read the remote registers into the block REGS. */ */
686 /* OBSOLETE static void */
687 /* OBSOLETE eb_fetch_registers (void) */
689 /* OBSOLETE int reg_index; */
690 /* OBSOLETE int regnum_index; */
691 /* OBSOLETE char tempbuf[10]; */
692 /* OBSOLETE int i; */
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 */
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) */
709 /* OBSOLETE sprintf (tempbuf, "GR%03d ", reg_index); */
710 /* OBSOLETE expect (tempbuf); */
711 /* OBSOLETE get_hex_regs (4, regnum_index); */
712 /* OBSOLETE expect ("\n"); */
715 /* OBSOLETE for (i = 0; i < 128; i += 32) */
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) */
725 /* OBSOLETE sprintf (tempbuf, "LR%03d ", reg_index); */
726 /* OBSOLETE expect (tempbuf); */
727 /* OBSOLETE get_hex_regs (4, regnum_index); */
728 /* OBSOLETE expect ("\n"); */
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"); */
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"); */
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"); */
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"); */
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) */
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"); */
763 /* OBSOLETE /* There doesn't seem to be any way to get these. */ */
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); */
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 (); */
778 /* OBSOLETE /* Fetch register REGNO, or all registers if REGNO is -1. */
779 /* OBSOLETE Returns errno value. */ */
781 /* OBSOLETE eb_fetch_register (int regno) */
783 /* OBSOLETE if (regno == -1) */
784 /* OBSOLETE eb_fetch_registers (); */
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 (); */
794 /* OBSOLETE return; */
797 /* OBSOLETE /* Store the remote registers from the contents of the block REGS. */ */
799 /* OBSOLETE static void */
800 /* OBSOLETE eb_store_registers (void) */
802 /* OBSOLETE int i, j; */
803 /* OBSOLETE fprintf (eb_stream, "s gr1,%x\n", read_register (GR1_REGNUM)); */
804 /* OBSOLETE expect_prompt (); */
806 /* OBSOLETE for (j = 0; j < 32; j += 16) */
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 (); */
815 /* OBSOLETE for (j = 0; j < 128; j += 16) */
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 (); */
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 (); */
836 /* OBSOLETE /* Store register REGNO, or all if REGNO == 0. */
837 /* OBSOLETE Return errno value. */ */
839 /* OBSOLETE eb_store_register (int regno) */
841 /* OBSOLETE if (regno == -1) */
842 /* OBSOLETE eb_store_registers (); */
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 (); */
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. */ */
866 /* OBSOLETE eb_prepare_to_store (void) */
868 /* OBSOLETE /* Do nothing, since we can store individual regs */ */
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. */
875 /* OBSOLETE Returns the number of bytes transferred. */ */
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) */
882 /* OBSOLETE if (write) */
883 /* OBSOLETE return eb_write_inferior_memory (memaddr, myaddr, len); */
885 /* OBSOLETE return eb_read_inferior_memory (memaddr, myaddr, len); */
889 /* OBSOLETE eb_files_info (void) */
891 /* OBSOLETE printf ("\tAttached to %s at %d baud and running program %s.\n", */
892 /* OBSOLETE dev_name, baudrate, prog_name); */
895 /* OBSOLETE /* Copy LEN bytes of data from debugger memory at MYADDR */
896 /* OBSOLETE to inferior's memory at MEMADDR. Returns length moved. */ */
898 /* OBSOLETE eb_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
900 /* OBSOLETE int i; */
902 /* OBSOLETE for (i = 0; i < len; i++) */
904 /* OBSOLETE if ((i % 16) == 0) */
905 /* OBSOLETE fprintf (eb_stream, "sb %x,", memaddr + i); */
906 /* OBSOLETE if ((i % 16) == 15 || i == len - 1) */
908 /* OBSOLETE fprintf (eb_stream, "%x\n", ((unsigned char *) myaddr)[i]); */
909 /* OBSOLETE expect_prompt (); */
912 /* OBSOLETE fprintf (eb_stream, "%x,", ((unsigned char *) myaddr)[i]); */
914 /* OBSOLETE return len; */
917 /* OBSOLETE /* Read LEN bytes from inferior memory at MEMADDR. Put the result */
918 /* OBSOLETE at debugger address MYADDR. Returns length moved. */ */
920 /* OBSOLETE eb_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
922 /* OBSOLETE int i; */
924 /* OBSOLETE /* Number of bytes read so far. */ */
925 /* OBSOLETE int count; */
927 /* OBSOLETE /* Starting address of this pass. */ */
928 /* OBSOLETE unsigned long startaddr; */
930 /* OBSOLETE /* Number of bytes to read in this pass. */ */
931 /* OBSOLETE int len_this_pass; */
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) */
944 /* OBSOLETE errno = EIO; */
945 /* OBSOLETE return 0; */
948 /* OBSOLETE startaddr = memaddr; */
949 /* OBSOLETE count = 0; */
950 /* OBSOLETE while (count < len) */
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); */
958 /* OBSOLETE fprintf (eb_stream, "db %x,%x\n", startaddr, */
959 /* OBSOLETE (startaddr - 1) + len_this_pass); */
960 /* OBSOLETE expect ("\n"); */
962 /* OBSOLETE /* Look for 8 hex digits. */ */
963 /* OBSOLETE i = 0; */
964 /* OBSOLETE while (1) */
966 /* OBSOLETE if (isxdigit (readchar ())) */
970 /* OBSOLETE expect_prompt (); */
971 /* OBSOLETE error ("Hex digit expected from remote system."); */
973 /* OBSOLETE if (i >= 8) */
974 /* OBSOLETE break; */
977 /* OBSOLETE expect (" "); */
979 /* OBSOLETE for (i = 0; i < len_this_pass; i++) */
980 /* OBSOLETE get_hex_byte (&myaddr[count++]); */
982 /* OBSOLETE expect_prompt (); */
984 /* OBSOLETE startaddr += len_this_pass; */
986 /* OBSOLETE return len; */
989 /* OBSOLETE static void */
990 /* OBSOLETE eb_kill (char *args, int from_tty) */
992 /* OBSOLETE return; /* Ignore attempts to kill target system */ */
995 /* OBSOLETE /* Clean up when a program exits. */
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. */ */
1002 /* OBSOLETE eb_mourn_inferior (void) */
1004 /* OBSOLETE remove_breakpoints (); */
1005 /* OBSOLETE unpush_target (&eb_ops); */
1006 /* OBSOLETE generic_mourn_inferior (); /* Do all the proper things now */ */
1008 /* OBSOLETE /* Define the target subroutine names */ */
1010 /* OBSOLETE struct target_ops eb_ops; */
1012 /* OBSOLETE static void */
1013 /* OBSOLETE init_eb_ops (void) */
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 */ */
1084 /* OBSOLETE _initialize_remote_eb (void) */
1086 /* OBSOLETE init_eb_ops (); */
1087 /* OBSOLETE add_target (&eb_ops); */
This page took 0.050612 seconds and 4 git commands to generate.