* remote.c (getpkt): If we get a timeout, actually retry rather
[deliverable/binutils-gdb.git] / gdb / remote.c
CommitLineData
b543979c 1/* Remote target communications for serial-line targets in custom GDB protocol
94d4b713 2 Copyright 1988, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
bd5635a1
RP
3
4This file is part of GDB.
5
b543979c 6This program is free software; you can redistribute it and/or modify
bd5635a1 7it under the terms of the GNU General Public License as published by
b543979c
JG
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
bd5635a1 10
b543979c 11This program is distributed in the hope that it will be useful,
bd5635a1
RP
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
b543979c
JG
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
bd5635a1
RP
19
20/* Remote communication protocol.
e50ebec8
JK
21
22 A debug packet whose contents are <data>
23 is encapsulated for transmission in the form:
24
25 $ <data> # CSUM1 CSUM2
26
27 <data> must be ASCII alphanumeric and cannot include characters
0c993550
JK
28 '$' or '#'. If <data> starts with two characters followed by
29 ':', then the existing stubs interpret this as a sequence number.
e50ebec8
JK
30
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.
34
35 Receiver responds with:
36
37 + - if CSUM is correct and ready for next packet
38 - - if CSUM is incorrect
39
40 <data> is as follows:
bd5635a1
RP
41 All values are encoded in ascii hex digits.
42
43 Request Packet
44
45 read registers g
46 reply XX....X Each byte of register data
47 is described by two hex digits.
48 Registers are in the internal order
49 for GDB, and the bytes in a register
50 are in the same order the machine uses.
51 or ENN for an error.
52
53 write regs GXX..XX Each byte of register data
54 is described by two hex digits.
55 reply OK for success
56 ENN for an error
57
0c993550 58 write reg Pn...=r... Write register n... with value r...,
4aa6fe10
JK
59 which contains two hex digits for each
60 byte in the register (target byte
61 order).
62 reply OK for success
63 ENN for an error
64 (not supported by all stubs).
65
bd5635a1
RP
66 read mem mAA..AA,LLLL AA..AA is address, LLLL is length.
67 reply XX..XX XX..XX is mem contents
d538b510
RP
68 Can be fewer bytes than requested
69 if able to read only part of the data.
bd5635a1
RP
70 or ENN NN is errno
71
72 write mem MAA..AA,LLLL:XX..XX
73 AA..AA is address,
74 LLLL is number of bytes,
75 XX..XX is data
76 reply OK for success
d538b510
RP
77 ENN for an error (this includes the case
78 where only part of the data was
79 written).
bd5635a1
RP
80
81 cont cAA..AA AA..AA is address to resume
82 If AA..AA is omitted,
83 resume at same address.
84
85 step sAA..AA AA..AA is address to resume
86 If AA..AA is omitted,
87 resume at same address.
88
89 last signal ? Reply the current reason for stopping.
90 This is the same reply as is generated
91 for step or cont : SAA where AA is the
92 signal number.
93
94 There is no immediate reply to step or cont.
95 The reply comes when the machine stops.
96 It is SAA AA is the "signal number"
97
e50ebec8
JK
98 or... TAAn...:r...;n:r...;n...:r...;
99 AA = signal number
100 n... = register number
101 r... = register contents
72bba93b 102 or... WAA The process exited, and AA is
758aeb93
ILT
103 the exit status. This is only
104 applicable for certains sorts of
105 targets.
d538b510
RP
106 kill request k
107
108 toggle debug d toggle debug flag (see 386 & 68k stubs)
109 reset r reset -- see sparc stub.
110 reserved <other> On other requests, the stub should
111 ignore the request and send an empty
112 response ($#<checksum>). This way
113 we can extend the protocol and GDB
114 can tell whether the stub it is
115 talking to uses the old or the new.
72bba93b 116 search tAA:PP,MM Search backwards starting at address
94d4b713
JK
117 AA for a match with pattern PP and
118 mask MM. PP and MM are 4 bytes.
119 Not supported by all stubs.
120
72bba93b
SG
121 general query qXXXX Request info about XXXX.
122 general set QXXXX=yyyy Set value of XXXX to yyyy.
123 query sect offs qOffsets Get section offsets. Reply is
124 Text=xxx;Data=yyy;Bss=zzz
72bba93b 125
94d4b713
JK
126 Responses can be run-length encoded to save space. A '*' means that
127 the next two characters are hex digits giving a repeat count which
128 stands for that many repititions of the character preceding the '*'.
129 Note that this means that responses cannot contain '*'. Example:
4aa6fe10 130 "0*03" means the same as "0000". */
bd5635a1 131
d747e0af 132#include "defs.h"
bd5635a1
RP
133#include <string.h>
134#include <fcntl.h>
bd5635a1
RP
135#include "frame.h"
136#include "inferior.h"
e50ebec8 137#include "bfd.h"
6b27ebe8 138#include "symfile.h"
bd5635a1
RP
139#include "target.h"
140#include "wait.h"
141#include "terminal.h"
8f86a4e4 142#include "gdbcmd.h"
758aeb93
ILT
143#include "objfiles.h"
144#include "gdb-stabs.h"
bd5635a1 145
d538b510
RP
146#include "dcache.h"
147
8f86a4e4 148#if !defined(DONT_USE_REMOTE)
bd5635a1
RP
149#ifdef USG
150#include <sys/types.h>
151#endif
152
153#include <signal.h>
ebdb9ade 154#include "serial.h"
bd5635a1 155
b543979c
JG
156/* Prototypes for local functions */
157
d538b510
RP
158static int
159remote_write_bytes PARAMS ((CORE_ADDR memaddr, unsigned char *myaddr, int len));
b543979c 160
d538b510
RP
161static int
162remote_read_bytes PARAMS ((CORE_ADDR memaddr, unsigned char *myaddr, int len));
b543979c
JG
163
164static void
5af4f5f6 165remote_files_info PARAMS ((struct target_ops *ignore));
b543979c
JG
166
167static int
5af4f5f6
JK
168remote_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len,
169 int should_write, struct target_ops *target));
b543979c
JG
170
171static void
172remote_prepare_to_store PARAMS ((void));
173
174static void
5af4f5f6 175remote_fetch_registers PARAMS ((int regno));
b543979c
JG
176
177static void
94d4b713 178remote_resume PARAMS ((int pid, int step, enum target_signal siggnal));
b543979c 179
7c622b41 180static int
5af4f5f6 181remote_start_remote PARAMS ((char *dummy));
7c622b41 182
b543979c 183static void
5af4f5f6 184remote_open PARAMS ((char *name, int from_tty));
b543979c
JG
185
186static void
5af4f5f6 187remote_close PARAMS ((int quitting));
b543979c
JG
188
189static void
5af4f5f6 190remote_store_registers PARAMS ((int regno));
b543979c
JG
191
192static void
5af4f5f6 193getpkt PARAMS ((char *buf, int forever));
b543979c
JG
194
195static void
5af4f5f6 196putpkt PARAMS ((char *buf));
b543979c
JG
197
198static void
5af4f5f6 199remote_send PARAMS ((char *buf));
b543979c
JG
200
201static int
202readchar PARAMS ((void));
203
94d4b713 204static int remote_wait PARAMS ((int pid, struct target_waitstatus *status));
b543979c
JG
205
206static int
5af4f5f6 207tohex PARAMS ((int nib));
b543979c
JG
208
209static int
5af4f5f6 210fromhex PARAMS ((int a));
b543979c
JG
211
212static void
5af4f5f6
JK
213remote_detach PARAMS ((char *args, int from_tty));
214
215static void
216remote_interrupt PARAMS ((int signo));
217
218static void
219remote_interrupt_twice PARAMS ((int signo));
b543979c 220
981a3309
SG
221static void
222interrupt_query PARAMS ((void));
223
bd5635a1
RP
224extern struct target_ops remote_ops; /* Forward decl */
225
ebdb9ade
JK
226/* This was 5 seconds, which is a long time to sit and wait.
227 Unless this is going though some terminal server or multiplexer or
228 other form of hairy serial connection, I would think 2 seconds would
229 be plenty. */
230static int timeout = 2;
bd5635a1
RP
231
232#if 0
233int icache;
234#endif
235
16e1d1d3 236/* Descriptor for I/O to remote machine. Initialize it to NULL so that
bd5635a1
RP
237 remote_open knows that we don't have a file open when the program
238 starts. */
ebdb9ade 239serial_t remote_desc = NULL;
bd5635a1 240
4d57c599
JK
241/* Having this larger than 400 causes us to be incompatible with m68k-stub.c
242 and i386-stub.c. Normally, no one would notice because it only matters
243 for writing large chunks of memory (e.g. in downloads). Also, this needs
244 to be more than 400 if required to hold the registers (see below, where
245 we round it up based on REGISTER_BYTES). */
246#define PBUFSIZ 400
bd5635a1
RP
247
248/* Maximum number of bytes to read/write at once. The value here
249 is chosen to fill up a packet (the headers account for the 32). */
250#define MAXBUFBYTES ((PBUFSIZ-32)/2)
251
b543979c
JG
252/* Round up PBUFSIZ to hold all the registers, at least. */
253#if REGISTER_BYTES > MAXBUFBYTES
254#undef PBUFSIZ
255#define PBUFSIZ (REGISTER_BYTES * 2 + 32)
bd5635a1 256#endif
4aa6fe10
JK
257
258/* Should we try the 'P' request? If this is set to one when the stub
259 doesn't support 'P', the only consequence is some unnecessary traffic. */
260static int stub_supports_P = 1;
261
bd5635a1 262\f
bd5635a1
RP
263/* Clean up connection to a remote debugger. */
264
e1ce8aa5 265/* ARGSUSED */
b543979c 266static void
bd5635a1
RP
267remote_close (quitting)
268 int quitting;
269{
ebdb9ade
JK
270 if (remote_desc)
271 SERIAL_CLOSE (remote_desc);
272 remote_desc = NULL;
b543979c
JG
273}
274
72bba93b
SG
275/* Query the remote side for the text, data and bss offsets. */
276
277static void
278get_offsets ()
279{
280 unsigned char buf [PBUFSIZ];
281 int nvals;
282 CORE_ADDR text_addr, data_addr, bss_addr;
283 struct section_offsets *offs;
284
285 putpkt ("qOffsets");
286
287 getpkt (buf, 1);
288
289 if (buf[0] == 'E')
290 {
291 warning ("Remote failure reply: %s", buf);
292 return;
293 }
294
295 nvals = sscanf (buf, "Text=%lx;Data=%lx;Bss=%lx", &text_addr, &data_addr,
296 &bss_addr);
297 if (nvals != 3)
298 error ("Malformed response to offset query, %s", buf);
299
300 if (symfile_objfile == NULL)
301 return;
302
303 offs = (struct section_offsets *) alloca (sizeof (struct section_offsets)
304 + symfile_objfile->num_sections
305 * sizeof (offs->offsets));
306 memcpy (offs, symfile_objfile->section_offsets,
307 sizeof (struct section_offsets)
308 + symfile_objfile->num_sections
309 * sizeof (offs->offsets));
310
4aa6fe10
JK
311 /* FIXME: This code assumes gdb-stabs.h is being used; it's broken
312 for xcoff, dwarf, sdb-coff, etc. But there is no simple
313 canonical representation for this stuff. (Just what does "text"
314 as seen by the stub mean, anyway? I think it means all sections
315 with SEC_CODE set, but we currently have no way to deal with that). */
316
72bba93b
SG
317 ANOFFSET (offs, SECT_OFF_TEXT) = text_addr;
318 ANOFFSET (offs, SECT_OFF_DATA) = data_addr;
319 ANOFFSET (offs, SECT_OFF_BSS) = bss_addr;
320
321 objfile_relocate (symfile_objfile, offs);
322}
323
7c622b41
JG
324/* Stub for catch_errors. */
325
326static int
327remote_start_remote (dummy)
328 char *dummy;
329{
ac7a377f
JK
330 immediate_quit = 1; /* Allow user to interrupt it */
331
7c622b41 332 /* Ack any packet which the remote side has already sent. */
72bba93b
SG
333
334 SERIAL_WRITE (remote_desc, "+", 1);
335
336 get_offsets (); /* Get text, data & bss offsets */
337
7c622b41 338 putpkt ("?"); /* initiate a query from remote machine */
ac7a377f 339 immediate_quit = 0;
7c622b41
JG
340
341 start_remote (); /* Initialize gdb process mechanisms */
72bba93b 342
7c622b41
JG
343 return 1;
344}
345
bd5635a1
RP
346/* Open a connection to a remote debugger.
347 NAME is the filename used for communication. */
348
d538b510
RP
349static DCACHE *remote_dcache;
350
b543979c 351static void
bd5635a1
RP
352remote_open (name, from_tty)
353 char *name;
354 int from_tty;
355{
bd5635a1
RP
356 if (name == 0)
357 error (
358"To open a remote debug connection, you need to specify what serial\n\
359device is attached to the remote system (e.g. /dev/ttya).");
360
f2fc6e7a
JK
361 target_preopen (from_tty);
362
ebdb9ade 363 unpush_target (&remote_ops);
bd5635a1 364
d538b510 365 remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
bd5635a1 366
ebdb9ade
JK
367 remote_desc = SERIAL_OPEN (name);
368 if (!remote_desc)
bd5635a1
RP
369 perror_with_name (name);
370
94d4b713 371 if (baud_rate != -1)
b543979c 372 {
94d4b713
JK
373 if (SERIAL_SETBAUDRATE (remote_desc, baud_rate))
374 {
375 SERIAL_CLOSE (remote_desc);
376 perror_with_name (name);
377 }
b543979c 378 }
ebdb9ade
JK
379
380 SERIAL_RAW (remote_desc);
bd5635a1 381
e15f2a54
JK
382 /* If there is something sitting in the buffer we might take it as a
383 response to a command, which would be bad. */
384 SERIAL_FLUSH_INPUT (remote_desc);
385
bd5635a1 386 if (from_tty)
7c622b41
JG
387 {
388 puts_filtered ("Remote debugging using ");
389 puts_filtered (name);
390 puts_filtered ("\n");
391 }
bd5635a1 392 push_target (&remote_ops); /* Switch to using remote target now */
bd5635a1 393
4aa6fe10
JK
394 /* Start out by trying the 'P' request to set registers. We set this each
395 time that we open a new target so that if the user switches from one
396 stub to another, we can (if the target is closed and reopened) cope. */
397 stub_supports_P = 1;
398
ac7a377f
JK
399 /* Start the remote connection; if error (0), discard this target.
400 In particular, if the user quits, be sure to discard it
401 (we'd be in an inconsistent state otherwise). */
7c622b41 402 if (!catch_errors (remote_start_remote, (char *)0,
e50ebec8 403 "Couldn't establish connection to remote target\n", RETURN_MASK_ALL))
7c622b41 404 pop_target();
bd5635a1
RP
405}
406
407/* remote_detach()
408 takes a program previously attached to and detaches it.
409 We better not have left any breakpoints
410 in the program or it'll die when it hits one.
411 Close the open connection to the remote debugger.
412 Use this when you want to detach and do something else
413 with your gdb. */
414
415static void
416remote_detach (args, from_tty)
417 char *args;
418 int from_tty;
419{
420 if (args)
421 error ("Argument given to \"detach\" when remotely debugging.");
422
423 pop_target ();
424 if (from_tty)
7c622b41 425 puts_filtered ("Ending remote debugging.\n");
bd5635a1
RP
426}
427
428/* Convert hex digit A to a number. */
429
430static int
431fromhex (a)
432 int a;
433{
434 if (a >= '0' && a <= '9')
435 return a - '0';
436 else if (a >= 'a' && a <= 'f')
437 return a - 'a' + 10;
438 else
439 error ("Reply contains invalid hex digit");
440 return -1;
441}
442
443/* Convert number NIB to a hex digit. */
444
445static int
446tohex (nib)
447 int nib;
448{
449 if (nib < 10)
450 return '0'+nib;
451 else
452 return 'a'+nib-10;
453}
454\f
455/* Tell the remote machine to resume. */
456
b543979c 457static void
d538b510 458remote_resume (pid, step, siggnal)
94d4b713
JK
459 int pid, step;
460 enum target_signal siggnal;
bd5635a1
RP
461{
462 char buf[PBUFSIZ];
463
464 if (siggnal)
ebdb9ade
JK
465 {
466 char *name;
467 target_terminal_ours_for_output ();
94d4b713
JK
468 printf_filtered
469 ("Can't send signals to a remote system. %s not sent.\n",
470 target_signal_to_name (siggnal));
ebdb9ade
JK
471 target_terminal_inferior ();
472 }
bd5635a1 473
d538b510 474 dcache_flush (remote_dcache);
bd5635a1
RP
475
476 strcpy (buf, step ? "s": "c");
477
478 putpkt (buf);
479}
ebdb9ade 480\f
b543979c
JG
481/* Send ^C to target to halt it. Target will respond, and send us a
482 packet. */
483
5af4f5f6
JK
484static void
485remote_interrupt (signo)
e676a15f 486 int signo;
b543979c 487{
ebdb9ade
JK
488 /* If this doesn't work, try more severe steps. */
489 signal (signo, remote_interrupt_twice);
8f86a4e4 490
d0d8484a 491 if (remote_debug)
199b2450 492 printf_unfiltered ("remote_interrupt called\n");
8f86a4e4 493
ebdb9ade 494 SERIAL_WRITE (remote_desc, "\003", 1); /* Send a ^C */
b543979c
JG
495}
496
5af4f5f6
JK
497static void (*ofunc)();
498
ebdb9ade
JK
499/* The user typed ^C twice. */
500static void
501remote_interrupt_twice (signo)
502 int signo;
503{
504 signal (signo, ofunc);
505
981a3309
SG
506 interrupt_query ();
507
508 signal (signo, remote_interrupt);
509}
510
511/* Ask the user what to do when an interrupt is received. */
512
513static void
514interrupt_query ()
515{
ebdb9ade 516 target_terminal_ours ();
981a3309 517
6b27ebe8 518 if (query ("Interrupted while waiting for the program.\n\
ebdb9ade
JK
519Give up (and stop debugging it)? "))
520 {
521 target_mourn_inferior ();
e50ebec8 522 return_to_top_level (RETURN_QUIT);
ebdb9ade 523 }
981a3309
SG
524
525 target_terminal_inferior ();
ebdb9ade 526}
b543979c 527
bd5635a1 528/* Wait until the remote machine stops, then return,
e1ce8aa5
JK
529 storing status in STATUS just as `wait' would.
530 Returns "pid" (though it's not clear what, if anything, that
531 means in the case of this target). */
bd5635a1 532
b543979c 533static int
d0d8484a
SG
534remote_wait (pid, status)
535 int pid;
94d4b713 536 struct target_waitstatus *status;
bd5635a1
RP
537{
538 unsigned char buf[PBUFSIZ];
8f86a4e4 539
94d4b713
JK
540 status->kind = TARGET_WAITKIND_EXITED;
541 status->value.integer = 0;
b543979c 542
4f8a48e5 543 while (1)
8f86a4e4 544 {
4f8a48e5 545 unsigned char *p;
a03d4f8e 546
4f8a48e5
ILT
547 ofunc = (void (*)()) signal (SIGINT, remote_interrupt);
548 getpkt ((char *) buf, 1);
549 signal (SIGINT, ofunc);
4ecee2f9 550
4f8a48e5
ILT
551 if (buf[0] == 'E')
552 warning ("Remote failure reply: %s", buf);
553 else if (buf[0] == 'T')
8f86a4e4 554 {
4f8a48e5
ILT
555 int i;
556 long regno;
557 char regs[MAX_REGISTER_RAW_SIZE];
a03d4f8e 558
4f8a48e5
ILT
559 /* Expedited reply, containing Signal, {regno, reg} repeat */
560 /* format is: 'Tssn...:r...;n...:r...;n...:r...;#cc', where
561 ss = signal number
562 n... = register number
563 r... = register contents
564 */
5af4f5f6 565
4f8a48e5 566 p = &buf[3]; /* after Txx */
5af4f5f6 567
4f8a48e5
ILT
568 while (*p)
569 {
570 unsigned char *p1;
5af4f5f6 571
4f8a48e5 572 regno = strtol (p, &p1, 16); /* Read the register number */
5af4f5f6 573
4f8a48e5
ILT
574 if (p1 == p)
575 warning ("Remote sent badly formed register number: %s\nPacket: '%s'\n",
576 p1, buf);
4ecee2f9 577
4f8a48e5 578 p = p1;
4ecee2f9 579
4f8a48e5
ILT
580 if (*p++ != ':')
581 warning ("Malformed packet (missing colon): %s\nPacket: '%s'\n",
582 p, buf);
a03d4f8e 583
4f8a48e5
ILT
584 if (regno >= NUM_REGS)
585 warning ("Remote sent bad register number %d: %s\nPacket: '%s'\n",
586 regno, p, buf);
587
588 for (i = 0; i < REGISTER_RAW_SIZE (regno); i++)
589 {
590 if (p[0] == 0 || p[1] == 0)
591 warning ("Remote reply is too short: %s", buf);
592 regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
593 p += 2;
594 }
595
596 if (*p++ != ';')
597 warning ("Remote register badly formatted: %s", buf);
598
599 supply_register (regno, regs);
600 }
601 break;
8f86a4e4 602 }
4f8a48e5
ILT
603 else if (buf[0] == 'W')
604 {
605 /* The remote process exited. */
94d4b713
JK
606 status->kind = TARGET_WAITKIND_EXITED;
607 status->value.integer = (fromhex (buf[1]) << 4) + fromhex (buf[2]);
4f8a48e5
ILT
608 return 0;
609 }
610 else if (buf[0] == 'S')
611 break;
612 else
613 warning ("Invalid remote reply: %s", buf);
758aeb93 614 }
8f86a4e4 615
94d4b713
JK
616 status->kind = TARGET_WAITKIND_STOPPED;
617 status->value.sig = (enum target_signal)
618 (((fromhex (buf[1])) << 4) + (fromhex (buf[2])));
8f86a4e4 619
e1ce8aa5 620 return 0;
bd5635a1
RP
621}
622
55fea07b
JK
623/* Number of bytes of registers this stub implements. */
624static int register_bytes_found;
625
bd5635a1 626/* Read the remote registers into the block REGS. */
e1ce8aa5
JK
627/* Currently we just read all the registers, so we don't use regno. */
628/* ARGSUSED */
b543979c 629static void
bd5635a1
RP
630remote_fetch_registers (regno)
631 int regno;
632{
633 char buf[PBUFSIZ];
634 int i;
635 char *p;
636 char regs[REGISTER_BYTES];
637
638 sprintf (buf, "g");
639 remote_send (buf);
640
55fea07b
JK
641 /* Unimplemented registers read as all bits zero. */
642 memset (regs, 0, REGISTER_BYTES);
643
981a3309
SG
644 /* We can get out of synch in various cases. If the first character
645 in the buffer is not a hex character, assume that has happened
646 and try to fetch another packet to read. */
647 while ((buf[0] < '0' || buf[0] > '9')
648 && (buf[0] < 'a' || buf[0] > 'f'))
649 {
d0d8484a 650 if (remote_debug)
199b2450 651 printf_unfiltered ("Bad register packet; fetching a new packet\n");
981a3309
SG
652 getpkt (buf, 0);
653 }
654
bd5635a1
RP
655 /* Reply describes registers byte by byte, each byte encoded as two
656 hex characters. Suck them all up, then supply them to the
657 register cacheing/storage mechanism. */
658
659 p = buf;
660 for (i = 0; i < REGISTER_BYTES; i++)
661 {
55fea07b
JK
662 if (p[0] == 0)
663 break;
664 if (p[1] == 0)
665 {
666 warning ("Remote reply is of odd length: %s", buf);
667 /* Don't change register_bytes_found in this case, and don't
668 print a second warning. */
669 goto supply_them;
670 }
bd5635a1
RP
671 regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
672 p += 2;
673 }
55fea07b
JK
674
675 if (i != register_bytes_found)
676 {
677 register_bytes_found = i;
678#ifdef REGISTER_BYTES_OK
679 if (!REGISTER_BYTES_OK (i))
680 warning ("Remote reply is too short: %s", buf);
681#endif
682 }
683
684 supply_them:
bd5635a1
RP
685 for (i = 0; i < NUM_REGS; i++)
686 supply_register (i, &regs[REGISTER_BYTE(i)]);
bd5635a1
RP
687}
688
4aa6fe10
JK
689/* Prepare to store registers. Since we may send them all (using a
690 'G' request), we have to read out the ones we don't want to change
691 first. */
bd5635a1 692
b543979c 693static void
bd5635a1
RP
694remote_prepare_to_store ()
695{
34517ebc
JG
696 /* Make sure the entire registers array is valid. */
697 read_register_bytes (0, (char *)NULL, REGISTER_BYTES);
bd5635a1
RP
698}
699
4aa6fe10
JK
700/* Store register REGNO, or all registers if REGNO == -1, from the contents
701 of REGISTERS. FIXME: ignores errors. */
bd5635a1 702
b543979c 703static void
bd5635a1
RP
704remote_store_registers (regno)
705 int regno;
706{
707 char buf[PBUFSIZ];
708 int i;
709 char *p;
710
4aa6fe10
JK
711 if (regno >= 0 && stub_supports_P)
712 {
713 /* Try storing a single register. */
714 char *regp;
715
0c993550 716 sprintf (buf, "P%x=", regno);
4aa6fe10
JK
717 p = buf + strlen (buf);
718 regp = &registers[REGISTER_BYTE (regno)];
719 for (i = 0; i < REGISTER_RAW_SIZE (regno); ++i)
720 {
721 *p++ = tohex ((regp[i] >> 4) & 0xf);
722 *p++ = tohex (regp[i] & 0xf);
723 }
724 *p = '\0';
725 remote_send (buf);
726 if (buf[0] != '\0')
727 {
728 /* The stub understands the 'P' request. We are done. */
729 return;
730 }
731
732 /* The stub does not support the 'P' request. Use 'G' instead,
733 and don't try using 'P' in the future (it will just waste our
734 time). */
735 stub_supports_P = 0;
736 }
737
bd5635a1 738 buf[0] = 'G';
4aa6fe10 739
bd5635a1
RP
740 /* Command describes registers byte by byte,
741 each byte encoded as two hex characters. */
742
743 p = buf + 1;
55fea07b
JK
744 /* remote_prepare_to_store insures that register_bytes_found gets set. */
745 for (i = 0; i < register_bytes_found; i++)
bd5635a1
RP
746 {
747 *p++ = tohex ((registers[i] >> 4) & 0xf);
748 *p++ = tohex (registers[i] & 0xf);
749 }
750 *p = '\0';
751
752 remote_send (buf);
bd5635a1
RP
753}
754
b43e0347
JK
755#if 0
756
757/* Use of the data cache is disabled because it loses for looking at
758 and changing hardware I/O ports and the like. Accepting `volatile'
759 would perhaps be one way to fix it, but a better way which would
760 win for more cases would be to use the executable file for the text
761 segment, like the `icache' code below but done cleanly (in some
762 target-independent place, perhaps in target_xfer_memory, perhaps
763 based on assigning each target a speed or perhaps by some simpler
764 mechanism). */
765
bd5635a1
RP
766/* Read a word from remote address ADDR and return it.
767 This goes through the data cache. */
768
b43e0347 769static int
bd5635a1
RP
770remote_fetch_word (addr)
771 CORE_ADDR addr;
772{
d538b510 773#if 0
bd5635a1
RP
774 if (icache)
775 {
776 extern CORE_ADDR text_start, text_end;
777
778 if (addr >= text_start && addr < text_end)
779 {
780 int buffer;
781 xfer_core_file (addr, &buffer, sizeof (int));
782 return buffer;
783 }
784 }
d538b510
RP
785#endif
786 return dcache_fetch (remote_dcache, addr);
bd5635a1
RP
787}
788
789/* Write a word WORD into remote address ADDR.
790 This goes through the data cache. */
791
b43e0347 792static void
bd5635a1
RP
793remote_store_word (addr, word)
794 CORE_ADDR addr;
795 int word;
796{
d538b510 797 dcache_poke (remote_dcache, addr, word);
bd5635a1 798}
b43e0347 799#endif /* 0 */
bd5635a1
RP
800\f
801/* Write memory data directly to the remote machine.
802 This does not inform the data cache; the data cache uses this.
803 MEMADDR is the address in the remote memory space.
804 MYADDR is the address of the buffer in our space.
d538b510 805 LEN is the number of bytes.
bd5635a1 806
d538b510
RP
807 Returns number of bytes transferred, or 0 for error. */
808
809static int
bd5635a1
RP
810remote_write_bytes (memaddr, myaddr, len)
811 CORE_ADDR memaddr;
d538b510 812 unsigned char *myaddr;
bd5635a1
RP
813 int len;
814{
815 char buf[PBUFSIZ];
816 int i;
817 char *p;
818
4aa6fe10
JK
819 /* FIXME-32x64: Need a version of print_address_numeric which doesn't
820 set use_local (and also puts the result in a buffer like sprintf). */
821 sprintf (buf, "M%lx,%x:", (unsigned long) memaddr, len);
bd5635a1 822
b543979c 823 /* We send target system values byte by byte, in increasing byte addresses,
bd5635a1
RP
824 each byte encoded as two hex characters. */
825
826 p = buf + strlen (buf);
827 for (i = 0; i < len; i++)
828 {
829 *p++ = tohex ((myaddr[i] >> 4) & 0xf);
830 *p++ = tohex (myaddr[i] & 0xf);
831 }
832 *p = '\0';
833
d538b510
RP
834 putpkt (buf);
835 getpkt (buf, 0);
836
837 if (buf[0] == 'E')
838 {
839 /* There is no correspondance between what the remote protocol uses
840 for errors and errno codes. We would like a cleaner way of
841 representing errors (big enough to include errno codes, bfd_error
842 codes, and others). But for now just return EIO. */
843 errno = EIO;
844 return 0;
845 }
846 return len;
bd5635a1
RP
847}
848
849/* Read memory data directly from the remote machine.
850 This does not use the data cache; the data cache uses this.
851 MEMADDR is the address in the remote memory space.
852 MYADDR is the address of the buffer in our space.
d538b510 853 LEN is the number of bytes.
bd5635a1 854
d538b510
RP
855 Returns number of bytes transferred, or 0 for error. */
856
857static int
bd5635a1
RP
858remote_read_bytes (memaddr, myaddr, len)
859 CORE_ADDR memaddr;
d538b510 860 unsigned char *myaddr;
bd5635a1
RP
861 int len;
862{
863 char buf[PBUFSIZ];
864 int i;
865 char *p;
866
867 if (len > PBUFSIZ / 2 - 1)
868 abort ();
869
4aa6fe10
JK
870 /* FIXME-32x64: Need a version of print_address_numeric which doesn't
871 set use_local (and also puts the result in a buffer like sprintf). */
872 sprintf (buf, "m%lx,%x", (unsigned long) memaddr, len);
d538b510
RP
873 putpkt (buf);
874 getpkt (buf, 0);
875
876 if (buf[0] == 'E')
877 {
878 /* There is no correspondance between what the remote protocol uses
879 for errors and errno codes. We would like a cleaner way of
880 representing errors (big enough to include errno codes, bfd_error
881 codes, and others). But for now just return EIO. */
882 errno = EIO;
883 return 0;
884 }
bd5635a1 885
b543979c 886 /* Reply describes memory byte by byte,
bd5635a1
RP
887 each byte encoded as two hex characters. */
888
889 p = buf;
890 for (i = 0; i < len; i++)
891 {
892 if (p[0] == 0 || p[1] == 0)
d538b510
RP
893 /* Reply is short. This means that we were able to read only part
894 of what we wanted to. */
895 break;
bd5635a1
RP
896 myaddr[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
897 p += 2;
898 }
d538b510 899 return i;
bd5635a1
RP
900}
901\f
902/* Read or write LEN bytes from inferior memory at MEMADDR, transferring
e1ce8aa5 903 to or from debugger address MYADDR. Write to inferior if SHOULD_WRITE is
bd5635a1
RP
904 nonzero. Returns length of data written or read; 0 for error. */
905
b543979c
JG
906/* ARGSUSED */
907static int
908remote_xfer_memory(memaddr, myaddr, len, should_write, target)
bd5635a1
RP
909 CORE_ADDR memaddr;
910 char *myaddr;
911 int len;
e1ce8aa5 912 int should_write;
b543979c 913 struct target_ops *target; /* ignored */
bd5635a1 914{
bd5635a1 915 int xfersize;
d538b510
RP
916 int bytes_xferred;
917 int total_xferred = 0;
918
bd5635a1
RP
919 while (len > 0)
920 {
921 if (len > MAXBUFBYTES)
922 xfersize = MAXBUFBYTES;
923 else
924 xfersize = len;
925
e1ce8aa5 926 if (should_write)
94d4b713
JK
927 bytes_xferred = remote_write_bytes (memaddr,
928 (unsigned char *)myaddr, xfersize);
bd5635a1 929 else
94d4b713
JK
930 bytes_xferred = remote_read_bytes (memaddr,
931 (unsigned char *)myaddr, xfersize);
d538b510
RP
932
933 /* If we get an error, we are done xferring. */
934 if (bytes_xferred == 0)
935 break;
936
937 memaddr += bytes_xferred;
938 myaddr += bytes_xferred;
939 len -= bytes_xferred;
940 total_xferred += bytes_xferred;
bd5635a1 941 }
d538b510 942 return total_xferred;
bd5635a1
RP
943}
944
94d4b713
JK
945#if 0
946/* Enable after 4.12. */
947
948void
949remote_search (len, data, mask, startaddr, increment, lorange, hirange
950 addr_found, data_found)
951 int len;
952 char *data;
953 char *mask;
954 CORE_ADDR startaddr;
955 int increment;
956 CORE_ADDR lorange;
957 CORE_ADDR hirange;
958 CORE_ADDR *addr_found;
959 char *data_found;
960{
961 if (increment == -4 && len == 4)
962 {
963 long mask_long, data_long;
964 long data_found_long;
965 CORE_ADDR addr_we_found;
966 char buf[PBUFSIZ];
967 long returned_long[2];
968 char *p;
969
970 mask_long = extract_unsigned_integer (mask, len);
971 data_long = extract_unsigned_integer (data, len);
972 sprintf (buf, "t%x:%x,%x", startaddr, data_long, mask_long);
973 putpkt (buf);
974 getpkt (buf, 0);
975 if (buf[0] == '\0')
976 {
977 /* The stub doesn't support the 't' request. We might want to
978 remember this fact, but on the other hand the stub could be
979 switched on us. Maybe we should remember it only until
980 the next "target remote". */
981 generic_search (len, data, mask, startaddr, increment, lorange,
982 hirange, addr_found, data_found);
983 return;
984 }
985
986 if (buf[0] == 'E')
987 /* There is no correspondance between what the remote protocol uses
988 for errors and errno codes. We would like a cleaner way of
989 representing errors (big enough to include errno codes, bfd_error
990 codes, and others). But for now just use EIO. */
991 memory_error (EIO, startaddr);
992 p = buf;
993 addr_we_found = 0;
994 while (*p != '\0' && *p != ',')
995 addr_we_found = (addr_we_found << 4) + fromhex (*p++);
996 if (*p == '\0')
997 error ("Protocol error: short return for search");
998
999 data_found_long = 0;
1000 while (*p != '\0' && *p != ',')
1001 data_found_long = (data_found_long << 4) + fromhex (*p++);
1002 /* Ignore anything after this comma, for future extensions. */
1003
1004 if (addr_we_found < lorange || addr_we_found >= hirange)
1005 {
1006 *addr_found = 0;
1007 return;
1008 }
1009
1010 *addr_found = addr_we_found;
1011 *data_found = store_unsigned_integer (data_we_found, len);
1012 return;
1013 }
1014 generic_search (len, data, mask, startaddr, increment, lorange,
1015 hirange, addr_found, data_found);
1016}
1017#endif /* 0 */
1018\f
b543979c 1019static void
8f86a4e4 1020remote_files_info (ignore)
5af4f5f6 1021 struct target_ops *ignore;
bd5635a1 1022{
7c622b41 1023 puts_filtered ("Debugging a target over a serial line.\n");
bd5635a1
RP
1024}
1025\f
e50ebec8
JK
1026/* Stuff for dealing with the packets which are part of this protocol.
1027 See comment at top of file for details. */
bd5635a1 1028
ebdb9ade 1029/* Read a single character from the remote end, masking it down to 7 bits. */
b543979c 1030
bd5635a1
RP
1031static int
1032readchar ()
1033{
ebdb9ade 1034 int ch;
bd5635a1 1035
ebdb9ade 1036 ch = SERIAL_READCHAR (remote_desc, timeout);
fce7f2d9 1037
ebdb9ade
JK
1038 if (ch < 0)
1039 return ch;
bd5635a1 1040
ebdb9ade 1041 return ch & 0x7f;
bd5635a1
RP
1042}
1043
1044/* Send the command in BUF to the remote machine,
1045 and read the reply into BUF.
1046 Report an error if we get an error reply. */
1047
1048static void
1049remote_send (buf)
1050 char *buf;
1051{
1052
1053 putpkt (buf);
7c622b41 1054 getpkt (buf, 0);
bd5635a1
RP
1055
1056 if (buf[0] == 'E')
1057 error ("Remote failure reply: %s", buf);
1058}
1059
1060/* Send a packet to the remote machine, with error checking.
1061 The data of the packet is in BUF. */
1062
1063static void
1064putpkt (buf)
1065 char *buf;
1066{
1067 int i;
1068 unsigned char csum = 0;
b543979c 1069 char buf2[PBUFSIZ];
bd5635a1 1070 int cnt = strlen (buf);
ebdb9ade 1071 int ch;
bd5635a1
RP
1072 char *p;
1073
1074 /* Copy the packet into buffer BUF2, encapsulating it
1075 and giving it a checksum. */
1076
b543979c
JG
1077 if (cnt > sizeof(buf2) - 5) /* Prosanity check */
1078 abort();
1079
bd5635a1
RP
1080 p = buf2;
1081 *p++ = '$';
1082
1083 for (i = 0; i < cnt; i++)
1084 {
1085 csum += buf[i];
1086 *p++ = buf[i];
1087 }
1088 *p++ = '#';
1089 *p++ = tohex ((csum >> 4) & 0xf);
1090 *p++ = tohex (csum & 0xf);
1091
1092 /* Send it over and over until we get a positive ack. */
1093
6b27ebe8
JK
1094 while (1)
1095 {
d0d8484a 1096 if (remote_debug)
6b27ebe8
JK
1097 {
1098 *p = '\0';
199b2450 1099 printf_unfiltered ("Sending packet: %s...", buf2); gdb_flush(gdb_stdout);
6b27ebe8
JK
1100 }
1101 if (SERIAL_WRITE (remote_desc, buf2, p - buf2))
1102 perror_with_name ("putpkt: write failed");
1103
1104 /* read until either a timeout occurs (-2) or '+' is read */
1105 while (1)
1106 {
1107 ch = readchar ();
1108
1109 switch (ch)
1110 {
1111 case '+':
d0d8484a 1112 if (remote_debug)
199b2450 1113 printf_unfiltered("Ack\n");
6b27ebe8
JK
1114 return;
1115 case SERIAL_TIMEOUT:
1116 break; /* Retransmit buffer */
1117 case SERIAL_ERROR:
1118 perror_with_name ("putpkt: couldn't read ACK");
1119 case SERIAL_EOF:
1120 error ("putpkt: EOF while trying to read ACK");
1121 default:
d0d8484a 1122 if (remote_debug)
199b2450 1123 printf_unfiltered ("%02X %c ", ch&0xFF, ch);
6b27ebe8
JK
1124 continue;
1125 }
1126 break; /* Here to retransmit */
1127 }
981a3309 1128
94d4b713
JK
1129#if 0
1130 /* This is wrong. If doing a long backtrace, the user should be
1131 able to get out next time we call QUIT, without anything as violent
1132 as interrupt_query. If we want to provide a way out of here
1133 without getting to the next QUIT, it should be based on hitting
1134 ^C twice as in remote_wait. */
981a3309
SG
1135 if (quit_flag)
1136 {
1137 quit_flag = 0;
1138 interrupt_query ();
1139 }
94d4b713 1140#endif
6b27ebe8 1141 }
bd5635a1
RP
1142}
1143
1144/* Read a packet from the remote machine, with error checking,
7c622b41
JG
1145 and store it in BUF. BUF is expected to be of size PBUFSIZ.
1146 If FOREVER, wait forever rather than timing out; this is used
1147 while the target is executing user code. */
bd5635a1
RP
1148
1149static void
94d4b713
JK
1150getpkt (retbuf, forever)
1151 char *retbuf;
ebdb9ade 1152 int forever;
bd5635a1
RP
1153{
1154 char *bp;
1155 unsigned char csum;
7c622b41 1156 int c = 0;
bd5635a1 1157 unsigned char c1, c2;
38094c60 1158 int retries = 0;
94d4b713
JK
1159 char buf[PBUFSIZ];
1160
38094c60 1161#define MAX_RETRIES 10
bd5635a1 1162
bd5635a1
RP
1163 while (1)
1164 {
94d4b713
JK
1165#if 0
1166 /* This is wrong. If doing a long backtrace, the user should be
1167 able to get out time next we call QUIT, without anything as violent
1168 as interrupt_query. If we want to provide a way out of here
1169 without getting to the next QUIT, it should be based on hitting
1170 ^C twice as in remote_wait. */
981a3309
SG
1171 if (quit_flag)
1172 {
1173 quit_flag = 0;
1174 interrupt_query ();
1175 }
94d4b713 1176#endif
981a3309 1177
7c622b41
JG
1178 /* This can loop forever if the remote side sends us characters
1179 continuously, but if it pauses, we'll get a zero from readchar
1180 because of timeout. Then we'll count that as a retry. */
6b27ebe8
JK
1181
1182 c = readchar();
1183 if (c > 0 && c != '$')
1184 continue;
1185
1186 if (c == SERIAL_TIMEOUT)
1187 {
1188 if (forever)
1189 continue;
0c993550
JK
1190 if (remote_debug)
1191 puts_filtered ("Timed out.\n");
1192 goto whole;
6b27ebe8
JK
1193 }
1194
1195 if (c == SERIAL_EOF)
1196 error ("Remote connection closed");
1197 if (c == SERIAL_ERROR)
1198 perror_with_name ("Remote communication error");
7c622b41 1199
bd5635a1
RP
1200 /* Force csum to be zero here because of possible error retry. */
1201 csum = 0;
bd5635a1 1202 bp = buf;
7c622b41 1203
bd5635a1
RP
1204 while (1)
1205 {
1206 c = readchar ();
ebdb9ade 1207 if (c == SERIAL_TIMEOUT)
7c622b41 1208 {
d0d8484a 1209 if (remote_debug)
7c622b41
JG
1210 puts_filtered ("Timeout in mid-packet, retrying\n");
1211 goto whole; /* Start a new packet, count retries */
1212 }
1213 if (c == '$')
1214 {
d0d8484a 1215 if (remote_debug)
7c622b41
JG
1216 puts_filtered ("Saw new packet start in middle of old one\n");
1217 goto whole; /* Start a new packet, count retries */
1218 }
bd5635a1
RP
1219 if (c == '#')
1220 break;
8f86a4e4
JG
1221 if (bp >= buf+PBUFSIZ-1)
1222 {
1223 *bp = '\0';
7c622b41
JG
1224 puts_filtered ("Remote packet too long: ");
1225 puts_filtered (buf);
1226 puts_filtered ("\n");
8f86a4e4
JG
1227 goto whole;
1228 }
bd5635a1
RP
1229 *bp++ = c;
1230 csum += c;
1231 }
1232 *bp = 0;
1233
1234 c1 = fromhex (readchar ());
1235 c2 = fromhex (readchar ());
1236 if ((csum & 0xff) == (c1 << 4) + c2)
1237 break;
7c622b41
JG
1238 printf_filtered ("Bad checksum, sentsum=0x%x, csum=0x%x, buf=",
1239 (c1 << 4) + c2, csum & 0xff);
1240 puts_filtered (buf);
1241 puts_filtered ("\n");
38094c60 1242
8f86a4e4
JG
1243 /* Try the whole thing again. */
1244whole:
38094c60
JG
1245 if (++retries < MAX_RETRIES)
1246 {
ebdb9ade 1247 SERIAL_WRITE (remote_desc, "-", 1);
38094c60
JG
1248 }
1249 else
1250 {
199b2450 1251 printf_unfiltered ("Ignoring packet error, continuing...\n");
38094c60
JG
1252 break;
1253 }
bd5635a1
RP
1254 }
1255
94d4b713
JK
1256 /* Deal with run-length encoding. */
1257 {
1258 char *src = buf;
1259 char *dest = retbuf;
1260 int i;
1261 int repeat;
1262 do {
1263 if (*src == '*')
1264 {
1265 if (src[1] == '\0' || src[2] == '\0')
1266 {
1267 if (remote_debug)
1268 puts_filtered ("Packet too short, retrying\n");
1269 goto whole;
1270 }
1271 repeat = (fromhex (src[1]) << 4) + fromhex (src[2]);
1272 for (i = 0; i < repeat; ++i)
1273 {
1274 *dest++ = src[-1];
1275 }
1276 src += 2;
1277 }
1278 else
1279 {
1280 *dest++ = *src;
1281 }
1282 } while (*src++ != '\0');
1283 }
7c622b41 1284
94d4b713 1285out:
ebdb9ade 1286 SERIAL_WRITE (remote_desc, "+", 1);
bd5635a1 1287
d0d8484a 1288 if (remote_debug)
199b2450 1289 fprintf_unfiltered (gdb_stderr,"Packet received: %s\n", buf);
bd5635a1
RP
1290}
1291\f
ebdb9ade
JK
1292static void
1293remote_kill ()
1294{
1295 putpkt ("k");
1296 /* Don't wait for it to die. I'm not really sure it matters whether
1297 we do or not. For the existing stubs, kill is a noop. */
1298 target_mourn_inferior ();
1299}
bd5635a1 1300
ebdb9ade
JK
1301static void
1302remote_mourn ()
1303{
1304 unpush_target (&remote_ops);
1305 generic_mourn_inferior ();
1306}
1307\f
5af4f5f6
JK
1308#ifdef REMOTE_BREAKPOINT
1309
1310/* On some machines, e.g. 68k, we may use a different breakpoint instruction
1311 than other targets. */
1312static unsigned char break_insn[] = REMOTE_BREAKPOINT;
1313
1314/* Check that it fits in BREAKPOINT_MAX bytes. */
1315static unsigned char check_break_insn_size[BREAKPOINT_MAX] = REMOTE_BREAKPOINT;
1316
1317#else /* No REMOTE_BREAKPOINT. */
1318
1319/* Same old breakpoint instruction. This code does nothing different
1320 than mem-break.c. */
1321static unsigned char break_insn[] = BREAKPOINT;
1322
1323#endif /* No REMOTE_BREAKPOINT. */
1324
1325/* Insert a breakpoint on targets that don't have any better breakpoint
1326 support. We read the contents of the target location and stash it,
1327 then overwrite it with a breakpoint instruction. ADDR is the target
1328 location in the target machine. CONTENTS_CACHE is a pointer to
1329 memory allocated for saving the target contents. It is guaranteed
1330 by the caller to be long enough to save sizeof BREAKPOINT bytes (this
1331 is accomplished via BREAKPOINT_MAX). */
1332
d538b510 1333static int
5af4f5f6
JK
1334remote_insert_breakpoint (addr, contents_cache)
1335 CORE_ADDR addr;
1336 char *contents_cache;
1337{
1338 int val;
1339
1340 val = target_read_memory (addr, contents_cache, sizeof break_insn);
1341
1342 if (val == 0)
1343 val = target_write_memory (addr, (char *)break_insn, sizeof break_insn);
1344
1345 return val;
1346}
1347
d538b510 1348static int
5af4f5f6
JK
1349remote_remove_breakpoint (addr, contents_cache)
1350 CORE_ADDR addr;
1351 char *contents_cache;
1352{
1353 return target_write_memory (addr, contents_cache, sizeof break_insn);
1354}
1355\f
bd5635a1
RP
1356/* Define the target subroutine names */
1357
1358struct target_ops remote_ops = {
b543979c
JG
1359 "remote", /* to_shortname */
1360 "Remote serial target in gdb-specific protocol", /* to_longname */
1361 "Use a remote computer via a serial line, using a gdb-specific protocol.\n\
1362Specify the serial device it is connected to (e.g. /dev/ttya).", /* to_doc */
1363 remote_open, /* to_open */
1364 remote_close, /* to_close */
1365 NULL, /* to_attach */
1366 remote_detach, /* to_detach */
1367 remote_resume, /* to_resume */
1368 remote_wait, /* to_wait */
1369 remote_fetch_registers, /* to_fetch_registers */
1370 remote_store_registers, /* to_store_registers */
1371 remote_prepare_to_store, /* to_prepare_to_store */
b543979c
JG
1372 remote_xfer_memory, /* to_xfer_memory */
1373 remote_files_info, /* to_files_info */
5af4f5f6
JK
1374
1375 remote_insert_breakpoint, /* to_insert_breakpoint */
1376 remote_remove_breakpoint, /* to_remove_breakpoint */
1377
b543979c
JG
1378 NULL, /* to_terminal_init */
1379 NULL, /* to_terminal_inferior */
1380 NULL, /* to_terminal_ours_for_output */
1381 NULL, /* to_terminal_ours */
1382 NULL, /* to_terminal_info */
ebdb9ade 1383 remote_kill, /* to_kill */
6b27ebe8 1384 generic_load, /* to_load */
b543979c
JG
1385 NULL, /* to_lookup_symbol */
1386 NULL, /* to_create_inferior */
ebdb9ade 1387 remote_mourn, /* to_mourn_inferior */
34517ebc 1388 0, /* to_can_run */
7c622b41 1389 0, /* to_notice_signals */
b543979c
JG
1390 process_stratum, /* to_stratum */
1391 NULL, /* to_next */
1392 1, /* to_has_all_memory */
1393 1, /* to_has_memory */
1394 1, /* to_has_stack */
1395 1, /* to_has_registers */
1396 1, /* to_has_execution */
1397 NULL, /* sections */
1398 NULL, /* sections_end */
1399 OPS_MAGIC /* to_magic */
bd5635a1 1400};
976bb0be 1401#endif /* Use remote. */
bd5635a1
RP
1402
1403void
1404_initialize_remote ()
1405{
976bb0be 1406#if !defined(DONT_USE_REMOTE)
bd5635a1 1407 add_target (&remote_ops);
8f86a4e4 1408#endif
976bb0be 1409}
This page took 0.242141 seconds and 4 git commands to generate.