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 /* Descriptor for I/O to remote machine. Initialize it to NULL so
122 that sds_open knows that we don't have a file open when the program
125 static serial_t sds_desc
= NULL
;
127 /* This limit comes from the monitor. */
131 /* Maximum number of bytes to read/write at once. The value here
132 is chosen to fill up a packet (the headers account for the 32). */
133 #define MAXBUFBYTES ((PBUFSIZ-32)/2)
135 static int next_msg_id
;
137 static int just_started
;
139 static int message_pending
;
142 /* Restart the remote side; this is an extended protocol operation. */
149 /* Clean up connection to a remote debugger. */
157 SERIAL_CLOSE (sds_desc
);
161 /* Stub for catch_errors. */
164 sds_start_remote (dummy
)
168 unsigned char buf
[200];
170 immediate_quit
= 1; /* Allow user to interrupt it */
172 /* Ack any packet which the remote side has already sent. */
173 SERIAL_WRITE (sds_desc
, "{#*\r\n", 5);
174 SERIAL_WRITE (sds_desc
, "{#}\r\n", 5);
176 while ((c
= readchar (1)) >= 0)
177 printf_unfiltered ("%c");
178 printf_unfiltered ("\n");
190 start_remote (); /* Initialize gdb process mechanisms */
194 /* Open a connection to a remote debugger.
195 NAME is the filename used for communication. */
197 static DCACHE
*sds_dcache
;
200 sds_open (name
, from_tty
)
205 error ("To open a remote debug connection, you need to specify what serial\n\
206 device is attached to the remote system (e.g. /dev/ttya).");
208 target_preopen (from_tty
);
210 unpush_target (&sds_ops
);
212 sds_dcache
= dcache_init (sds_read_bytes
, sds_write_bytes
);
214 sds_desc
= SERIAL_OPEN (name
);
216 perror_with_name (name
);
220 if (SERIAL_SETBAUDRATE (sds_desc
, baud_rate
))
222 SERIAL_CLOSE (sds_desc
);
223 perror_with_name (name
);
228 SERIAL_RAW (sds_desc
);
230 /* If there is something sitting in the buffer we might take it as a
231 response to a command, which would be bad. */
232 SERIAL_FLUSH_INPUT (sds_desc
);
236 puts_filtered ("Remote debugging using ");
237 puts_filtered (name
);
238 puts_filtered ("\n");
240 push_target (&sds_ops
); /* Switch to using remote target now */
242 /* Without this, some commands which require an active target (such
243 as kill) won't work. This variable serves (at least) double duty
244 as both the pid of the target process (if it has such), and as a
245 flag indicating that a target is active. These functions should
246 be split out into seperate variables, especially since GDB will
247 someday have a notion of debugging several processes. */
249 inferior_pid
= 42000;
253 /* Start the remote connection; if error (0), discard this target.
254 In particular, if the user quits, be sure to discard it (we'd be
255 in an inconsistent state otherwise). */
256 if (!catch_errors (sds_start_remote
, (char *)0,
257 "Couldn't establish connection to remote target\n",
262 /* This takes a program previously attached to and detaches it. After
263 this is done, GDB can be used to debug some other program. We
264 better not have left any breakpoints in the target program or it'll
265 die when it hits one. */
268 sds_detach (args
, from_tty
)
275 error ("Argument given to \"detach\" when remotely debugging.");
278 /* Tell the remote target to detach. */
285 puts_filtered ("Ending remote debugging.\n");
288 /* Convert hex digit A to a number. */
294 if (a
>= '0' && a
<= '9')
296 else if (a
>= 'a' && a
<= 'f')
299 error ("Reply contains invalid hex digit %d", a
);
302 /* Convert number NIB to a hex digit. */
315 tob64 (inbuf
, outbuf
, len
)
316 unsigned char *inbuf
;
324 error ("bad length");
327 for (i
= 0; i
< len
; i
+= 3)
329 /* Collect the next three bytes into a number. */
330 sum
= ((long) *inbuf
++) << 16;
331 sum
|= ((long) *inbuf
++) << 8;
332 sum
|= ((long) *inbuf
++);
334 /* Spit out 4 6-bit encodings. */
335 *p
++ = ((sum
>> 18) & 0x3f) + '0';
336 *p
++ = ((sum
>> 12) & 0x3f) + '0';
337 *p
++ = ((sum
>> 6) & 0x3f) + '0';
338 *p
++ = (sum
& 0x3f) + '0';
344 fromb64 (inbuf
, outbuf
, len
)
345 char *inbuf
, *outbuf
;
351 error ("bad length");
353 for (i
= 0; i
< len
; i
+= 4)
355 /* Collect 4 6-bit digits. */
356 sum
= (*inbuf
++ - '0') << 18;
357 sum
|= (*inbuf
++ - '0') << 12;
358 sum
|= (*inbuf
++ - '0') << 6;
359 sum
|= (*inbuf
++ - '0');
361 /* Now take the resulting 24-bit number and get three bytes out
363 *outbuf
++ = (sum
>> 16) & 0xff;
364 *outbuf
++ = (sum
>> 8) & 0xff;
365 *outbuf
++ = sum
& 0xff;
368 return (len
/ 4) * 3;
372 /* Tell the remote machine to resume. */
374 static enum target_signal last_sent_signal
= TARGET_SIGNAL_0
;
378 sds_resume (pid
, step
, siggnal
)
380 enum target_signal siggnal
;
382 unsigned char buf
[PBUFSIZ
];
384 dcache_flush (sds_dcache
);
386 last_sent_signal
= siggnal
;
387 last_sent_step
= step
;
389 buf
[0] = (step
? 21 : 20);
390 buf
[1] = 0; /* (should be signal?) */
395 /* Send a message to target to halt it. Target will respond, and send
396 us a message pending notice. */
399 sds_interrupt (signo
)
402 unsigned char buf
[PBUFSIZ
];
404 /* If this doesn't work, try more severe steps. */
405 signal (signo
, sds_interrupt_twice
);
408 printf_unfiltered ("sds_interrupt called\n");
414 static void (*ofunc
)();
416 /* The user typed ^C twice. */
419 sds_interrupt_twice (signo
)
422 signal (signo
, ofunc
);
426 signal (signo
, sds_interrupt
);
429 /* Ask the user what to do when an interrupt is received. */
434 target_terminal_ours ();
436 if (query ("Interrupted while waiting for the program.\n\
437 Give up (and stop debugging it)? "))
439 target_mourn_inferior ();
440 return_to_top_level (RETURN_QUIT
);
443 target_terminal_inferior ();
446 /* If nonzero, ignore the next kill. */
449 /* Wait until the remote machine stops, then return, storing status in
450 STATUS just as `wait' would. Returns "pid" (though it's not clear
451 what, if anything, that means in the case of this target). */
454 sds_wait (pid
, status
)
456 struct target_waitstatus
*status
;
458 unsigned char buf
[PBUFSIZ
];
461 status
->kind
= TARGET_WAITKIND_EXITED
;
462 status
->value
.integer
= 0;
464 ofunc
= (void (*)()) signal (SIGINT
, sds_interrupt
);
466 signal (SIGINT
, ofunc
);
471 status
->kind
= TARGET_WAITKIND_STOPPED
;
482 retlen
= sds_send (buf
, 1);
485 fprintf_unfiltered (gdb_stderr
, "Signals: %04x %02x %02x\n",
486 ((int) buf
[0]) << 8 + buf
[1],
490 status
->kind
= TARGET_WAITKIND_STOPPED
;
491 status
->value
.sig
= TARGET_SIGNAL_TRAP
;
499 static unsigned char sprs
[16];
501 /* Read the remote registers into the block REGS. */
502 /* Currently we just read all the registers, so we don't use regno. */
506 sds_fetch_registers (regno
)
509 unsigned char buf
[PBUFSIZ
];
512 char regs
[REGISTER_BYTES
];
514 /* Unimplemented registers read as all bits zero. */
515 memset (regs
, 0, REGISTER_BYTES
);
520 retlen
= sds_send (buf
, 3);
522 for (i
= 0; i
< 4 * 6; ++i
)
523 regs
[i
+ 4 * 32 + 8 * 32] = buf
[i
];
524 for (i
= 0; i
< 4 * 4; ++i
)
525 sprs
[i
] = buf
[i
+ 4 * 7];
530 retlen
= sds_send (buf
, 3);
532 for (i
= 0; i
< retlen
; i
++)
535 /* (should warn about reply too short) */
537 for (i
= 0; i
< NUM_REGS
; i
++)
538 supply_register (i
, ®s
[REGISTER_BYTE(i
)]);
541 /* Prepare to store registers. Since we may send them all, we have to
542 read out the ones we don't want to change first. */
545 sds_prepare_to_store ()
547 /* Make sure the entire registers array is valid. */
548 read_register_bytes (0, (char *)NULL
, REGISTER_BYTES
);
551 /* Store register REGNO, or all registers if REGNO == -1, from the contents
552 of REGISTERS. FIXME: ignores errors. */
555 sds_store_registers (regno
)
558 unsigned char *p
, buf
[PBUFSIZ
];
561 /* Store all the special-purpose registers. */
567 for (i
= 0; i
< 4 * 6; i
++)
568 *p
++ = registers
[i
+ 4 * 32 + 8 * 32];
569 for (i
= 0; i
< 4 * 1; i
++)
571 for (i
= 0; i
< 4 * 4; i
++)
574 sds_send (buf
, p
- buf
);
576 /* Store all the general-purpose registers. */
582 for (i
= 0; i
< 4 * 32; i
++)
585 sds_send (buf
, p
- buf
);
589 /* Write memory data directly to the remote machine. This does not
590 inform the data cache; the data cache uses this. MEMADDR is the
591 address in the remote memory space. MYADDR is the address of the
592 buffer in our space. LEN is the number of bytes.
594 Returns number of bytes transferred, or 0 for error. */
597 sds_write_bytes (memaddr
, myaddr
, len
)
602 int max_buf_size
; /* Max size of packet output buffer */
604 unsigned char buf
[PBUFSIZ
];
608 /* Chop the transfer down if necessary */
615 todo
= min (len
, max_buf_size
);
619 buf
[2] = (int) (memaddr
>> 24) & 0xff;
620 buf
[3] = (int) (memaddr
>> 16) & 0xff;
621 buf
[4] = (int) (memaddr
>> 8) & 0xff;
622 buf
[5] = (int) (memaddr
) & 0xff;
626 for (i
= 0; i
< todo
; i
++)
627 buf
[i
+ 8] = myaddr
[i
];
629 sds_send (buf
, 8 + todo
);
631 /* (should look at result) */
640 /* Read memory data directly from the remote machine. This does not
641 use the data cache; the data cache uses this. MEMADDR is the
642 address in the remote memory space. MYADDR is the address of the
643 buffer in our space. LEN is the number of bytes.
645 Returns number of bytes transferred, or 0 for error. */
648 sds_read_bytes (memaddr
, myaddr
, len
)
653 int max_buf_size
; /* Max size of packet output buffer */
655 unsigned char buf
[PBUFSIZ
];
659 /* Chop the transfer down if necessary */
666 todo
= min (len
, max_buf_size
);
670 buf
[2] = (int) (memaddr
>> 24) & 0xff;
671 buf
[3] = (int) (memaddr
>> 16) & 0xff;
672 buf
[4] = (int) (memaddr
>> 8) & 0xff;
673 buf
[5] = (int) (memaddr
) & 0xff;
674 buf
[6] = (int) (todo
>> 8) & 0xff;
675 buf
[7] = (int) (todo
) & 0xff;
678 retlen
= sds_send (buf
, 9);
680 if (retlen
- 2 != todo
)
685 /* Reply describes memory byte by byte. */
687 for (i
= 0; i
< todo
; i
++)
688 myaddr
[i
] = buf
[i
+ 2];
698 /* Read or write LEN bytes from inferior memory at MEMADDR,
699 transferring to or from debugger address MYADDR. Write to inferior
700 if SHOULD_WRITE is nonzero. Returns length of data written or
701 read; 0 for error. */
705 sds_xfer_memory(memaddr
, myaddr
, len
, should_write
, target
)
710 struct target_ops
*target
; /* ignored */
712 return dcache_xfer_memory (sds_dcache
, memaddr
, myaddr
, len
, should_write
);
717 sds_files_info (ignore
)
718 struct target_ops
*ignore
;
720 puts_filtered ("Debugging over a serial connection, using SDS protocol.\n");
723 /* Stuff for dealing with the packets which are part of this protocol.
724 See comment at top of file for details. */
726 /* Read a single character from the remote end, masking it down to 7 bits. */
734 ch
= SERIAL_READCHAR (sds_desc
, timeout
);
736 if (remote_debug
> 1 && ch
>= 0)
737 printf_unfiltered("%c(%x)", ch
, ch
);
742 error ("Remote connection closed");
744 perror_with_name ("Remote communication error");
752 /* An SDS-style checksum is a sum of the bytes modulo 253. (Presumably
753 because 253, 254, and 255 are special flags in the protocol.) */
756 compute_checksum (csum
, buf
, len
)
762 for (i
= 0; i
< len
; ++i
)
763 csum
+= (unsigned char) buf
[i
];
769 /* Send the command in BUF to the remote machine, and read the reply
777 putmessage (buf
, len
);
779 return getmessage (buf
, 0);
782 /* Send a message to the remote machine. */
785 putmessage (buf
, len
)
790 unsigned char csum
= 0;
791 char buf2
[PBUFSIZ
], buf3
[PBUFSIZ
];
792 unsigned char header
[3];
797 /* Copy the packet into buffer BUF2, encapsulating it
798 and giving it a checksum. */
800 if (len
> 170) /* Prosanity check */
805 fprintf_unfiltered (gdb_stderr
, "Message to send: \"");
806 for (i
= 0; i
< len
; ++i
)
807 fprintf_unfiltered (gdb_stderr
, "%02x", buf
[i
]);
808 fprintf_unfiltered (gdb_stderr
, "\"\n");
820 header
[1] = next_msg_id
;
824 csum
= compute_checksum (csum
, buf
, len
);
825 csum
= compute_checksum (csum
, header
+ 1, 2);
829 tob64 (header
, p
, 3);
831 enclen
= tob64 (buf
, buf3
, ((len
+ 2) / 3) * 3);
833 for (i
= 0; i
< enclen
; ++i
)
838 next_msg_id
= (next_msg_id
+ 3) % 245;
840 /* Send it over and over until we get a positive ack. */
844 int started_error_output
= 0;
849 printf_unfiltered ("Sending encoded: \"%s\"", buf2
);
850 printf_unfiltered (" (Checksum %d, id %d, length %d)\n",
851 header
[0], header
[1], header
[2]);
852 gdb_flush (gdb_stdout
);
854 if (SERIAL_WRITE (sds_desc
, buf2
, p
- buf2
))
855 perror_with_name ("putmessage: write failed");
863 /* Come here after finding the start of the frame. Collect the rest
864 into BUF. Returns 0 on any error, 1 on success. */
877 c
= readchar (sds_timeout
);
883 puts_filtered ("Timeout in mid-message, retrying\n");
887 puts_filtered ("Saw new packet start in middle of old one\n");
888 return 0; /* Start a new packet, count retries */
896 fprintf_unfiltered (gdb_stderr
, "Received encoded: \"%s\"\n",
902 if (bp
< buf
+ PBUFSIZ
- 1)
909 puts_filtered ("Message too long: ");
911 puts_filtered ("\n");
918 /* Read a packet from the remote machine, with error checking,
919 and store it in BUF. BUF is expected to be of size PBUFSIZ.
920 If FOREVER, wait forever rather than timing out; this is used
921 while the target is executing user code. */
924 getmessage (buf
, forever
)
931 int val
, i
, len
, csum
;
932 unsigned char header
[3];
933 unsigned char inbuf
[500];
935 strcpy (buf
, "timeout");
939 #ifdef MAINTENANCE_CMDS
940 timeout
= watchdog
> 0 ? watchdog
: -1;
947 timeout
= sds_timeout
;
951 for (tries
= 1; tries
<= MAX_TRIES
; tries
++)
953 /* This can loop forever if the remote side sends us characters
954 continuously, but if it pauses, we'll get a zero from readchar
955 because of timeout. Then we'll count that as a retry. */
957 /* Note that we will only wait forever prior to the start of a packet.
958 After that, we expect characters to arrive at a brisk pace. They
959 should show up within sds_timeout intervals. */
963 c
= readchar (timeout
);
965 if (c
== SERIAL_TIMEOUT
)
967 #ifdef MAINTENANCE_CMDS
968 if (forever
) /* Watchdog went off. Kill the target. */
970 target_mourn_inferior ();
971 error ("Watchdog has expired. Target detached.\n");
975 puts_filtered ("Timed out.\n");
979 while (c
!= '$' && c
!= '{');
981 /* We might have seen a "trigraph", a sequence of three characters
982 that indicate various sorts of communication state. */
986 /* Read the other two chars of the trigraph. */
987 c2
= readchar (timeout
);
988 c3
= readchar (timeout
);
990 fprintf_unfiltered (gdb_stderr
, "Trigraph %c%c%c received\n",
1000 val
= read_frame (inbuf
);
1004 fromb64 (inbuf
, header
, 4);
1005 /* (should check out other bits) */
1006 fromb64 (inbuf
+ 4, buf
, strlen (inbuf
) - 4);
1011 csum
= compute_checksum (csum
, buf
, len
);
1012 csum
= compute_checksum (csum
, header
+ 1, 2);
1014 if (csum
!= header
[0])
1015 fprintf_unfiltered (gdb_stderr
,
1016 "Checksum mismatch: computed %d, received %d\n",
1019 if (header
[2] == 0xff)
1020 fprintf_unfiltered (gdb_stderr
, "Requesting resend...\n");
1024 fprintf_unfiltered (gdb_stderr
,
1025 "... (Got checksum %d, id %d, length %d)\n",
1026 header
[0], header
[1], header
[2]);
1027 fprintf_unfiltered (gdb_stderr
, "Message received: \"");
1028 for (i
= 0; i
< len
; ++i
)
1030 fprintf_unfiltered (gdb_stderr
, "%02x", (unsigned char) buf
[i
]);
1032 fprintf_unfiltered (gdb_stderr
, "\"\n");
1035 /* no ack required? */
1039 /* Try the whole thing again. */
1041 /* need to do something here */
1044 /* We have tried hard enough, and just can't receive the packet. Give up. */
1046 printf_unfiltered ("Ignoring packet error, continuing...\n");
1052 /* For some mysterious reason, wait_for_inferior calls kill instead of
1053 mourn after it gets TARGET_WAITKIND_SIGNALLED. Work around it. */
1057 target_mourn_inferior ();
1061 #if 0 /* fix to use 1-arg fn */
1062 /* Use catch_errors so the user can quit from gdb even when we aren't on
1063 speaking terms with the remote system. */
1064 catch_errors (putmessage
, "k", "", RETURN_MASK_ERROR
);
1067 /* Don't wait for it to die. I'm not really sure it matters whether
1068 we do or not. For the existing stubs, kill is a noop. */
1069 target_mourn_inferior ();
1075 unpush_target (&sds_ops
);
1076 generic_mourn_inferior ();
1080 sds_create_inferior (exec_file
, args
, env
)
1085 /* Rip out the breakpoints; we'll reinsert them after restarting
1086 the remote server. */
1087 remove_breakpoints ();
1089 /* Now restart the remote server. */
1092 /* Now put the breakpoints back in. This way we're safe if the
1093 restart function works via a unix fork on the remote side. */
1094 insert_breakpoints ();
1096 /* Clean up from the last time we were running. */
1097 clear_proceed_status ();
1099 /* Let the remote process run. */
1100 proceed (-1, TARGET_SIGNAL_0
, 0);
1104 /* The SDS monitor has commands for breakpoint insertion, although it
1105 it doesn't actually manage the breakpoints, it just returns the
1106 replaced instruction back to the debugger. */
1109 sds_insert_breakpoint (addr
, contents_cache
)
1111 char *contents_cache
;
1114 unsigned char *p
, buf
[PBUFSIZ
];
1119 *p
++ = (int) (addr
>> 24) & 0xff;
1120 *p
++ = (int) (addr
>> 16) & 0xff;
1121 *p
++ = (int) (addr
>> 8) & 0xff;
1122 *p
++ = (int) (addr
) & 0xff;
1124 retlen
= sds_send (buf
, p
- buf
);
1126 for (i
= 0; i
< 4; ++i
)
1127 contents_cache
[i
] = buf
[i
+ 2];
1133 sds_remove_breakpoint (addr
, contents_cache
)
1135 char *contents_cache
;
1138 unsigned char *p
, buf
[PBUFSIZ
];
1143 *p
++ = (int) (addr
>> 24) & 0xff;
1144 *p
++ = (int) (addr
>> 16) & 0xff;
1145 *p
++ = (int) (addr
>> 8) & 0xff;
1146 *p
++ = (int) (addr
) & 0xff;
1147 for (i
= 0; i
< 4; ++i
)
1148 *p
++ = contents_cache
[i
];
1150 retlen
= sds_send (buf
, p
- buf
);
1155 /* Define the target operations vector. */
1157 static struct target_ops sds_ops
=
1159 "sds", /* to_shortname */
1160 "Remote serial target with SDS protocol", /* to_longname */
1161 "Use a remote computer via a serial line, using the SDS protocol.\n\
1162 Specify the serial device it is connected to (e.g. /dev/ttya).", /* to_doc */
1163 sds_open
, /* to_open */
1164 sds_close
, /* to_close */
1165 NULL
, /* to_attach */
1166 sds_detach
, /* to_detach */
1167 sds_resume
, /* to_resume */
1168 sds_wait
, /* to_wait */
1169 sds_fetch_registers
, /* to_fetch_registers */
1170 sds_store_registers
, /* to_store_registers */
1171 sds_prepare_to_store
, /* to_prepare_to_store */
1172 sds_xfer_memory
, /* to_xfer_memory */
1173 sds_files_info
, /* to_files_info */
1174 sds_insert_breakpoint
, /* to_insert_breakpoint */
1175 sds_remove_breakpoint
, /* to_remove_breakpoint */
1176 NULL
, /* to_terminal_init */
1177 NULL
, /* to_terminal_inferior */
1178 NULL
, /* to_terminal_ours_for_output */
1179 NULL
, /* to_terminal_ours */
1180 NULL
, /* to_terminal_info */
1181 sds_kill
, /* to_kill */
1182 generic_load
, /* to_load */
1183 NULL
, /* to_lookup_symbol */
1184 sds_create_inferior
, /* to_create_inferior */
1185 sds_mourn
, /* to_mourn_inferior */
1187 0, /* to_notice_signals */
1188 0, /* to_thread_alive */
1190 process_stratum
, /* to_stratum */
1192 1, /* to_has_all_memory */
1193 1, /* to_has_memory */
1194 1, /* to_has_stack */
1195 1, /* to_has_registers */
1196 1, /* to_has_execution */
1197 NULL
, /* sections */
1198 NULL
, /* sections_end */
1199 OPS_MAGIC
/* to_magic */
1202 /* Put a command string, in args, out to the monitor and display the
1206 sds_command (args
, from_tty
)
1212 unsigned char buf
[1000];
1214 /* Convert hexadecimal chars into a byte buffer. */
1219 buf
[len
++] = fromhex (p
[0]) * 16 + fromhex (p
[1]);
1225 retlen
= sds_send (buf
, len
);
1227 printf_filtered ("Reply is ");
1228 for (i
= 0; i
< retlen
; ++i
)
1230 printf_filtered ("%02x", buf
[i
]);
1232 printf_filtered ("\n");
1236 _initialize_remote_sds ()
1238 add_target (&sds_ops
);
1240 add_show_from_set (add_set_cmd ("sdstimeout", no_class
,
1241 var_integer
, (char *)&sds_timeout
,
1242 "Set timeout value for sds read.\n", &setlist
),
1245 add_com ("sds", class_obscure
, sds_command
,
1246 "Send a command to the SDS monitor.");