1 /* Remote target communications for serial-line targets using SDS' protocol.
2 Copyright 1997 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 /* This interface was written by studying the behavior of the SDS
21 monitor on an ADS 821/860 board, and by consulting the
22 documentation of the monitor that is available on Motorola's web
26 #include "gdb_string.h"
36 #include "gdb-stabs.h"
37 #include "gdbthread.h"
42 #include <sys/types.h>
48 /* Declarations of local functions. */
50 static int sds_write_bytes PARAMS ((CORE_ADDR, char *, int));
52 static int sds_read_bytes PARAMS ((CORE_ADDR, char *, int));
54 static void sds_files_info PARAMS ((struct target_ops *ignore));
56 static int sds_xfer_memory PARAMS ((CORE_ADDR, char *,
57 int, int, struct target_ops *));
59 static void sds_prepare_to_store PARAMS ((void));
61 static void sds_fetch_registers PARAMS ((int));
63 static void sds_resume PARAMS ((int, int, enum target_signal));
65 static int sds_start_remote PARAMS ((char *));
67 static void sds_open PARAMS ((char *, int));
69 static void sds_close PARAMS ((int));
71 static void sds_store_registers PARAMS ((int));
73 static void sds_mourn PARAMS ((void));
75 static void sds_restart PARAMS ((void));
77 static void sds_create_inferior PARAMS ((char *, char *, char **));
79 static int getmessage PARAMS ((unsigned char *, int));
81 static int putmessage PARAMS ((unsigned char *, int));
83 static int sds_send PARAMS ((unsigned char *, int));
85 static int readchar PARAMS ((int));
87 static int sds_wait PARAMS ((int, struct target_waitstatus *));
89 static void sds_kill PARAMS ((void));
91 static int tohex PARAMS ((int));
93 static int fromhex PARAMS ((int));
95 static void sds_detach PARAMS ((char *, int));
97 static void sds_interrupt PARAMS ((int));
99 static void sds_interrupt_twice PARAMS ((int));
101 static void interrupt_query PARAMS ((void));
103 static int read_frame PARAMS ((char *));
105 static int sds_insert_breakpoint PARAMS ((CORE_ADDR, char *));
107 static int sds_remove_breakpoint PARAMS ((CORE_ADDR, char *));
110 static struct target_ops sds_ops; /* Forward decl */
112 /* This was 5 seconds, which is a long time to sit and wait.
113 Unless this is going though some terminal server or multiplexer or
114 other form of hairy serial connection, I would think 2 seconds would
117 /* Changed to allow option to set timeout value.
118 was static int sds_timeout = 2; */
119 static int sds_timeout = 2;
121 /* This variable chooses whether to send a ^C or a break when the user
122 requests program interruption. Although ^C is usually what remote
123 systems expect, and that is the default here, sometimes a break is
124 preferable instead. */
126 static int sds_break;
128 /* Descriptor for I/O to remote machine. Initialize it to NULL so
129 that sds_open knows that we don't have a file open when the program
132 static serial_t sds_desc = NULL;
134 /* Having this larger than 400 causes us to be incompatible with m68k-stub.c
135 and i386-stub.c. Normally, no one would notice because it only matters
136 for writing large chunks of memory (e.g. in downloads). Also, this needs
137 to be more than 400 if required to hold the registers (see below, where
138 we round it up based on REGISTER_BYTES). */
141 /* Maximum number of bytes to read/write at once. The value here
142 is chosen to fill up a packet (the headers account for the 32). */
143 #define MAXBUFBYTES ((PBUFSIZ-32)/2)
145 /* Round up PBUFSIZ to hold all the registers, at least. */
146 /* The blank line after the #if seems to be required to work around a
147 bug in HP's PA compiler. */
148 #if REGISTER_BYTES > MAXBUFBYTES
151 #define PBUFSIZ (REGISTER_BYTES * 2 + 32)
154 static int next_msg_id;
156 static int just_started;
158 static int message_pending;
161 /* Restart the remote side; this is an extended protocol operation. */
168 /* Clean up connection to a remote debugger. */
176 SERIAL_CLOSE (sds_desc);
180 /* Stub for catch_errors. */
183 sds_start_remote (dummy)
187 unsigned char buf[200];
189 immediate_quit = 1; /* Allow user to interrupt it */
191 /* Ack any packet which the remote side has already sent. */
192 SERIAL_WRITE (sds_desc, "{#*\r\n", 5);
193 SERIAL_WRITE (sds_desc, "{#}\r\n", 5);
195 while ((c = readchar (1)) >= 0)
196 printf_unfiltered ("%c");
197 printf_unfiltered ("\n");
209 start_remote (); /* Initialize gdb process mechanisms */
213 /* Open a connection to a remote debugger.
214 NAME is the filename used for communication. */
216 static DCACHE *sds_dcache;
219 sds_open (name, from_tty)
224 error ("To open a remote debug connection, you need to specify what serial\n\
225 device is attached to the remote system (e.g. /dev/ttya).");
227 target_preopen (from_tty);
229 unpush_target (&sds_ops);
231 sds_dcache = dcache_init (sds_read_bytes, sds_write_bytes);
233 sds_desc = SERIAL_OPEN (name);
235 perror_with_name (name);
239 if (SERIAL_SETBAUDRATE (sds_desc, baud_rate))
241 SERIAL_CLOSE (sds_desc);
242 perror_with_name (name);
247 SERIAL_RAW (sds_desc);
249 /* If there is something sitting in the buffer we might take it as a
250 response to a command, which would be bad. */
251 SERIAL_FLUSH_INPUT (sds_desc);
255 puts_filtered ("Remote debugging using ");
256 puts_filtered (name);
257 puts_filtered ("\n");
259 push_target (&sds_ops); /* Switch to using remote target now */
261 /* Without this, some commands which require an active target (such
262 as kill) won't work. This variable serves (at least) double duty
263 as both the pid of the target process (if it has such), and as a
264 flag indicating that a target is active. These functions should
265 be split out into seperate variables, especially since GDB will
266 someday have a notion of debugging several processes. */
268 inferior_pid = 42000;
272 /* Start the remote connection; if error (0), discard this target.
273 In particular, if the user quits, be sure to discard it (we'd be
274 in an inconsistent state otherwise). */
275 if (!catch_errors (sds_start_remote, (char *)0,
276 "Couldn't establish connection to remote target\n",
281 /* This takes a program previously attached to and detaches it. After
282 this is done, GDB can be used to debug some other program. We
283 better not have left any breakpoints in the target program or it'll
284 die when it hits one. */
287 sds_detach (args, from_tty)
294 error ("Argument given to \"detach\" when remotely debugging.");
297 /* Tell the remote target to detach. */
304 puts_filtered ("Ending remote debugging.\n");
307 /* Convert hex digit A to a number. */
313 if (a >= '0' && a <= '9')
315 else if (a >= 'a' && a <= 'f')
318 error ("Reply contains invalid hex digit %d", a);
321 /* Convert number NIB to a hex digit. */
334 tob64 (inbuf, outbuf, len)
335 unsigned char *inbuf;
342 error ("bad length");
344 for (i = 0; i < len; i += 3)
346 /* Collect the next three bytes into a number. */
347 sum = ((long) *inbuf++) << 16;
348 sum |= ((long) *inbuf++) << 8;
349 sum |= ((long) *inbuf++);
351 /* Spit out 4 6-bit encodings. */
352 *outbuf++ = ((sum >> 18) & 0x3f) + '0';
353 *outbuf++ = ((sum >> 12) & 0x3f) + '0';
354 *outbuf++ = ((sum >> 6) & 0x3f) + '0';
355 *outbuf++ = (sum & 0x3f) + '0';
360 fromb64 (inbuf, outbuf, len)
361 char *inbuf, *outbuf;
367 error ("bad length");
369 for (i = 0; i < len; i += 4)
371 /* Collect 4 6-bit digits. */
372 sum = (*inbuf++ - '0') << 18;
373 sum |= (*inbuf++ - '0') << 12;
374 sum |= (*inbuf++ - '0') << 6;
375 sum |= (*inbuf++ - '0');
377 /* Now take the resulting 24-bit number and get three bytes out
379 *outbuf++ = (sum >> 16) & 0xff;
380 *outbuf++ = (sum >> 8) & 0xff;
381 *outbuf++ = sum & 0xff;
384 return (len / 4) * 3;
388 /* Tell the remote machine to resume. */
390 static enum target_signal last_sent_signal = TARGET_SIGNAL_0;
394 sds_resume (pid, step, siggnal)
396 enum target_signal siggnal;
398 unsigned char buf[PBUFSIZ];
400 dcache_flush (sds_dcache);
402 last_sent_signal = siggnal;
403 last_sent_step = step;
405 buf[0] = (step ? 21 : 20);
406 buf[1] = 0; /* (should be signal?) */
411 /* Send ^C to target to halt it. Target will respond, and send us a
415 sds_interrupt (signo)
418 /* If this doesn't work, try more severe steps. */
419 signal (signo, sds_interrupt_twice);
422 printf_unfiltered ("sds_interrupt called\n");
424 /* Send a break or a ^C, depending on user preference. */
426 SERIAL_SEND_BREAK (sds_desc);
428 SERIAL_WRITE (sds_desc, "\003", 1);
431 static void (*ofunc)();
433 /* The user typed ^C twice. */
435 sds_interrupt_twice (signo)
438 signal (signo, ofunc);
442 signal (signo, sds_interrupt);
445 /* Ask the user what to do when an interrupt is received. */
450 target_terminal_ours ();
452 if (query ("Interrupted while waiting for the program.\n\
453 Give up (and stop debugging it)? "))
455 target_mourn_inferior ();
456 return_to_top_level (RETURN_QUIT);
459 target_terminal_inferior ();
462 /* If nonzero, ignore the next kill. */
465 /* Wait until the remote machine stops, then return, storing status in
466 STATUS just as `wait' would. Returns "pid" (though it's not clear
467 what, if anything, that means in the case of this target). */
470 sds_wait (pid, status)
472 struct target_waitstatus *status;
474 unsigned char buf[PBUFSIZ];
477 status->kind = TARGET_WAITKIND_EXITED;
478 status->value.integer = 0;
480 ofunc = (void (*)()) signal (SIGINT, sds_interrupt);
482 signal (SIGINT, ofunc);
487 status->kind = TARGET_WAITKIND_STOPPED;
498 retlen = sds_send (buf, 1);
500 status->kind = TARGET_WAITKIND_STOPPED;
508 /* Number of bytes of registers this stub implements. */
509 static int register_bytes_found;
511 /* Read the remote registers into the block REGS. */
512 /* Currently we just read all the registers, so we don't use regno. */
516 sds_fetch_registers (regno)
519 unsigned char buf[PBUFSIZ];
522 char regs[REGISTER_BYTES];
524 /* Unimplemented registers read as all bits zero. */
525 memset (regs, 0, REGISTER_BYTES);
530 len = sds_send (buf, 3);
532 /* Reply describes registers byte by byte. Suck them all up, then
533 supply them to the register cacheing/storage mechanism. */
535 for (i = 0; i < len; i++)
541 len = sds_send (buf, 3);
543 for (i = 0; i < 4 * 6; i++)
545 regs[i + 4 * 32 + 8 * 32] = buf[i];
548 /* (should warn about reply too short) */
551 for (i = 0; i < NUM_REGS; i++)
552 supply_register (i, ®s[REGISTER_BYTE(i)]);
555 /* Prepare to store registers. Since we may send them all (using a
556 'G' request), we have to read out the ones we don't want to change
560 sds_prepare_to_store ()
562 /* Make sure the entire registers array is valid. */
563 read_register_bytes (0, (char *)NULL, REGISTER_BYTES);
566 /* Store register REGNO, or all registers if REGNO == -1, from the contents
567 of REGISTERS. FIXME: ignores errors. */
570 sds_store_registers (regno)
573 unsigned char buf[PBUFSIZ];
584 for (i = 0; i < 4 * 32; i++)
587 sds_send (buf, 4 + 4 * 32);
596 for (i = 0; i < 4 * 10; i++)
599 sds_send (buf, 4 + 4 * 10);
603 Use of the data cache *used* to be disabled because it loses for looking at
604 and changing hardware I/O ports and the like. Accepting `volatile'
605 would perhaps be one way to fix it. Another idea would be to use the
606 executable file for the text segment (for all SEC_CODE sections?
607 For all SEC_READONLY sections?). This has problems if you want to
608 actually see what the memory contains (e.g. self-modifying code,
609 clobbered memory, user downloaded the wrong thing).
611 Because it speeds so much up, it's now enabled, if you're playing
612 with registers you turn it of (set remotecache 0)
615 /* Read a word from remote address ADDR and return it.
616 This goes through the data cache. */
620 sds_fetch_word (addr)
623 return dcache_fetch (sds_dcache, addr);
626 /* Write a word WORD into remote address ADDR.
627 This goes through the data cache. */
630 sds_store_word (addr, word)
634 dcache_poke (sds_dcache, addr, word);
636 #endif /* 0 (unused?) */
639 /* Write memory data directly to the remote machine. This does not
640 inform the data cache; the data cache uses this. MEMADDR is the
641 address in the remote memory space. MYADDR is the address of the
642 buffer in our space. LEN is the number of bytes.
644 Returns number of bytes transferred, or 0 for error. */
647 sds_write_bytes (memaddr, myaddr, len)
652 int max_buf_size; /* Max size of packet output buffer */
654 unsigned char buf[PBUFSIZ];
658 /* Chop the transfer down if necessary */
665 todo = min (len, max_buf_size);
669 buf[2] = (int) (memaddr >> 24) & 0xff;
670 buf[3] = (int) (memaddr >> 16) & 0xff;
671 buf[4] = (int) (memaddr >> 8) & 0xff;
672 buf[5] = (int) (memaddr ) & 0xff;
676 for (i = 0; i < todo; i++)
677 buf[i + 8] = myaddr[i];
679 sds_send (buf, 8 + todo);
681 /* (should look at result) */
690 /* Read memory data directly from the remote machine. This does not
691 use the data cache; the data cache uses this. MEMADDR is the
692 address in the remote memory space. MYADDR is the address of the
693 buffer in our space. LEN is the number of bytes.
695 Returns number of bytes transferred, or 0 for error. */
698 sds_read_bytes (memaddr, myaddr, len)
703 int max_buf_size; /* Max size of packet output buffer */
705 unsigned char buf[PBUFSIZ];
709 /* Chop the transfer down if necessary */
716 todo = min (len, max_buf_size);
720 buf[2] = (int) (memaddr >> 24) & 0xff;
721 buf[3] = (int) (memaddr >> 16) & 0xff;
722 buf[4] = (int) (memaddr >> 8) & 0xff;
723 buf[5] = (int) (memaddr ) & 0xff;
724 buf[6] = (int) (todo >> 8) & 0xff;
725 buf[7] = (int) (todo ) & 0xff;
728 retlen = sds_send (buf, 9);
730 if (retlen - 2 != todo)
735 /* Reply describes memory byte by byte. */
737 for (i = 0; i < todo; i++)
738 myaddr[i] = buf[i + 2];
748 /* Read or write LEN bytes from inferior memory at MEMADDR,
749 transferring to or from debugger address MYADDR. Write to inferior
750 if SHOULD_WRITE is nonzero. Returns length of data written or
751 read; 0 for error. */
755 sds_xfer_memory(memaddr, myaddr, len, should_write, target)
760 struct target_ops *target; /* ignored */
762 return dcache_xfer_memory (sds_dcache, memaddr, myaddr, len, should_write);
767 sds_files_info (ignore)
768 struct target_ops *ignore;
770 puts_filtered ("Debugging a target over a serial line.\n");
773 /* Stuff for dealing with the packets which are part of this protocol.
774 See comment at top of file for details. */
776 /* Read a single character from the remote end, masking it down to 7 bits. */
784 ch = SERIAL_READCHAR (sds_desc, timeout);
786 if (remote_debug > 1 && ch >= 0)
787 printf_unfiltered("%c(%x)", ch, ch);
792 error ("Remote connection closed");
794 perror_with_name ("Remote communication error");
803 compute_checksum (csum, buf, len)
809 for (i = 0; i < len; ++i)
810 csum += (unsigned char) buf[i];
816 /* Send the command in BUF to the remote machine, and read the reply
824 putmessage (buf, len);
826 return getmessage (buf, 0);
829 /* Send a message to the remote machine. */
832 putmessage (buf, len)
837 unsigned char csum = 0;
838 char buf2[PBUFSIZ], buf3[PBUFSIZ];
839 unsigned char header[3];
844 /* Copy the packet into buffer BUF2, encapsulating it
845 and giving it a checksum. */
847 if (len > (int) sizeof (buf2) - 5) /* Prosanity check */
852 fprintf_unfiltered (gdb_stderr, "Message to send: \"");
853 for (i = 0; i < len; ++i)
854 fprintf_unfiltered (gdb_stderr, "%02x", buf[i]);
855 fprintf_unfiltered (gdb_stderr, "\"\n");
861 header[1] = next_msg_id;
869 len = ((len + 2) / 3) * 3;
873 csum = compute_checksum (csum, buf, len);
874 csum = compute_checksum (csum, header+1, 2);
878 tob64 (header, p, 3);
880 tob64 (buf, buf3, len);
882 for (i = 0; i < (len / 3) * 4; i++)
889 next_msg_id = (next_msg_id + 3) % 245;
891 /* Send it over and over until we get a positive ack. */
895 int started_error_output = 0;
900 printf_unfiltered ("Sending encoded: \"%s\"", buf2);
901 printf_unfiltered (" (Checksum %d, id %d, length %d)\n",
902 header[0], header[1], header[2]);
903 gdb_flush (gdb_stdout);
905 if (SERIAL_WRITE (sds_desc, buf2, p - buf2))
906 perror_with_name ("putmessage: write failed");
914 /* Come here after finding the start of the frame. Collect the rest
915 into BUF. Returns 0 on any error, 1 on success. */
928 c = readchar (sds_timeout);
934 puts_filtered ("Timeout in mid-message, retrying\n");
938 puts_filtered ("Saw new packet start in middle of old one\n");
939 return 0; /* Start a new packet, count retries */
947 printf_filtered ("Received encoded: \"%s\"\n", buf);
952 if (bp < buf + PBUFSIZ - 1)
959 puts_filtered ("Message too long: ");
961 puts_filtered ("\n");
968 /* Read a packet from the remote machine, with error checking,
969 and store it in BUF. BUF is expected to be of size PBUFSIZ.
970 If FOREVER, wait forever rather than timing out; this is used
971 while the target is executing user code. */
974 getmessage (buf, forever)
981 int val, i, len, csum;
982 unsigned char header[3];
983 unsigned char inbuf[500];
985 strcpy (buf, "timeout");
989 #ifdef MAINTENANCE_CMDS
990 timeout = watchdog > 0 ? watchdog : -1;
997 timeout = sds_timeout;
1001 for (tries = 1; tries <= MAX_TRIES; tries++)
1003 /* This can loop forever if the remote side sends us characters
1004 continuously, but if it pauses, we'll get a zero from readchar
1005 because of timeout. Then we'll count that as a retry. */
1007 /* Note that we will only wait forever prior to the start of a packet.
1008 After that, we expect characters to arrive at a brisk pace. They
1009 should show up within sds_timeout intervals. */
1013 c = readchar (timeout);
1015 if (c == SERIAL_TIMEOUT)
1017 #ifdef MAINTENANCE_CMDS
1018 if (forever) /* Watchdog went off. Kill the target. */
1020 target_mourn_inferior ();
1021 error ("Watchdog has expired. Target detached.\n");
1025 puts_filtered ("Timed out.\n");
1029 while (c != '$' && c != '{');
1031 /* We might have seen a "trigraph", a sequence of three characters
1032 that indicate various sorts of communication state. */
1036 /* Read the other two chars of the trigraph. */
1037 c2 = readchar (timeout);
1038 c3 = readchar (timeout);
1040 fprintf_unfiltered (gdb_stderr, "Trigraph %c%c%c received\n",
1044 message_pending = 1;
1050 val = read_frame (inbuf);
1054 fromb64 (inbuf, header, 4);
1055 /* (should check out other bits) */
1056 fromb64 (inbuf + 4, buf, strlen (inbuf) - 4);
1061 csum = compute_checksum (csum, buf, len);
1062 csum = compute_checksum (csum, header + 1, 2);
1064 if (csum != header[0])
1065 fprintf_unfiltered (gdb_stderr,
1066 "Checksum mismatch: computed %d, received %d\n",
1069 if (header[2] == 0xff)
1070 fprintf_unfiltered (gdb_stderr, "Requesting resend...\n");
1074 fprintf_unfiltered (gdb_stderr,
1075 "... (Got checksum %d, id %d, length %d)\n",
1076 header[0], header[1], header[2]);
1077 fprintf_unfiltered (gdb_stderr, "Message received: \"");
1078 for (i = 0; i < len; ++i)
1080 fprintf_unfiltered (gdb_stderr, "%02x", (unsigned char) buf[i]);
1082 fprintf_unfiltered (gdb_stderr, "\"\n");
1085 /* no ack required? */
1089 /* Try the whole thing again. */
1091 /* need to do something here */
1094 /* We have tried hard enough, and just can't receive the packet. Give up. */
1096 printf_unfiltered ("Ignoring packet error, continuing...\n");
1102 /* For some mysterious reason, wait_for_inferior calls kill instead of
1103 mourn after it gets TARGET_WAITKIND_SIGNALLED. Work around it. */
1107 target_mourn_inferior ();
1111 #if 0 /* fix to use 1-arg fn */
1112 /* Use catch_errors so the user can quit from gdb even when we aren't on
1113 speaking terms with the remote system. */
1114 catch_errors (putmessage, "k", "", RETURN_MASK_ERROR);
1117 /* Don't wait for it to die. I'm not really sure it matters whether
1118 we do or not. For the existing stubs, kill is a noop. */
1119 target_mourn_inferior ();
1125 unpush_target (&sds_ops);
1126 generic_mourn_inferior ();
1130 sds_create_inferior (exec_file, args, env)
1135 /* Rip out the breakpoints; we'll reinsert them after restarting
1136 the remote server. */
1137 remove_breakpoints ();
1139 /* Now restart the remote server. */
1142 /* Now put the breakpoints back in. This way we're safe if the
1143 restart function works via a unix fork on the remote side. */
1144 insert_breakpoints ();
1146 /* Clean up from the last time we were running. */
1147 clear_proceed_status ();
1149 /* Let the remote process run. */
1150 proceed (-1, TARGET_SIGNAL_0, 0);
1154 /* The SDS monitor has commands for breakpoint insertion, although it
1155 it doesn't actually manage the breakpoints, it just returns the
1156 replaced instruction back to the debugger. */
1159 sds_insert_breakpoint (addr, contents_cache)
1161 char *contents_cache;
1164 unsigned char buf[PBUFSIZ];
1169 retlen = sds_send (buf, 7);
1173 sds_remove_breakpoint (addr, contents_cache)
1175 char *contents_cache;
1178 unsigned char buf[PBUFSIZ];
1183 retlen = sds_send (buf, 7);
1186 /* Define the target operations vector. */
1188 static struct target_ops sds_ops =
1190 "sds", /* to_shortname */
1191 "Remote serial target with SDS protocol", /* to_longname */
1192 "Use a remote computer via a serial line, using the SDS protocol.\n\
1193 Specify the serial device it is connected to (e.g. /dev/ttya).", /* to_doc */
1194 sds_open, /* to_open */
1195 sds_close, /* to_close */
1196 NULL, /* to_attach */
1197 sds_detach, /* to_detach */
1198 sds_resume, /* to_resume */
1199 sds_wait, /* to_wait */
1200 sds_fetch_registers, /* to_fetch_registers */
1201 sds_store_registers, /* to_store_registers */
1202 sds_prepare_to_store, /* to_prepare_to_store */
1203 sds_xfer_memory, /* to_xfer_memory */
1204 sds_files_info, /* to_files_info */
1205 sds_insert_breakpoint, /* to_insert_breakpoint */
1206 sds_remove_breakpoint, /* to_remove_breakpoint */
1207 NULL, /* to_terminal_init */
1208 NULL, /* to_terminal_inferior */
1209 NULL, /* to_terminal_ours_for_output */
1210 NULL, /* to_terminal_ours */
1211 NULL, /* to_terminal_info */
1212 sds_kill, /* to_kill */
1213 generic_load, /* to_load */
1214 NULL, /* to_lookup_symbol */
1215 sds_create_inferior, /* to_create_inferior */
1216 sds_mourn, /* to_mourn_inferior */
1218 0, /* to_notice_signals */
1219 0, /* to_thread_alive */
1221 process_stratum, /* to_stratum */
1223 1, /* to_has_all_memory */
1224 1, /* to_has_memory */
1225 1, /* to_has_stack */
1226 1, /* to_has_registers */
1227 1, /* to_has_execution */
1228 NULL, /* sections */
1229 NULL, /* sections_end */
1230 OPS_MAGIC /* to_magic */
1233 /* Put a command string, in args, out to the monitor and display the
1237 sds_command (args, from_tty)
1242 int i, len, resp_len;
1243 unsigned char buf[1000];
1245 /* Convert hexadecimal chars into a byte buffer. */
1250 buf[len++] = fromhex (p[0]) * 16 + fromhex (p[1]);
1256 len = sds_send (buf, len);
1258 printf_filtered ("Reply is ");
1259 for (i = 0; i < len; ++i)
1261 printf_filtered ("%02x", buf[i]);
1263 printf_filtered ("\n");
1267 _initialize_remote_sds ()
1269 add_target (&sds_ops);
1271 add_show_from_set (add_set_cmd ("sdstimeout", no_class,
1272 var_integer, (char *)&sds_timeout,
1273 "Set timeout value for sds read.\n", &setlist),
1276 add_com ("sds", class_obscure, sds_command,
1277 "Send a command to the SDS monitor.");