1 /* Remote target communications for serial-line targets in custom GDB protocol
2 Copyright 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 /* Remote communication protocol.
22 A debug packet whose contents are <data>
23 is encapsulated for transmission in the form:
25 $ <data> # CSUM1 CSUM2
27 <data> must be ASCII alphanumeric and cannot include characters
28 '$' or '#'. If <data> starts with two characters followed by
29 ':', then the existing stubs interpret this as a sequence number.
31 CSUM1 and CSUM2 are ascii hex representation of an 8-bit
32 checksum of <data>, the most significant nibble is sent first.
33 the hex digits 0-9,a-f are used.
35 Receiver responds with:
37 + - if CSUM is correct and ready for next packet
38 - - if CSUM is incorrect
41 Most values are encoded in ascii hex digits. Signal numbers are according
42 to the numbering in target.h.
46 set thread Hct... Set thread for subsequent operations.
47 c = 'c' for thread used in step and
48 continue; t... can be -1 for all
50 c = 'g' for thread used in other
51 operations. If zero, pick a thread,
57 reply XX....X Each byte of register data
58 is described by two hex digits.
59 Registers are in the internal order
60 for GDB, and the bytes in a register
61 are in the same order the machine uses.
64 write regs GXX..XX Each byte of register data
65 is described by two hex digits.
69 write reg Pn...=r... Write register n... with value r...,
70 which contains two hex digits for each
71 byte in the register (target byte
75 (not supported by all stubs).
77 read mem mAA..AA,LLLL AA..AA is address, LLLL is length.
78 reply XX..XX XX..XX is mem contents
79 Can be fewer bytes than requested
80 if able to read only part of the data.
83 write mem MAA..AA,LLLL:XX..XX
85 LLLL is number of bytes,
88 ENN for an error (this includes the case
89 where only part of the data was
92 continue cAA..AA AA..AA is address to resume
94 resume at same address.
96 step sAA..AA AA..AA is address to resume
98 resume at same address.
100 continue with Csig;AA..AA Continue with signal sig (hex signal
101 signal number). If ;AA..AA is omitted, resume
104 step with Ssig;AA..AA Like 'C' but step not continue.
107 last signal ? Reply the current reason for stopping.
108 This is the same reply as is generated
109 for step or cont : SAA where AA is the
114 There is no immediate reply to step or cont.
115 The reply comes when the machine stops.
116 It is SAA AA is the signal number.
118 or... TAAn...:r...;n...:r...;n...:r...;
120 n... = register number (hex)
121 r... = register contents
123 r... = thread process ID. This is
125 n... = other string not starting
126 with valid hex digit.
127 gdb should ignore this n,r pair
128 and go on to the next. This way
129 we can extend the protocol.
130 or... WAA The process exited, and AA is
131 the exit status. This is only
132 applicable for certains sorts of
134 or... XAA The process terminated with signal
136 or... OXX..XX XX..XX is hex encoding of ASCII data. This
137 can happen at any time while the program is
138 running and the debugger should
139 continue to wait for 'W', 'T', etc.
141 thread alive TXX Find out if the thread XX is alive.
142 reply OK thread is still alive
145 remote restart RXX Restart the remote server
147 extended ops ! Use the extended remote protocol.
148 Sticky -- only needs to be set once.
152 toggle debug d toggle debug flag (see 386 & 68k stubs)
153 reset r reset -- see sparc stub.
154 reserved <other> On other requests, the stub should
155 ignore the request and send an empty
156 response ($#<checksum>). This way
157 we can extend the protocol and GDB
158 can tell whether the stub it is
159 talking to uses the old or the new.
160 search tAA:PP,MM Search backwards starting at address
161 AA for a match with pattern PP and
162 mask MM. PP and MM are 4 bytes.
163 Not supported by all stubs.
165 general query qXXXX Request info about XXXX.
166 general set QXXXX=yyyy Set value of XXXX to yyyy.
167 query sect offs qOffsets Get section offsets. Reply is
168 Text=xxx;Data=yyy;Bss=zzz
170 Responses can be run-length encoded to save space. A '*' means that
171 the next character is an ASCII encoding giving a repeat count which
172 stands for that many repititions of the character preceding the '*'.
173 The encoding is n+29, yielding a printable character where n >=3
174 (which is where rle starts to win). Don't use an n > 126.
177 "0* " means the same as "0000". */
180 #include "gdb_string.h"
183 #include "inferior.h"
188 /*#include "terminal.h"*/
190 #include "objfiles.h"
191 #include "gdb-stabs.h"
192 #include "gdbthread.h"
197 #include <sys/types.h>
203 /* Prototypes for local functions */
205 static int remote_write_bytes PARAMS ((CORE_ADDR memaddr,
206 char *myaddr, int len));
208 static int remote_read_bytes PARAMS ((CORE_ADDR memaddr,
209 char *myaddr, int len));
211 static void remote_files_info PARAMS ((struct target_ops *ignore));
213 static int remote_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr,
214 int len, int should_write,
215 struct target_ops *target));
217 static void remote_prepare_to_store PARAMS ((void));
219 static void remote_fetch_registers PARAMS ((int regno));
221 static void remote_resume PARAMS ((int pid, int step,
222 enum target_signal siggnal));
224 static int remote_start_remote PARAMS ((char *dummy));
226 static void remote_open PARAMS ((char *name, int from_tty));
228 static void extended_remote_open PARAMS ((char *name, int from_tty));
230 static void remote_open_1 PARAMS ((char *, int, struct target_ops *, int extended_p));
232 static void remote_close PARAMS ((int quitting));
234 static void remote_store_registers PARAMS ((int regno));
236 static void remote_mourn PARAMS ((void));
238 static void extended_remote_restart PARAMS ((void));
240 static void extended_remote_mourn PARAMS ((void));
242 static void extended_remote_create_inferior PARAMS ((char *, char *, char **));
244 static void remote_mourn_1 PARAMS ((struct target_ops *));
246 static void remote_send PARAMS ((char *buf));
248 static int readchar PARAMS ((int timeout));
250 static int remote_wait PARAMS ((int pid, struct target_waitstatus *status));
252 static void remote_kill PARAMS ((void));
254 static int tohex PARAMS ((int nib));
256 static void remote_detach PARAMS ((char *args, int from_tty));
258 static void remote_interrupt PARAMS ((int signo));
260 static void remote_interrupt_twice PARAMS ((int signo));
262 static void interrupt_query PARAMS ((void));
264 static void set_thread PARAMS ((int, int));
266 static int remote_thread_alive PARAMS ((int));
268 static void get_offsets PARAMS ((void));
270 static int read_frame PARAMS ((char *));
272 static int remote_insert_breakpoint PARAMS ((CORE_ADDR, char *));
274 static int remote_remove_breakpoint PARAMS ((CORE_ADDR, char *));
276 static int hexnumlen PARAMS ((ULONGEST num));
278 static void init_remote_ops PARAMS ((void));
280 static void init_extended_remote_ops PARAMS ((void));
282 /* exported functions */
284 extern int fromhex PARAMS ((int a));
285 extern void getpkt PARAMS ((char *buf, int forever));
286 extern int putpkt PARAMS ((char *buf));
288 static struct target_ops remote_ops ;
290 static struct target_ops extended_remote_ops ;
292 /* This was 5 seconds, which is a long time to sit and wait.
293 Unless this is going though some terminal server or multiplexer or
294 other form of hairy serial connection, I would think 2 seconds would
297 /* Changed to allow option to set timeout value.
298 was static int remote_timeout = 2; */
299 extern int remote_timeout;
301 /* This variable chooses whether to send a ^C or a break when the user
302 requests program interruption. Although ^C is usually what remote
303 systems expect, and that is the default here, sometimes a break is
304 preferable instead. */
306 static int remote_break;
308 /* Descriptor for I/O to remote machine. Initialize it to NULL so that
309 remote_open knows that we don't have a file open when the program
311 static serial_t remote_desc = NULL;
313 /* Having this larger than 400 causes us to be incompatible with m68k-stub.c
314 and i386-stub.c. Normally, no one would notice because it only matters
315 for writing large chunks of memory (e.g. in downloads). Also, this needs
316 to be more than 400 if required to hold the registers (see below, where
317 we round it up based on REGISTER_BYTES). */
320 /* Maximum number of bytes to read/write at once. The value here
321 is chosen to fill up a packet (the headers account for the 32). */
322 #define MAXBUFBYTES ((PBUFSIZ-32)/2)
324 /* Round up PBUFSIZ to hold all the registers, at least. */
325 /* The blank line after the #if seems to be required to work around a
326 bug in HP's PA compiler. */
327 #if REGISTER_BYTES > MAXBUFBYTES
330 #define PBUFSIZ (REGISTER_BYTES * 2 + 32)
333 /* This variable sets the number of bytes to be written to the target
334 in a single packet. Normally PBUFSIZ is satisfactory, but some
335 targets need smaller values (perhaps because the receiving end
338 static int remote_write_size = PBUFSIZ;
340 /* This is the size (in chars) of the first response to the `g' command. This
341 is used to limit the size of the memory read and write commands to prevent
342 stub buffers from overflowing. The size does not include headers and
343 trailers, it is only the payload size. */
345 static int remote_register_buf_size = 0;
347 /* Should we try the 'P' request? If this is set to one when the stub
348 doesn't support 'P', the only consequence is some unnecessary traffic. */
349 static int stub_supports_P = 1;
351 /* These are pointers to hook functions that may be set in order to
352 modify resume/wait behavior for a particular architecture. */
354 void (*target_resume_hook) PARAMS ((void));
355 void (*target_wait_loop_hook) PARAMS ((void));
358 /* These are the threads which we last sent to the remote system. -1 for all
359 or -2 for not sent yet. */
369 int state = gen ? general_thread : cont_thread;
373 buf[1] = gen ? 'g' : 'c';
380 sprintf (&buf[2], "-%x", -th);
382 sprintf (&buf[2], "%x", th);
391 /* Return nonzero if the thread TH is still alive on the remote system. */
394 remote_thread_alive (th)
401 sprintf (&buf[1], "-%x", -th);
403 sprintf (&buf[1], "%x", th);
406 return (buf[0] == 'O' && buf[1] == 'K');
409 /* Restart the remote side; this is an extended protocol operation. */
412 extended_remote_restart ()
416 /* Send the restart command; for reasons I don't understand the
417 remote side really expects a number after the "R". */
419 sprintf (&buf[1], "%x", 0);
422 /* Now query for status so this looks just like we restarted
423 gdbserver from scratch. */
428 /* Clean up connection to a remote debugger. */
432 remote_close (quitting)
436 SERIAL_CLOSE (remote_desc);
440 /* Query the remote side for the text, data and bss offsets. */
445 char buf[PBUFSIZ], *ptr;
447 CORE_ADDR text_addr, data_addr, bss_addr;
448 struct section_offsets *offs;
454 if (buf[0] == '\000')
455 return; /* Return silently. Stub doesn't support this
459 warning ("Remote failure reply: %s", buf);
463 /* Pick up each field in turn. This used to be done with scanf, but
464 scanf will make trouble if CORE_ADDR size doesn't match
465 conversion directives correctly. The following code will work
466 with any size of CORE_ADDR. */
467 text_addr = data_addr = bss_addr = 0;
471 if (strncmp (ptr, "Text=", 5) == 0)
474 /* Don't use strtol, could lose on big values. */
475 while (*ptr && *ptr != ';')
476 text_addr = (text_addr << 4) + fromhex (*ptr++);
481 if (!lose && strncmp (ptr, ";Data=", 6) == 0)
484 while (*ptr && *ptr != ';')
485 data_addr = (data_addr << 4) + fromhex (*ptr++);
490 if (!lose && strncmp (ptr, ";Bss=", 5) == 0)
493 while (*ptr && *ptr != ';')
494 bss_addr = (bss_addr << 4) + fromhex (*ptr++);
500 error ("Malformed response to offset query, %s", buf);
502 if (symfile_objfile == NULL)
505 offs = (struct section_offsets *) alloca (sizeof (struct section_offsets)
506 + symfile_objfile->num_sections
507 * sizeof (offs->offsets));
508 memcpy (offs, symfile_objfile->section_offsets,
509 sizeof (struct section_offsets)
510 + symfile_objfile->num_sections
511 * sizeof (offs->offsets));
513 ANOFFSET (offs, SECT_OFF_TEXT) = text_addr;
515 /* This is a temporary kludge to force data and bss to use the same offsets
516 because that's what nlmconv does now. The real solution requires changes
517 to the stub and remote.c that I don't have time to do right now. */
519 ANOFFSET (offs, SECT_OFF_DATA) = data_addr;
520 ANOFFSET (offs, SECT_OFF_BSS) = data_addr;
522 objfile_relocate (symfile_objfile, offs);
525 /* Stub for catch_errors. */
528 remote_start_remote (dummy)
531 immediate_quit = 1; /* Allow user to interrupt it */
533 /* Ack any packet which the remote side has already sent. */
534 SERIAL_WRITE (remote_desc, "+", 1);
536 /* Let the stub know that we want it to return the thread. */
539 get_offsets (); /* Get text, data & bss offsets */
541 putpkt ("?"); /* initiate a query from remote machine */
544 start_remote (); /* Initialize gdb process mechanisms */
548 /* Open a connection to a remote debugger.
549 NAME is the filename used for communication. */
552 remote_open (name, from_tty)
556 remote_open_1 (name, from_tty, &remote_ops, 0);
559 /* Open a connection to a remote debugger using the extended
560 remote gdb protocol. NAME is the filename used for communication. */
563 extended_remote_open (name, from_tty)
567 remote_open_1 (name, from_tty, &extended_remote_ops, 1/*extended_p*/);
570 /* Generic code for opening a connection to a remote target. */
571 static DCACHE *remote_dcache;
574 remote_open_1 (name, from_tty, target, extended_p)
577 struct target_ops *target;
581 error ("To open a remote debug connection, you need to specify what serial\n\
582 device is attached to the remote system (e.g. /dev/ttya).");
584 target_preopen (from_tty);
586 unpush_target (target);
588 remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
590 remote_desc = SERIAL_OPEN (name);
592 perror_with_name (name);
596 if (SERIAL_SETBAUDRATE (remote_desc, baud_rate))
598 SERIAL_CLOSE (remote_desc);
599 perror_with_name (name);
604 SERIAL_RAW (remote_desc);
606 /* If there is something sitting in the buffer we might take it as a
607 response to a command, which would be bad. */
608 SERIAL_FLUSH_INPUT (remote_desc);
612 puts_filtered ("Remote debugging using ");
613 puts_filtered (name);
614 puts_filtered ("\n");
616 push_target (target); /* Switch to using remote target now */
618 /* Start out by trying the 'P' request to set registers. We set this each
619 time that we open a new target so that if the user switches from one
620 stub to another, we can (if the target is closed and reopened) cope. */
626 /* Without this, some commands which require an active target (such as kill)
627 won't work. This variable serves (at least) double duty as both the pid
628 of the target process (if it has such), and as a flag indicating that a
629 target is active. These functions should be split out into seperate
630 variables, especially since GDB will someday have a notion of debugging
631 several processes. */
633 inferior_pid = 42000;
634 /* Start the remote connection; if error (0), discard this target.
635 In particular, if the user quits, be sure to discard it
636 (we'd be in an inconsistent state otherwise). */
637 if (!catch_errors (remote_start_remote, (char *)0,
638 "Couldn't establish connection to remote target\n", RETURN_MASK_ALL))
646 /* tell the remote that we're using the extended protocol. */
653 /* This takes a program previously attached to and detaches it. After
654 this is done, GDB can be used to debug some other program. We
655 better not have left any breakpoints in the target program or it'll
656 die when it hits one. */
659 remote_detach (args, from_tty)
666 error ("Argument given to \"detach\" when remotely debugging.");
668 /* Tell the remote target to detach. */
674 puts_filtered ("Ending remote debugging.\n");
677 /* Convert hex digit A to a number. */
683 if (a >= '0' && a <= '9')
685 else if (a >= 'a' && a <= 'f')
687 else if (a >= 'A' && a <= 'F')
690 error ("Reply contains invalid hex digit %d", a);
693 /* Convert number NIB to a hex digit. */
705 /* Tell the remote machine to resume. */
707 static enum target_signal last_sent_signal = TARGET_SIGNAL_0;
711 remote_resume (pid, step, siggnal)
713 enum target_signal siggnal;
718 set_thread (inferior_pid, 0);
722 dcache_flush (remote_dcache);
724 last_sent_signal = siggnal;
725 last_sent_step = step;
727 /* A hook for when we need to do something at the last moment before
729 if (target_resume_hook)
730 (*target_resume_hook) ();
732 if (siggnal != TARGET_SIGNAL_0)
734 buf[0] = step ? 'S' : 'C';
735 buf[1] = tohex (((int)siggnal >> 4) & 0xf);
736 buf[2] = tohex ((int)siggnal & 0xf);
740 strcpy (buf, step ? "s": "c");
745 /* Send ^C to target to halt it. Target will respond, and send us a
749 remote_interrupt (signo)
752 /* If this doesn't work, try more severe steps. */
753 signal (signo, remote_interrupt_twice);
756 printf_unfiltered ("remote_interrupt called\n");
758 /* Send a break or a ^C, depending on user preference. */
760 SERIAL_SEND_BREAK (remote_desc);
762 SERIAL_WRITE (remote_desc, "\003", 1);
765 static void (*ofunc)();
767 /* The user typed ^C twice. */
769 remote_interrupt_twice (signo)
772 signal (signo, ofunc);
776 signal (signo, remote_interrupt);
779 /* Ask the user what to do when an interrupt is received. */
784 target_terminal_ours ();
786 if (query ("Interrupted while waiting for the program.\n\
787 Give up (and stop debugging it)? "))
789 target_mourn_inferior ();
790 return_to_top_level (RETURN_QUIT);
793 target_terminal_inferior ();
796 /* If nonzero, ignore the next kill. */
800 remote_console_output (msg)
805 for (p = msg; *p; p +=2)
808 char c = fromhex (p[0]) * 16 + fromhex (p[1]);
811 if (target_output_hook)
812 target_output_hook (tb);
814 fputs_filtered (tb, gdb_stdout);
818 /* Wait until the remote machine stops, then return,
819 storing status in STATUS just as `wait' would.
820 Returns "pid" (though it's not clear what, if anything, that
821 means in the case of this target). */
824 remote_wait (pid, status)
826 struct target_waitstatus *status;
828 unsigned char buf[PBUFSIZ];
831 status->kind = TARGET_WAITKIND_EXITED;
832 status->value.integer = 0;
838 ofunc = (void (*)()) signal (SIGINT, remote_interrupt);
839 getpkt ((char *) buf, 1);
840 signal (SIGINT, ofunc);
842 /* This is a hook for when we need to do something (perhaps the
843 collection of trace data) every time the target stops. */
844 if (target_wait_loop_hook)
845 (*target_wait_loop_hook) ();
849 case 'E': /* Error of some sort */
850 warning ("Remote failure reply: %s", buf);
852 case 'T': /* Status with PC, SP, FP, ... */
856 char regs[MAX_REGISTER_RAW_SIZE];
858 /* Expedited reply, containing Signal, {regno, reg} repeat */
859 /* format is: 'Tssn...:r...;n...:r...;n...:r...;#cc', where
861 n... = register number
862 r... = register contents
864 p = &buf[3]; /* after Txx */
871 regno = strtol ((const char *) p, &p_temp, 16); /* Read the register number */
872 p1 = (unsigned char *)p_temp;
876 p1 = (unsigned char *) strchr ((const char *) p, ':');
878 warning ("Malformed packet (missing colon): %s\n\
881 if (strncmp ((const char *) p, "thread", p1 - p) == 0)
883 thread_num = strtol ((const char *) ++p1, &p_temp, 16);
884 p = (unsigned char *)p_temp;
892 warning ("Malformed packet (missing colon): %s\n\
896 if (regno >= NUM_REGS)
897 warning ("Remote sent bad register number %ld: %s\n\
901 for (i = 0; i < REGISTER_RAW_SIZE (regno); i++)
903 if (p[0] == 0 || p[1] == 0)
904 warning ("Remote reply is too short: %s", buf);
905 regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
908 supply_register (regno, regs);
912 warning ("Remote register badly formatted: %s", buf);
916 case 'S': /* Old style status, just signal only */
917 status->kind = TARGET_WAITKIND_STOPPED;
918 status->value.sig = (enum target_signal)
919 (((fromhex (buf[1])) << 4) + (fromhex (buf[2])));
922 case 'W': /* Target exited */
924 /* The remote process exited. */
925 status->kind = TARGET_WAITKIND_EXITED;
926 status->value.integer = (fromhex (buf[1]) << 4) + fromhex (buf[2]);
930 status->kind = TARGET_WAITKIND_SIGNALLED;
931 status->value.sig = (enum target_signal)
932 (((fromhex (buf[1])) << 4) + (fromhex (buf[2])));
936 case 'O': /* Console output */
937 remote_console_output (buf + 1);
940 if (last_sent_signal != TARGET_SIGNAL_0)
942 /* Zero length reply means that we tried 'S' or 'C' and
943 the remote system doesn't support it. */
944 target_terminal_ours_for_output ();
946 ("Can't send signals to this remote system. %s not sent.\n",
947 target_signal_to_name (last_sent_signal));
948 last_sent_signal = TARGET_SIGNAL_0;
949 target_terminal_inferior ();
951 strcpy ((char *) buf, last_sent_step ? "s" : "c");
952 putpkt ((char *) buf);
955 /* else fallthrough */
957 warning ("Invalid remote reply: %s", buf);
962 if (thread_num != -1)
964 /* Initial thread value can only be acquired via wait, so deal with
965 this marker which is used before the first thread value is
967 if (inferior_pid == 42000)
969 inferior_pid = thread_num;
970 add_thread (inferior_pid);
977 /* Number of bytes of registers this stub implements. */
978 static int register_bytes_found;
980 /* Read the remote registers into the block REGS. */
981 /* Currently we just read all the registers, so we don't use regno. */
984 remote_fetch_registers (regno)
990 char regs[REGISTER_BYTES];
992 set_thread (inferior_pid, 1);
997 if (remote_register_buf_size == 0)
998 remote_register_buf_size = strlen (buf);
1000 /* Unimplemented registers read as all bits zero. */
1001 memset (regs, 0, REGISTER_BYTES);
1003 /* We can get out of synch in various cases. If the first character
1004 in the buffer is not a hex character, assume that has happened
1005 and try to fetch another packet to read. */
1006 while ((buf[0] < '0' || buf[0] > '9')
1007 && (buf[0] < 'a' || buf[0] > 'f'))
1010 printf_unfiltered ("Bad register packet; fetching a new packet\n");
1014 /* Reply describes registers byte by byte, each byte encoded as two
1015 hex characters. Suck them all up, then supply them to the
1016 register cacheing/storage mechanism. */
1019 for (i = 0; i < REGISTER_BYTES; i++)
1025 warning ("Remote reply is of odd length: %s", buf);
1026 /* Don't change register_bytes_found in this case, and don't
1027 print a second warning. */
1030 regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
1034 if (i != register_bytes_found)
1036 register_bytes_found = i;
1037 #ifdef REGISTER_BYTES_OK
1038 if (!REGISTER_BYTES_OK (i))
1039 warning ("Remote reply is too short: %s", buf);
1044 for (i = 0; i < NUM_REGS; i++)
1045 supply_register (i, ®s[REGISTER_BYTE(i)]);
1048 /* Prepare to store registers. Since we may send them all (using a
1049 'G' request), we have to read out the ones we don't want to change
1053 remote_prepare_to_store ()
1055 /* Make sure the entire registers array is valid. */
1056 read_register_bytes (0, (char *)NULL, REGISTER_BYTES);
1059 /* Store register REGNO, or all registers if REGNO == -1, from the contents
1060 of REGISTERS. FIXME: ignores errors. */
1063 remote_store_registers (regno)
1070 set_thread (inferior_pid, 1);
1072 if (regno >= 0 && stub_supports_P)
1074 /* Try storing a single register. */
1077 sprintf (buf, "P%x=", regno);
1078 p = buf + strlen (buf);
1079 regp = ®isters[REGISTER_BYTE (regno)];
1080 for (i = 0; i < REGISTER_RAW_SIZE (regno); ++i)
1082 *p++ = tohex ((regp[i] >> 4) & 0xf);
1083 *p++ = tohex (regp[i] & 0xf);
1089 /* The stub understands the 'P' request. We are done. */
1093 /* The stub does not support the 'P' request. Use 'G' instead,
1094 and don't try using 'P' in the future (it will just waste our
1096 stub_supports_P = 0;
1101 /* Command describes registers byte by byte,
1102 each byte encoded as two hex characters. */
1105 /* remote_prepare_to_store insures that register_bytes_found gets set. */
1106 for (i = 0; i < register_bytes_found; i++)
1108 *p++ = tohex ((registers[i] >> 4) & 0xf);
1109 *p++ = tohex (registers[i] & 0xf);
1117 Use of the data cache *used* to be disabled because it loses for looking at
1118 and changing hardware I/O ports and the like. Accepting `volatile'
1119 would perhaps be one way to fix it. Another idea would be to use the
1120 executable file for the text segment (for all SEC_CODE sections?
1121 For all SEC_READONLY sections?). This has problems if you want to
1122 actually see what the memory contains (e.g. self-modifying code,
1123 clobbered memory, user downloaded the wrong thing).
1125 Because it speeds so much up, it's now enabled, if you're playing
1126 with registers you turn it of (set remotecache 0)
1129 /* Read a word from remote address ADDR and return it.
1130 This goes through the data cache. */
1134 remote_fetch_word (addr)
1137 return dcache_fetch (remote_dcache, addr);
1140 /* Write a word WORD into remote address ADDR.
1141 This goes through the data cache. */
1144 remote_store_word (addr, word)
1148 dcache_poke (remote_dcache, addr, word);
1150 #endif /* 0 (unused?) */
1154 /* Return the number of hex digits in num. */
1162 for (i = 0; num != 0; i++)
1168 /* Write memory data directly to the remote machine.
1169 This does not inform the data cache; the data cache uses this.
1170 MEMADDR is the address in the remote memory space.
1171 MYADDR is the address of the buffer in our space.
1172 LEN is the number of bytes.
1174 Returns number of bytes transferred, or 0 for error. */
1177 remote_write_bytes (memaddr, myaddr, len)
1182 int max_buf_size; /* Max size of packet output buffer */
1185 /* Chop the transfer down if necessary */
1187 max_buf_size = min (remote_write_size, PBUFSIZ);
1188 if (remote_register_buf_size != 0)
1189 max_buf_size = min (max_buf_size, remote_register_buf_size);
1191 /* Subtract header overhead from max payload size - $M<memaddr>,<len>:#nn */
1192 max_buf_size -= 2 + hexnumlen (memaddr + len - 1) + 1 + hexnumlen (len) + 4;
1202 todo = min (len, max_buf_size / 2); /* num bytes that will fit */
1204 /* FIXME-32x64: Need a version of print_address_numeric which puts the
1205 result in a buffer like sprintf. */
1206 sprintf (buf, "M%lx,%x:", (unsigned long) memaddr, todo);
1208 /* We send target system values byte by byte, in increasing byte addresses,
1209 each byte encoded as two hex characters. */
1211 p = buf + strlen (buf);
1212 for (i = 0; i < todo; i++)
1214 *p++ = tohex ((myaddr[i] >> 4) & 0xf);
1215 *p++ = tohex (myaddr[i] & 0xf);
1224 /* There is no correspondance between what the remote protocol uses
1225 for errors and errno codes. We would like a cleaner way of
1226 representing errors (big enough to include errno codes, bfd_error
1227 codes, and others). But for now just return EIO. */
1238 /* Read memory data directly from the remote machine.
1239 This does not use the data cache; the data cache uses this.
1240 MEMADDR is the address in the remote memory space.
1241 MYADDR is the address of the buffer in our space.
1242 LEN is the number of bytes.
1244 Returns number of bytes transferred, or 0 for error. */
1247 remote_read_bytes (memaddr, myaddr, len)
1252 int max_buf_size; /* Max size of packet output buffer */
1255 /* Chop the transfer down if necessary */
1257 max_buf_size = min (remote_write_size, PBUFSIZ);
1258 if (remote_register_buf_size != 0)
1259 max_buf_size = min (max_buf_size, remote_register_buf_size);
1269 todo = min (len, max_buf_size / 2); /* num bytes that will fit */
1271 /* FIXME-32x64: Need a version of print_address_numeric which puts the
1272 result in a buffer like sprintf. */
1273 sprintf (buf, "m%lx,%x", (unsigned long) memaddr, todo);
1279 /* There is no correspondance between what the remote protocol uses
1280 for errors and errno codes. We would like a cleaner way of
1281 representing errors (big enough to include errno codes, bfd_error
1282 codes, and others). But for now just return EIO. */
1287 /* Reply describes memory byte by byte,
1288 each byte encoded as two hex characters. */
1291 for (i = 0; i < todo; i++)
1293 if (p[0] == 0 || p[1] == 0)
1294 /* Reply is short. This means that we were able to read only part
1295 of what we wanted to. */
1296 return i + (origlen - len);
1297 myaddr[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
1307 /* Read or write LEN bytes from inferior memory at MEMADDR, transferring
1308 to or from debugger address MYADDR. Write to inferior if SHOULD_WRITE is
1309 nonzero. Returns length of data written or read; 0 for error. */
1313 remote_xfer_memory(memaddr, myaddr, len, should_write, target)
1318 struct target_ops *target; /* ignored */
1320 #ifdef REMOTE_TRANSLATE_XFER_ADDRESS
1323 REMOTE_TRANSLATE_XFER_ADDRESS (memaddr, len, targaddr, targlen);
1330 return dcache_xfer_memory (remote_dcache, memaddr, myaddr, len, should_write);
1335 /* Enable after 4.12. */
1338 remote_search (len, data, mask, startaddr, increment, lorange, hirange
1339 addr_found, data_found)
1343 CORE_ADDR startaddr;
1347 CORE_ADDR *addr_found;
1350 if (increment == -4 && len == 4)
1352 long mask_long, data_long;
1353 long data_found_long;
1354 CORE_ADDR addr_we_found;
1356 long returned_long[2];
1359 mask_long = extract_unsigned_integer (mask, len);
1360 data_long = extract_unsigned_integer (data, len);
1361 sprintf (buf, "t%x:%x,%x", startaddr, data_long, mask_long);
1366 /* The stub doesn't support the 't' request. We might want to
1367 remember this fact, but on the other hand the stub could be
1368 switched on us. Maybe we should remember it only until
1369 the next "target remote". */
1370 generic_search (len, data, mask, startaddr, increment, lorange,
1371 hirange, addr_found, data_found);
1376 /* There is no correspondance between what the remote protocol uses
1377 for errors and errno codes. We would like a cleaner way of
1378 representing errors (big enough to include errno codes, bfd_error
1379 codes, and others). But for now just use EIO. */
1380 memory_error (EIO, startaddr);
1383 while (*p != '\0' && *p != ',')
1384 addr_we_found = (addr_we_found << 4) + fromhex (*p++);
1386 error ("Protocol error: short return for search");
1388 data_found_long = 0;
1389 while (*p != '\0' && *p != ',')
1390 data_found_long = (data_found_long << 4) + fromhex (*p++);
1391 /* Ignore anything after this comma, for future extensions. */
1393 if (addr_we_found < lorange || addr_we_found >= hirange)
1399 *addr_found = addr_we_found;
1400 *data_found = store_unsigned_integer (data_we_found, len);
1403 generic_search (len, data, mask, startaddr, increment, lorange,
1404 hirange, addr_found, data_found);
1409 remote_files_info (ignore)
1410 struct target_ops *ignore;
1412 puts_filtered ("Debugging a target over a serial line.\n");
1415 /* Stuff for dealing with the packets which are part of this protocol.
1416 See comment at top of file for details. */
1418 /* Read a single character from the remote end, masking it down to 7 bits. */
1426 ch = SERIAL_READCHAR (remote_desc, timeout);
1431 error ("Remote connection closed");
1433 perror_with_name ("Remote communication error");
1434 case SERIAL_TIMEOUT:
1441 /* Send the command in BUF to the remote machine,
1442 and read the reply into BUF.
1443 Report an error if we get an error reply. */
1453 error ("Remote failure reply: %s", buf);
1456 /* Display a null-terminated packet on stdout, for debugging, using C
1459 print_packet (char *buf)
1461 puts_filtered ("\"");
1463 gdb_printchar (*buf++, gdb_stdout, '"');
1464 puts_filtered ("\"");
1468 /* Send a packet to the remote machine, with error checking.
1469 The data of the packet is in BUF. */
1476 unsigned char csum = 0;
1478 int cnt = strlen (buf);
1483 /* Copy the packet into buffer BUF2, encapsulating it
1484 and giving it a checksum. */
1486 if (cnt > (int) sizeof (buf2) - 5) /* Prosanity check */
1492 for (i = 0; i < cnt; i++)
1498 *p++ = tohex ((csum >> 4) & 0xf);
1499 *p++ = tohex (csum & 0xf);
1501 /* Send it over and over until we get a positive ack. */
1505 int started_error_output = 0;
1510 printf_unfiltered ("Sending packet: %s...", buf2);
1511 gdb_flush(gdb_stdout);
1513 if (SERIAL_WRITE (remote_desc, buf2, p - buf2))
1514 perror_with_name ("putpkt: write failed");
1516 /* read until either a timeout occurs (-2) or '+' is read */
1519 ch = readchar (remote_timeout);
1526 case SERIAL_TIMEOUT:
1528 if (started_error_output)
1530 putchar_unfiltered ('\n');
1531 started_error_output = 0;
1540 printf_unfiltered("Ack\n");
1542 case SERIAL_TIMEOUT:
1546 break; /* Retransmit buffer */
1549 char junkbuf[PBUFSIZ];
1551 /* It's probably an old response, and we're out of sync. Just
1552 gobble up the packet and ignore it. */
1553 getpkt (junkbuf, 0);
1554 continue; /* Now, go look for + */
1559 if (!started_error_output)
1561 started_error_output = 1;
1562 printf_unfiltered ("putpkt: Junk: ");
1564 putchar_unfiltered (ch & 0177);
1568 break; /* Here to retransmit */
1572 /* This is wrong. If doing a long backtrace, the user should be
1573 able to get out next time we call QUIT, without anything as violent
1574 as interrupt_query. If we want to provide a way out of here
1575 without getting to the next QUIT, it should be based on hitting
1576 ^C twice as in remote_wait. */
1586 /* Come here after finding the start of the frame. Collect the rest into BUF,
1587 verifying the checksum, length, and handling run-length compression.
1588 Returns 0 on any error, 1 on success. */
1603 c = readchar (remote_timeout);
1607 case SERIAL_TIMEOUT:
1609 puts_filtered ("Timeout in mid-packet, retrying\n");
1613 puts_filtered ("Saw new packet start in middle of old one\n");
1614 return 0; /* Start a new packet, count retries */
1617 unsigned char pktcsum;
1621 pktcsum = fromhex (readchar (remote_timeout)) << 4;
1622 pktcsum |= fromhex (readchar (remote_timeout));
1624 if (csum == pktcsum)
1629 printf_filtered ("Bad checksum, sentsum=0x%x, csum=0x%x, buf=",
1631 puts_filtered (buf);
1632 puts_filtered ("\n");
1636 case '*': /* Run length encoding */
1638 c = readchar (remote_timeout);
1640 c = c - ' ' + 3; /* Compute repeat count */
1643 if (c > 0 && c < 255 && bp + c - 1 < buf + PBUFSIZ - 1)
1645 memset (bp, *(bp - 1), c);
1651 printf_filtered ("Repeat count %d too large for buffer: ", c);
1652 puts_filtered (buf);
1653 puts_filtered ("\n");
1657 if (bp < buf + PBUFSIZ - 1)
1665 puts_filtered ("Remote packet too long: ");
1666 puts_filtered (buf);
1667 puts_filtered ("\n");
1674 /* Read a packet from the remote machine, with error checking,
1675 and store it in BUF. BUF is expected to be of size PBUFSIZ.
1676 If FOREVER, wait forever rather than timing out; this is used
1677 while the target is executing user code. */
1680 getpkt (buf, forever)
1689 strcpy (buf,"timeout");
1693 #ifdef MAINTENANCE_CMDS
1694 timeout = watchdog > 0 ? watchdog : -1;
1701 timeout = remote_timeout;
1705 for (tries = 1; tries <= MAX_TRIES; tries++)
1707 /* This can loop forever if the remote side sends us characters
1708 continuously, but if it pauses, we'll get a zero from readchar
1709 because of timeout. Then we'll count that as a retry. */
1711 /* Note that we will only wait forever prior to the start of a packet.
1712 After that, we expect characters to arrive at a brisk pace. They
1713 should show up within remote_timeout intervals. */
1717 c = readchar (timeout);
1719 if (c == SERIAL_TIMEOUT)
1721 #ifdef MAINTENANCE_CMDS
1722 if (forever) /* Watchdog went off. Kill the target. */
1724 target_mourn_inferior ();
1725 error ("Watchdog has expired. Target detached.\n");
1729 puts_filtered ("Timed out.\n");
1735 /* We've found the start of a packet, now collect the data. */
1737 val = read_frame (buf);
1742 fprintf_unfiltered (gdb_stdout, "Packet received: %s\n", buf);
1743 SERIAL_WRITE (remote_desc, "+", 1);
1747 /* Try the whole thing again. */
1749 SERIAL_WRITE (remote_desc, "-", 1);
1752 /* We have tried hard enough, and just can't receive the packet. Give up. */
1754 printf_unfiltered ("Ignoring packet error, continuing...\n");
1755 SERIAL_WRITE (remote_desc, "+", 1);
1761 /* For some mysterious reason, wait_for_inferior calls kill instead of
1762 mourn after it gets TARGET_WAITKIND_SIGNALLED. Work around it. */
1766 target_mourn_inferior ();
1770 /* Use catch_errors so the user can quit from gdb even when we aren't on
1771 speaking terms with the remote system. */
1772 catch_errors (putpkt, "k", "", RETURN_MASK_ERROR);
1774 /* Don't wait for it to die. I'm not really sure it matters whether
1775 we do or not. For the existing stubs, kill is a noop. */
1776 target_mourn_inferior ();
1782 remote_mourn_1 (&remote_ops);
1786 extended_remote_mourn ()
1788 /* We do _not_ want to mourn the target like this; this will
1789 remove the extended remote target from the target stack,
1790 and the next time the user says "run" it'll fail.
1792 FIXME: What is the right thing to do here? */
1794 remote_mourn_1 (&extended_remote_ops);
1798 /* Worker function for remote_mourn. */
1800 remote_mourn_1 (target)
1801 struct target_ops *target;
1803 unpush_target (target);
1804 generic_mourn_inferior ();
1807 /* In the extended protocol we want to be able to do things like
1808 "run" and have them basically work as expected. So we need
1809 a special create_inferior function.
1811 FIXME: One day add support for changing the exec file
1812 we're debugging, arguments and an environment. */
1815 extended_remote_create_inferior (exec_file, args, env)
1820 /* Rip out the breakpoints; we'll reinsert them after restarting
1821 the remote server. */
1822 remove_breakpoints ();
1824 /* Now restart the remote server. */
1825 extended_remote_restart ();
1827 /* Now put the breakpoints back in. This way we're safe if the
1828 restart function works via a unix fork on the remote side. */
1829 insert_breakpoints ();
1831 /* Clean up from the last time we were running. */
1832 clear_proceed_status ();
1834 /* Let the remote process run. */
1835 proceed (-1, TARGET_SIGNAL_0, 0);
1839 /* On some machines, e.g. 68k, we may use a different breakpoint instruction
1840 than other targets; in those use REMOTE_BREAKPOINT instead of just
1841 BREAKPOINT. Also, bi-endian targets may define LITTLE_REMOTE_BREAKPOINT
1842 and BIG_REMOTE_BREAKPOINT. If none of these are defined, we just call
1843 the standard routines that are in mem-break.c. */
1845 /* FIXME, these ought to be done in a more dynamic fashion. For instance,
1846 the choice of breakpoint instruction affects target program design and
1847 vice versa, and by making it user-tweakable, the special code here
1848 goes away and we need fewer special GDB configurations. */
1850 #if defined (LITTLE_REMOTE_BREAKPOINT) && defined (BIG_REMOTE_BREAKPOINT) && !defined(REMOTE_BREAKPOINT)
1851 #define REMOTE_BREAKPOINT
1854 #ifdef REMOTE_BREAKPOINT
1856 /* If the target isn't bi-endian, just pretend it is. */
1857 #if !defined (LITTLE_REMOTE_BREAKPOINT) && !defined (BIG_REMOTE_BREAKPOINT)
1858 #define LITTLE_REMOTE_BREAKPOINT REMOTE_BREAKPOINT
1859 #define BIG_REMOTE_BREAKPOINT REMOTE_BREAKPOINT
1862 static unsigned char big_break_insn[] = BIG_REMOTE_BREAKPOINT;
1863 static unsigned char little_break_insn[] = LITTLE_REMOTE_BREAKPOINT;
1865 #endif /* REMOTE_BREAKPOINT */
1867 /* Insert a breakpoint on targets that don't have any better breakpoint
1868 support. We read the contents of the target location and stash it,
1869 then overwrite it with a breakpoint instruction. ADDR is the target
1870 location in the target machine. CONTENTS_CACHE is a pointer to
1871 memory allocated for saving the target contents. It is guaranteed
1872 by the caller to be long enough to save sizeof BREAKPOINT bytes (this
1873 is accomplished via BREAKPOINT_MAX). */
1876 remote_insert_breakpoint (addr, contents_cache)
1878 char *contents_cache;
1880 #ifdef REMOTE_BREAKPOINT
1883 val = target_read_memory (addr, contents_cache, sizeof big_break_insn);
1887 if (TARGET_BYTE_ORDER == BIG_ENDIAN)
1888 val = target_write_memory (addr, (char *) big_break_insn,
1889 sizeof big_break_insn);
1891 val = target_write_memory (addr, (char *) little_break_insn,
1892 sizeof little_break_insn);
1897 return memory_insert_breakpoint (addr, contents_cache);
1898 #endif /* REMOTE_BREAKPOINT */
1902 remote_remove_breakpoint (addr, contents_cache)
1904 char *contents_cache;
1906 #ifdef REMOTE_BREAKPOINT
1907 return target_write_memory (addr, contents_cache, sizeof big_break_insn);
1909 return memory_remove_breakpoint (addr, contents_cache);
1910 #endif /* REMOTE_BREAKPOINT */
1913 /* Some targets are only capable of doing downloads, and afterwards they switch
1914 to the remote serial protocol. This function provides a clean way to get
1915 from the download target to the remote target. It's basically just a
1916 wrapper so that we don't have to expose any of the internal workings of
1919 Prior to calling this routine, you should shutdown the current target code,
1920 else you will get the "A program is being debugged already..." message.
1921 Usually a call to pop_target() suffices.
1925 push_remote_target (name, from_tty)
1929 printf_filtered ("Switching to remote protocol\n");
1930 remote_open (name, from_tty);
1933 /* Other targets want to use the entire remote serial module but with
1934 certain remote_ops overridden. */
1937 open_remote_target (name, from_tty, target, extended_p)
1940 struct target_ops *target;
1943 printf_filtered ("Selecting the %sremote protocol\n",
1944 (extended_p ? "extended-" : ""));
1945 remote_open_1 (name, from_tty, target, extended_p);
1948 /* Table used by the crc32 function to calcuate the checksum. */
1949 static unsigned long crc32_table[256] = {0, 0};
1951 static unsigned long
1952 crc32 (buf, len, crc)
1957 if (! crc32_table[1])
1959 /* Initialize the CRC table and the decoding table. */
1963 for (i = 0; i < 256; i++)
1965 for (c = i << 24, j = 8; j > 0; --j)
1966 c = c & 0x80000000 ? (c << 1) ^ 0x04c11db7 : (c << 1);
1973 crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ *buf) & 255];
1980 compare_sections_command (args, from_tty)
1985 unsigned long host_crc, target_crc;
1986 extern bfd *exec_bfd;
1987 struct cleanup *old_chain;
1988 char *tmp, *sectdata, *sectname, buf[PBUFSIZ];
1995 error ("command cannot be used without an exec file");
1996 if (!current_target.to_shortname ||
1997 strcmp (current_target.to_shortname, "remote") != 0)
1998 error ("command can only be used with remote target");
2000 for (s = exec_bfd->sections; s; s = s->next)
2002 if (!(s->flags & SEC_LOAD))
2003 continue; /* skip non-loadable section */
2005 size = bfd_get_section_size_before_reloc (s);
2007 continue; /* skip zero-length section */
2009 sectname = (char *) bfd_get_section_name (exec_bfd, s);
2010 if (args && strcmp (args, sectname) != 0)
2011 continue; /* not the section selected by user */
2013 matched = 1; /* do this section */
2015 /* FIXME: assumes lma can fit into long */
2016 sprintf (buf, "qCRC:%lx,%lx", (long) lma, (long) size);
2019 /* be clever; compute the host_crc before waiting for target reply */
2020 sectdata = xmalloc (size);
2021 old_chain = make_cleanup (free, sectdata);
2022 bfd_get_section_contents (exec_bfd, s, sectdata, 0, size);
2023 host_crc = crc32 ((unsigned char *) sectdata, size, 0xffffffff);
2027 error ("target memory fault, section %s, range 0x%08x -- 0x%08x",
2028 sectname, lma, lma + size);
2030 error ("remote target does not support this operation");
2032 for (target_crc = 0, tmp = &buf[1]; *tmp; tmp++)
2033 target_crc = target_crc * 16 + fromhex (*tmp);
2035 printf_filtered ("Section %s, range 0x%08x -- 0x%08x: ",
2036 sectname, lma, lma + size);
2037 if (host_crc == target_crc)
2038 printf_filtered ("matched.\n");
2041 printf_filtered ("MIS-MATCHED!\n");
2045 do_cleanups (old_chain);
2048 warning ("One or more sections of the remote executable does not match\nthe loaded file\n");
2049 if (args && !matched)
2050 printf_filtered ("No loaded section named '%s'.\n", args);
2054 packet_command (args, from_tty)
2062 if (!current_target.to_shortname ||
2063 strcmp (current_target.to_shortname, "remote") != 0)
2064 error ("command can only be used with remote target");
2067 error ("remote-packet command requires packet text as argument");
2069 puts_filtered ("sending: ");
2070 print_packet (args);
2071 puts_filtered ("\n");
2075 puts_filtered ("received: ");
2077 puts_filtered ("\n");
2083 remote_ops.to_shortname = "remote";
2084 remote_ops.to_longname = "Remote serial target in gdb-specific protocol";
2085 remote_ops.to_doc = "Use a remote computer via a serial line; using a gdb-specific protocol.\n\
2086 Specify the serial device it is connected to (e.g. /dev/ttya).";
2087 remote_ops.to_open = remote_open;
2088 remote_ops.to_close = remote_close;
2089 remote_ops.to_detach = remote_detach;
2090 remote_ops.to_resume = remote_resume;
2091 remote_ops.to_wait = remote_wait;
2092 remote_ops.to_fetch_registers = remote_fetch_registers;
2093 remote_ops.to_store_registers = remote_store_registers;
2094 remote_ops.to_prepare_to_store = remote_prepare_to_store;
2095 remote_ops.to_xfer_memory = remote_xfer_memory;
2096 remote_ops.to_files_info = remote_files_info;
2097 remote_ops.to_insert_breakpoint = remote_insert_breakpoint;
2098 remote_ops.to_remove_breakpoint = remote_remove_breakpoint;
2099 remote_ops.to_kill = remote_kill;
2100 remote_ops.to_load = generic_load;
2101 remote_ops.to_mourn_inferior = remote_mourn;
2102 remote_ops.to_thread_alive = remote_thread_alive;
2103 remote_ops.to_stratum = process_stratum;
2104 remote_ops.to_has_all_memory = 1;
2105 remote_ops.to_has_memory = 1;
2106 remote_ops.to_has_stack = 1;
2107 remote_ops.to_has_registers = 1;
2108 remote_ops.to_has_execution = 1;
2109 remote_ops.to_magic = OPS_MAGIC;
2113 init_extended_remote_ops ()
2115 extended_remote_ops = remote_ops;
2117 extended_remote_ops.to_shortname = "extended-remote";
2118 extended_remote_ops.to_longname = "Extended remote serial target in gdb-specific protocol";
2119 extended_remote_ops.to_doc = "Use a remote computer via a serial line; using a gdb-specific protocol.\n\
2120 Specify the serial device it is connected to (e.g. /dev/ttya).",
2121 extended_remote_ops.to_open = extended_remote_open;
2122 extended_remote_ops.to_create_inferior = extended_remote_create_inferior;
2123 extended_remote_ops.to_mourn_inferior = extended_remote_mourn;
2127 _initialize_remote ()
2130 add_target (&remote_ops);
2132 init_extended_remote_ops ();
2133 add_target (&extended_remote_ops);
2135 add_cmd ("compare-sections", class_obscure, compare_sections_command,
2136 "Compare section data on target to the exec file.\n\
2137 Argument is a single section name (default: all loaded sections).",
2140 add_cmd ("packet", class_maintenance, packet_command,
2141 "Send an arbitrary packet to a remote target.\n\
2142 maintenance packet TEXT\n\
2143 If GDB is talking to an inferior via the GDB serial protocol, then\n\
2144 this command sends the string TEXT to the inferior, and displays the\n\
2145 response packet. GDB supplies the initial `$' character, and the\n\
2146 terminating `#' character and checksum. This command was originally\n\
2147 provided for use by the gdb.emc test suite.",
2150 add_show_from_set (add_set_cmd ("remotetimeout", no_class,
2151 var_integer, (char *)&remote_timeout,
2152 "Set timeout value for remote read.\n", &setlist),
2155 add_show_from_set (add_set_cmd ("remotebreak", no_class,
2156 var_integer, (char *)&remote_break,
2157 "Set whether to send break if interrupted.\n", &setlist),
2160 add_show_from_set (add_set_cmd ("remotewritesize", no_class,
2161 var_integer, (char *)&remote_write_size,
2162 "Set the maximum number of bytes in each memory write packet.\n", &setlist),