1 /* Remote target communications for serial-line targets in custom GDB protocol
2 Copyright 1988, 1991, 1992, 1993 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., 675 Mass Ave, Cambridge, MA 02139, 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
30 CSUM1 and CSUM2 are ascii hex representation of an 8-bit
31 checksum of <data>, the most significant nibble is sent first.
32 the hex digits 0-9,a-f are used.
34 Receiver responds with:
36 + - if CSUM is correct and ready for next packet
37 - - if CSUM is incorrect
40 All values are encoded in ascii hex digits.
45 reply XX....X Each byte of register data
46 is described by two hex digits.
47 Registers are in the internal order
48 for GDB, and the bytes in a register
49 are in the same order the machine uses.
52 write regs GXX..XX Each byte of register data
53 is described by two hex digits.
57 read mem mAA..AA,LLLL AA..AA is address, LLLL is length.
58 reply XX..XX XX..XX is mem contents
59 Can be fewer bytes than requested
60 if able to read only part of the data.
63 write mem MAA..AA,LLLL:XX..XX
65 LLLL is number of bytes,
68 ENN for an error (this includes the case
69 where only part of the data was
72 cont cAA..AA AA..AA is address to resume
74 resume at same address.
76 step sAA..AA AA..AA is address to resume
78 resume at same address.
80 last signal ? Reply the current reason for stopping.
81 This is the same reply as is generated
82 for step or cont : SAA where AA is the
85 There is no immediate reply to step or cont.
86 The reply comes when the machine stops.
87 It is SAA AA is the "signal number"
89 or... TAAn...:r...;n:r...;n...:r...;
91 n... = register number
92 r... = register contents
93 or... WAA The process extited, and AA is
94 the exit status. This is only
95 applicable for certains sorts of
97 or... NAATT;DD;BB Relocate the object file.
102 This is used by the NLM stub,
103 which is why it only has three
104 addresses rather than one per
105 section: the NLM stub always
106 sees only three sections, even
107 though gdb may see more.
111 toggle debug d toggle debug flag (see 386 & 68k stubs)
112 reset r reset -- see sparc stub.
113 reserved <other> On other requests, the stub should
114 ignore the request and send an empty
115 response ($#<checksum>). This way
116 we can extend the protocol and GDB
117 can tell whether the stub it is
118 talking to uses the old or the new.
125 #include "inferior.h"
130 #include "terminal.h"
132 #include "objfiles.h"
133 #include "gdb-stabs.h"
136 #include "remote-utils.h"
138 #if !defined(DONT_USE_REMOTE)
140 #include <sys/types.h>
146 /* Prototypes for local functions */
149 remote_write_bytes
PARAMS ((CORE_ADDR memaddr
, unsigned char *myaddr
, int len
));
152 remote_read_bytes
PARAMS ((CORE_ADDR memaddr
, unsigned char *myaddr
, int len
));
155 remote_files_info
PARAMS ((struct target_ops
*ignore
));
158 remote_xfer_memory
PARAMS ((CORE_ADDR memaddr
, char *myaddr
, int len
,
159 int should_write
, struct target_ops
*target
));
162 remote_prepare_to_store
PARAMS ((void));
165 remote_fetch_registers
PARAMS ((int regno
));
168 remote_resume
PARAMS ((int pid
, int step
, int siggnal
));
171 remote_start_remote
PARAMS ((char *dummy
));
174 remote_open
PARAMS ((char *name
, int from_tty
));
177 remote_close
PARAMS ((int quitting
));
180 remote_store_registers
PARAMS ((int regno
));
183 getpkt
PARAMS ((char *buf
, int forever
));
186 putpkt
PARAMS ((char *buf
));
189 remote_send
PARAMS ((char *buf
));
192 readchar
PARAMS ((void));
195 remote_wait
PARAMS ((WAITTYPE
*status
));
198 tohex
PARAMS ((int nib
));
201 fromhex
PARAMS ((int a
));
204 remote_detach
PARAMS ((char *args
, int from_tty
));
207 remote_interrupt
PARAMS ((int signo
));
210 remote_interrupt_twice
PARAMS ((int signo
));
212 extern struct target_ops remote_ops
; /* Forward decl */
214 /* This was 5 seconds, which is a long time to sit and wait.
215 Unless this is going though some terminal server or multiplexer or
216 other form of hairy serial connection, I would think 2 seconds would
218 static int timeout
= 2;
224 /* Descriptor for I/O to remote machine. Initialize it to NULL so that
225 remote_open knows that we don't have a file open when the program
227 serial_t remote_desc
= NULL
;
231 /* Maximum number of bytes to read/write at once. The value here
232 is chosen to fill up a packet (the headers account for the 32). */
233 #define MAXBUFBYTES ((PBUFSIZ-32)/2)
235 /* Round up PBUFSIZ to hold all the registers, at least. */
236 #if REGISTER_BYTES > MAXBUFBYTES
238 #define PBUFSIZ (REGISTER_BYTES * 2 + 32)
241 /* Clean up connection to a remote debugger. */
245 remote_close (quitting
)
249 SERIAL_CLOSE (remote_desc
);
253 /* Stub for catch_errors. */
256 remote_start_remote (dummy
)
259 immediate_quit
= 1; /* Allow user to interrupt it */
261 /* Ack any packet which the remote side has already sent. */
262 /* I'm not sure this \r is needed; we don't use it any other time we
264 SERIAL_WRITE (remote_desc
, "+\r", 2);
265 putpkt ("?"); /* initiate a query from remote machine */
268 start_remote (); /* Initialize gdb process mechanisms */
272 /* Open a connection to a remote debugger.
273 NAME is the filename used for communication. */
275 static DCACHE
*remote_dcache
;
278 remote_open (name
, from_tty
)
284 "To open a remote debug connection, you need to specify what serial\n\
285 device is attached to the remote system (e.g. /dev/ttya).");
287 target_preopen (from_tty
);
289 unpush_target (&remote_ops
);
291 remote_dcache
= dcache_init (remote_read_bytes
, remote_write_bytes
);
293 remote_desc
= SERIAL_OPEN (name
);
295 perror_with_name (name
);
297 if (SERIAL_SETBAUDRATE (remote_desc
, sr_get_baud_rate()))
299 SERIAL_CLOSE (remote_desc
);
300 perror_with_name (name
);
303 SERIAL_RAW (remote_desc
);
305 /* If there is something sitting in the buffer we might take it as a
306 response to a command, which would be bad. */
307 SERIAL_FLUSH_INPUT (remote_desc
);
311 puts_filtered ("Remote debugging using ");
312 puts_filtered (name
);
313 puts_filtered ("\n");
315 push_target (&remote_ops
); /* Switch to using remote target now */
317 /* Start the remote connection; if error (0), discard this target.
318 In particular, if the user quits, be sure to discard it
319 (we'd be in an inconsistent state otherwise). */
320 if (!catch_errors (remote_start_remote
, (char *)0,
321 "Couldn't establish connection to remote target\n", RETURN_MASK_ALL
))
326 takes a program previously attached to and detaches it.
327 We better not have left any breakpoints
328 in the program or it'll die when it hits one.
329 Close the open connection to the remote debugger.
330 Use this when you want to detach and do something else
334 remote_detach (args
, from_tty
)
339 error ("Argument given to \"detach\" when remotely debugging.");
343 puts_filtered ("Ending remote debugging.\n");
346 /* Convert hex digit A to a number. */
352 if (a
>= '0' && a
<= '9')
354 else if (a
>= 'a' && a
<= 'f')
357 error ("Reply contains invalid hex digit");
361 /* Convert number NIB to a hex digit. */
373 /* Tell the remote machine to resume. */
376 remote_resume (pid
, step
, siggnal
)
377 int pid
, step
, siggnal
;
384 target_terminal_ours_for_output ();
385 printf_filtered ("Can't send signals to a remote system. ");
386 name
= strsigno (siggnal
);
388 printf_filtered (name
);
390 printf_filtered ("Signal %d", siggnal
);
391 printf_filtered (" not sent.\n");
392 target_terminal_inferior ();
395 dcache_flush (remote_dcache
);
397 strcpy (buf
, step
? "s": "c");
402 /* Send ^C to target to halt it. Target will respond, and send us a
406 remote_interrupt (signo
)
409 /* If this doesn't work, try more severe steps. */
410 signal (signo
, remote_interrupt_twice
);
413 printf ("remote_interrupt called\n");
415 SERIAL_WRITE (remote_desc
, "\003", 1); /* Send a ^C */
418 static void (*ofunc
)();
420 /* The user typed ^C twice. */
422 remote_interrupt_twice (signo
)
425 signal (signo
, ofunc
);
427 target_terminal_ours ();
428 if (query ("Interrupted while waiting for the program.\n\
429 Give up (and stop debugging it)? "))
431 target_mourn_inferior ();
432 return_to_top_level (RETURN_QUIT
);
436 signal (signo
, remote_interrupt
);
437 target_terminal_inferior ();
441 /* Wait until the remote machine stops, then return,
442 storing status in STATUS just as `wait' would.
443 Returns "pid" (though it's not clear what, if anything, that
444 means in the case of this target). */
450 unsigned char buf
[PBUFSIZ
];
452 WSETEXIT ((*status
), 0);
458 ofunc
= (void (*)()) signal (SIGINT
, remote_interrupt
);
459 getpkt ((char *) buf
, 1);
460 signal (SIGINT
, ofunc
);
463 warning ("Remote failure reply: %s", buf
);
464 else if (buf
[0] == 'T')
468 char regs
[MAX_REGISTER_RAW_SIZE
];
470 /* Expedited reply, containing Signal, {regno, reg} repeat */
471 /* format is: 'Tssn...:r...;n...:r...;n...:r...;#cc', where
473 n... = register number
474 r... = register contents
477 p
= &buf
[3]; /* after Txx */
483 regno
= strtol (p
, &p1
, 16); /* Read the register number */
486 warning ("Remote sent badly formed register number: %s\nPacket: '%s'\n",
492 warning ("Malformed packet (missing colon): %s\nPacket: '%s'\n",
495 if (regno
>= NUM_REGS
)
496 warning ("Remote sent bad register number %d: %s\nPacket: '%s'\n",
499 for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
++)
501 if (p
[0] == 0 || p
[1] == 0)
502 warning ("Remote reply is too short: %s", buf
);
503 regs
[i
] = fromhex (p
[0]) * 16 + fromhex (p
[1]);
508 warning ("Remote register badly formatted: %s", buf
);
510 supply_register (regno
, regs
);
514 else if (buf
[0] == 'N')
517 bfd_vma text_addr
, data_addr
, bss_addr
;
519 /* Relocate object file. Format is NAATT;DD;BB where AA is
520 the signal number, TT is the new text address, DD is the
521 new data address, and BB is the new bss address. This is
522 used by the NLM stub; gdb may see more sections. */
524 text_addr
= strtol (p
, &p1
, 16);
525 if (p1
== p
|| *p1
!= ';')
526 warning ("Malformed relocation packet: Packet '%s'", buf
);
528 data_addr
= strtol (p
, &p1
, 16);
529 if (p1
== p
|| *p1
!= ';')
530 warning ("Malformed relocation packet: Packet '%s'", buf
);
532 bss_addr
= strtol (p
, &p1
, 16);
534 warning ("Malformed relocation packet: Packet '%s'", buf
);
536 if (symfile_objfile
!= NULL
)
538 struct section_offsets
*offs
;
540 /* FIXME: This code assumes gdb-stabs.h is being used;
541 it's broken for xcoff, dwarf, sdb-coff, etc. But
542 there is no simple canonical representation for this
543 stuff. (Just what does "text" as seen by the stub
546 /* FIXME: Why don't the various symfile_offsets routines
547 in the sym_fns vectors set this?
548 (no good reason -kingdon). */
549 if (symfile_objfile
->num_sections
== 0)
550 symfile_objfile
->num_sections
= SECT_OFF_MAX
;
552 offs
= ((struct section_offsets
*)
553 alloca (sizeof (struct section_offsets
)
554 + (symfile_objfile
->num_sections
555 * sizeof (offs
->offsets
))));
556 memcpy (offs
, symfile_objfile
->section_offsets
,
557 (sizeof (struct section_offsets
)
558 + (symfile_objfile
->num_sections
559 * sizeof (offs
->offsets
))));
560 ANOFFSET (offs
, SECT_OFF_TEXT
) = text_addr
;
561 ANOFFSET (offs
, SECT_OFF_DATA
) = data_addr
;
562 ANOFFSET (offs
, SECT_OFF_BSS
) = bss_addr
;
564 objfile_relocate (symfile_objfile
, offs
);
568 else if (buf
[0] == 'W')
570 /* The remote process exited. */
571 WSETEXIT (*status
, (fromhex (buf
[1]) << 4) + fromhex (buf
[2]));
574 else if (buf
[0] == 'S')
577 warning ("Invalid remote reply: %s", buf
);
580 WSETSTOP ((*status
), (((fromhex (buf
[1])) << 4) + (fromhex (buf
[2]))));
585 /* Number of bytes of registers this stub implements. */
586 static int register_bytes_found
;
588 /* Read the remote registers into the block REGS. */
589 /* Currently we just read all the registers, so we don't use regno. */
592 remote_fetch_registers (regno
)
598 char regs
[REGISTER_BYTES
];
603 /* Unimplemented registers read as all bits zero. */
604 memset (regs
, 0, REGISTER_BYTES
);
606 /* Reply describes registers byte by byte, each byte encoded as two
607 hex characters. Suck them all up, then supply them to the
608 register cacheing/storage mechanism. */
611 for (i
= 0; i
< REGISTER_BYTES
; i
++)
617 warning ("Remote reply is of odd length: %s", buf
);
618 /* Don't change register_bytes_found in this case, and don't
619 print a second warning. */
622 regs
[i
] = fromhex (p
[0]) * 16 + fromhex (p
[1]);
626 if (i
!= register_bytes_found
)
628 register_bytes_found
= i
;
629 #ifdef REGISTER_BYTES_OK
630 if (!REGISTER_BYTES_OK (i
))
631 warning ("Remote reply is too short: %s", buf
);
636 for (i
= 0; i
< NUM_REGS
; i
++)
637 supply_register (i
, ®s
[REGISTER_BYTE(i
)]);
640 /* Prepare to store registers. Since we send them all, we have to
641 read out the ones we don't want to change first. */
644 remote_prepare_to_store ()
646 /* Make sure the entire registers array is valid. */
647 read_register_bytes (0, (char *)NULL
, REGISTER_BYTES
);
650 /* Store the remote registers from the contents of the block REGISTERS.
651 FIXME, eventually just store one register if that's all that is needed. */
655 remote_store_registers (regno
)
664 /* Command describes registers byte by byte,
665 each byte encoded as two hex characters. */
668 /* remote_prepare_to_store insures that register_bytes_found gets set. */
669 for (i
= 0; i
< register_bytes_found
; i
++)
671 *p
++ = tohex ((registers
[i
] >> 4) & 0xf);
672 *p
++ = tohex (registers
[i
] & 0xf);
681 /* Use of the data cache is disabled because it loses for looking at
682 and changing hardware I/O ports and the like. Accepting `volatile'
683 would perhaps be one way to fix it, but a better way which would
684 win for more cases would be to use the executable file for the text
685 segment, like the `icache' code below but done cleanly (in some
686 target-independent place, perhaps in target_xfer_memory, perhaps
687 based on assigning each target a speed or perhaps by some simpler
690 /* Read a word from remote address ADDR and return it.
691 This goes through the data cache. */
694 remote_fetch_word (addr
)
700 extern CORE_ADDR text_start
, text_end
;
702 if (addr
>= text_start
&& addr
< text_end
)
705 xfer_core_file (addr
, &buffer
, sizeof (int));
710 return dcache_fetch (remote_dcache
, addr
);
713 /* Write a word WORD into remote address ADDR.
714 This goes through the data cache. */
717 remote_store_word (addr
, word
)
721 dcache_poke (remote_dcache
, addr
, word
);
725 /* Write memory data directly to the remote machine.
726 This does not inform the data cache; the data cache uses this.
727 MEMADDR is the address in the remote memory space.
728 MYADDR is the address of the buffer in our space.
729 LEN is the number of bytes.
731 Returns number of bytes transferred, or 0 for error. */
734 remote_write_bytes (memaddr
, myaddr
, len
)
736 unsigned char *myaddr
;
743 if (len
> PBUFSIZ
/ 2 - 20)
746 sprintf (buf
, "M%x,%x:", memaddr
, len
);
748 /* We send target system values byte by byte, in increasing byte addresses,
749 each byte encoded as two hex characters. */
751 p
= buf
+ strlen (buf
);
752 for (i
= 0; i
< len
; i
++)
754 *p
++ = tohex ((myaddr
[i
] >> 4) & 0xf);
755 *p
++ = tohex (myaddr
[i
] & 0xf);
764 /* There is no correspondance between what the remote protocol uses
765 for errors and errno codes. We would like a cleaner way of
766 representing errors (big enough to include errno codes, bfd_error
767 codes, and others). But for now just return EIO. */
774 /* Read memory data directly from the remote machine.
775 This does not use the data cache; the data cache uses this.
776 MEMADDR is the address in the remote memory space.
777 MYADDR is the address of the buffer in our space.
778 LEN is the number of bytes.
780 Returns number of bytes transferred, or 0 for error. */
783 remote_read_bytes (memaddr
, myaddr
, len
)
785 unsigned char *myaddr
;
792 if (len
> PBUFSIZ
/ 2 - 1)
795 sprintf (buf
, "m%x,%x", memaddr
, len
);
801 /* There is no correspondance between what the remote protocol uses
802 for errors and errno codes. We would like a cleaner way of
803 representing errors (big enough to include errno codes, bfd_error
804 codes, and others). But for now just return EIO. */
809 /* Reply describes memory byte by byte,
810 each byte encoded as two hex characters. */
813 for (i
= 0; i
< len
; i
++)
815 if (p
[0] == 0 || p
[1] == 0)
816 /* Reply is short. This means that we were able to read only part
817 of what we wanted to. */
819 myaddr
[i
] = fromhex (p
[0]) * 16 + fromhex (p
[1]);
825 /* Read or write LEN bytes from inferior memory at MEMADDR, transferring
826 to or from debugger address MYADDR. Write to inferior if SHOULD_WRITE is
827 nonzero. Returns length of data written or read; 0 for error. */
831 remote_xfer_memory(memaddr
, myaddr
, len
, should_write
, target
)
836 struct target_ops
*target
; /* ignored */
840 int total_xferred
= 0;
844 if (len
> MAXBUFBYTES
)
845 xfersize
= MAXBUFBYTES
;
850 bytes_xferred
= remote_write_bytes (memaddr
, myaddr
, xfersize
);
852 bytes_xferred
= remote_read_bytes (memaddr
, myaddr
, xfersize
);
854 /* If we get an error, we are done xferring. */
855 if (bytes_xferred
== 0)
858 memaddr
+= bytes_xferred
;
859 myaddr
+= bytes_xferred
;
860 len
-= bytes_xferred
;
861 total_xferred
+= bytes_xferred
;
863 return total_xferred
;
867 remote_files_info (ignore
)
868 struct target_ops
*ignore
;
870 puts_filtered ("Debugging a target over a serial line.\n");
873 /* Stuff for dealing with the packets which are part of this protocol.
874 See comment at top of file for details. */
876 /* Read a single character from the remote end, masking it down to 7 bits. */
883 ch
= SERIAL_READCHAR (remote_desc
, timeout
);
891 /* Send the command in BUF to the remote machine,
892 and read the reply into BUF.
893 Report an error if we get an error reply. */
904 error ("Remote failure reply: %s", buf
);
907 /* Send a packet to the remote machine, with error checking.
908 The data of the packet is in BUF. */
915 unsigned char csum
= 0;
917 int cnt
= strlen (buf
);
921 /* Copy the packet into buffer BUF2, encapsulating it
922 and giving it a checksum. */
924 if (cnt
> sizeof(buf2
) - 5) /* Prosanity check */
930 for (i
= 0; i
< cnt
; i
++)
936 *p
++ = tohex ((csum
>> 4) & 0xf);
937 *p
++ = tohex (csum
& 0xf);
939 /* Send it over and over until we get a positive ack. */
946 printf ("Sending packet: %s...", buf2
); fflush(stdout
);
948 if (SERIAL_WRITE (remote_desc
, buf2
, p
- buf2
))
949 perror_with_name ("putpkt: write failed");
951 /* read until either a timeout occurs (-2) or '+' is read */
963 break; /* Retransmit buffer */
965 perror_with_name ("putpkt: couldn't read ACK");
967 error ("putpkt: EOF while trying to read ACK");
970 printf ("%02X %c ", ch
&0xFF, ch
);
973 break; /* Here to retransmit */
978 /* Read a packet from the remote machine, with error checking,
979 and store it in BUF. BUF is expected to be of size PBUFSIZ.
980 If FOREVER, wait forever rather than timing out; this is used
981 while the target is executing user code. */
984 getpkt (buf
, forever
)
991 unsigned char c1
, c2
;
993 #define MAX_RETRIES 10
997 /* This can loop forever if the remote side sends us characters
998 continuously, but if it pauses, we'll get a zero from readchar
999 because of timeout. Then we'll count that as a retry. */
1002 if (c
> 0 && c
!= '$')
1005 if (c
== SERIAL_TIMEOUT
)
1009 if (++retries
>= MAX_RETRIES
)
1010 if (sr_get_debug ()) puts_filtered ("Timed out.\n");
1014 if (c
== SERIAL_EOF
)
1015 error ("Remote connection closed");
1016 if (c
== SERIAL_ERROR
)
1017 perror_with_name ("Remote communication error");
1019 /* Force csum to be zero here because of possible error retry. */
1026 if (c
== SERIAL_TIMEOUT
)
1028 if (sr_get_debug ())
1029 puts_filtered ("Timeout in mid-packet, retrying\n");
1030 goto whole
; /* Start a new packet, count retries */
1034 if (sr_get_debug ())
1035 puts_filtered ("Saw new packet start in middle of old one\n");
1036 goto whole
; /* Start a new packet, count retries */
1040 if (bp
>= buf
+PBUFSIZ
-1)
1043 puts_filtered ("Remote packet too long: ");
1044 puts_filtered (buf
);
1045 puts_filtered ("\n");
1053 c1
= fromhex (readchar ());
1054 c2
= fromhex (readchar ());
1055 if ((csum
& 0xff) == (c1
<< 4) + c2
)
1057 printf_filtered ("Bad checksum, sentsum=0x%x, csum=0x%x, buf=",
1058 (c1
<< 4) + c2
, csum
& 0xff);
1059 puts_filtered (buf
);
1060 puts_filtered ("\n");
1062 /* Try the whole thing again. */
1064 if (++retries
< MAX_RETRIES
)
1066 SERIAL_WRITE (remote_desc
, "-", 1);
1070 printf ("Ignoring packet error, continuing...\n");
1077 SERIAL_WRITE (remote_desc
, "+", 1);
1079 if (sr_get_debug ())
1080 fprintf (stderr
,"Packet received: %s\n", buf
);
1087 /* Don't wait for it to die. I'm not really sure it matters whether
1088 we do or not. For the existing stubs, kill is a noop. */
1089 target_mourn_inferior ();
1095 unpush_target (&remote_ops
);
1096 generic_mourn_inferior ();
1099 #ifdef REMOTE_BREAKPOINT
1101 /* On some machines, e.g. 68k, we may use a different breakpoint instruction
1102 than other targets. */
1103 static unsigned char break_insn
[] = REMOTE_BREAKPOINT
;
1105 /* Check that it fits in BREAKPOINT_MAX bytes. */
1106 static unsigned char check_break_insn_size
[BREAKPOINT_MAX
] = REMOTE_BREAKPOINT
;
1108 #else /* No REMOTE_BREAKPOINT. */
1110 /* Same old breakpoint instruction. This code does nothing different
1111 than mem-break.c. */
1112 static unsigned char break_insn
[] = BREAKPOINT
;
1114 #endif /* No REMOTE_BREAKPOINT. */
1116 /* Insert a breakpoint on targets that don't have any better breakpoint
1117 support. We read the contents of the target location and stash it,
1118 then overwrite it with a breakpoint instruction. ADDR is the target
1119 location in the target machine. CONTENTS_CACHE is a pointer to
1120 memory allocated for saving the target contents. It is guaranteed
1121 by the caller to be long enough to save sizeof BREAKPOINT bytes (this
1122 is accomplished via BREAKPOINT_MAX). */
1125 remote_insert_breakpoint (addr
, contents_cache
)
1127 char *contents_cache
;
1131 val
= target_read_memory (addr
, contents_cache
, sizeof break_insn
);
1134 val
= target_write_memory (addr
, (char *)break_insn
, sizeof break_insn
);
1140 remote_remove_breakpoint (addr
, contents_cache
)
1142 char *contents_cache
;
1144 return target_write_memory (addr
, contents_cache
, sizeof break_insn
);
1147 /* Define the target subroutine names */
1149 struct target_ops remote_ops
= {
1150 "remote", /* to_shortname */
1151 "Remote serial target in gdb-specific protocol", /* to_longname */
1152 "Use a remote computer via a serial line, using a gdb-specific protocol.\n\
1153 Specify the serial device it is connected to (e.g. /dev/ttya).", /* to_doc */
1154 remote_open
, /* to_open */
1155 remote_close
, /* to_close */
1156 NULL
, /* to_attach */
1157 remote_detach
, /* to_detach */
1158 remote_resume
, /* to_resume */
1159 remote_wait
, /* to_wait */
1160 remote_fetch_registers
, /* to_fetch_registers */
1161 remote_store_registers
, /* to_store_registers */
1162 remote_prepare_to_store
, /* to_prepare_to_store */
1163 remote_xfer_memory
, /* to_xfer_memory */
1164 remote_files_info
, /* to_files_info */
1166 remote_insert_breakpoint
, /* to_insert_breakpoint */
1167 remote_remove_breakpoint
, /* to_remove_breakpoint */
1169 NULL
, /* to_terminal_init */
1170 NULL
, /* to_terminal_inferior */
1171 NULL
, /* to_terminal_ours_for_output */
1172 NULL
, /* to_terminal_ours */
1173 NULL
, /* to_terminal_info */
1174 remote_kill
, /* to_kill */
1175 generic_load
, /* to_load */
1176 NULL
, /* to_lookup_symbol */
1177 NULL
, /* to_create_inferior */
1178 remote_mourn
, /* to_mourn_inferior */
1180 0, /* to_notice_signals */
1181 process_stratum
, /* to_stratum */
1183 1, /* to_has_all_memory */
1184 1, /* to_has_memory */
1185 1, /* to_has_stack */
1186 1, /* to_has_registers */
1187 1, /* to_has_execution */
1188 NULL
, /* sections */
1189 NULL
, /* sections_end */
1190 OPS_MAGIC
/* to_magic */
1194 _initialize_remote ()
1196 add_target (&remote_ops
);
This page took 0.054341 seconds and 4 git commands to generate.