diff options
author | Jim Kingdon <jkingdon@engr.sgi.com> | 1994-03-19 18:49:50 +0000 |
---|---|---|
committer | Jim Kingdon <jkingdon@engr.sgi.com> | 1994-03-19 18:49:50 +0000 |
commit | 94d4b713731d53fac28864a85e1974aa34fe7c39 (patch) | |
tree | 72b4d5f61bc77345f73d427f16078eee19cb9cae /gdb/remote.c | |
parent | 1732fbd47ae938e02720801967b6dd9c3f489ba6 (diff) | |
download | gdb-94d4b713731d53fac28864a85e1974aa34fe7c39.zip gdb-94d4b713731d53fac28864a85e1974aa34fe7c39.tar.gz gdb-94d4b713731d53fac28864a85e1974aa34fe7c39.tar.bz2 |
* Makefile.in (TAGS): Use variables directly, rather than using
find, to locate TM_FILE, XM_FILE, and NAT_FILE. This is faster
and means that these filenames no longer need be unique across all
the config/* directories.
* configure.in: Put the config/*/ into TM_FILE, etc.
* m68k-stub.c (computeSignal): Return SIGFPE, not SIGURG, for chk
and trapv exceptions.
* target.h (struct section_table), objfiles.h (struct obj_section):
Change name of field sec_ptr to the_bfd_section. More mnemonic
and avoids the (sort of, for the ptx compiler) name clash with
the name of the typedef.
* exec.c, xcoffexec.c, sparc-tdep.c, rs6000-nat.c, osfsolib.c,
solib.c, irix5-nat.c, objfiles.c, remote.c: Change users.
* utils.c: Include readline.h.
* Makefile.in (utils.o): Add dependency.
* remote.c (getpkt): Add support for run-length encoding.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r-- | gdb/remote.c | 184 |
1 files changed, 158 insertions, 26 deletions
diff --git a/gdb/remote.c b/gdb/remote.c index 87437a1..7240f0b 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1,5 +1,5 @@ /* Remote target communications for serial-line targets in custom GDB protocol - Copyright 1988, 1991, 1992, 1993 Free Software Foundation, Inc. + Copyright 1988, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of GDB. @@ -116,7 +116,16 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ we can extend the protocol and GDB can tell whether the stub it is talking to uses the old or the new. -*/ + search tAA:PP,MM Search backward starting at address + AA for a match with pattern PP and + mask MM. PP and MM are 4 bytes. + Not supported by all stubs. + + Responses can be run-length encoded to save space. A '*' means that + the next two characters are hex digits giving a repeat count which + stands for that many repititions of the character preceding the '*'. + Note that this means that responses cannot contain '*'. Example: + "0*03" means the same as "0000". */ #include "defs.h" #include <string.h> @@ -164,7 +173,7 @@ static void remote_fetch_registers PARAMS ((int regno)); static void -remote_resume PARAMS ((int pid, int step, int siggnal)); +remote_resume PARAMS ((int pid, int step, enum target_signal siggnal)); static int remote_start_remote PARAMS ((char *dummy)); @@ -190,8 +199,7 @@ remote_send PARAMS ((char *buf)); static int readchar PARAMS ((void)); -static int -remote_wait PARAMS ((int pid, WAITTYPE *status)); +static int remote_wait PARAMS ((int pid, struct target_waitstatus *status)); static int tohex PARAMS ((int nib)); @@ -301,10 +309,13 @@ device is attached to the remote system (e.g. /dev/ttya)."); if (!remote_desc) perror_with_name (name); - if (SERIAL_SETBAUDRATE (remote_desc, baud_rate)) + if (baud_rate != -1) { - SERIAL_CLOSE (remote_desc); - perror_with_name (name); + if (SERIAL_SETBAUDRATE (remote_desc, baud_rate)) + { + SERIAL_CLOSE (remote_desc); + perror_with_name (name); + } } SERIAL_RAW (remote_desc); @@ -381,7 +392,8 @@ tohex (nib) static void remote_resume (pid, step, siggnal) - int pid, step, siggnal; + int pid, step; + enum target_signal siggnal; { char buf[PBUFSIZ]; @@ -389,13 +401,9 @@ remote_resume (pid, step, siggnal) { char *name; target_terminal_ours_for_output (); - printf_filtered ("Can't send signals to a remote system. "); - name = strsigno (siggnal); - if (name) - printf_filtered (name); - else - printf_filtered ("Signal %d", siggnal); - printf_filtered (" not sent.\n"); + printf_filtered + ("Can't send signals to a remote system. %s not sent.\n", + target_signal_to_name (siggnal)); target_terminal_inferior (); } @@ -461,11 +469,12 @@ Give up (and stop debugging it)? ")) static int remote_wait (pid, status) int pid; - WAITTYPE *status; + struct target_waitstatus *status; { unsigned char buf[PBUFSIZ]; - WSETEXIT ((*status), 0); + status->kind = TARGET_WAITKIND_EXITED; + status->value.integer = 0; while (1) { @@ -589,7 +598,7 @@ remote_wait (pid, status) { flagword flags; - flags = bfd_get_section_flags (abfd, s->sec_ptr); + flags = bfd_get_section_flags (abfd, s->the_bfd_section); if (flags & SEC_CODE) { @@ -614,7 +623,8 @@ remote_wait (pid, status) else if (buf[0] == 'W') { /* The remote process exited. */ - WSETEXIT (*status, (fromhex (buf[1]) << 4) + fromhex (buf[2])); + status->kind = TARGET_WAITKIND_EXITED; + status->value.integer = (fromhex (buf[1]) << 4) + fromhex (buf[2]); return 0; } else if (buf[0] == 'S') @@ -623,7 +633,9 @@ remote_wait (pid, status) warning ("Invalid remote reply: %s", buf); } - WSETSTOP ((*status), (((fromhex (buf[1])) << 4) + (fromhex (buf[2])))); + status->kind = TARGET_WAITKIND_STOPPED; + status->value.sig = (enum target_signal) + (((fromhex (buf[1])) << 4) + (fromhex (buf[2]))); return 0; } @@ -901,9 +913,11 @@ remote_xfer_memory(memaddr, myaddr, len, should_write, target) xfersize = len; if (should_write) - bytes_xferred = remote_write_bytes (memaddr, myaddr, xfersize); + bytes_xferred = remote_write_bytes (memaddr, + (unsigned char *)myaddr, xfersize); else - bytes_xferred = remote_read_bytes (memaddr, myaddr, xfersize); + bytes_xferred = remote_read_bytes (memaddr, + (unsigned char *)myaddr, xfersize); /* If we get an error, we are done xferring. */ if (bytes_xferred == 0) @@ -917,6 +931,80 @@ remote_xfer_memory(memaddr, myaddr, len, should_write, target) return total_xferred; } +#if 0 +/* Enable after 4.12. */ + +void +remote_search (len, data, mask, startaddr, increment, lorange, hirange + addr_found, data_found) + int len; + char *data; + char *mask; + CORE_ADDR startaddr; + int increment; + CORE_ADDR lorange; + CORE_ADDR hirange; + CORE_ADDR *addr_found; + char *data_found; +{ + if (increment == -4 && len == 4) + { + long mask_long, data_long; + long data_found_long; + CORE_ADDR addr_we_found; + char buf[PBUFSIZ]; + long returned_long[2]; + char *p; + + mask_long = extract_unsigned_integer (mask, len); + data_long = extract_unsigned_integer (data, len); + sprintf (buf, "t%x:%x,%x", startaddr, data_long, mask_long); + putpkt (buf); + getpkt (buf, 0); + if (buf[0] == '\0') + { + /* The stub doesn't support the 't' request. We might want to + remember this fact, but on the other hand the stub could be + switched on us. Maybe we should remember it only until + the next "target remote". */ + generic_search (len, data, mask, startaddr, increment, lorange, + hirange, addr_found, data_found); + return; + } + + if (buf[0] == 'E') + /* There is no correspondance between what the remote protocol uses + for errors and errno codes. We would like a cleaner way of + representing errors (big enough to include errno codes, bfd_error + codes, and others). But for now just use EIO. */ + memory_error (EIO, startaddr); + p = buf; + addr_we_found = 0; + while (*p != '\0' && *p != ',') + addr_we_found = (addr_we_found << 4) + fromhex (*p++); + if (*p == '\0') + error ("Protocol error: short return for search"); + + data_found_long = 0; + while (*p != '\0' && *p != ',') + data_found_long = (data_found_long << 4) + fromhex (*p++); + /* Ignore anything after this comma, for future extensions. */ + + if (addr_we_found < lorange || addr_we_found >= hirange) + { + *addr_found = 0; + return; + } + + *addr_found = addr_we_found; + *data_found = store_unsigned_integer (data_we_found, len); + return; + } + generic_search (len, data, mask, startaddr, increment, lorange, + hirange, addr_found, data_found); +} +#endif /* 0 */ + static void remote_files_info (ignore) struct target_ops *ignore; @@ -1027,11 +1115,18 @@ putpkt (buf) break; /* Here to retransmit */ } +#if 0 + /* This is wrong. If doing a long backtrace, the user should be + able to get out next time we call QUIT, without anything as violent + as interrupt_query. If we want to provide a way out of here + without getting to the next QUIT, it should be based on hitting + ^C twice as in remote_wait. */ if (quit_flag) { quit_flag = 0; interrupt_query (); } +#endif } } @@ -1041,8 +1136,8 @@ putpkt (buf) while the target is executing user code. */ static void -getpkt (buf, forever) - char *buf; +getpkt (retbuf, forever) + char *retbuf; int forever; { char *bp; @@ -1050,15 +1145,24 @@ getpkt (buf, forever) int c = 0; unsigned char c1, c2; int retries = 0; + char buf[PBUFSIZ]; + #define MAX_RETRIES 10 while (1) { +#if 0 + /* This is wrong. If doing a long backtrace, the user should be + able to get out time next we call QUIT, without anything as violent + as interrupt_query. If we want to provide a way out of here + without getting to the next QUIT, it should be based on hitting + ^C twice as in remote_wait. */ if (quit_flag) { quit_flag = 0; interrupt_query (); } +#endif /* This can loop forever if the remote side sends us characters continuously, but if it pauses, we'll get a zero from readchar @@ -1138,8 +1242,36 @@ whole: } } -out: + /* Deal with run-length encoding. */ + { + char *src = buf; + char *dest = retbuf; + int i; + int repeat; + do { + if (*src == '*') + { + if (src[1] == '\0' || src[2] == '\0') + { + if (remote_debug) + puts_filtered ("Packet too short, retrying\n"); + goto whole; + } + repeat = (fromhex (src[1]) << 4) + fromhex (src[2]); + for (i = 0; i < repeat; ++i) + { + *dest++ = src[-1]; + } + src += 2; + } + else + { + *dest++ = *src; + } + } while (*src++ != '\0'); + } +out: SERIAL_WRITE (remote_desc, "+", 1); if (remote_debug) |