1 /* OBSOLETE /* Remote debugging interface for AMD 290*0 Adapt Monitor Version 2.1d18. */
2 /* OBSOLETE Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, */
3 /* OBSOLETE 2001 Free Software Foundation, Inc. */
4 /* OBSOLETE Contributed by David Wood at New York University (wood@lab.ultra.nyu.edu). */
5 /* OBSOLETE Adapted from work done at Cygnus Support in remote-eb.c. */
7 /* OBSOLETE This file is part of GDB. */
9 /* OBSOLETE This program is free software; you can redistribute it and/or modify */
10 /* OBSOLETE it under the terms of the GNU General Public License as published by */
11 /* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
12 /* OBSOLETE (at your option) any later version. */
14 /* OBSOLETE This program is distributed in the hope that it will be useful, */
15 /* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
16 /* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
17 /* OBSOLETE GNU General Public License for more details. */
19 /* OBSOLETE You should have received a copy of the GNU General Public License */
20 /* OBSOLETE along with this program; if not, write to the Free Software */
21 /* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, */
22 /* OBSOLETE Boston, MA 02111-1307, USA. */ */
24 /* OBSOLETE /* This is like remote.c but is for an esoteric situation-- */
25 /* OBSOLETE having a 29k board attached to an Adapt inline monitor. */
26 /* OBSOLETE The monitor is connected via serial line to a unix machine */
27 /* OBSOLETE running gdb. */
29 /* OBSOLETE 3/91 - developed on Sun3 OS 4.1, by David Wood */
30 /* OBSOLETE o - I can't get binary coff to load. */
31 /* OBSOLETE o - I can't get 19200 baud rate to work. */
32 /* OBSOLETE 7/91 o - Freeze mode tracing can be done on a 29050. */ */
36 /* OBSOLETE #include "defs.h" */
37 /* OBSOLETE #include "gdb_string.h" */
38 /* OBSOLETE #include "inferior.h" */
39 /* OBSOLETE #include "value.h" */
40 /* OBSOLETE #include <ctype.h> */
41 /* OBSOLETE #include <fcntl.h> */
42 /* OBSOLETE #include <signal.h> */
43 /* OBSOLETE #include <errno.h> */
44 /* OBSOLETE #include "terminal.h" */
45 /* OBSOLETE #include "target.h" */
46 /* OBSOLETE #include "gdbcore.h" */
47 /* OBSOLETE #include "regcache.h" */
49 /* OBSOLETE /* This processor is getting rusty but I am trying to keep it */
50 /* OBSOLETE up to date at least with data structure changes. */
51 /* OBSOLETE Activate this block to compile just this file. */
53 /* OBSOLETE #define COMPILE_CHECK 0 */
54 /* OBSOLETE #if COMPILE_CHECK */
55 /* OBSOLETE #define Q_REGNUM 0 */
56 /* OBSOLETE #define VAB_REGNUM 0 */
57 /* OBSOLETE #define CPS_REGNUM 0 */
58 /* OBSOLETE #define IPA_REGNUM 0 */
59 /* OBSOLETE #define IPB_REGNUM 0 */
60 /* OBSOLETE #define GR1_REGNUM 0 */
61 /* OBSOLETE #define LR0_REGNUM 0 */
62 /* OBSOLETE #define IPC_REGNUM 0 */
63 /* OBSOLETE #define CR_REGNUM 0 */
64 /* OBSOLETE #define BP_REGNUM 0 */
65 /* OBSOLETE #define FC_REGNUM 0 */
66 /* OBSOLETE #define INTE_REGNUM 0 */
67 /* OBSOLETE #define EXO_REGNUM 0 */
68 /* OBSOLETE #define GR96_REGNUM 0 */
69 /* OBSOLETE #define NPC_REGNUM */
70 /* OBSOLETE #define FPE_REGNUM 0 */
71 /* OBSOLETE #define PC2_REGNUM 0 */
72 /* OBSOLETE #define FPS_REGNUM 0 */
73 /* OBSOLETE #define ALU_REGNUM 0 */
74 /* OBSOLETE #define LRU_REGNUM 0 */
75 /* OBSOLETE #define TERMINAL int */
76 /* OBSOLETE #define RAW 1 */
77 /* OBSOLETE #define ANYP 1 */
78 /* OBSOLETE extern int a29k_freeze_mode; */
79 /* OBSOLETE extern int processor_type; */
80 /* OBSOLETE extern char *processor_name; */
83 /* OBSOLETE /* External data declarations */ */
84 /* OBSOLETE extern int stop_soon_quietly; /* for wait_for_inferior */ */
86 /* OBSOLETE /* Forward data declarations */ */
87 /* OBSOLETE extern struct target_ops adapt_ops; /* Forward declaration */ */
89 /* OBSOLETE /* Forward function declarations */ */
90 /* OBSOLETE static void adapt_fetch_registers (); */
91 /* OBSOLETE static void adapt_store_registers (); */
92 /* OBSOLETE static void adapt_close (); */
93 /* OBSOLETE static int adapt_clear_breakpoints (); */
95 /* OBSOLETE #define FREEZE_MODE (read_register(CPS_REGNUM) && 0x400) */
96 /* OBSOLETE #define USE_SHADOW_PC ((processor_type == a29k_freeze_mode) && FREEZE_MODE) */
98 /* OBSOLETE /* Can't seem to get binary coff working */ */
99 /* OBSOLETE #define ASCII_COFF /* Adapt will be downloaded with ascii coff */ */
101 /* OBSOLETE /* FIXME: Replace with `set remotedebug'. */ */
102 /* OBSOLETE #define LOG_FILE "adapt.log" */
103 /* OBSOLETE #if defined (LOG_FILE) */
104 /* OBSOLETE FILE *log_file = NULL; */
105 /* OBSOLETE #endif */
107 /* OBSOLETE static int timeout = 5; */
108 /* OBSOLETE static char *dev_name; */
110 /* OBSOLETE /* Descriptor for I/O to remote machine. Initialize it to -1 so that */
111 /* OBSOLETE adapt_open knows that we don't have a file open when the program */
112 /* OBSOLETE starts. */ */
113 /* OBSOLETE int adapt_desc = -1; */
115 /* OBSOLETE /* stream which is fdopen'd from adapt_desc. Only valid when */
116 /* OBSOLETE adapt_desc != -1. */ */
117 /* OBSOLETE FILE *adapt_stream; */
119 /* OBSOLETE #define ON 1 */
120 /* OBSOLETE #define OFF 0 */
121 /* OBSOLETE static void */
122 /* OBSOLETE rawmode (int desc, int turnon) */
125 /* OBSOLETE TERMINAL sg; */
127 /* OBSOLETE if (desc < 0) */
128 /* OBSOLETE return; */
130 /* OBSOLETE ioctl (desc, TIOCGETP, &sg); */
132 /* OBSOLETE if (turnon) */
134 /* OBSOLETE #ifdef HAVE_TERMIO */
135 /* OBSOLETE sg.c_lflag &= ~(ICANON); */
137 /* OBSOLETE sg.sg_flags |= RAW; */
138 /* OBSOLETE #endif */
142 /* OBSOLETE #ifdef HAVE_TERMIO */
143 /* OBSOLETE sg.c_lflag |= ICANON; */
145 /* OBSOLETE sg.sg_flags &= ~(RAW); */
146 /* OBSOLETE #endif */
148 /* OBSOLETE ioctl (desc, TIOCSETP, &sg); */
151 /* OBSOLETE /* Suck up all the input from the adapt */ */
152 /* OBSOLETE slurp_input (void) */
154 /* OBSOLETE char buf[8]; */
156 /* OBSOLETE #ifdef HAVE_TERMIO */
157 /* OBSOLETE /* termio does the timeout for us. */ */
158 /* OBSOLETE while (read (adapt_desc, buf, 8) > 0); */
160 /* OBSOLETE alarm (timeout); */
161 /* OBSOLETE while (read (adapt_desc, buf, 8) > 0); */
162 /* OBSOLETE alarm (0); */
163 /* OBSOLETE #endif */
166 /* OBSOLETE /* Read a character from the remote system, doing all the fancy */
167 /* OBSOLETE timeout stuff. */ */
168 /* OBSOLETE static int */
169 /* OBSOLETE readchar (void) */
171 /* OBSOLETE char buf; */
173 /* OBSOLETE buf = '\0'; */
174 /* OBSOLETE #ifdef HAVE_TERMIO */
175 /* OBSOLETE /* termio does the timeout for us. */ */
176 /* OBSOLETE read (adapt_desc, &buf, 1); */
178 /* OBSOLETE alarm (timeout); */
179 /* OBSOLETE if (read (adapt_desc, &buf, 1) < 0) */
181 /* OBSOLETE if (errno == EINTR) */
182 /* OBSOLETE error ("Timeout reading from remote system."); */
184 /* OBSOLETE perror_with_name ("remote"); */
186 /* OBSOLETE alarm (0); */
187 /* OBSOLETE #endif */
189 /* OBSOLETE if (buf == '\0') */
190 /* OBSOLETE error ("Timeout reading from remote system."); */
191 /* OBSOLETE #if defined (LOG_FILE) */
192 /* OBSOLETE putc (buf & 0x7f, log_file); */
193 /* OBSOLETE #endif */
194 /* OBSOLETE return buf & 0x7f; */
197 /* OBSOLETE /* Keep discarding input from the remote system, until STRING is found. */
198 /* OBSOLETE Let the user break out immediately. */ */
199 /* OBSOLETE static void */
200 /* OBSOLETE expect (char *string) */
202 /* OBSOLETE char *p = string; */
204 /* OBSOLETE fflush (adapt_stream); */
205 /* OBSOLETE immediate_quit++; */
206 /* OBSOLETE while (1) */
208 /* OBSOLETE if (readchar () == *p) */
211 /* OBSOLETE if (*p == '\0') */
213 /* OBSOLETE immediate_quit--; */
214 /* OBSOLETE return; */
218 /* OBSOLETE p = string; */
222 /* OBSOLETE /* Keep discarding input until we see the adapt prompt. */
224 /* OBSOLETE The convention for dealing with the prompt is that you */
225 /* OBSOLETE o give your command */
226 /* OBSOLETE o *then* wait for the prompt. */
228 /* OBSOLETE Thus the last thing that a procedure does with the serial line */
229 /* OBSOLETE will be an expect_prompt(). Exception: adapt_resume does not */
230 /* OBSOLETE wait for the prompt, because the terminal is being handed over */
231 /* OBSOLETE to the inferior. However, the next thing which happens after that */
232 /* OBSOLETE is a adapt_wait which does wait for the prompt. */
233 /* OBSOLETE Note that this includes abnormal exit, e.g. error(). This is */
234 /* OBSOLETE necessary to prevent getting into states from which we can't */
235 /* OBSOLETE recover. */ */
236 /* OBSOLETE static void */
237 /* OBSOLETE expect_prompt (void) */
239 /* OBSOLETE #if defined (LOG_FILE) */
240 /* OBSOLETE /* This is a convenient place to do this. The idea is to do it often */
241 /* OBSOLETE enough that we never lose much data if we terminate abnormally. */ */
242 /* OBSOLETE fflush (log_file); */
243 /* OBSOLETE #endif */
244 /* OBSOLETE fflush (adapt_stream); */
245 /* OBSOLETE expect ("\n# "); */
248 /* OBSOLETE /* Get a hex digit from the remote system & return its value. */
249 /* OBSOLETE If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */ */
250 /* OBSOLETE static int */
251 /* OBSOLETE get_hex_digit (int ignore_space) */
253 /* OBSOLETE int ch; */
254 /* OBSOLETE while (1) */
256 /* OBSOLETE ch = readchar (); */
257 /* OBSOLETE if (ch >= '0' && ch <= '9') */
258 /* OBSOLETE return ch - '0'; */
259 /* OBSOLETE else if (ch >= 'A' && ch <= 'F') */
260 /* OBSOLETE return ch - 'A' + 10; */
261 /* OBSOLETE else if (ch >= 'a' && ch <= 'f') */
262 /* OBSOLETE return ch - 'a' + 10; */
263 /* OBSOLETE else if (ch == ' ' && ignore_space) */
267 /* OBSOLETE expect_prompt (); */
268 /* OBSOLETE error ("Invalid hex digit from remote system."); */
273 /* OBSOLETE /* Get a byte from adapt_desc and put it in *BYT. Accept any number */
274 /* OBSOLETE leading spaces. */ */
275 /* OBSOLETE static void */
276 /* OBSOLETE get_hex_byte (char *byt) */
278 /* OBSOLETE int val; */
280 /* OBSOLETE val = get_hex_digit (1) << 4; */
281 /* OBSOLETE val |= get_hex_digit (0); */
282 /* OBSOLETE *byt = val; */
285 /* OBSOLETE /* Read a 32-bit hex word from the adapt, preceded by a space */ */
286 /* OBSOLETE static long */
287 /* OBSOLETE get_hex_word (void) */
289 /* OBSOLETE long val; */
290 /* OBSOLETE int j; */
292 /* OBSOLETE val = 0; */
293 /* OBSOLETE for (j = 0; j < 8; j++) */
294 /* OBSOLETE val = (val << 4) + get_hex_digit (j == 0); */
295 /* OBSOLETE return val; */
297 /* OBSOLETE /* Get N 32-bit hex words from remote, each preceded by a space */
298 /* OBSOLETE and put them in registers starting at REGNO. */ */
299 /* OBSOLETE static void */
300 /* OBSOLETE get_hex_regs (int n, int regno) */
302 /* OBSOLETE long val; */
303 /* OBSOLETE while (n--) */
305 /* OBSOLETE val = get_hex_word (); */
306 /* OBSOLETE supply_register (regno++, (char *) &val); */
309 /* OBSOLETE /* Called when SIGALRM signal sent due to alarm() timeout. */ */
310 /* OBSOLETE #ifndef HAVE_TERMIO */
312 /* OBSOLETE volatile int n_alarms; */
315 /* OBSOLETE adapt_timer (void) */
318 /* OBSOLETE if (kiodebug) */
319 /* OBSOLETE printf ("adapt_timer called\n"); */
320 /* OBSOLETE #endif */
321 /* OBSOLETE n_alarms++; */
323 /* OBSOLETE #endif */
325 /* OBSOLETE /* malloc'd name of the program on the remote system. */ */
326 /* OBSOLETE static char *prog_name = NULL; */
328 /* OBSOLETE /* Number of SIGTRAPs we need to simulate. That is, the next */
329 /* OBSOLETE NEED_ARTIFICIAL_TRAP calls to adapt_wait should just return */
330 /* OBSOLETE SIGTRAP without actually waiting for anything. */ */
332 /* OBSOLETE static int need_artificial_trap = 0; */
335 /* OBSOLETE adapt_kill (char *arg, int from_tty) */
337 /* OBSOLETE fprintf (adapt_stream, "K"); */
338 /* OBSOLETE fprintf (adapt_stream, "\r"); */
339 /* OBSOLETE expect_prompt (); */
342 /* OBSOLETE * Download a file specified in 'args', to the adapt. */
343 /* OBSOLETE * FIXME: Assumes the file to download is a binary coff file. */
345 /* OBSOLETE static void */
346 /* OBSOLETE adapt_load (char *args, int fromtty) */
348 /* OBSOLETE FILE *fp; */
349 /* OBSOLETE int n; */
350 /* OBSOLETE char buffer[1024]; */
352 /* OBSOLETE if (!adapt_stream) */
354 /* OBSOLETE printf_filtered ("Adapt not open. Use 'target' command to open adapt\n"); */
355 /* OBSOLETE return; */
358 /* OBSOLETE /* OK, now read in the file. Y=read, C=COFF, T=dTe port */
359 /* OBSOLETE 0=start address. */ */
361 /* OBSOLETE #ifdef ASCII_COFF /* Ascii coff */ */
362 /* OBSOLETE fprintf (adapt_stream, "YA T,0\r"); */
363 /* OBSOLETE fflush (adapt_stream); /* Just in case */ */
364 /* OBSOLETE /* FIXME: should check args for only 1 argument */ */
365 /* OBSOLETE sprintf (buffer, "cat %s | btoa > /tmp/#adapt-btoa", args); */
366 /* OBSOLETE system (buffer); */
367 /* OBSOLETE fp = fopen ("/tmp/#adapt-btoa", "r"); */
368 /* OBSOLETE rawmode (adapt_desc, OFF); */
369 /* OBSOLETE while (n = fread (buffer, 1, 1024, fp)) */
373 /* OBSOLETE n -= write (adapt_desc, buffer, n); */
375 /* OBSOLETE while (n > 0); */
376 /* OBSOLETE if (n < 0) */
378 /* OBSOLETE perror ("writing ascii coff"); */
379 /* OBSOLETE break; */
382 /* OBSOLETE fclose (fp); */
383 /* OBSOLETE rawmode (adapt_desc, ON); */
384 /* OBSOLETE system ("rm /tmp/#adapt-btoa"); */
385 /* OBSOLETE #else /* Binary coff - can't get it to work . */ */
386 /* OBSOLETE fprintf (adapt_stream, "YC T,0\r"); */
387 /* OBSOLETE fflush (adapt_stream); /* Just in case */ */
388 /* OBSOLETE if (!(fp = fopen (args, "r"))) */
390 /* OBSOLETE printf_filtered ("Can't open %s\n", args); */
391 /* OBSOLETE return; */
393 /* OBSOLETE while (n = fread (buffer, 1, 512, fp)) */
397 /* OBSOLETE n -= write (adapt_desc, buffer, n); */
399 /* OBSOLETE while (n > 0); */
400 /* OBSOLETE if (n < 0) */
402 /* OBSOLETE perror ("writing ascii coff"); */
403 /* OBSOLETE break; */
406 /* OBSOLETE fclose (fp); */
407 /* OBSOLETE #endif */
408 /* OBSOLETE expect_prompt (); /* Skip garbage that comes out */ */
409 /* OBSOLETE fprintf (adapt_stream, "\r"); */
410 /* OBSOLETE expect_prompt (); */
413 /* OBSOLETE /* This is called not only when we first attach, but also when the */
414 /* OBSOLETE user types "run" after having attached. */ */
416 /* OBSOLETE adapt_create_inferior (char *execfile, char *args, char **env) */
418 /* OBSOLETE int entry_pt; */
420 /* OBSOLETE if (args && *args) */
421 /* OBSOLETE error ("Can't pass arguments to remote adapt process."); */
423 /* OBSOLETE if (execfile == 0 || exec_bfd == 0) */
424 /* OBSOLETE error ("No executable file specified"); */
426 /* OBSOLETE entry_pt = (int) bfd_get_start_address (exec_bfd); */
428 /* OBSOLETE if (adapt_stream) */
430 /* OBSOLETE adapt_kill (NULL, NULL); */
431 /* OBSOLETE adapt_clear_breakpoints (); */
432 /* OBSOLETE init_wait_for_inferior (); */
433 /* OBSOLETE /* Clear the input because what the adapt sends back is different */
434 /* OBSOLETE * depending on whether it was running or not. */
436 /* OBSOLETE slurp_input (); /* After this there should be a prompt */ */
437 /* OBSOLETE fprintf (adapt_stream, "\r"); */
438 /* OBSOLETE expect_prompt (); */
439 /* OBSOLETE printf_filtered ("Do you want to download '%s' (y/n)? [y] : ", prog_name); */
441 /* OBSOLETE char buffer[10]; */
442 /* OBSOLETE gets (buffer); */
443 /* OBSOLETE if (*buffer != 'n') */
445 /* OBSOLETE adapt_load (prog_name, 0); */
449 /* OBSOLETE #ifdef NOTDEF */
450 /* OBSOLETE /* Set the PC and wait for a go/cont */ */
451 /* OBSOLETE fprintf (adapt_stream, "G %x,N\r", entry_pt); */
452 /* OBSOLETE printf_filtered ("Now use the 'continue' command to start.\n"); */
453 /* OBSOLETE expect_prompt (); */
455 /* OBSOLETE insert_breakpoints (); /* Needed to get correct instruction in cache */ */
456 /* OBSOLETE proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0); */
457 /* OBSOLETE #endif */
462 /* OBSOLETE printf_filtered ("Adapt not open yet.\n"); */
466 /* OBSOLETE /* Translate baud rates from integers to damn B_codes. Unix should */
467 /* OBSOLETE have outgrown this crap years ago, but even POSIX wouldn't buck it. */ */
469 /* OBSOLETE #ifndef B19200 */
470 /* OBSOLETE #define B19200 EXTA */
471 /* OBSOLETE #endif */
472 /* OBSOLETE #ifndef B38400 */
473 /* OBSOLETE #define B38400 EXTB */
474 /* OBSOLETE #endif */
476 /* OBSOLETE static struct */
478 /* OBSOLETE int rate, damn_b; */
480 /* OBSOLETE baudtab[] = */
487 /* OBSOLETE 50, B50 */
491 /* OBSOLETE 75, B75 */
495 /* OBSOLETE 110, B110 */
499 /* OBSOLETE 134, B134 */
503 /* OBSOLETE 150, B150 */
507 /* OBSOLETE 200, B200 */
511 /* OBSOLETE 300, B300 */
515 /* OBSOLETE 600, B600 */
519 /* OBSOLETE 1200, B1200 */
523 /* OBSOLETE 1800, B1800 */
527 /* OBSOLETE 2400, B2400 */
531 /* OBSOLETE 4800, B4800 */
535 /* OBSOLETE 9600, B9600 */
539 /* OBSOLETE 19200, B19200 */
543 /* OBSOLETE 38400, B38400 */
547 /* OBSOLETE -1, -1 */
552 /* OBSOLETE static int */
553 /* OBSOLETE damn_b (int rate) */
555 /* OBSOLETE int i; */
557 /* OBSOLETE for (i = 0; baudtab[i].rate != -1; i++) */
558 /* OBSOLETE if (rate == baudtab[i].rate) */
559 /* OBSOLETE return baudtab[i].damn_b; */
560 /* OBSOLETE return B38400; /* Random */ */
564 /* OBSOLETE /* Open a connection to a remote debugger. */
565 /* OBSOLETE NAME is the filename used for communication, then a space, */
566 /* OBSOLETE then the baud rate. */
569 /* OBSOLETE static int baudrate = 9600; */
570 /* OBSOLETE static void */
571 /* OBSOLETE adapt_open (char *name, int from_tty) */
573 /* OBSOLETE TERMINAL sg; */
574 /* OBSOLETE unsigned int prl; */
575 /* OBSOLETE char *p; */
577 /* OBSOLETE /* Find the first whitespace character, it separates dev_name from */
578 /* OBSOLETE prog_name. */ */
579 /* OBSOLETE if (name == 0) */
580 /* OBSOLETE goto erroid; */
582 /* OBSOLETE for (p = name; */
583 /* OBSOLETE *p != '\0' && !isspace (*p); p++) */
585 /* OBSOLETE if (*p == '\0') */
586 /* OBSOLETE erroid: */
587 /* OBSOLETE error ("\ */
588 /* OBSOLETE Please include the name of the device for the serial port,\n\ */
589 /* OBSOLETE the baud rate, and the name of the program to run on the remote system."); */
590 /* OBSOLETE dev_name = (char *) xmalloc (p - name + 1); */
591 /* OBSOLETE strncpy (dev_name, name, p - name); */
592 /* OBSOLETE dev_name[p - name] = '\0'; */
594 /* OBSOLETE /* Skip over the whitespace after dev_name */ */
595 /* OBSOLETE for (; isspace (*p); p++) */
596 /* OBSOLETE /*EMPTY */ ; */
598 /* OBSOLETE if (1 != sscanf (p, "%d ", &baudrate)) */
599 /* OBSOLETE goto erroid; */
601 /* OBSOLETE /* Skip the number and then the spaces */ */
602 /* OBSOLETE for (; isdigit (*p); p++) */
603 /* OBSOLETE /*EMPTY */ ; */
604 /* OBSOLETE for (; isspace (*p); p++) */
605 /* OBSOLETE /*EMPTY */ ; */
607 /* OBSOLETE if (prog_name != NULL) */
608 /* OBSOLETE xfree (prog_name); */
609 /* OBSOLETE prog_name = savestring (p, strlen (p)); */
611 /* OBSOLETE adapt_close (0); */
613 /* OBSOLETE adapt_desc = open (dev_name, O_RDWR); */
614 /* OBSOLETE if (adapt_desc < 0) */
615 /* OBSOLETE perror_with_name (dev_name); */
616 /* OBSOLETE ioctl (adapt_desc, TIOCGETP, &sg); */
617 /* OBSOLETE #if ! defined(COMPILE_CHECK) */
618 /* OBSOLETE #ifdef HAVE_TERMIO */
619 /* OBSOLETE sg.c_cc[VMIN] = 0; /* read with timeout. */ */
620 /* OBSOLETE sg.c_cc[VTIME] = timeout * 10; */
621 /* OBSOLETE sg.c_lflag &= ~(ICANON | ECHO); */
622 /* OBSOLETE sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate); */
624 /* OBSOLETE sg.sg_ispeed = damn_b (baudrate); */
625 /* OBSOLETE sg.sg_ospeed = damn_b (baudrate); */
626 /* OBSOLETE sg.sg_flags |= RAW | ANYP; */
627 /* OBSOLETE sg.sg_flags &= ~ECHO; */
628 /* OBSOLETE #endif */
630 /* OBSOLETE ioctl (adapt_desc, TIOCSETP, &sg); */
631 /* OBSOLETE adapt_stream = fdopen (adapt_desc, "r+"); */
632 /* OBSOLETE #endif /* compile_check */ */
633 /* OBSOLETE push_target (&adapt_ops); */
635 /* OBSOLETE #ifndef HAVE_TERMIO */
636 /* OBSOLETE #ifndef NO_SIGINTERRUPT */
637 /* OBSOLETE /* Cause SIGALRM's to make reads fail with EINTR instead of resuming */
638 /* OBSOLETE the read. */ */
639 /* OBSOLETE if (siginterrupt (SIGALRM, 1) != 0) */
640 /* OBSOLETE perror ("adapt_open: error in siginterrupt"); */
641 /* OBSOLETE #endif */
643 /* OBSOLETE /* Set up read timeout timer. */ */
644 /* OBSOLETE if ((void (*)) signal (SIGALRM, adapt_timer) == (void (*)) -1) */
645 /* OBSOLETE perror ("adapt_open: error in signal"); */
646 /* OBSOLETE #endif */
648 /* OBSOLETE #if defined (LOG_FILE) */
649 /* OBSOLETE log_file = fopen (LOG_FILE, "w"); */
650 /* OBSOLETE if (log_file == NULL) */
651 /* OBSOLETE perror_with_name (LOG_FILE); */
652 /* OBSOLETE #endif */
654 /* OBSOLETE /* Put this port into NORMAL mode, send the 'normal' character */ */
655 /* OBSOLETE write (adapt_desc, "\ 1", 1); /* Control A */ */
656 /* OBSOLETE write (adapt_desc, "\r", 1); */
657 /* OBSOLETE expect_prompt (); */
659 /* OBSOLETE /* Hello? Are you there? */ */
660 /* OBSOLETE write (adapt_desc, "\r", 1); */
662 /* OBSOLETE expect_prompt (); */
664 /* OBSOLETE /* Clear any break points */ */
665 /* OBSOLETE adapt_clear_breakpoints (); */
667 /* OBSOLETE /* Print out some stuff, letting the user now what's going on */ */
668 /* OBSOLETE printf_filtered ("Connected to an Adapt via %s.\n", dev_name); */
669 /* OBSOLETE /* FIXME: can this restriction be removed? */ */
670 /* OBSOLETE printf_filtered ("Remote debugging using virtual addresses works only\n"); */
671 /* OBSOLETE printf_filtered ("\twhen virtual addresses map 1:1 to physical addresses.\n"); */
672 /* OBSOLETE if (processor_type != a29k_freeze_mode) */
674 /* OBSOLETE fprintf_filtered (gdb_stderr, */
675 /* OBSOLETE "Freeze-mode debugging not available, and can only be done on an A29050.\n"); */
679 /* OBSOLETE /* Close out all files and local state before this target loses control. */ */
681 /* OBSOLETE static void */
682 /* OBSOLETE adapt_close (int quitting) */
685 /* OBSOLETE /* Clear any break points */ */
686 /* OBSOLETE adapt_clear_breakpoints (); */
688 /* OBSOLETE /* Put this port back into REMOTE mode */ */
689 /* OBSOLETE if (adapt_stream) */
691 /* OBSOLETE fflush (adapt_stream); */
692 /* OBSOLETE sleep (1); /* Let any output make it all the way back */ */
693 /* OBSOLETE write (adapt_desc, "R\r", 2); */
696 /* OBSOLETE /* Due to a bug in Unix, fclose closes not only the stdio stream, */
697 /* OBSOLETE but also the file descriptor. So we don't actually close */
698 /* OBSOLETE adapt_desc. */ */
699 /* OBSOLETE if (adapt_stream) */
700 /* OBSOLETE fclose (adapt_stream); /* This also closes adapt_desc */ */
701 /* OBSOLETE if (adapt_desc >= 0) */
702 /* OBSOLETE /* close (adapt_desc); */ */
704 /* OBSOLETE /* Do not try to close adapt_desc again, later in the program. */ */
705 /* OBSOLETE adapt_stream = NULL; */
706 /* OBSOLETE adapt_desc = -1; */
708 /* OBSOLETE #if defined (LOG_FILE) */
709 /* OBSOLETE if (log_file) */
711 /* OBSOLETE if (ferror (log_file)) */
712 /* OBSOLETE printf_filtered ("Error writing log file.\n"); */
713 /* OBSOLETE if (fclose (log_file) != 0) */
714 /* OBSOLETE printf_filtered ("Error closing log file.\n"); */
715 /* OBSOLETE log_file = NULL; */
717 /* OBSOLETE #endif */
720 /* OBSOLETE /* Attach to the target that is already loaded and possibly running */ */
721 /* OBSOLETE static void */
722 /* OBSOLETE adapt_attach (char *args, int from_tty) */
725 /* OBSOLETE if (from_tty) */
726 /* OBSOLETE printf_filtered ("Attaching to remote program %s.\n", prog_name); */
728 /* OBSOLETE /* Send the adapt a kill. It is ok if it is not already running */ */
729 /* OBSOLETE fprintf (adapt_stream, "K\r"); */
730 /* OBSOLETE fflush (adapt_stream); */
731 /* OBSOLETE expect_prompt (); /* Slurp the echo */ */
735 /* OBSOLETE /* Terminate the open connection to the remote debugger. */
736 /* OBSOLETE Use this when you want to detach and do something else */
737 /* OBSOLETE with your gdb. */ */
739 /* OBSOLETE adapt_detach (char *args, int from_tty) */
742 /* OBSOLETE if (adapt_stream) */
743 /* OBSOLETE { /* Send it on its way (tell it to continue) */ */
744 /* OBSOLETE adapt_clear_breakpoints (); */
745 /* OBSOLETE fprintf (adapt_stream, "G\r"); */
748 /* OBSOLETE pop_target (); /* calls adapt_close to do the real work */ */
749 /* OBSOLETE if (from_tty) */
750 /* OBSOLETE printf_filtered ("Ending remote %s debugging\n", target_shortname); */
753 /* OBSOLETE /* Tell the remote machine to resume. */ */
756 /* OBSOLETE adapt_resume (ptid_t ptid, int step, enum target_signal sig) */
758 /* OBSOLETE if (step) */
760 /* OBSOLETE write (adapt_desc, "t 1,s\r", 6); */
761 /* OBSOLETE /* Wait for the echo. */ */
762 /* OBSOLETE expect ("t 1,s\r\n"); */
763 /* OBSOLETE /* Then comes a line containing the instruction we stepped to. */ */
764 /* OBSOLETE expect ("@"); */
765 /* OBSOLETE /* Then we get the prompt. */ */
766 /* OBSOLETE expect_prompt (); */
768 /* OBSOLETE /* Force the next adapt_wait to return a trap. Not doing anything */
769 /* OBSOLETE about I/O from the target means that the user has to type */
770 /* OBSOLETE "continue" to see any. FIXME, this should be fixed. */ */
771 /* OBSOLETE need_artificial_trap = 1; */
775 /* OBSOLETE write (adapt_desc, "G\r", 2); */
776 /* OBSOLETE /* Swallow the echo. */ */
777 /* OBSOLETE expect_prompt (); */
781 /* OBSOLETE /* Wait until the remote machine stops, then return, */
782 /* OBSOLETE storing status in STATUS just as `wait' would. */ */
784 /* OBSOLETE ptid_t */
785 /* OBSOLETE adapt_wait (ptid_t ptid, struct target_waitstatus *status) */
787 /* OBSOLETE /* Strings to look for. '?' means match any single character. */
788 /* OBSOLETE Note that with the algorithm we use, the initial character */
789 /* OBSOLETE of the string cannot recur in the string, or we will not */
790 /* OBSOLETE find some cases of the string in the input. */ */
792 /* OBSOLETE static char bpt[] = "@"; */
793 /* OBSOLETE /* It would be tempting to look for "\n[__exit + 0x8]\n" */
794 /* OBSOLETE but that requires loading symbols with "yc i" and even if */
795 /* OBSOLETE we did do that we don't know that the file has symbols. */ */
796 /* OBSOLETE static char exitmsg[] = "@????????I JMPTI GR121,LR0"; */
797 /* OBSOLETE char *bp = bpt; */
798 /* OBSOLETE char *ep = exitmsg; */
800 /* OBSOLETE /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars. */ */
801 /* OBSOLETE char swallowed[50]; */
802 /* OBSOLETE /* Current position in swallowed. */ */
803 /* OBSOLETE char *swallowed_p = swallowed; */
805 /* OBSOLETE int ch; */
806 /* OBSOLETE int ch_handled; */
807 /* OBSOLETE int old_timeout = timeout; */
808 /* OBSOLETE int old_immediate_quit = immediate_quit; */
810 /* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */
811 /* OBSOLETE status->value.integer = 0; */
813 /* OBSOLETE if (need_artificial_trap != 0) */
815 /* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
816 /* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
817 /* OBSOLETE need_artificial_trap--; */
818 /* OBSOLETE return inferior_ptid; */
821 /* OBSOLETE timeout = 0; /* Don't time out -- user program is running. */ */
822 /* OBSOLETE immediate_quit = 1; /* Helps ability to QUIT */ */
823 /* OBSOLETE while (1) */
825 /* OBSOLETE QUIT; /* Let user quit and leave process running */ */
826 /* OBSOLETE ch_handled = 0; */
827 /* OBSOLETE ch = readchar (); */
828 /* OBSOLETE if (ch == *bp) */
831 /* OBSOLETE if (*bp == '\0') */
832 /* OBSOLETE break; */
833 /* OBSOLETE ch_handled = 1; */
835 /* OBSOLETE *swallowed_p++ = ch; */
838 /* OBSOLETE bp = bpt; */
839 /* OBSOLETE if (ch == *ep || *ep == '?') */
842 /* OBSOLETE if (*ep == '\0') */
843 /* OBSOLETE break; */
845 /* OBSOLETE if (!ch_handled) */
846 /* OBSOLETE *swallowed_p++ = ch; */
847 /* OBSOLETE ch_handled = 1; */
850 /* OBSOLETE ep = exitmsg; */
851 /* OBSOLETE if (!ch_handled) */
853 /* OBSOLETE char *p; */
854 /* OBSOLETE /* Print out any characters which have been swallowed. */ */
855 /* OBSOLETE for (p = swallowed; p < swallowed_p; ++p) */
856 /* OBSOLETE putc (*p, stdout); */
857 /* OBSOLETE swallowed_p = swallowed; */
858 /* OBSOLETE putc (ch, stdout); */
861 /* OBSOLETE expect_prompt (); */
862 /* OBSOLETE if (*bp == '\0') */
864 /* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
865 /* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
869 /* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */
870 /* OBSOLETE status->value.integer = 0; */
872 /* OBSOLETE timeout = old_timeout; */
873 /* OBSOLETE immediate_quit = old_immediate_quit; */
874 /* OBSOLETE return inferior_ptid; */
877 /* OBSOLETE /* Return the name of register number REGNO */
878 /* OBSOLETE in the form input and output by adapt. */
880 /* OBSOLETE Returns a pointer to a static buffer containing the answer. */ */
881 /* OBSOLETE static char * */
882 /* OBSOLETE get_reg_name (int regno) */
884 /* OBSOLETE static char buf[80]; */
885 /* OBSOLETE if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) */
886 /* OBSOLETE sprintf (buf, "GR%03d", regno - GR96_REGNUM + 96); */
887 /* OBSOLETE #if defined(GR64_REGNUM) */
888 /* OBSOLETE else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32) */
889 /* OBSOLETE sprintf (buf, "GR%03d", regno - GR64_REGNUM + 64); */
890 /* OBSOLETE #endif */
891 /* OBSOLETE else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) */
892 /* OBSOLETE sprintf (buf, "LR%03d", regno - LR0_REGNUM); */
893 /* OBSOLETE else if (regno == Q_REGNUM) */
894 /* OBSOLETE strcpy (buf, "SR131"); */
895 /* OBSOLETE else if (regno >= BP_REGNUM && regno <= CR_REGNUM) */
896 /* OBSOLETE sprintf (buf, "SR%03d", regno - BP_REGNUM + 133); */
897 /* OBSOLETE else if (regno == ALU_REGNUM) */
898 /* OBSOLETE strcpy (buf, "SR132"); */
899 /* OBSOLETE else if (regno >= IPC_REGNUM && regno <= IPB_REGNUM) */
900 /* OBSOLETE sprintf (buf, "SR%03d", regno - IPC_REGNUM + 128); */
901 /* OBSOLETE else if (regno >= VAB_REGNUM && regno <= LRU_REGNUM) */
903 /* OBSOLETE /* When a 29050 is in freeze-mode, read shadow pcs instead */ */
904 /* OBSOLETE if ((regno >= NPC_REGNUM && regno <= PC2_REGNUM) && USE_SHADOW_PC) */
905 /* OBSOLETE sprintf (buf, "SR%03d", regno - NPC_REGNUM + 20); */
907 /* OBSOLETE sprintf (buf, "SR%03d", regno - VAB_REGNUM); */
909 /* OBSOLETE else if (regno == GR1_REGNUM) */
910 /* OBSOLETE strcpy (buf, "GR001"); */
911 /* OBSOLETE return buf; */
914 /* OBSOLETE /* Read the remote registers. */ */
916 /* OBSOLETE static void */
917 /* OBSOLETE adapt_fetch_registers (void) */
919 /* OBSOLETE int reg_index; */
920 /* OBSOLETE int regnum_index; */
921 /* OBSOLETE char tempbuf[10]; */
922 /* OBSOLETE int sreg_buf[16]; */
923 /* OBSOLETE int i, j; */
926 /* OBSOLETE * Global registers */
928 /* OBSOLETE #if defined(GR64_REGNUM) */
929 /* OBSOLETE write (adapt_desc, "dw gr64,gr95\r", 13); */
930 /* OBSOLETE for (reg_index = 64, regnum_index = GR64_REGNUM; */
931 /* OBSOLETE reg_index < 96; */
932 /* OBSOLETE reg_index += 4, regnum_index += 4) */
934 /* OBSOLETE sprintf (tempbuf, "GR%03d ", reg_index); */
935 /* OBSOLETE expect (tempbuf); */
936 /* OBSOLETE get_hex_regs (4, regnum_index); */
937 /* OBSOLETE expect ("\n"); */
939 /* OBSOLETE #endif */
940 /* OBSOLETE write (adapt_desc, "dw gr96,gr127\r", 14); */
941 /* OBSOLETE for (reg_index = 96, regnum_index = GR96_REGNUM; */
942 /* OBSOLETE reg_index < 128; */
943 /* OBSOLETE reg_index += 4, regnum_index += 4) */
945 /* OBSOLETE sprintf (tempbuf, "GR%03d ", reg_index); */
946 /* OBSOLETE expect (tempbuf); */
947 /* OBSOLETE get_hex_regs (4, regnum_index); */
948 /* OBSOLETE expect ("\n"); */
952 /* OBSOLETE * Local registers */
954 /* OBSOLETE for (i = 0; i < 128; i += 32) */
956 /* OBSOLETE /* The PC has a tendency to hang if we get these */
957 /* OBSOLETE all in one fell swoop ("dw lr0,lr127"). */ */
958 /* OBSOLETE sprintf (tempbuf, "dw lr%d\r", i); */
959 /* OBSOLETE write (adapt_desc, tempbuf, strlen (tempbuf)); */
960 /* OBSOLETE for (reg_index = i, regnum_index = LR0_REGNUM + i; */
961 /* OBSOLETE reg_index < i + 32; */
962 /* OBSOLETE reg_index += 4, regnum_index += 4) */
964 /* OBSOLETE sprintf (tempbuf, "LR%03d ", reg_index); */
965 /* OBSOLETE expect (tempbuf); */
966 /* OBSOLETE get_hex_regs (4, regnum_index); */
967 /* OBSOLETE expect ("\n"); */
972 /* OBSOLETE * Special registers */
974 /* OBSOLETE sprintf (tempbuf, "dw sr0\r"); */
975 /* OBSOLETE write (adapt_desc, tempbuf, strlen (tempbuf)); */
976 /* OBSOLETE for (i = 0; i < 4; i++) */
977 /* OBSOLETE { /* SR0 - SR14 */ */
978 /* OBSOLETE sprintf (tempbuf, "SR%3d", i * 4); */
979 /* OBSOLETE expect (tempbuf); */
980 /* OBSOLETE for (j = 0; j < (i == 3 ? 3 : 4); j++) */
981 /* OBSOLETE sreg_buf[i * 4 + j] = get_hex_word (); */
983 /* OBSOLETE expect_prompt (); */
985 /* OBSOLETE * Read the pcs individually if we are in freeze mode. */
986 /* OBSOLETE * See get_reg_name(), it translates the register names for the pcs to */
987 /* OBSOLETE * the names of the shadow pcs. */
989 /* OBSOLETE if (USE_SHADOW_PC) */
991 /* OBSOLETE sreg_buf[10] = read_register (NPC_REGNUM); /* pc0 */ */
992 /* OBSOLETE sreg_buf[11] = read_register (PC_REGNUM); /* pc1 */ */
993 /* OBSOLETE sreg_buf[12] = read_register (PC2_REGNUM); /* pc2 */ */
995 /* OBSOLETE for (i = 0; i < 14; i++) /* Supply vab -> lru */ */
996 /* OBSOLETE supply_register (VAB_REGNUM + i, (char *) &sreg_buf[i]); */
997 /* OBSOLETE sprintf (tempbuf, "dw sr128\r"); */
998 /* OBSOLETE write (adapt_desc, tempbuf, strlen (tempbuf)); */
999 /* OBSOLETE for (i = 0; i < 2; i++) */
1000 /* OBSOLETE { /* SR128 - SR135 */ */
1001 /* OBSOLETE sprintf (tempbuf, "SR%3d", 128 + i * 4); */
1002 /* OBSOLETE expect (tempbuf); */
1003 /* OBSOLETE for (j = 0; j < 4; j++) */
1004 /* OBSOLETE sreg_buf[i * 4 + j] = get_hex_word (); */
1006 /* OBSOLETE expect_prompt (); */
1007 /* OBSOLETE supply_register (IPC_REGNUM, (char *) &sreg_buf[0]); */
1008 /* OBSOLETE supply_register (IPA_REGNUM, (char *) &sreg_buf[1]); */
1009 /* OBSOLETE supply_register (IPB_REGNUM, (char *) &sreg_buf[2]); */
1010 /* OBSOLETE supply_register (Q_REGNUM, (char *) &sreg_buf[3]); */
1011 /* OBSOLETE /* Skip ALU */ */
1012 /* OBSOLETE supply_register (BP_REGNUM, (char *) &sreg_buf[5]); */
1013 /* OBSOLETE supply_register (FC_REGNUM, (char *) &sreg_buf[6]); */
1014 /* OBSOLETE supply_register (CR_REGNUM, (char *) &sreg_buf[7]); */
1016 /* OBSOLETE /* There doesn't seem to be any way to get these. */ */
1018 /* OBSOLETE int val = -1; */
1019 /* OBSOLETE supply_register (FPE_REGNUM, (char *) &val); */
1020 /* OBSOLETE supply_register (INTE_REGNUM, (char *) &val); */
1021 /* OBSOLETE supply_register (FPS_REGNUM, (char *) &val); */
1022 /* OBSOLETE supply_register (EXO_REGNUM, (char *) &val); */
1025 /* OBSOLETE write (adapt_desc, "dw gr1,gr1\r", 11); */
1026 /* OBSOLETE expect ("GR001 "); */
1027 /* OBSOLETE get_hex_regs (1, GR1_REGNUM); */
1028 /* OBSOLETE expect_prompt (); */
1031 /* OBSOLETE /* Fetch register REGNO, or all registers if REGNO is -1. */
1033 /* OBSOLETE static void */
1034 /* OBSOLETE adapt_fetch_register (int regno) */
1036 /* OBSOLETE if (regno == -1) */
1037 /* OBSOLETE adapt_fetch_registers (); */
1040 /* OBSOLETE char *name = get_reg_name (regno); */
1041 /* OBSOLETE fprintf (adapt_stream, "dw %s,%s\r", name, name); */
1042 /* OBSOLETE expect (name); */
1043 /* OBSOLETE expect (" "); */
1044 /* OBSOLETE get_hex_regs (1, regno); */
1045 /* OBSOLETE expect_prompt (); */
1049 /* OBSOLETE /* Store the remote registers from the contents of the block REGS. */ */
1051 /* OBSOLETE static void */
1052 /* OBSOLETE adapt_store_registers (void) */
1054 /* OBSOLETE int i, j; */
1056 /* OBSOLETE fprintf (adapt_stream, "s gr1,%x\r", read_register (GR1_REGNUM)); */
1057 /* OBSOLETE expect_prompt (); */
1059 /* OBSOLETE #if defined(GR64_REGNUM) */
1060 /* OBSOLETE for (j = 0; j < 32; j += 16) */
1062 /* OBSOLETE fprintf (adapt_stream, "s gr%d,", j + 64); */
1063 /* OBSOLETE for (i = 0; i < 15; ++i) */
1064 /* OBSOLETE fprintf (adapt_stream, "%x,", read_register (GR64_REGNUM + j + i)); */
1065 /* OBSOLETE fprintf (adapt_stream, "%x\r", read_register (GR64_REGNUM + j + 15)); */
1066 /* OBSOLETE expect_prompt (); */
1068 /* OBSOLETE #endif */
1069 /* OBSOLETE for (j = 0; j < 32; j += 16) */
1071 /* OBSOLETE fprintf (adapt_stream, "s gr%d,", j + 96); */
1072 /* OBSOLETE for (i = 0; i < 15; ++i) */
1073 /* OBSOLETE fprintf (adapt_stream, "%x,", read_register (GR96_REGNUM + j + i)); */
1074 /* OBSOLETE fprintf (adapt_stream, "%x\r", read_register (GR96_REGNUM + j + 15)); */
1075 /* OBSOLETE expect_prompt (); */
1078 /* OBSOLETE for (j = 0; j < 128; j += 16) */
1080 /* OBSOLETE fprintf (adapt_stream, "s lr%d,", j); */
1081 /* OBSOLETE for (i = 0; i < 15; ++i) */
1082 /* OBSOLETE fprintf (adapt_stream, "%x,", read_register (LR0_REGNUM + j + i)); */
1083 /* OBSOLETE fprintf (adapt_stream, "%x\r", read_register (LR0_REGNUM + j + 15)); */
1084 /* OBSOLETE expect_prompt (); */
1087 /* OBSOLETE fprintf (adapt_stream, "s sr128,%x,%x,%x\r", read_register (IPC_REGNUM), */
1088 /* OBSOLETE read_register (IPA_REGNUM), read_register (IPB_REGNUM)); */
1089 /* OBSOLETE expect_prompt (); */
1090 /* OBSOLETE fprintf (adapt_stream, "s sr133,%x,%x,%x\r", read_register (BP_REGNUM), */
1091 /* OBSOLETE read_register (FC_REGNUM), read_register (CR_REGNUM)); */
1092 /* OBSOLETE expect_prompt (); */
1093 /* OBSOLETE fprintf (adapt_stream, "s sr131,%x\r", read_register (Q_REGNUM)); */
1094 /* OBSOLETE expect_prompt (); */
1095 /* OBSOLETE fprintf (adapt_stream, "s sr0,"); */
1096 /* OBSOLETE for (i = 0; i < 7; ++i) */
1097 /* OBSOLETE fprintf (adapt_stream, "%x,", read_register (VAB_REGNUM + i)); */
1098 /* OBSOLETE expect_prompt (); */
1099 /* OBSOLETE fprintf (adapt_stream, "s sr7,"); */
1100 /* OBSOLETE for (i = 7; i < 14; ++i) */
1101 /* OBSOLETE fprintf (adapt_stream, "%x,", read_register (VAB_REGNUM + i)); */
1102 /* OBSOLETE expect_prompt (); */
1105 /* OBSOLETE /* Store register REGNO, or all if REGNO == -1. */
1106 /* OBSOLETE Return errno value. */ */
1108 /* OBSOLETE adapt_store_register (int regno) */
1110 /* OBSOLETE /* printf("adapt_store_register() called.\n"); fflush(stdout); /* */ */
1111 /* OBSOLETE if (regno == -1) */
1112 /* OBSOLETE adapt_store_registers (); */
1115 /* OBSOLETE char *name = get_reg_name (regno); */
1116 /* OBSOLETE fprintf (adapt_stream, "s %s,%x\r", name, read_register (regno)); */
1117 /* OBSOLETE /* Setting GR1 changes the numbers of all the locals, so */
1118 /* OBSOLETE invalidate the register cache. Do this *after* calling */
1119 /* OBSOLETE read_register, because we want read_register to return the */
1120 /* OBSOLETE value that write_register has just stuffed into the registers */
1121 /* OBSOLETE array, not the value of the register fetched from the */
1122 /* OBSOLETE inferior. */ */
1123 /* OBSOLETE if (regno == GR1_REGNUM) */
1124 /* OBSOLETE registers_changed (); */
1125 /* OBSOLETE expect_prompt (); */
1129 /* OBSOLETE /* Get ready to modify the registers array. On machines which store */
1130 /* OBSOLETE individual registers, this doesn't need to do anything. On machines */
1131 /* OBSOLETE which store all the registers in one fell swoop, this makes sure */
1132 /* OBSOLETE that registers contains all the registers from the program being */
1133 /* OBSOLETE debugged. */ */
1136 /* OBSOLETE adapt_prepare_to_store (void) */
1138 /* OBSOLETE /* Do nothing, since we can store individual regs */ */
1141 /* OBSOLETE static CORE_ADDR */
1142 /* OBSOLETE translate_addr (CORE_ADDR addr) */
1144 /* OBSOLETE #if defined(KERNEL_DEBUGGING) */
1145 /* OBSOLETE /* Check for a virtual address in the kernel */ */
1146 /* OBSOLETE /* Assume physical address of ublock is in paddr_u register */ */
1147 /* OBSOLETE if (addr >= UVADDR) */
1149 /* OBSOLETE /* PADDR_U register holds the physical address of the ublock */ */
1150 /* OBSOLETE CORE_ADDR i = (CORE_ADDR) read_register (PADDR_U_REGNUM); */
1151 /* OBSOLETE return (i + addr - (CORE_ADDR) UVADDR); */
1155 /* OBSOLETE return (addr); */
1157 /* OBSOLETE #else */
1158 /* OBSOLETE return (addr); */
1159 /* OBSOLETE #endif */
1163 /* OBSOLETE /* FIXME! Merge these two. */ */
1165 /* OBSOLETE adapt_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, */
1166 /* OBSOLETE struct mem_attrib *attrib ATTRIBUTE_UNUSED, */
1167 /* OBSOLETE struct target_ops *target ATTRIBUTE_UNUSED) */
1170 /* OBSOLETE memaddr = translate_addr (memaddr); */
1172 /* OBSOLETE if (write) */
1173 /* OBSOLETE return adapt_write_inferior_memory (memaddr, myaddr, len); */
1175 /* OBSOLETE return adapt_read_inferior_memory (memaddr, myaddr, len); */
1179 /* OBSOLETE adapt_files_info (void) */
1181 /* OBSOLETE printf_filtered ("\tAttached to %s at %d baud and running program %s\n", */
1182 /* OBSOLETE dev_name, baudrate, prog_name); */
1183 /* OBSOLETE printf_filtered ("\ton an %s processor.\n", processor_name[processor_type]); */
1186 /* OBSOLETE /* Copy LEN bytes of data from debugger memory at MYADDR */
1187 /* OBSOLETE to inferior's memory at MEMADDR. Returns errno value. */
1188 /* OBSOLETE * sb/sh instructions don't work on unaligned addresses, when TU=1. */
1191 /* OBSOLETE adapt_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
1193 /* OBSOLETE int i; */
1194 /* OBSOLETE unsigned int cps; */
1196 /* OBSOLETE /* Turn TU bit off so we can do 'sb' commands */ */
1197 /* OBSOLETE cps = read_register (CPS_REGNUM); */
1198 /* OBSOLETE if (cps & 0x00000800) */
1199 /* OBSOLETE write_register (CPS_REGNUM, cps & ~(0x00000800)); */
1201 /* OBSOLETE for (i = 0; i < len; i++) */
1203 /* OBSOLETE if ((i % 16) == 0) */
1204 /* OBSOLETE fprintf (adapt_stream, "sb %x,", memaddr + i); */
1205 /* OBSOLETE if ((i % 16) == 15 || i == len - 1) */
1207 /* OBSOLETE fprintf (adapt_stream, "%x\r", ((unsigned char *) myaddr)[i]); */
1208 /* OBSOLETE expect_prompt (); */
1211 /* OBSOLETE fprintf (adapt_stream, "%x,", ((unsigned char *) myaddr)[i]); */
1213 /* OBSOLETE /* Restore the old value of cps if the TU bit was on */ */
1214 /* OBSOLETE if (cps & 0x00000800) */
1215 /* OBSOLETE write_register (CPS_REGNUM, cps); */
1216 /* OBSOLETE return len; */
1219 /* OBSOLETE /* Read LEN bytes from inferior memory at MEMADDR. Put the result */
1220 /* OBSOLETE at debugger address MYADDR. Returns errno value. */ */
1222 /* OBSOLETE adapt_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
1224 /* OBSOLETE int i; */
1226 /* OBSOLETE /* Number of bytes read so far. */ */
1227 /* OBSOLETE int count; */
1229 /* OBSOLETE /* Starting address of this pass. */ */
1230 /* OBSOLETE unsigned long startaddr; */
1232 /* OBSOLETE /* Number of bytes to read in this pass. */ */
1233 /* OBSOLETE int len_this_pass; */
1235 /* OBSOLETE /* Note that this code works correctly if startaddr is just less */
1236 /* OBSOLETE than UINT_MAX (well, really CORE_ADDR_MAX if there was such a */
1237 /* OBSOLETE thing). That is, something like */
1238 /* OBSOLETE adapt_read_bytes (CORE_ADDR_MAX - 4, foo, 4) */
1239 /* OBSOLETE works--it never adds len to memaddr and gets 0. */ */
1240 /* OBSOLETE /* However, something like */
1241 /* OBSOLETE adapt_read_bytes (CORE_ADDR_MAX - 3, foo, 4) */
1242 /* OBSOLETE doesn't need to work. Detect it and give up if there's an attempt */
1243 /* OBSOLETE to do that. */ */
1245 /* OBSOLETE if (((memaddr - 1) + len) < memaddr) */
1246 /* OBSOLETE return EIO; */
1248 /* OBSOLETE startaddr = memaddr; */
1249 /* OBSOLETE count = 0; */
1250 /* OBSOLETE while (count < len) */
1252 /* OBSOLETE len_this_pass = 16; */
1253 /* OBSOLETE if ((startaddr % 16) != 0) */
1254 /* OBSOLETE len_this_pass -= startaddr % 16; */
1255 /* OBSOLETE if (len_this_pass > (len - count)) */
1256 /* OBSOLETE len_this_pass = (len - count); */
1258 /* OBSOLETE fprintf (adapt_stream, "db %x,%x\r", startaddr, */
1259 /* OBSOLETE (startaddr - 1) + len_this_pass); */
1261 /* OBSOLETE #ifdef NOTDEF /* Why do this */ */
1262 /* OBSOLETE expect ("\n"); */
1263 /* OBSOLETE /* Look for 8 hex digits. */ */
1264 /* OBSOLETE i = 0; */
1265 /* OBSOLETE while (1) */
1267 /* OBSOLETE if (isxdigit (readchar ())) */
1271 /* OBSOLETE expect_prompt (); */
1272 /* OBSOLETE error ("Hex digit expected from remote system."); */
1274 /* OBSOLETE if (i >= 8) */
1275 /* OBSOLETE break; */
1277 /* OBSOLETE #endif /* NOTDEF */ */
1279 /* OBSOLETE expect (" "); */
1281 /* OBSOLETE for (i = 0; i < len_this_pass; i++) */
1282 /* OBSOLETE get_hex_byte (&myaddr[count++]); */
1284 /* OBSOLETE expect_prompt (); */
1286 /* OBSOLETE startaddr += len_this_pass; */
1288 /* OBSOLETE return count; */
1291 /* OBSOLETE #define MAX_BREAKS 8 */
1292 /* OBSOLETE static int num_brkpts = 0; */
1294 /* OBSOLETE /* Insert a breakpoint at ADDR. SAVE is normally the address of the */
1295 /* OBSOLETE pattern buffer where the instruction that the breakpoint overwrites */
1296 /* OBSOLETE is saved. It is unused here since the Adapt Monitor is responsible */
1297 /* OBSOLETE for saving/restoring the original instruction. */ */
1299 /* OBSOLETE static int */
1300 /* OBSOLETE adapt_insert_breakpoint (CORE_ADDR addr, char *save) */
1302 /* OBSOLETE if (num_brkpts < MAX_BREAKS) */
1304 /* OBSOLETE num_brkpts++; */
1305 /* OBSOLETE fprintf (adapt_stream, "B %x", addr); */
1306 /* OBSOLETE fprintf (adapt_stream, "\r"); */
1307 /* OBSOLETE expect_prompt (); */
1308 /* OBSOLETE return (0); /* Success */ */
1312 /* OBSOLETE fprintf_filtered (gdb_stderr, */
1313 /* OBSOLETE "Too many break points, break point not installed\n"); */
1314 /* OBSOLETE return (1); /* Failure */ */
1319 /* OBSOLETE /* Remove a breakpoint at ADDR. SAVE is normally the previously */
1320 /* OBSOLETE saved pattern, but is unused here as the Adapt Monitor is */
1321 /* OBSOLETE responsible for saving/restoring instructions. */ */
1323 /* OBSOLETE static int */
1324 /* OBSOLETE adapt_remove_breakpoint (CORE_ADDR addr, char *save) */
1326 /* OBSOLETE if (num_brkpts > 0) */
1328 /* OBSOLETE num_brkpts--; */
1329 /* OBSOLETE fprintf (adapt_stream, "BR %x", addr); */
1330 /* OBSOLETE fprintf (adapt_stream, "\r"); */
1331 /* OBSOLETE fflush (adapt_stream); */
1332 /* OBSOLETE expect_prompt (); */
1334 /* OBSOLETE return (0); */
1337 /* OBSOLETE /* Clear the adapts notion of what the break points are */ */
1338 /* OBSOLETE static int */
1339 /* OBSOLETE adapt_clear_breakpoints (void) */
1341 /* OBSOLETE if (adapt_stream) */
1343 /* OBSOLETE fprintf (adapt_stream, "BR"); /* Clear all break points */ */
1344 /* OBSOLETE fprintf (adapt_stream, "\r"); */
1345 /* OBSOLETE fflush (adapt_stream); */
1346 /* OBSOLETE expect_prompt (); */
1348 /* OBSOLETE num_brkpts = 0; */
1350 /* OBSOLETE static void */
1351 /* OBSOLETE adapt_mourn (void) */
1353 /* OBSOLETE adapt_clear_breakpoints (); */
1354 /* OBSOLETE pop_target (); /* Pop back to no-child state */ */
1355 /* OBSOLETE generic_mourn_inferior (); */
1358 /* OBSOLETE /* Display everthing we read in from the adapt until we match/see the */
1359 /* OBSOLETE * specified string */
1361 /* OBSOLETE static int */
1362 /* OBSOLETE display_until (char *str) */
1364 /* OBSOLETE int i = 0, j, c; */
1366 /* OBSOLETE while (c = readchar ()) */
1368 /* OBSOLETE if (c == str[i]) */
1371 /* OBSOLETE if (i == strlen (str)) */
1372 /* OBSOLETE return; */
1376 /* OBSOLETE if (i) */
1378 /* OBSOLETE for (j = 0; j < i; j++) /* Put everthing we matched */ */
1379 /* OBSOLETE putchar (str[j]); */
1380 /* OBSOLETE i = 0; */
1382 /* OBSOLETE putchar (c); */
1389 /* OBSOLETE /* Put a command string, in args, out to the adapt. The adapt is assumed to */
1390 /* OBSOLETE be in raw mode, all writing/reading done through adapt_desc. */
1391 /* OBSOLETE Ouput from the adapt is placed on the users terminal until the */
1392 /* OBSOLETE prompt from the adapt is seen. */
1393 /* OBSOLETE FIXME: Can't handle commands that take input. */ */
1396 /* OBSOLETE adapt_com (char *args, int fromtty) */
1398 /* OBSOLETE if (!adapt_stream) */
1400 /* OBSOLETE printf_filtered ("Adapt not open. Use the 'target' command to open.\n"); */
1401 /* OBSOLETE return; */
1404 /* OBSOLETE /* Clear all input so only command relative output is displayed */ */
1405 /* OBSOLETE slurp_input (); */
1407 /* OBSOLETE switch (islower (args[0]) ? toupper (args[0]) : args[0]) */
1409 /* OBSOLETE default: */
1410 /* OBSOLETE printf_filtered ("Unknown/Unimplemented adapt command '%s'\n", args); */
1411 /* OBSOLETE break; */
1412 /* OBSOLETE case 'G': /* Go, begin execution */ */
1413 /* OBSOLETE write (adapt_desc, args, strlen (args)); */
1414 /* OBSOLETE write (adapt_desc, "\r", 1); */
1415 /* OBSOLETE expect_prompt (); */
1416 /* OBSOLETE break; */
1417 /* OBSOLETE case 'B': /* Break points, B or BR */ */
1418 /* OBSOLETE case 'C': /* Check current 29k status (running/halted) */ */
1419 /* OBSOLETE case 'D': /* Display data/registers */ */
1420 /* OBSOLETE case 'I': /* Input from i/o space */ */
1421 /* OBSOLETE case 'J': /* Jam an instruction */ */
1422 /* OBSOLETE case 'K': /* Kill, stop execution */ */
1423 /* OBSOLETE case 'L': /* Disassemble */ */
1424 /* OBSOLETE case 'O': /* Output to i/o space */ */
1425 /* OBSOLETE case 'T': /* Trace */ */
1426 /* OBSOLETE case 'P': /* Pulse an input line */ */
1427 /* OBSOLETE case 'X': /* Examine special purpose registers */ */
1428 /* OBSOLETE case 'Z': /* Display trace buffer */ */
1429 /* OBSOLETE write (adapt_desc, args, strlen (args)); */
1430 /* OBSOLETE write (adapt_desc, "\r", 1); */
1431 /* OBSOLETE expect (args); /* Don't display the command */ */
1432 /* OBSOLETE display_until ("# "); */
1433 /* OBSOLETE break; */
1434 /* OBSOLETE /* Begin commands that take input in the form 'c x,y[,z...]' */ */
1435 /* OBSOLETE case 'S': /* Set memory or register */ */
1436 /* OBSOLETE if (strchr (args, ',')) */
1437 /* OBSOLETE { /* Assume it is properly formatted */ */
1438 /* OBSOLETE write (adapt_desc, args, strlen (args)); */
1439 /* OBSOLETE write (adapt_desc, "\r", 1); */
1440 /* OBSOLETE expect_prompt (); */
1442 /* OBSOLETE break; */
1446 /* OBSOLETE /* Define the target subroutine names */ */
1448 /* OBSOLETE struct target_ops adapt_ops; */
1450 /* OBSOLETE static void */
1451 /* OBSOLETE init_adapt_ops (void) */
1453 /* OBSOLETE adapt_ops.to_shortname = "adapt"; */
1454 /* OBSOLETE adapt_ops.to_longname = "Remote AMD `Adapt' target"; */
1455 /* OBSOLETE adapt_ops.to_doc = "Remote debug an AMD 290*0 using an `Adapt' monitor via RS232"; */
1456 /* OBSOLETE adapt_ops.to_open = adapt_open; */
1457 /* OBSOLETE adapt_ops.to_close = adapt_close; */
1458 /* OBSOLETE adapt_ops.to_attach = adapt_attach; */
1459 /* OBSOLETE adapt_ops.to_post_attach = NULL; */
1460 /* OBSOLETE adapt_ops.to_require_attach = NULL; */
1461 /* OBSOLETE adapt_ops.to_detach = adapt_detach; */
1462 /* OBSOLETE adapt_ops.to_require_detach = NULL; */
1463 /* OBSOLETE adapt_ops.to_resume = adapt_resume; */
1464 /* OBSOLETE adapt_ops.to_wait = adapt_wait; */
1465 /* OBSOLETE adapt_ops.to_post_wait = NULL; */
1466 /* OBSOLETE adapt_ops.to_fetch_registers = adapt_fetch_register; */
1467 /* OBSOLETE adapt_ops.to_store_registers = adapt_store_register; */
1468 /* OBSOLETE adapt_ops.to_prepare_to_store = adapt_prepare_to_store; */
1469 /* OBSOLETE adapt_ops.to_xfer_memory = adapt_xfer_inferior_memory; */
1470 /* OBSOLETE adapt_ops.to_files_info = adapt_files_info; */
1471 /* OBSOLETE adapt_ops.to_insert_breakpoint = adapt_insert_breakpoint; */
1472 /* OBSOLETE adapt_ops.to_remove_breakpoint = adapt_remove_breakpoint; */
1473 /* OBSOLETE adapt_ops.to_terminal_init = 0; */
1474 /* OBSOLETE adapt_ops.to_terminal_inferior = 0; */
1475 /* OBSOLETE adapt_ops.to_terminal_ours_for_output = 0; */
1476 /* OBSOLETE adapt_ops.to_terminal_ours = 0; */
1477 /* OBSOLETE adapt_ops.to_terminal_info = 0; */
1478 /* OBSOLETE adapt_ops.to_kill = adapt_kill; */
1479 /* OBSOLETE adapt_ops.to_load = adapt_load; */
1480 /* OBSOLETE adapt_ops.to_lookup_symbol = 0; */
1481 /* OBSOLETE adapt_ops.to_create_inferior = adapt_create_inferior; */
1482 /* OBSOLETE adapt_ops.to_post_startup_inferior = NULL; */
1483 /* OBSOLETE adapt_ops.to_acknowledge_created_inferior = NULL; */
1484 /* OBSOLETE adapt_ops.to_clone_and_follow_inferior = NULL; */
1485 /* OBSOLETE adapt_ops.to_post_follow_inferior_by_clone = NULL; */
1486 /* OBSOLETE adapt_ops.to_insert_fork_catchpoint = NULL; */
1487 /* OBSOLETE adapt_ops.to_remove_fork_catchpoint = NULL; */
1488 /* OBSOLETE adapt_ops.to_insert_vfork_catchpoint = NULL; */
1489 /* OBSOLETE adapt_ops.to_remove_vfork_catchpoint = NULL; */
1490 /* OBSOLETE adapt_ops.to_has_forked = NULL; */
1491 /* OBSOLETE adapt_ops.to_has_vforked = NULL; */
1492 /* OBSOLETE adapt_ops.to_can_follow_vfork_prior_to_exec = NULL; */
1493 /* OBSOLETE adapt_ops.to_post_follow_vfork = NULL; */
1494 /* OBSOLETE adapt_ops.to_insert_exec_catchpoint = NULL; */
1495 /* OBSOLETE adapt_ops.to_remove_exec_catchpoint = NULL; */
1496 /* OBSOLETE adapt_ops.to_has_execd = NULL; */
1497 /* OBSOLETE adapt_ops.to_reported_exec_events_per_exec_call = NULL; */
1498 /* OBSOLETE adapt_ops.to_has_exited = NULL; */
1499 /* OBSOLETE adapt_ops.to_mourn_inferior = adapt_mourn; */
1500 /* OBSOLETE adapt_ops.to_can_run = 0; */
1501 /* OBSOLETE adapt_ops.to_notice_signals = 0; */
1502 /* OBSOLETE adapt_ops.to_thread_alive = 0; */
1503 /* OBSOLETE adapt_ops.to_stop = 0; /* process_stratum; */ */
1504 /* OBSOLETE adapt_ops.to_pid_to_exec_file = NULL; */
1505 /* OBSOLETE adapt_ops.to_stratum = 0; */
1506 /* OBSOLETE adapt_ops.DONT_USE = 0; */
1507 /* OBSOLETE adapt_ops.to_has_all_memory = 1; */
1508 /* OBSOLETE adapt_ops.to_has_memory = 1; */
1509 /* OBSOLETE adapt_ops.to_has_stack = 1; */
1510 /* OBSOLETE adapt_ops.to_has_registers = 1; */
1511 /* OBSOLETE adapt_ops.to_has_execution = 0; */
1512 /* OBSOLETE adapt_ops.to_sections = 0; */
1513 /* OBSOLETE adapt_ops.to_sections_end = 0; */
1514 /* OBSOLETE adapt_ops.to_magic = OPS_MAGIC; */
1515 /* OBSOLETE } /* init_adapt_ops */ */
1518 /* OBSOLETE _initialize_remote_adapt (void) */
1520 /* OBSOLETE init_adapt_ops (); */
1521 /* OBSOLETE add_target (&adapt_ops); */
1522 /* OBSOLETE add_com ("adapt <command>", class_obscure, adapt_com, */
1523 /* OBSOLETE "Send a command to the AMD Adapt remote monitor."); */
This page took 0.06229 seconds and 4 git commands to generate.