diff options
author | Stu Grossman <grossman@cygnus> | 1995-03-07 09:26:39 +0000 |
---|---|---|
committer | Stu Grossman <grossman@cygnus> | 1995-03-07 09:26:39 +0000 |
commit | 1265e2d82361cdf254aade96eb9840d81a36a8fd (patch) | |
tree | f4967a7af882294dd7fbe48b25beea9dc63c6e1f /gdb | |
parent | 09374c9863316b51b7e44ce94a5b89706b107e66 (diff) | |
download | gdb-1265e2d82361cdf254aade96eb9840d81a36a8fd.zip gdb-1265e2d82361cdf254aade96eb9840d81a36a8fd.tar.gz gdb-1265e2d82361cdf254aade96eb9840d81a36a8fd.tar.bz2 |
* Makefile.in: Add rules for monitor.o and rom68k-rom.o to make
Sun make (with VPATH) work...
* monitor.c monitor.h rom68k-rom.c: Serious cleanup to make IDP
(rom68k) target work right.
* array-rom.c op50-rom.c w89k-rom.c: Partial updates to new
monitor.c interface. More work needs to be done here.
* config/m68k/tm-monitor.h: Change DECR_PC_AFTER_BREAK to 0 to
match the IDP monitor. Also, set NUM_REGS to 18 cuz there's no
floating-point for this card.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 11 | ||||
-rw-r--r-- | gdb/Makefile.in | 12 | ||||
-rw-r--r-- | gdb/array-rom.c | 26 | ||||
-rw-r--r-- | gdb/monitor.c | 1459 | ||||
-rw-r--r-- | gdb/monitor.h | 67 | ||||
-rw-r--r-- | gdb/op50-rom.c | 22 | ||||
-rw-r--r-- | gdb/rom68k-rom.c | 113 | ||||
-rw-r--r-- | gdb/w89k-rom.c | 22 |
8 files changed, 517 insertions, 1215 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 18bf0c7..3368751 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,16 @@ Tue Mar 7 00:23:47 1995 Stu Grossman (grossman@cygnus.com) + * Makefile.in: Add rules for monitor.o and rom68k-rom.o to make + Sun make (with VPATH) work... + + * monitor.c monitor.h rom68k-rom.c: Serious cleanup to make IDP + (rom68k) target work right. + * array-rom.c op50-rom.c w89k-rom.c: Partial updates to new + monitor.c interface. More work needs to be done here. + * config/m68k/tm-monitor.h: Change DECR_PC_AFTER_BREAK to 0 to + match the IDP monitor. Also, set NUM_REGS to 18 cuz there's no + floating-point for this card. + * serial.h ser-go32.c ser-go32-para.c ser-mac.c ser-tcp.c ser-unix.c: Add SERIAL_SETSTOPBITS to set the number of stopbits (needed for IDP board?!?!?). diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 9c8647c..6fc2936 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -185,7 +185,7 @@ REGEX1 = regex.o # you can use 'CLIBS=$(INSTALLED_LIBS)' 'CDEPS=' INSTALLED_LIBS=-lbfd -lreadline $(TERMCAP) -lopcodes -lmmalloc \ -liberty $(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) $(ENABLE_CLIBS) -CLIBS = $(BFD) $(READLINE) $(OPCODES) $(MMALLOC) \ +CLIBS = $(BFD) $(READLINE) $(OPCODES) $(MMALLOC) $(LIBIBERTY) \ $(ENABLE_CLIBS) $(TERMCAP) $(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) \ $(LIBIBERTY) CDEPS = $(XM_CDEPS) $(TM_CDEPS) $(NAT_CDEPS) $(BFD) $(READLINE) $(OPCODES) \ @@ -251,7 +251,7 @@ FLAGS_TO_PASS = \ CC_FOR_TARGET = ` \ if [ -f $${rootme}/../gcc/xgcc ] ; then \ if [ -f $${rootme}/../newlib/Makefile ] ; then \ - echo $${rootme}/../gcc/xgcc -B$${rootme}/../gcc/ -idirafter $${rootme}/newlib/targ-include -idirafter $${rootsrc}/../newlib/libc/include -nostdinc -L$${rootme}/../../newlib -B$${rootme}/../../newlib/; \ + echo $${rootme}/../gcc/xgcc -B$${rootme}/../gcc/ -idirafter $${rootme}/newlib/targ-include -idirafter $${rootsrc}/../newlib/libc/include -nostdinc -L$${rootme}/../newlib -B$${rootme}/../newlib/; \ else \ echo $${rootme}/../gcc/xgcc -B$${rootme}/../gcc/; \ fi; \ @@ -267,7 +267,7 @@ CXX = gcc CXX_FOR_TARGET = ` \ if [ -f $${rootme}/../gcc/Makefile ] ; then \ if [ -f $${rootme}/../newlib/Makefile ] ; then \ - echo $${rootme}/../gcc/xgcc -B$${rootme}/../gcc/ -idirafter $${rootme}/newlib/targ-include -idirafter $${rootsrc}/../newlib/libc/include -nostdinc -L$${rootme}/../../newlib -B$${rootme}/../../newlib/; \ + echo $${rootme}/../gcc/xgcc -B$${rootme}/../gcc/ -idirafter $${rootme}/newlib/targ-include -idirafter $${rootsrc}/../newlib/libc/include -nostdinc -L$${rootme}/../newlib -B$${rootme}/../newlib/; \ else \ echo $${rootme}/../gcc/xgcc -B$${rootme}/../gcc/; \ fi; \ @@ -1254,6 +1254,9 @@ mipsread.o: mipsread.c buildsym.h complaints.h $(bfd_h) $(defs_h) \ mipsv4-nat.o: mipsv4-nat.c $(defs_h) $(gdbcore_h) $(inferior_h) target.h +monitor.o: monitor.c monitor.h $(bfd_h) $(wait_h) $(defs_h) $(gdbcmd_h) \ + $(inferior_h) target.h serial.h terminal.h + news-xdep.o: news-xdep.c Onindy.o: nindy-share/Onindy.c $(wait_h) nindy-share/block_io.h \ @@ -1367,6 +1370,9 @@ remote-utils.o: remote-utils.c $(defs_h) $(gdbcmd_h) $(gdbcore_h) \ remote.o: remote.c $(bfd_h) $(wait_h) $(defs_h) $(gdbcmd_h) \ $(inferior_h) $(remote_utils_h) symfile.h terminal.h +rom68k-rom.o: rom68k-rom.c monitor.h $(bfd_h) $(wait_h) $(defs_h) $(gdbcmd_h) \ + $(inferior_h) target.h serial.h terminal.h + rs6000-nat.o: rs6000-nat.c $(bfd_h) $(defs_h) $(inferior_h) target.h rs6000-tdep.o: rs6000-tdep.c $(defs_h) $(gdbcore_h) $(inferior_h) \ diff --git a/gdb/array-rom.c b/gdb/array-rom.c index 6e5b943..adc0cc0 100644 --- a/gdb/array-rom.c +++ b/gdb/array-rom.c @@ -27,7 +27,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ extern int baud_rate; void array_open(); -void monitor_open(); /* * this array of registers need to match the indexes used by GDB. The @@ -45,14 +44,15 @@ extern int mips_set_processor_type(); * strings. We also need a CR or LF on the end. */ -struct target_ops array_ops = { +static struct target_ops array_ops = +{ "array", "Debug using the standard GDB remote protocol for the Array Tech target.", "Debug using the standard GDB remote protocol for the Array Tech target.\n\ Specify the serial device it is connected to (e.g. /dev/ttya).", array_open, monitor_close, - monitor_attach, + NULL, monitor_detach, monitor_resume, monitor_wait, @@ -89,7 +89,11 @@ Specify the serial device it is connected to (e.g. /dev/ttya).", OPS_MAGIC, /* Always the last thing */ }; -struct monitor_ops array_cmds = { +static char *array_loadtypes[] = {"none", "srec", "default", NULL}; +static char *array_loadprotos[] = {"none", NULL}; + +static struct monitor_ops array_cmds = +{ 0, /* 1 for ASCII, 0 for binary */ "$?#b8+\n", /* monitor init string */ "go %x\n", /* execute or usually GO command */ @@ -123,10 +127,10 @@ struct monitor_ops array_cmds = { "", /* end-of-command delimitor */ "", /* optional command terminator */ &array_ops, /* target operations */ - "none,srec,default", /* load types */ - "none", /* load protocols */ + array_loadtypes, /* loadtypes */ + array_loadprotos, /* loadprotos */ "4800", /* supported baud rates */ - 2, /* number of stop bits */ + SERIAL_2_STOPBITS, /* number of stop bits */ array_regnames /* registers names */ }; @@ -141,12 +145,7 @@ array_open(args, from_tty) tmp_mips_processor_type = "lsi33k"; /* change the default from r3051 */ mips_set_processor_type_command ("lsi33k", 0); - baud_rate = 4800; /* this is the only supported baud rate */ - - target_preopen(from_tty); - push_target (&array_ops); - push_monitor (&array_cmds); - monitor_open (args, "array", from_tty); + monitor_open (args, &array_cmds, from_tty); } /* @@ -156,6 +155,7 @@ void _initialize_array () { add_target (&array_ops); + baud_rate = 4800; /* this is the only supported baud rate */ } diff --git a/gdb/monitor.c b/gdb/monitor.c index af2a4a4..270f107 100644 --- a/gdb/monitor.c +++ b/gdb/monitor.c @@ -39,36 +39,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "command.h" #include "serial.h" #include "monitor.h" -#include "remote-utils.h" +#include "gdbcmd.h" +#include "inferior.h" -#if !defined (HAVE_TERMIOS) && !defined (HAVE_TERMIO) && !defined (HAVE_SGTTY) -#define HAVE_SGTTY -#endif - -#ifdef HAVE_TERMIOS -#include <termio.h> -#include <termios.h> -# define TERMINAL struct termios -#else -#include <fcntl.h> -# define TERMINAL struct sgttyb -#endif -#include "terminal.h" -#ifndef CSTOPB -#define CSTOPB 0x00000040 -#endif - -static const char hexchars[] = "0123456789abcdef"; -static char *hex2mem (); - -static void make_xmodem_packet(); -static void print_xmodem_packet(); -static void make_gdb_packet(); -static unsigned long ascii2hexword(); -static char *hexword2ascii(); -static int tohex(); -static int to_hex(); -static int from_hex(); +static void make_xmodem_packet (); +static void print_xmodem_packet (); static void monitor_load_ascii_srec PARAMS ((char *file, int fromtty)); @@ -76,32 +51,24 @@ static int monitor_make_srec PARAMS ((char *buffer, int type, CORE_ADDR memaddr, unsigned char *myaddr, int len)); -static unsigned long ascii2hexword (); -static char *hexword2ascii (); -static int tohex (); -static int to_hex (); +static void monitor_fetch_register PARAMS ((int regno)); +static void monitor_store_register PARAMS ((int regno)); + static int from_hex (); +static unsigned long get_hex_word PARAMS ((void)); struct monitor_ops *current_monitor; -extern struct cmd_list_element *setlist; -extern struct cmd_list_element *unsetlist; - -struct cmd_list_element *showlist; - -extern char *version; -extern char *host_name; -extern char *target_name; +static char *loadtype_str = "srec"; +static char *loadproto_str = "none"; static int hashmark; /* flag set by "set hash" */ -#define LOG_FILE "monitor.log" -#if defined (LOG_FILE) -FILE *log_file; -#endif - static int timeout = 30; +static int expect PARAMS ((char *string, char *buf, int buflen)); +static int expect_prompt PARAMS ((char *buf, int buflen)); + /* Having this larger than 400 causes us to be incompatible with m68k-stub.c and i386-stub.c. Normally, no one would notice because it only matters for writing large chunks of memory (e.g. in downloads). Also, this needs @@ -114,16 +81,9 @@ static int timeout = 30; that monitor_open knows that we don't have a file open when the program starts. */ -serial_t monitor_desc = NULL; - -/* sets the download protocol, choices are srec, generic, boot */ -char *loadtype; +static serial_t monitor_desc = NULL; -static char *loadtype_str; -static char *loadproto_str; -static void set_loadtype_command(); -static void set_loadproto_command(); -static void monitor_load_srec(); +static void monitor_load_srec (); /* These definitions are for xmodem protocol. */ @@ -138,77 +98,34 @@ static void monitor_load_srec(); #define XMODEM_PACKETSIZE 131 /* the packet size is ALWAYS 132 (zero based) */ #define XMODEM 1 -/* - * set_loadtype_command -- set the type for downloading. Check to make - * sure you have a support protocol for this target. - */ +static unsigned char output_buf[0x200]; +static int obp; + static void -set_loadtype_command (ignore, from_tty, c) - char *ignore; - int from_tty; - struct cmd_list_element *c; +debug_save_output (buf, len) + unsigned char *buf; + int len; { - char *tmp; - char *type; +#if 0 + for (; len > 0; len--) + output_buf[obp++ & 0x1ff] = *buf++; +#else + fputs_unfiltered (buf, gdb_stdout); +#endif +} - if (current_monitor == 0x0) - return; +static unsigned char input_buf[0x200]; +static int ibp; - if (STREQ (LOADTYPES, "")) { - error ("No loadtype set"); - return; - } - - tmp = savestring (LOADTYPES, strlen(LOADTYPES)); - type = strtok(tmp, ","); - if (STREQ (type, (*(char **) c->var))) { - loadtype_str = savestring (*(char **) c->var, strlen (*(char **) c->var)); - return; - } - - while ((type = strtok (NULL, ",")) != (char *)NULL) { - if (STREQ (type, (*(char **) c->var))) - loadtype_str = savestring (*(char **) c->var, strlen (*(char **) c->var)); - return; - } - free (tmp); - error ("Loadtype \"%s\" does not exist.", (*(char **) c->var)); -} -/* - * set_loadproto_command -- set the protocol for downloading. Check to make - * sure you have a supported protocol for this target. - */ static void -set_loadproto_command (ignore, from_tty, c) - char *ignore; - int from_tty; - struct cmd_list_element *c; +debug_save_input_char (c) + int c; { - char *tmp; - char *type; - - if (current_monitor == 0x0) - return; - - if (STREQ (LOADPROTOS, "")) { - error ("No load protocols set"); - return; - } - - tmp = savestring (LOADPROTOS, strlen(LOADPROTOS)); - type = strtok(tmp, ","); - if (STREQ (type, (*(char **) c->var))) { - loadproto_str = savestring (*(char **) c->var, strlen (*(char **) c->var)); - return; - } - - while ((type = strtok (NULL, ",")) != (char *)NULL) { - if (STREQ (type, (*(char **) c->var))) - loadproto_str = savestring (*(char **) c->var, strlen (*(char **) c->var)); - return; - } - free (tmp); - error ("Load protocol \"%s\" does not exist.", (*(char **) c->var)); +#if 0 + input_buf[ibp++ & 0x1ff] = c; +#else + fputc_unfiltered (c, gdb_stdout); +#endif } /* printf_monitor -- send data to monitor. Works just like printf. */ @@ -227,12 +144,13 @@ printf_monitor (va_alist) vsprintf (buf, pattern, args); - debuglogs (1, "printf_monitor(), Sending: \"%s\".", buf); + if (remote_debug > 0) + debug_save_output (buf, strlen (buf)); if (strlen (buf) > PBUFSIZ) error ("printf_monitor(): string too long"); if (SERIAL_WRITE(monitor_desc, buf, strlen (buf))) - fprintf (stderr, "SERIAL_WRITE failed: %s\n", safe_strerror (errno)); + fprintf_unfiltered (stderr, "SERIAL_WRITE failed: %s\n", safe_strerror (errno)); } /* Send raw data to monitor. */ @@ -243,102 +161,9 @@ write_monitor (data, len) int len; { if (SERIAL_WRITE (monitor_desc, data, len)) - fprintf (stderr, "SERIAL_WRITE failed: %s\n", safe_strerror(errno)); + fprintf_unfiltered (stderr, "SERIAL_WRITE failed: %s\n", safe_strerror(errno)); *(data + len + 1) = '\0'; - debuglogs (1, "write_monitor(), Sending: \"%s\".", data); -} - -/* Deal with debugging info to multiple sources. This takes two real - args, the first one is the level to be compared against the - sr_get_debug() value, the second arg is a printf buffer and args to - be formatted and printed. A CR is added after each string is - printed. */ - -void -debuglogs (va_alist) - va_dcl -{ - va_list args; - char *pattern, *p; - unsigned char buf[PBUFSIZ]; - char newbuf[PBUFSIZ]; - int level, i; - - va_start(args); - - level = va_arg(args, int); /* get the debug level */ - if ((level < 0) || (level > 100)) - { - error ("Bad argument passed to debuglogs(), needs debug level"); - return; - } - - pattern = va_arg(args, char *); /* get the printf style pattern */ - - vsprintf(buf, pattern, args); /* format the string */ - - /* convert some characters so it'll look right in the log */ - p = newbuf; - for (i = 0 ; buf[i] != '\0'; i++) - { - if (i > PBUFSIZ) - error ("Debug message too long"); - switch (buf[i]) - { - case '\n': /* newlines */ - *p++ = '\\'; - *p++ = 'n'; - continue; - case '\r': /* carriage returns */ - *p++ = '\\'; - *p++ = 'r'; - continue; - case '\033': /* escape */ - *p++ = '\\'; - *p++ = 'e'; - continue; - case '\t': /* tab */ - *p++ = '\\'; - *p++ = 't'; - continue; - case '\b': /* backspace */ - *p++ = '\\'; - *p++ = 'b'; - continue; - default: /* no change */ - *p++ = buf[i]; - } - - /* modify control characters */ - if (buf[i] < 26) - { - *p++ = '^'; - *p++ = buf[i] + 'A'; - continue; - } - - /* modify control characters */ - if (buf[i] >= 128) - { - *p++ = '!'; - *p++ = buf[i] + 'A'; - continue; - } - } - *p = '\0'; /* terminate the string */ - - if (sr_get_debug () > level) - printf_unfiltered ("%s\n", newbuf); - -#ifdef LOG_FILE /* write to the monitor log */ - if (log_file != 0x0) - { - fputs (newbuf, log_file); - fputc ('\n', log_file); - fflush (log_file); - } -#endif } /* Read a character from the remote system, doing all the fancy @@ -352,16 +177,8 @@ readchar (timeout) c = SERIAL_READCHAR (monitor_desc, timeout); - if (sr_get_debug () > 5) - { - putchar (c & 0x7f); - debuglogs (5, "readchar: timeout = %d\n", timeout); - } - -#ifdef LOG_FILE - if (isascii (c)) - putc(c & 0x7f, log_file); -#endif + if (remote_debug > 0) + debug_save_input_char (c & 0x7f); if (c >= 0) return c & 0x7f; @@ -371,54 +188,57 @@ readchar (timeout) if (timeout == 0) return c; /* Polls shouldn't generate timeout errors */ error ("Timeout reading from remote system."); -#ifdef LOG_FILE - fputs ("ERROR: Timeout reading from remote system", log_file); -#endif } perror_with_name ("remote-monitor"); } -/* Scan input from the remote system, until STRING is found. If - DISCARD is non-zero, then discard non-matching input, else print it - out. Let the user break out immediately. */ +/* Scan input from the remote system, until STRING is found. If BUF is non- + zero, then collect input until either STRING has been collected or BUFLEN + chars have been collected. If input overflows BUF because STRING can't be + found, return -1, else return number of chars in BUF (including STRING). */ -static void -expect (string, discard) +static int +expect (string, buf, buflen) char *string; - int discard; + char *buf; + int buflen; { char *p = string; + int obuflen = buflen; int c; - debuglogs (1, "Expecting \"%s\".", string); - immediate_quit = 1; while (1) { - c = readchar (timeout); - if (!isascii (c)) - continue; - if (c == *p++) + if (buf) { - if (*p == '\0') + if (buflen <= 0) { immediate_quit = 0; - debuglogs (4, "Matched"); - return; + return -1; } + + c = readchar (timeout); + *buf++ = c; + buflen--; } else + c = readchar (timeout); + + if (c == *p++) { - if (!discard) + if (*p == '\0') { - putc_unfiltered (c); -#if 0 - fwrite(string, 1, (p - 1) - string, stdout); - putchar ((char)c); - fflush (stdout); -#endif + immediate_quit = 0; + + return obuflen - buflen; } + } + else + { p = string; + if (c == *p) + p++; } } } @@ -438,11 +258,12 @@ expect (string, discard) necessary to prevent getting into states from which we can't recover. */ -static void -expect_prompt (discard) - int discard; +static int +expect_prompt (buf, buflen) + char *buf; + int buflen; { - expect (PROMPT, discard); + return expect (PROMPT, buf, buflen); } /* Ignore junk characters. Returns a 1 if junk, 0 otherwise. */ @@ -459,12 +280,8 @@ junk (ch) case '\t': case '\r': case '\n': - if (sr_get_debug () > 5) - debuglogs (5, "Ignoring \'%c\'.", ch); return 1; default: - if (sr_get_debug () > 5) - debuglogs (5, "Accepting \'%c\'.", ch); return 0; } } @@ -483,22 +300,6 @@ get_hex_digit (ignore) ch = readchar (timeout); if (junk (ch)) continue; - if (sr_get_debug () > 4) - { - debuglogs (4, "get_hex_digit() got a 0x%x(%c)", ch, ch); - } - else - { -#ifdef LOG_FILE /* write to the monitor log */ - if (log_file != 0x0) - { - fputs ("get_hex_digit() got a 0x", log_file); - fputc (ch, log_file); - fputc ('\n', log_file); - fflush (log_file); - } -#endif - } if (ch >= '0' && ch <= '9') return ch - '0'; @@ -510,8 +311,7 @@ get_hex_digit (ignore) ; else { - expect_prompt (1); - debuglogs (4, "Invalid hex digit from remote system. (0x%x)", ch); + expect_prompt (NULL, 0); error ("Invalid hex digit from remote system. (0x%x)", ch); } } @@ -527,44 +327,34 @@ get_hex_byte (byt) int val; val = get_hex_digit (1) << 4; - debuglogs (4, "get_hex_byte() -- Read first nibble 0x%x", val); val |= get_hex_digit (0); - debuglogs (4, "get_hex_byte() -- Read second nibble 0x%x", val); *byt = val; - - debuglogs (4, "get_hex_byte() -- Read a 0x%x", val); } /* Get N 32-bit words from remote, each preceded by a space, and put them in registers starting at REGNO. */ -static int +static unsigned long get_hex_word () { - long val; + unsigned long val; int i; + int ch; - val = 0; + do + ch = readchar (timeout); + while (isspace(ch)); -#if 0 - if (HOST_BYTE_ORDER == BIG_ENDIAN) - { -#endif - for (i = 0; i < 8; i++) - val = (val << 4) + get_hex_digit (i == 0); -#if 0 - } - else + val = from_hex (ch); + + for (i = 7; i >= 1; i--) { - for (i = 7; i >= 0; i--) - val = (val << 4) + get_hex_digit (i == 0); + ch = readchar (timeout); + if (!isxdigit (ch)) + break; + val = (val << 4) | from_hex (ch); } -#endif - - debuglogs (4, "get_hex_word() got a 0x%x for a %s host.", - val, - (HOST_BYTE_ORDER == BIG_ENDIAN) ? "big endian" : "little endian"); return val; } @@ -612,28 +402,36 @@ monitor_create_inferior (execfile, args, env) /* Open a connection to a remote debugger. NAME is the filename used for communication. */ -static int baudrate = 9600; -static char dev_name[100]; +static char *dev_name; void -monitor_open (args, name, from_tty) +monitor_open (args, mon_ops, from_tty) char *args; - char *name; + struct monitor_ops *mon_ops; int from_tty; { - TERMINAL *temptempio; + struct target_ops *targ_ops; + char *name; + int i; + + targ_ops = mon_ops->target; + name = targ_ops->to_shortname; - if (args == NULL) + if (!args) error ("Use `target %s DEVICE-NAME' to use a serial port, or \n\ `target %s HOST-NAME:PORT-NUMBER' to use a network connection.", name, name); -/* if (is_open) */ - monitor_close (0); + target_preopen (from_tty); + + unpush_target (targ_ops); + + if (dev_name) + free (dev_name); + dev_name = strsave (args); - strcpy (dev_name, args); monitor_desc = SERIAL_OPEN (dev_name); - if (monitor_desc == NULL) + if (!monitor_desc) perror_with_name (dev_name); if (baud_rate != -1) @@ -641,65 +439,59 @@ monitor_open (args, name, from_tty) if (SERIAL_SETBAUDRATE (monitor_desc, baud_rate)) { SERIAL_CLOSE (monitor_desc); - perror_with_name (name); + perror_with_name (dev_name); } } SERIAL_RAW (monitor_desc); + SERIAL_FLUSH_INPUT (monitor_desc); + /* some systems only work with 2 stop bits */ -#if !defined(__GO32__) && !defined(GDB_TARGET_IS_PA_ELF) - if (STOPBITS == 2) { - if (!strchr (dev_name, ':')) { /* don't set for a tcp connection */ - temptempio = (TERMINAL *) SERIAL_GET_TTY_STATE (monitor_desc); -#ifdef HAVE_SGTTY - temptempio->sg_cflag |= baud_rate | CSTOPB; -#else - temptempio->c_cflag |= baud_rate | CSTOPB; -#endif - SERIAL_SET_TTY_STATE (monitor_desc, temptempio); - debuglogs (4, "Set serial port to 2 stop bits"); - } - } -#endif /* __GO32__ */ - -#if defined (LOG_FILE) - log_file = fopen (LOG_FILE, "w"); - if (log_file == NULL) - perror_with_name (LOG_FILE); - fprintf_filtered (log_file, "GDB %s (%s", version, host_name); - fprintf_filtered (log_file, " --target %s)\n", target_name); - fprintf_filtered (log_file, "Remote target %s connected to %s\n\n", - TARGET_NAME, dev_name); -#endif + + SERIAL_SETSTOPBITS (monitor_desc, mon_ops->stopbits); + + current_monitor = mon_ops; /* see if the target is alive. For a ROM monitor, we can just try to - force the prompt to print a few times. FOr the GDB remote - protocol, the application being debugged is sitting at a - breakpoint and waiting for GDB to initialize the connection. We - force it to give us an empty packet to see if it's alive. */ + force the prompt to print a few times. */ - if (GDBPROTO) - { - debuglogs (3, "Trying to ACK the target's debug stub"); - printf_monitor (INIT_CMD); /* ask for the last signal */ - expect ("$S05#b8",0); /* look for a response */ - printf_monitor ("+"); /* ask for the last signal */ - expect_prompt (1); /* See if we get a prompt */ - } - else - { - /* wake up the monitor and see if it's alive */ - printf_monitor (INIT_CMD); - expect_prompt (1); /* See if we get a prompt */ + /* wake up the monitor and see if it's alive */ + printf_monitor (mon_ops->init); + expect_prompt (NULL, 0); /* See if we get a prompt */ - /* try again to be sure */ - printf_monitor (INIT_CMD); - expect_prompt (1); /* See if we get a prompt */ - } + /* try again to be sure */ + printf_monitor (mon_ops->init); + expect_prompt (NULL, 0); /* See if we get a prompt */ + + /* Setup the suffixes for the `set remoteloadtype' command */ + + add_show_from_set (add_set_enum_cmd ("remoteloadtype", no_class, + mon_ops->loadtypes, + (char *)&loadtype_str, + "Set the remote load type.", + &setlist), + &showlist); + + /* Setup the suffixes for the `set remoteloadprotocol' command */ + + add_show_from_set (add_set_enum_cmd ("remoteloadprotocol", no_class, + mon_ops->loadprotos, + (char *)&loadproto_str, + "Set the remote load protocol.", + &setlist), + &showlist); if (from_tty) - printf ("Remote target %s connected to %s\n", TARGET_NAME, dev_name); + printf_unfiltered ("Remote target %s connected to %s\n", name, dev_name); + + push_target (targ_ops); + + inferior_pid = 42000; /* Make run command think we are busy... */ + + printf_monitor ("\r"); + + start_remote (); } /* Close out all files and local state before this target loses @@ -709,53 +501,24 @@ void monitor_close (quitting) int quitting; { - SERIAL_CLOSE (monitor_desc); + if (monitor_desc) + SERIAL_CLOSE (monitor_desc); monitor_desc = NULL; - - debuglogs (1, "monitor_close (quitting=%d)", quitting); - -#if defined (LOG_FILE) - if (log_file) - { - if (ferror (log_file)) - printf_filtered ("Error writing log file.\n"); - if (fclose (log_file) != 0) - printf_filtered ("Error closing log file.\n"); - } -#endif } /* Terminate the open connection to the remote debugger. Use this when you want to detach and do something else with your gdb. */ void -monitor_detach (from_tty) +monitor_detach (args, from_tty) + char *args; int from_tty; { - debuglogs (1, "monitor_detach ()"); - pop_target (); /* calls monitor_close to do the real work */ if (from_tty) - printf ("Ending remote %s debugging\n", target_shortname); + printf_unfiltered ("Ending remote %s debugging\n", target_shortname); } -/* Attach GDB to the target. */ - -void -monitor_attach (args, from_tty) - char *args; - int from_tty; -{ - if (from_tty) - printf ("Starting remote %s debugging\n", target_shortname); - - debuglogs (1, "monitor_attach (args=%s)", args); - - printf_monitor (GO_CMD); - /* swallow the echo. */ - expect (GO_CMD, 1); -} - /* Tell the remote machine to resume. */ void @@ -763,8 +526,6 @@ monitor_resume (pid, step, sig) int pid, step; enum target_signal sig; { - debuglogs (1, "monitor_resume (step=%d, sig=%d)", step, sig); - if (step) printf_monitor (STEP_CMD); else @@ -781,22 +542,19 @@ monitor_wait (pid, status) { int old_timeout = timeout; - debuglogs(1, "monitor_wait (), printing extraneous text."); - status->kind = TARGET_WAITKIND_EXITED; status->value.integer = 0; - timeout = 0; /* Don't time out -- user program is running. */ + timeout = -1; /* Don't time out -- user program is running. */ - expect_prompt (0); /* Wait for prompt, outputting extraneous text */ - debuglogs (4, "monitor_wait(), got the prompt."); + expect_prompt (NULL, 0); /* Wait for prompt, outputting extraneous text */ status->kind = TARGET_WAITKIND_STOPPED; status->value.sig = TARGET_SIGNAL_TRAP; timeout = old_timeout; - return 0; + return inferior_pid; } /* Return the name of register number regno in the form input and output by @@ -807,197 +565,141 @@ static char * get_reg_name (regno) int regno; { - static char buf[50]; - const char *p; - char *b; - - b = buf; - - if (regno < 0) - return (""); + if (regno < 0 || regno > NUM_REGS) + return NULL; + else + return REGNAMES (regno); +} - for (p = REGNAMES (regno); *p; p++) - *b++ = tolower (*p); +/* Fetch register REGNO, or all registers if REGNO is -1. Returns + errno value. */ - *b = '\000'; +static void +monitor_fetch_register (regno) + int regno; +{ + unsigned LONGEST val; + unsigned char regbuf[MAX_REGISTER_RAW_SIZE]; + char buf[200]; + char *p, *p1; + char *name; + int resp_len; - debuglogs (5, "Got name \"%s\" from regno #%d.", buf, regno); + name = get_reg_name (regno); - return buf; -} + if (!name) + return; -/* Read the remote registers into the block regs. */ + /* send the register examine command */ -void -monitor_fetch_registers (ignored) - int ignored; -{ - int regno, i; - unsigned char packet[PBUFSIZ]; - char regs[REGISTER_BYTES]; + printf_monitor (current_monitor->getreg.cmd, name); - debuglogs (1, "monitor_fetch_registers (ignored=%d)\n", ignored); +/* If TERM is present, we wait for that to show up. Also, (if TERM is + present), we will send TERM_CMD if that is present. In any case, we collect + all of the output into buf, and then wait for the normal prompt. */ - memset (packet, 0, PBUFSIZ); - if (GDBPROTO) + if (current_monitor->getreg.term) { - /* Unimplemented registers read as all bits zero. */ - memset (regs, 0, REGISTER_BYTES); - make_gdb_packet (packet, "g"); - if (monitor_send_packet (packet) == 0) - error ("Couldn't transmit packet\n"); - if (monitor_get_packet (packet) == 0) - error ("Couldn't receive packet\n"); - /* FIXME: read bytes from packet */ - debuglogs (4, "monitor_fetch_registers: Got a \"%s\" back\n", packet); - for (regno = 0; regno <= PC_REGNUM+4; regno++) + resp_len = expect (current_monitor->getreg.term, buf, sizeof buf); /* get response */ + + if (resp_len <= 0) + error ("monitor_fetch_register (%d): excessive response from monitor: %.*s.", resp_len, buf); + + if (current_monitor->getreg.term_cmd) { - /* supply register stores in target byte order, so swap here */ - /* FIXME: convert from ASCII hex to raw bytes */ - i = ascii2hexword (packet + (regno * 8)); - debuglogs (5, "Adding register %d = %x\n", regno, i); - SWAP_TARGET_AND_HOST (&i, 4); - supply_register (regno, (char *)&i); + SERIAL_WRITE (monitor_desc, current_monitor->getreg.term_cmd, + strlen (current_monitor->getreg.term_cmd)); + expect_prompt (NULL, 0); } } else + resp_len = expect_prompt (buf, sizeof buf); /* get response */ + + + /* If RESP_DELIM is specified, we search for that as a leading delimiter for + the register value. Otherwise, we just start searching from the start of + the buf. */ + + if (current_monitor->getreg.resp_delim) { - for (regno = 0; regno <= PC_REGNUM; regno++) - monitor_fetch_register (regno); + p = strstr (buf, current_monitor->getreg.resp_delim); + if (!p) + error ("monitor_fetch_register (%d): bad response from monitor: %.*s.", resp_len, buf); + p += strlen (current_monitor->getreg.resp_delim); } -} + else + p = buf; -/* Fetch register REGNO, or all registers if REGNO is -1. Returns - errno value. */ + val = strtoul (p, &p1, 16); -void -monitor_fetch_register (regno) - int regno; -{ - int val; - char *name; + if (val == 0 && p == p1) + error ("monitor_fetch_register (%d): bad value from monitor: %.*s.", + resp_len, buf); - debuglogs (1, "monitor_fetch_register (reg=%s)", get_reg_name (regno)); + /* supply register stores in target byte order, so swap here */ - if (regno < 0) - monitor_fetch_registers (); - else - { - name = get_reg_name (regno); - - if (STREQ (name, "")) - return; - - printf_monitor (ROMCMD (GET_REG), name); /* send the command */ - expect (name, 1); /* then strip the leading garbage */ - if (*ROMDELIM (GET_REG) != 0) - expect (ROMDELIM (GET_REG), 1); - - val = get_hex_word (); /* get the value, ignore junk */ - - /* supply register stores in target byte order, so swap here */ - SWAP_TARGET_AND_HOST (&val, 4); - supply_register (regno, (char *) &val); - - if (*ROMDELIM(GET_REG) != 0) - { - /*** expect (ROMRES(GET_REG)); ***/ - printf_monitor (CMD_END); - } - expect_prompt (1); - } + store_unsigned_integer (regbuf, REGISTER_RAW_SIZE (regno), val); + + supply_register (regno, regbuf); } -/* Store the remote registers. */ +/* Read the remote registers into the block regs. */ void -monitor_store_registers (ignored) - int ignored; +monitor_fetch_registers (regno) + int regno; { - int regno; - unsigned long i; - char packet[PBUFSIZ]; - char buf[PBUFSIZ]; - char num[9]; - - debuglogs (1, "monitor_store_registers()"); - - if (GDBPROTO) + if (regno >= 0) { - memset (packet, 0, PBUFSIZ); - memset (buf, 0, PBUFSIZ); - buf[0] = 'G'; - - /* Unimplemented registers read as all bits zero. */ - /* FIXME: read bytes from packet */ - for (regno = 0; regno < 41; regno++) /* FIXME */ - { - /* supply register stores in target byte order, so swap here */ - /* FIXME: convert from ASCII hex to raw bytes */ - i = (unsigned long)read_register (regno); -#if 0 - SWAP_TARGET_AND_HOST (&i, 4); -#endif - hexword2ascii (num, i); - strcpy (buf + (regno * 8) + 1, num); - } - - *(buf + (regno * 8) + 2) = 0; - make_gdb_packet (packet, buf); - if (monitor_send_packet (packet) == 0) - error ("Couldn't transmit packet\n"); - if (monitor_get_packet (packet) == 0) - error ("Couldn't receive packet\n"); - } - else - { - for (regno = 0; regno <= PC_REGNUM; regno++) - monitor_store_register(regno); + monitor_fetch_register (regno); + return; } - registers_changed (); + for (regno = 0; regno < NUM_REGS; regno++) + monitor_fetch_register (regno); } /* Store register REGNO, or all if REGNO == 0. Return errno value. */ -void +static void monitor_store_register (regno) int regno; { char *name; - int i; + unsigned LONGEST val; - i = read_register (regno); + name = get_reg_name (regno); + if (!name) + return; - debuglogs (1, "monitor_store_register (regno=%d)", regno); + val = read_register (regno); - if (regno < 0) - monitor_store_registers (); - else + /* send the register deposit command */ + + printf_monitor (current_monitor->setreg.cmd, name, val); + +/* It's possible that there are actually some monitors out there that will + prompt you when you set a register. In that case, you may need to add some + code here to deal with TERM and TERM_CMD (see monitor_fetch_register to get + an idea of what's needed...) */ + + expect_prompt (NULL, 0); +} + +/* Store the remote registers. */ + +void +monitor_store_registers (regno) + int regno; +{ + if (regno >= 0) { - debuglogs (3, "Setting register %s to 0x%x", - get_reg_name (regno), read_register (regno)); - - name = get_reg_name (regno); - if (STREQ (name, "")) - return; - printf_monitor (ROMCMD (SET_REG), name, read_register (regno)); - expect (name, 1); /* strip the leading garbage */ - if (*ROMDELIM (SET_REG) != 0) - { - expect (ROMDELIM (SET_REG), 1); - get_hex_word (1); - printf_monitor ("%d%s\n", i, CMD_END); - } - expect_prompt (1); + monitor_store_register (regno); + return; } - return; -#if 0 - printf_monitor (SET_REG, get_reg_name (regno), - read_register (regno)); - expect_prompt (1); -#endif + for (regno = 0; regno < NUM_REGS; regno++) + monitor_store_register (regno); } /* Get ready to modify the registers array. On machines which store @@ -1015,189 +717,100 @@ monitor_prepare_to_store () void monitor_files_info () { - printf ("\tAttached to %s at %d baud.\n", dev_name, baudrate); + printf_unfiltered ("\tAttached to %s at %d baud.\n", dev_name, baud_rate); } -/* Copy LEN bytes of data from debugger memory at MYADDR to inferior's - memory at MEMADDR. Returns length moved. */ - -int -monitor_write_inferior_memory (memaddr, myaddr, len) +static int +monitor_write_memory (memaddr, myaddr, len) CORE_ADDR memaddr; unsigned char *myaddr; int len; { - unsigned long i; - int j; - char packet[PBUFSIZ]; - char buf[PBUFSIZ]; - char num[9]; - char *p; - - debuglogs (1, "monitor_write_inferior_memory (memaddr=0x%x, myaddr=0x%x, len=%d)", - memaddr, myaddr, len); - memset (buf, '\0', PBUFSIZ); /* this also sets the string terminator */ - p = buf; + /* send the memory deposit command */ - if (GDBPROTO) - { - *p++ = 'M'; /* The command to write memory */ - hexword2ascii (num, memaddr); /* convert the address */ - strcpy (p, num); /* copy the address */ - p += 8; - *p++ = ','; /* add comma delimeter */ - hexword2ascii (num, len); /* Get the length as a 4 digit number */ - *p++ = num[4]; - *p++ = num[5]; - *p++ = num[6]; - *p++ = num[7]; - *p++ = ':'; /* add the colon delimeter */ - for (j = 0; j < len; j++) - { /* copy the data in after converting it */ - *p++ = tohex ((myaddr[j] >> 4) & 0xf); - *p++ = tohex (myaddr[j] & 0xf); - } + printf_monitor (current_monitor->setmem.cmd, memaddr, *myaddr); - make_gdb_packet (packet, buf); - if (monitor_send_packet (packet) == 0) - error ("Couldn't transmit packet\n"); - if (monitor_get_packet (packet) == 0) - error ("Couldn't receive packet\n"); - } - else - { - for (i = 0; i < len; i++) - { - printf_monitor (ROMCMD (SET_MEM), memaddr + i, myaddr[i]); - if (*ROMDELIM (SET_MEM) != 0) - { - expect (ROMDELIM (SET_MEM), 1); - expect (CMD_DELIM); - printf_monitor ("%x", myaddr[i]); - } - /*** printf_monitor ("%x", myaddr[i]); ***/ - if (sr_get_debug() > 1) - printf ("\nSet 0x%x to 0x%x\n", memaddr + i, myaddr[i]); - if (*ROMDELIM (SET_MEM) != 0) - { - expect (CMD_DELIM); - printf_monitor (CMD_END); - } - expect_prompt (1); - } - } - return len; +/* It's possible that there are actually some monitors out there that will + prompt you when you deposit to memory. In that case, you may need to add + some code here to deal with TERM and TERM_CMD (see monitor_read_memory to + get an idea of what's needed...) */ + + expect_prompt (NULL, 0); + + return 1; } -/* Read LEN bytes from inferior memory at MEMADDR. Put the result at - debugger address MYADDR. Returns length moved. */ +/* Copy LEN bytes of data from debugger memory at MYADDR to inferior's memory + at MEMADDR. Returns length moved. Currently, we only do one byte at a + time. */ -int -monitor_read_inferior_memory(memaddr, myaddr, len) +static int +monitor_read_memory (memaddr, myaddr, len) CORE_ADDR memaddr; char *myaddr; int len; { - int i, j; - char buf[20]; - char packet[PBUFSIZ]; - - /* Number of bytes read so far. */ - int count; - - /* Starting address of this pass. */ - unsigned long startaddr; - - /* Starting address of this pass. */ - unsigned long endaddr; - - /* Number of bytes to read in this pass. */ - int len_this_pass; - - debuglogs (1, "monitor_read_inferior_memory (memaddr=0x%x, myaddr=0x%x, len=%d)", memaddr, myaddr, len); - - /* Note that this code works correctly if startaddr is just less - than UINT_MAX (well, really CORE_ADDR_MAX if there was such a - thing). That is, something like - monitor_read_bytes (CORE_ADDR_MAX - 4, foo, 4) - works--it never adds len To memaddr and gets 0. */ - /* However, something like - monitor_read_bytes (CORE_ADDR_MAX - 3, foo, 4) - doesn't need to work. Detect it and give up if there's an attempt - to do that. */ - if (((memaddr - 1) + len) < memaddr) - { - errno = EIO; - return 0; - } - - startaddr = memaddr; - count = 0; - while (count < len) + unsigned LONGEST val; + unsigned char regbuf[MAX_REGISTER_RAW_SIZE]; + char buf[200]; + char *p, *p1; + char *name; + int resp_len; + + /* send the memory examine command */ + + printf_monitor (current_monitor->getmem.cmd, memaddr); + +/* If TERM is present, we wait for that to show up. Also, (if TERM is + present), we will send TERM_CMD if that is present. In any case, we collect + all of the output into buf, and then wait for the normal prompt. */ + + if (current_monitor->getmem.term) { - len_this_pass = 16; - if ((startaddr % 16) != 0) - len_this_pass -= startaddr % 16; - if (len_this_pass > (len - count)) - len_this_pass = (len - count); - - debuglogs (3, "Display %d bytes at %x for Big Endian host", - len_this_pass, startaddr); - - if (GDBPROTO) + resp_len = expect (current_monitor->getmem.term, buf, sizeof buf); /* get response */ + + if (resp_len <= 0) + error ("monitor_read_memory (%d): excessive response from monitor: %.*s.", resp_len, buf); + + if (current_monitor->getmem.term_cmd) { - for (i = 0; i < len_this_pass; i++) - { - sprintf (buf, "m%08x,%04x", startaddr, len_this_pass); - make_gdb_packet (packet, buf); - if (monitor_send_packet (packet) == 0) - error ("Couldn't transmit packet\n"); - if (monitor_get_packet (packet) == 0) - error ("Couldn't receive packet\n"); - debuglogs (4, "monitor_read_inferior: Got a \"%s\" back\n", - packet); - for (j = 0; j < len_this_pass ; j++) - { - myaddr[count++] = - from_hex (*(packet+(j*2))) * 16 - + from_hex (*(packet+(j*2)+1)); - debuglogs (5, "myaddr set to %x\n", myaddr[count-1]); - } - startaddr += 1; - } - } - else - { - for (i = 0; i < len_this_pass; i++) - { - printf_monitor (ROMCMD (GET_MEM), startaddr, startaddr); - sprintf (buf, ROMCMD (GET_MEM), startaddr, startaddr); - if (*ROMDELIM(GET_MEM) != 0) - { - expect (ROMDELIM(GET_MEM), 1); - } - else - { - sprintf (buf, ROMCMD (GET_MEM), startaddr, startaddr); - expect (buf,1); /* get the command echo */ - get_hex_word (1); /* strip away the address */ - } - get_hex_byte (&myaddr[count++]); /* get the value at this address */ - - if (*ROMDELIM(GET_MEM) != 0) - printf_monitor (CMD_END); - expect_prompt (1); - startaddr += 1; - } + SERIAL_WRITE (monitor_desc, current_monitor->getmem.term_cmd, + strlen (current_monitor->getmem.term_cmd)); + expect_prompt (NULL, 0); } } - return len; + else + resp_len = expect_prompt (buf, sizeof buf); /* get response */ + + /* If RESP_DELIM is specified, we search for that as a leading delimiter for + the register value. Otherwise, we just start searching from the start of + the buf. */ + + if (current_monitor->getmem.resp_delim) + { + p = strstr (buf, current_monitor->getmem.resp_delim); + if (!p) + error ("monitor_read_memory (%d): bad response from monitor: %.*s.", resp_len, buf); + p += strlen (current_monitor->getmem.resp_delim); + } + else + p = buf; + + val = strtoul (p, &p1, 16); + + if (val == 0 && p == p1) + error ("monitor_read_memory (%d): bad value from monitor: %.*s.", + resp_len, buf); + + *myaddr = val; + + return 1; /* Got 1 byte */ } /* FIXME-someday! merge these two. */ int -monitor_xfer_inferior_memory (memaddr, myaddr, len, write, target) +monitor_xfer_memory (memaddr, myaddr, len, write, target) CORE_ADDR memaddr; char *myaddr; int len; @@ -1205,9 +818,9 @@ monitor_xfer_inferior_memory (memaddr, myaddr, len, write, target) struct target_ops *target; /* ignored */ { if (write) - return monitor_write_inferior_memory (memaddr, myaddr, len); + return monitor_write_memory (memaddr, myaddr, len); else - return monitor_read_inferior_memory (memaddr, myaddr, len); + return monitor_read_memory (memaddr, myaddr, len); } void @@ -1230,10 +843,9 @@ monitor_mourn_inferior () generic_mourn_inferior (); /* Do all the proper things now */ } -#define MAX_MONITOR_BREAKPOINTS 16 +#define NUM_MONITOR_BREAKPOINTS 8 -extern int memory_breakpoint_size; -static CORE_ADDR breakaddr[MAX_MONITOR_BREAKPOINTS] = {0}; +static CORE_ADDR breakaddr[NUM_MONITOR_BREAKPOINTS] = {0}; /* Tell the monitor to add a breakpoint. */ @@ -1243,25 +855,21 @@ monitor_insert_breakpoint (addr, shadow) char *shadow; { int i; + static unsigned char break_insn[] = BREAKPOINT; - debuglogs (1, "monitor_insert_breakpoint() addr = 0x%x", addr); - - for (i = 0; i <= MAX_MONITOR_BREAKPOINTS; i++) + for (i = 0; i < NUM_MONITOR_BREAKPOINTS; i++) { if (breakaddr[i] == 0) { breakaddr[i] = addr; - if (sr_get_debug () > 4) - printf ("Breakpoint at %x\n", addr); - monitor_read_inferior_memory (addr, shadow, memory_breakpoint_size); + monitor_read_memory (addr, shadow, sizeof (break_insn)); printf_monitor (SET_BREAK_CMD, addr); - expect_prompt (1); + expect_prompt (NULL, 0); return 0; } } - fprintf (stderr, "Too many breakpoints (> 16) for monitor\n"); - return 1; + error ("Too many breakpoints (> %d) for monitor.", NUM_MONITOR_BREAKPOINTS); } /* Tell the monitor to remove a breakpoint. */ @@ -1273,9 +881,7 @@ monitor_remove_breakpoint (addr, shadow) { int i; - debuglogs (1, "monitor_remove_breakpoint() addr = 0x%x", addr); - - for (i = 0; i < MAX_MONITOR_BREAKPOINTS; i++) + for (i = 0; i < NUM_MONITOR_BREAKPOINTS; i++) { if (breakaddr[i] == addr) { @@ -1285,11 +891,11 @@ monitor_remove_breakpoint (addr, shadow) printf_monitor(CLR_BREAK_CMD, addr); else printf_monitor(CLR_BREAK_CMD, i); - expect_prompt (1); + expect_prompt (NULL, 0); return 0; } } - fprintf (stderr, "Can't find breakpoint associated with 0x%x\n", addr); + fprintf_unfiltered (stderr, "Can't find breakpoint associated with 0x%x\n", addr); return 1; } @@ -1315,13 +921,10 @@ monitor_load (file, fromtty) char *file; int fromtty; { - debuglogs (1, "Loading %s to monitor", file); - /* default, load a binary */ if (STREQ (loadtype_str, "default")) { - gr_load_image (file, fromtty); /* by writing it into memory */ - return; + error ("default load type not supported."); } /* load an srecord by converting */ @@ -1372,8 +975,6 @@ monitor_load_ascii_srec (file, fromtty) char buf[DOWNLOAD_LINE_SIZE]; int i, bytes_read; - debuglogs (1, "Loading an ASCII srecord file, %s.", file); - download = fopen (file, "r"); if (download == NULL) { @@ -1388,12 +989,12 @@ monitor_load_ascii_srec (file, fromtty) bytes_read = fread (buf, sizeof (char), DOWNLOAD_LINE_SIZE, download); if (hashmark) { - putchar ('.'); - fflush (stdout); + putchar_unfiltered ('.'); + gdb_flush (gdb_stdout); } if (SERIAL_WRITE (monitor_desc, buf, bytes_read)) { - fprintf (stderr, "SERIAL_WRITE failed: (while downloading) %s\n", + fprintf_unfiltered (stderr, "SERIAL_WRITE failed: (while downloading) %s\n", safe_strerror (errno)); break; } @@ -1408,11 +1009,11 @@ monitor_load_ascii_srec (file, fromtty) } if (hashmark) - putchar ('\n'); + putchar_unfiltered ('\n'); if (!feof (download)) error ("Never got EOF while downloading"); - expect_prompt (1); + expect_prompt (NULL, 0); fclose (download); } @@ -1429,8 +1030,6 @@ monitor_command (args, fromtty) p = PROMPT; - debuglogs (1, "monitor_command (args=%s)", args); - if (monitor_desc == NULL) error ("monitor target not open."); @@ -1439,7 +1038,7 @@ monitor_command (args, fromtty) printf_monitor ("%s\n", (args ? args : "")); - expect_prompt (0); + expect_prompt (NULL, 0); } /* Download a binary file by converting it to srecords. This @@ -1495,14 +1094,9 @@ monitor_load_srec (args, protocol) /* get the NAK from the target */ if (protocol == XMODEM) { - if (GETNAK) - { - debuglogs (3, "Got the NAK to start loading"); - } - else + if (!GETNAK) { printf_monitor ("%c", EOT); - debuglogs (3, "Never got the NAK to start loading"); error ("Never got the NAK to start loading"); } } @@ -1516,7 +1110,7 @@ monitor_load_srec (args, protocol) printf_filtered ("%s\t: 0x%4x .. 0x%4x ", s->name, s->vma, s->vma + s->_raw_size); - fflush (stdout); + gdb_flush (gdb_stdout); for (i = 0; i < s->_raw_size; i += srec_frame) { if (srec_frame > s->_raw_size - i) @@ -1535,7 +1129,6 @@ monitor_load_srec (args, protocol) /* Resend packet */ if (GETNAK) { - debuglogs (3, "Got a NAK, resending packet"); sleep (1); /* send it again */ write_monitor (packet, XMODEM_PACKETSIZE+1); @@ -1546,10 +1139,9 @@ monitor_load_srec (args, protocol) { /* assume we got an ACK */ if (hashmark) { - putc_unfiltered ('#'); + putchar_unfiltered ('#'); gdb_flush (gdb_stdout); } - debuglogs (3, "Got an ACK, sending next packet"); break; } } @@ -1565,21 +1157,17 @@ monitor_load_srec (args, protocol) } if (hashmark) { - putc_unfiltered ('#'); + putchar_unfiltered ('#'); gdb_flush (gdb_stdout); } type = 3; /* switch to a 4 byte address record */ - fflush (gdb_stdout); + gdb_flush (gdb_stdout); } free (buffer); } - else - { - debuglogs (3, "%s doesn't need to be loaded", s->name); - } s = s->next; } - putc_unfiltered ('\n'); + putchar_unfiltered ('\n'); /* Write a type 7 terminator record. no data for a type 7, and there is no data, so len is 0. */ @@ -1604,9 +1192,9 @@ monitor_load_srec (args, protocol) } if (hashmark) - putc_unfiltered ('\n'); + putchar_unfiltered ('\n'); - expect_prompt (); + expect_prompt (NULL, 0); } /* Get an ACK or a NAK from the target. returns 1 (true) or 0 (false) @@ -1631,35 +1219,23 @@ getacknak (byte) character = (char) readchar (0); if ((character == 0xfffffffe) || (character == 0x7f)) { /* empty uart */ - if (sr_get_debug () > 3) - putchar ('.'); - fflush (stdout); sleep (1); continue; } if (character == CANCEL) { /* target aborted load */ - expect_prompt (0); + expect_prompt (NULL, 0); error ("Got a CANCEL from the target."); } if (character == '*') { /* look for missed error message */ - expect_prompt (0); + expect_prompt (NULL, 0); error ("Got an error message from the target"); } - debuglogs (3, "Got a %s (0x%x or \'%c\'), expecting a %s.\n", - (character == ACK) ? "ACK" - : (character == NAK) ? "NAK" - : "BOGUS", - character, character, (byte == ACK) ? "ACK" : "NAK"); if (character == byte) /* got what we wanted */ return 1; if (character == ((byte == ACK) ? NAK : ACK)) - { /* got the opposite */ - debuglogs (3, "Got the opposite, wanted 0x%x, got a 0x%x", - byte, character); - return 0; - } + return 0; sleep (1); } @@ -1720,8 +1296,7 @@ monitor_make_srec (buffer, type, memaddr, myaddr, len) char *buf; buf = buffer; - debuglogs (4, "monitor_make_srec (buffer=0x%x, type=%d, memaddr=0x%x, len=%d", - buffer, type, memaddr, len); + checksum = 0; /* Create the header for the srec. 4 is the number of bytes in the address, @@ -1747,7 +1322,6 @@ monitor_make_srec (buffer, type, memaddr, myaddr, len) } sprintf(buf, "%02X", ~checksum & 0xff); /* add the checksum */ - debuglogs (3, "srec is \"%s\"", buffer); return 0; } @@ -1798,13 +1372,6 @@ make_xmodem_packet (packet, data, len) packet[i] = '0'; packet[XMODEM_PACKETSIZE] = sum & 0xff; /* add the checksum */ - - if (sr_get_debug () > 4) - { - debuglogs (4, "The xmodem checksum is %d (0x%x)\n", - sum & 0xff, sum & 0xff); - print_xmodem_packet (packet); - } } /* Print the packet as a debug check. */ @@ -1819,7 +1386,7 @@ print_xmodem_packet (packet) /* take apart the packet header the packet header */ if (packet[0] == SOH) - printf ("SOH"); + printf_unfiltered ("SOH"); else error ("xmodem: SOH is wrong"); @@ -1840,292 +1407,15 @@ print_xmodem_packet (packet) /* ignore the data */ #if 0 - printf (" [128 bytes of data] %d\n", sum & 0xff); + printf_unfiltered (" [128 bytes of data] %d\n", sum & 0xff); #endif printf_filtered (" [%s] %d\n", packet, sum & 0xff); if ((packet[XMODEM_PACKETSIZE] & 0xff) != (sum & 0xff)) - debuglogs (4, "xmodem: data checksum wrong, got a %d", - packet[XMODEM_PACKETSIZE] & 0xff); - - putchar ('\n'); -} - -/* Make a GDB packet. The data is always ASCII. - * A debug packet whose contents are <data> - * is encapsulated for transmission in the form: - * - * $ <data> # CSUM1 CSUM2 - * - * <data> must be ASCII alphanumeric and cannot include characters - * '$' or '#'. If <data> starts with two characters followed by - * ':', then the existing stubs interpret this as a sequence number. - * - * CSUM1 and CSUM2 are ascii hex representation of an 8-bit - * checksum of <data>, the most significant nibble is sent first. - * the hex digits 0-9,a-f are used. */ - -static void -make_gdb_packet (buf, data) - char *buf, *data; -{ - int i; - unsigned char csum = 0; - int cnt; - char *p; - - debuglogs (3, "make_gdb_packet(%s)\n", data); - cnt = strlen (data); - if (cnt > PBUFSIZ) - error ("make_gdb_packet(): to much data\n"); - - /* start with the packet header */ - p = buf; - *p++ = '$'; - - /* calculate the checksum */ - for (i = 0; i < cnt; i++) - { - csum += data[i]; - *p++ = data[i]; - } - - /* terminate the data with a '#' */ - *p++ = '#'; - - /* add the checksum as two ascii digits */ - *p++ = tohex ((csum >> 4) & 0xf); - *p++ = tohex (csum & 0xf); - *p = 0x0; /* Null terminator on string */ -} - -/* Send a GDB packet to the target with error handling. We get a '+' - (ACK) back if the packet is received and the checksum - matches. Otherwise a '-' (NAK) is returned. It returns a 1 for a - successful transmition, or a 0 for a failure. */ - -int -monitor_send_packet (packet) - char *packet; -{ - int c, retries, i; - char junk[PBUFSIZ]; - - retries = 0; - -#if 0 - /* scan the packet to make sure it only contains valid characters. - this may sound silly, but sometimes a garbled packet will hang - the target board. We scan the whole thing, then print the error - message. - */ - for (i = 0; i < strlen(packet); i++) { - debuglogs (5, "monitor_send_packet(): Scanning \'%c\'\n", packet[i]); - /* legit hex numbers or command */ - if ((isxdigit(packet[i])) || (isalpha(packet[i]))) - continue; - switch (packet[i]) { - case '+': /* ACK */ - case '-': /* NAK */ - case '#': /* end of packet */ - case '$': /* start of packet */ - continue; - default: /* bogus character */ - retries++; - debuglogs (4, "monitor_send_packet(): Found a non-ascii digit \'%c\' in the packet.\n", packet[i]); - } - } -#endif - - if (retries > 0) - error ("Can't send packet, found %d non-ascii characters", retries); - - /* ok, try to send the packet */ - retries = 0; - while (retries <= 10) - { - printf_monitor ("%s", packet); - - /* read until either a timeout occurs (-2) or '+' is read */ - while (retries <= 10) - { - c = readchar (timeout); - debuglogs (3, "Reading a GDB protocol packet... Got a '%c'\n", c); - switch (c) - { - case '+': - debuglogs (3, "Got Ack\n"); - return 1; - case SERIAL_TIMEOUT: - debuglogs (3, "Timed out reading serial port\n"); - break; /* Retransmit buffer */ - case '-': - debuglogs (3, "Got NAK\n"); - break; /* FIXME: (maybe) was a continue */ - case '$': - /* It's probably an old response, or the echo of our - command. just gobble up the packet and ignore it. */ - debuglogs (3, "Got a junk packet\n"); - do - { - c = readchar (timeout); - junk[i++] = c; - } while (c != '#'); - c = readchar (timeout); - junk[i++] = c; - c = readchar (timeout); - junk[i++] = c; - junk[i++] = '\0'; - debuglogs (3, "Reading a junk packet, got a \"%s\"\n", junk); - continue; /* Now, go look for next packet */ - default: - continue; - } - retries++; - debuglogs (3, "Retransmitting packet \"%s\"\n", packet); - break; /* Here to retransmit */ - } - } /* outer while */ - return 0; -} - -/* Get a GDB packet from the target. Basically we read till we see a - '#', then check the checksum. It returns a 1 if it's gotten a - packet, or a 0 it the packet wasn't transmitted correctly. */ - -int -monitor_get_packet (packet) - char *packet; -{ - int c; - int retries; - unsigned char csum; - unsigned char pktcsum; - char *bp; + printf_unfiltered ("xmodem: data checksum wrong, got a %d", + packet[XMODEM_PACKETSIZE] & 0xff); - csum = 0; - bp = packet; - - memset (packet, 1, PBUFSIZ); - retries = 0; - while (retries <= 10) - { - do - { - c = readchar (timeout); - if (c == SERIAL_TIMEOUT) - { - debuglogs (3, "monitor_get_packet: got time out from serial port.\n"); - } - debuglogs (3, "Waiting for a '$', got a %c\n", c); - } while (c != '$'); - - retries = 0; - while (retries <= 10) - { - c = readchar (timeout); - debuglogs (3, "monitor_get_packet: got a '%c'\n", c); - switch (c) - { - case SERIAL_TIMEOUT: - debuglogs (3, "Timeout in mid-packet, retrying\n"); - return 0; - case '$': - debuglogs (3, "Saw new packet start in middle of old one\n"); - return 0; /* Start a new packet, count retries */ - case '#': - *bp = '\0'; - pktcsum = from_hex (readchar (timeout)) << 4; - pktcsum |= from_hex (readchar (timeout)); - if (csum == pktcsum) - { - debuglogs (3, "\nGDB packet checksum correct, packet data is \"%s\",\n", packet); - printf_monitor ("+"); - expect_prompt (1); - return 1; - } - debuglogs (3, "Bad checksum, sentsum=0x%x, csum=0x%x\n", pktcsum, csum); - return 0; - case '*': /* Run length encoding */ - debuglogs (5, "Run length encoding in packet\n"); - csum += c; - c = readchar (timeout); - csum += c; - c = c - ' ' + 3; /* Compute repeat count */ - - if (c > 0 && c < 255 && bp + c - 1 < packet + PBUFSIZ - 1) - { - memset (bp, *(bp - 1), c); - bp += c; - continue; - } - *bp = '\0'; - printf_filtered ("Repeat count %d too large for buffer.\n", c); - return 0; - - default: - if ((!isxdigit (c)) && (!ispunct (c))) - debuglogs (4, "Got a non-ascii digit \'%c\'.\\n", c); - if (bp < packet + PBUFSIZ - 1) - { - *bp++ = c; - csum += c; - continue; - } - - *bp = '\0'; - puts_filtered ("Remote packet too long.\n"); - return 0; - } - } - } -} - -/* Convert an ascii number represented by 8 digits to a hex value. */ - -static unsigned long -ascii2hexword (mem) - unsigned char *mem; -{ - unsigned long val; - int i; - char buf[9]; - - val = 0; - for (i = 0; i < 8; i++) - { - val <<= 4; - if (mem[i] >= 'A' && mem[i] <= 'F') - val = val + mem[i] - 'A' + 10; - if (mem[i] >= 'a' && mem[i] <= 'f') - val = val + mem[i] - 'a' + 10; - if (mem[i] >= '0' && mem[i] <= '9') - val = val + mem[i] - '0'; - buf[i] = mem[i]; - } - buf[8] = '\0'; - debuglogs (4, "ascii2hexword() got a 0x%x from %s(%x).\n", val, buf, mem); - return val; -} - -/* Convert a hex value to an ascii number represented by 8 digits. */ - -static char * -hexword2ascii (mem, num) - unsigned char *mem; - unsigned long num; -{ - int i; - - debuglogs (4, "hexword2ascii() converting %x ", num); - for (i = 7; i >= 0; i--) - { - mem[i] = tohex ((num >> 4) & 0xf); - mem[i] = tohex (num & 0xf); - num = num >> 4; - } - mem[8] = '\0'; - debuglogs (4, "\tto a %s", mem); + putchar_unfiltered ('\n'); } /* Convert hex digit A to a number. */ @@ -2134,29 +1424,14 @@ static int from_hex (a) int a; { - if (a == 0) - return 0; - - debuglogs (4, "from_hex got a 0x%x(%c)\n",a,a); if (a >= '0' && a <= '9') return a - '0'; if (a >= 'a' && a <= 'f') return a - 'a' + 10; if (a >= 'A' && a <= 'F') return a - 'A' + 10; - error ("Reply contains invalid hex digit 0x%x", a); -} -/* Convert number NIB to a hex digit. */ - -static int -tohex (nib) - int nib; -{ - if (nib < 10) - return '0' + nib; - else - return 'a' + nib - 10; + error ("Reply contains invalid hex digit 0x%x", a); } /* Define additional commands that are usually only used by monitors. */ @@ -2164,26 +1439,10 @@ tohex (nib) void _initialize_remote_monitors () { - struct cmd_list_element *c; - - /* this sets the type of download protocol */ - c = add_set_cmd ("remoteloadprotocol", no_class, var_string, (char *)&loadproto_str, - "Set the type of the remote load protocol.\n", &setlist); - c->function.sfunc = set_loadproto_command; - add_show_from_set (c, &showlist); - loadproto_str = savestring ("none", 5); - - /* this sets the conversion type when loading */ - c = add_set_cmd ("remoteloadtype", no_class, var_string, (char *)&loadtype_str, - "Set the type of the remote load protocol.\n", &setlist); - c->function.sfunc = set_loadtype_command; - add_show_from_set (c, &showlist); - loadtype_str = savestring ("srec", 5); - add_show_from_set (add_set_cmd ("hash", no_class, var_boolean, (char *)&hashmark, "Set display of activity while downloading a file.\n\ -When enabled, a period \'.\' is displayed.", +When enabled, a hashmark \'#\' is displayed.", &setlist), &showlist); diff --git a/gdb/monitor.h b/gdb/monitor.h index 6194ea0..93e104f 100644 --- a/gdb/monitor.h +++ b/gdb/monitor.h @@ -28,6 +28,41 @@ struct rom_cmd_data { char *result; /* the result */ }; +/* This structure describes the strings necessary to give small command + sequences to the monitor, and parse the response. + + CMD is the actual command typed at the monitor. Usually this has embedded + sequences ala printf, which are substituted with the arguments appropriate + to that type of command. Ie: to examine a register, we substitute the + register name for the first arg. To modify memory, we substitute the memory + location and the new contents for the first and second args, etc... + + RESP_DELIM used to home in on the response string, and is used to + disambiguate the answer within the pile of text returned by the monitor. + This should be a unique string that immediately precedes the answer. Ie: if + your monitor prints out `PC: 00000001= ' in response to asking for the PC, + you should use `: ' as the RESP_DELIM. RESP_DELIM may be NULL if the res- + ponse is going to be ignored, or has no particular leading text. + + TERM is the string that the monitor outputs to indicate that it is idle, and + waiting for input. This is usually a prompt of some sort. In the previous + example, it would be `= '. It is important that TERM really means that the + monitor is idle, otherwise GDB may try to type at it when it isn't ready for + input. This is a problem because many monitors cannot deal with type-ahead. + TERM may be NULL if the normal prompt is output. + + TERM_CMD is used to quit out of the subcommand mode and get back to the main + prompt. TERM_CMD may be NULL if it isn't necessary. It will also be + ignored if TERM is NULL. +*/ + +struct cmd_resp { + char *cmd; /* Command to send */ + char *resp_delim; /* String just prior to the desired value */ + char *term; /* Terminating string to search for */ + char *term_cmd; /* String to get out of sub-mode (if necessary) */ +}; + struct monitor_ops { int type; /* 1 is ascii, 0 is GDB remote protocol */ char *init; /* initialize to the monitor */ @@ -37,17 +72,17 @@ struct monitor_ops { char *set_break; /* set a breakpoint */ char *clr_break; /* clear a breakpoint */ int clr_type; /* number or address for clearing */ - struct rom_cmd_data setmem; /* set memory to a value */ - struct rom_cmd_data getmem; /* display memory */ - struct rom_cmd_data regset; /* set a register */ - struct rom_cmd_data regget; /* read a register */ + struct cmd_resp setmem; /* set memory to a value */ + struct cmd_resp getmem; /* display memory */ + struct cmd_resp setreg; /* set a register */ + struct cmd_resp getreg; /* get a register */ char *load; /* load command */ char *prompt; /* monitor command prompt */ char *cmd_delim; /* end-of-command delimitor */ char *cmd_end; /* optional command terminator */ struct target_ops *target; /* target operations */ - char *loadtypes; /* the load types that are supported */ - char *loadprotos; /* the load protocols that are supported */ + char **loadtypes; /* the load types that are supported */ + char **loadprotos; /* the load protocols that are supported */ char *baudrates; /* supported baud rates */ int stopbits; /* number of stop bits */ char **regnames; /* array of register names in ascii */ @@ -87,19 +122,15 @@ extern struct monitor_ops *current_monitor; #define SREC_SIZE 160 #define GDBPROTO ((current_monitor->type) ? 0: 1) -extern void debuglogs(); -extern void monitor_open(); -extern void monitor_close(); -extern void monitor_detach(); -extern void monitor_attach(); -extern void monitor_resume(); -extern int monitor_wait(); -extern void monitor_fetch_register(); -extern void monitor_store_register(); -extern void monitor_fetch_registers(); -extern void monitor_store_registers(); +extern void monitor_open PARAMS ((char *args, struct monitor_ops *ops, int from_tty)); +extern void monitor_close PARAMS ((int quitting)); +extern void monitor_detach PARAMS ((char *args, int from_tty)); +extern void monitor_resume PARAMS ((int pid, int step, enum target_signal sig)); +extern int monitor_wait PARAMS ((int pid, struct target_waitstatus *status)); +extern void monitor_fetch_registers PARAMS ((int regno)); +extern void monitor_store_registers PARAMS ((int regno)); extern void monitor_prepare_to_store(); -extern int monitor_xfer_inferior_memory(); +extern int monitor_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len, int write, struct target_ops *target)); extern void monitor_files_info(); extern int monitor_insert_breakpoint(); extern int monitor_remove_breakpoint(); diff --git a/gdb/op50-rom.c b/gdb/op50-rom.c index c6a3276..5d3b228 100644 --- a/gdb/op50-rom.c +++ b/gdb/op50-rom.c @@ -58,7 +58,8 @@ static char *op50n_regnames[] = { * strings. We also need a CR or LF on the end. */ -struct target_ops op50n_ops = { +static struct target_ops op50n_ops = +{ "op50n", "Oki's debug monitor for the Op50n Eval board", @@ -66,7 +67,7 @@ struct target_ops op50n_ops = { Specify the serial device it is connected to (e.g. /dev/ttya).", op50n_open, monitor_close, - monitor_attach, + NULL, monitor_detach, monitor_resume, monitor_wait, @@ -102,7 +103,11 @@ Specify the serial device it is connected to (e.g. /dev/ttya).", OPS_MAGIC, /* Always the last thing */ }; -struct monitor_ops op50n_cmds = { +static char *op50n_loadtype[] = {"none", "srec", "default", NULL}; +static char *op50n_loadprotos[] = {"none", NULL}; + +static struct monitor_ops op50n_cmds = +{ 1, /* 1 for ASCII, 0 for binary */ "\003.\n", /* monitor init string */ "g %x\n", /* execute or usually GO command */ @@ -136,10 +141,10 @@ struct monitor_ops op50n_cmds = { " ", /* end-of-command delimitor */ ".\n", /* optional command terminator */ &op50n_ops, /* target operations */ - "none,srec,default", /* load types */ - "none", /* load types */ + op50n_loadtypes, /* loadtypes */ + op50n_loadprotos, /* loadprotos */ "2400,4800,9600,19200,exta,38400,extb", /* supported baud rates */ - 1, /* number of stop bits */ + SERIAL_1_STOPBITS, /* number of stop bits */ op50n_regnames }; @@ -148,10 +153,7 @@ op50n_open(args, from_tty) char *args; int from_tty; { - target_preopen(from_tty); - push_target(&op50n_ops); - push_monitor (&op50n_cmds); - monitor_open (args, "op50n", from_tty); + monitor_open (args, &op50n_cmds, from_tty); } void diff --git a/gdb/rom68k-rom.c b/gdb/rom68k-rom.c index 0bd64a2..608f753 100644 --- a/gdb/rom68k-rom.c +++ b/gdb/rom68k-rom.c @@ -23,11 +23,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdbcore.h" #include "target.h" #include "monitor.h" - -extern int baud_rate; +#include "serial.h" void rom68k_open(); -void monitor_open(); /* * this array of registers need to match the indexes used by GDB. The @@ -35,23 +33,10 @@ void monitor_open(); * different strings than GDB does, and doesn't support all the * registers either. So, typing "info reg sp" becomes a "r30". */ -static char *rom68k_regnames[] = { - "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a0", "a1", - "a2", "a3", "a4", "a5", "a6", "usp", "ssp","pc", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "" -}; +static char *rom68k_regnames[NUM_REGS] = { + "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", + "A0", "A1", "A2", "A3", "A4", "A5", "A6", "ISP", + "SR", "PC" }; /* * Define the monitor command strings. Since these are passed directly @@ -59,21 +44,22 @@ static char *rom68k_regnames[] = { * strings. We also need a CR or LF on the end. */ -struct target_ops rom68k_ops = { +static struct target_ops rom68k_ops = +{ "rom68k", "Rom68k debug monitor for the IDP Eval board", "Debug on a Motorola IDP eval board running the ROM68K monitor.\n\ Specify the serial device it is connected to (e.g. /dev/ttya).", rom68k_open, monitor_close, - monitor_attach, + NULL, monitor_detach, monitor_resume, monitor_wait, - monitor_fetch_register, - monitor_store_register, + monitor_fetch_registers, + monitor_store_registers, monitor_prepare_to_store, - monitor_xfer_inferior_memory, + monitor_xfer_memory, monitor_files_info, monitor_insert_breakpoint, monitor_remove_breakpoint, /* Breakpoints */ @@ -102,56 +88,61 @@ Specify the serial device it is connected to (e.g. /dev/ttya).", OPS_MAGIC /* Always the last thing */ }; -struct monitor_ops rom68k_cmds = { - 1, /* 1 for ASCII, 0 for binary */ - "\n", /* monitor init string */ - "go \n", /* execute or usually GO command */ - "go \n", /* continue command */ - "st \n", /* single step */ - "db %x\n", /* set a breakpoint */ - "cb %x\r", /* clear a breakpoint */ - 0, /* 0 for number, 1 for address */ +static char *rom68k_loadtypes[] = {"none", "srec", "default", NULL}; +static char *rom68k_loadprotos[] = {"none", NULL}; + +static struct monitor_ops rom68k_cmds = +{ + 1, /* 1 for ASCII, 0 for binary */ + ".\r\r", /* monitor init string */ + "go \r", /* execute or usually GO command */ + "go \r", /* continue command */ + "st \r", /* single step */ + "db %x\r", /* set a breakpoint */ + "cb %x\r", /* clear a breakpoint */ + 0, /* 0 for number, 1 for address */ { - "pm %x %x\r", /* set memory */ - "=", /* delimiter */ - "", /* the result */ + "pm %x %x\r", /* setmem.cmd (addr, value) */ + NULL, /* setreg.resp_delim */ + NULL, /* setreg.term */ + NULL, /* setreg.term_cmd */ }, { - "dm %x 1\r", /* get memory */ - "", /* delimiter */ - "", /* the result */ + "dm %x 1\r", /* getmem.cmd (addr) */ + " ", /* getmem.resp_delim */ + NULL, /* getmem.term */ + NULL, /* getmem.term_cmd */ }, { - "pr %s %x\r", /* set a register */ - "", /* delimiter between registers */ - "", /* the result */ + "pr %s %x\r", /* setreg.cmd (name, value) */ + NULL, /* setreg.resp_delim */ + NULL, /* setreg.term */ + NULL /* setreg.term_cmd */ }, { - "pr %s\n", /* get a register */ - ":", /* delimiter between registers */ - "", /* the result */ + "pr %s\r", /* getreg.cmd (name) */ + ": ", /* getreg.resp_delim */ + "= ", /* getreg.term */ + ".\r" /* getreg.term_cmd */ }, - "dc\n", /* download command */ - "ROM68K :->", /* monitor command prompt */ - "=", /* end-of-command delimitor */ - ".\n", /* optional command terminator */ - &rom68k_ops, /* target operations */ - "none,srec,default", /* load types */ - "none", /* load protocols */ - "9600", /* supported baud rates */ - 1, /* number of stop bits */ - rom68k_regnames /* registers names */ -}; + "dc\r", /* download command */ + "ROM68K :->", /* monitor command prompt */ + "=", /* end-of-command delimitor */ + ".\r", /* optional command terminator */ + &rom68k_ops, /* target operations */ + rom68k_loadtypes, /* loadtypes */ + rom68k_loadprotos, /* loadprotos */ + "9600", /* supported baud rates */ + SERIAL_1_STOPBITS, /* number of stop bits */ + rom68k_regnames /* registers names */ + }; void rom68k_open(args, from_tty) char *args; int from_tty; { - target_preopen(from_tty); - push_target (&rom68k_ops); - push_monitor (&rom68k_cmds); - monitor_open (args, "rom68k", from_tty); + monitor_open (args, &rom68k_cmds, from_tty); } void diff --git a/gdb/w89k-rom.c b/gdb/w89k-rom.c index e2536f8..64bc5fad 100644 --- a/gdb/w89k-rom.c +++ b/gdb/w89k-rom.c @@ -59,14 +59,15 @@ static char *w89k_regnames[] = { * strings. We also need a CR or LF on the end. */ -struct target_ops w89k_ops = { +static struct target_ops w89k_ops = +{ "w89k", "WinBond's debug monitor for the W89k Eval board", "Debug on a WinBond W89K eval board.\n\ Specify the serial device it is connected to (e.g. /dev/ttya).", w89k_open, monitor_close, - monitor_attach, + NULL, monitor_detach, monitor_resume, monitor_wait, @@ -102,7 +103,11 @@ Specify the serial device it is connected to (e.g. /dev/ttya).", OPS_MAGIC, /* Always the last thing */ }; -struct monitor_ops w89k_cmds = { +static char *loadtypes[] = {"none", "srec", "default", NULL}; +static char *loadprotos[] = {"none", "xmodem", NULL}; + +static struct monitor_ops w89k_cmds = +{ 1, /* 1 for ASCII, 0 for binary */ "\n", /* monitor init string */ "g = %x\n", /* execute or usually GO command */ @@ -136,10 +141,10 @@ struct monitor_ops w89k_cmds = { "", /* end-of-command delimitor */ "", /* optional command terminator */ &w89k_ops, /* target operations */ - "none,srec,default", /* load types */ - "none,xmodem", /* load protocols */ + w89k_loadtypes, /* loadtypes */ + w89k_loadprotos, /* loadprotos */ "9600", /* supported baud rates */ - 1, /* number of stop bits */ + SERIAL_1_STOPBITS, /* number of stop bits */ w89k_regnames /* registers names */ }; @@ -148,10 +153,7 @@ w89k_open(args, from_tty) char *args; int from_tty; { - target_preopen(from_tty); - push_target (&w89k_ops); - push_monitor (&w89k_cmds); - monitor_open (args, "w89k", from_tty); + monitor_open (args, &w89k_cmds, from_tty); } void |