1 /* Main code for remote server for GDB.
2 Copyright (C) 1989, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2002, 2003,
3 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
34 unsigned long cont_thread
;
35 unsigned long general_thread
;
36 unsigned long step_thread
;
37 unsigned long thread_from_wait
;
38 unsigned long old_thread_from_wait
;
39 int extended_protocol
;
42 /* Enable miscellaneous debugging output. The name is historical - it
43 was originally used to debug LinuxThreads support. */
46 int pass_signals
[TARGET_SIGNAL_LAST
];
50 /* The PID of the originally created or attached inferior. Used to
51 send signals to the process when GDB sends us an asynchronous interrupt
52 (user hitting Control-C in the client), and to wait for the child to exit
53 when no longer debugging it. */
55 unsigned long signal_pid
;
58 /* A file descriptor for the controlling terminal. */
61 /* TERMINAL_FD's original foreground group. */
62 pid_t old_foreground_pgrp
;
64 /* Hand back terminal ownership to the original foreground group. */
67 restore_old_foreground_pgrp (void)
69 tcsetpgrp (terminal_fd
, old_foreground_pgrp
);
74 start_inferior (char *argv
[], char *statusptr
)
77 signal (SIGTTOU
, SIG_DFL
);
78 signal (SIGTTIN
, SIG_DFL
);
81 signal_pid
= create_inferior (argv
[0], argv
);
83 /* FIXME: we don't actually know at this point that the create
84 actually succeeded. We won't know that until we wait. */
85 fprintf (stderr
, "Process %s created; pid = %ld\n", argv
[0],
90 signal (SIGTTOU
, SIG_IGN
);
91 signal (SIGTTIN
, SIG_IGN
);
92 terminal_fd
= fileno (stderr
);
93 old_foreground_pgrp
= tcgetpgrp (terminal_fd
);
94 tcsetpgrp (terminal_fd
, signal_pid
);
95 atexit (restore_old_foreground_pgrp
);
98 /* Wait till we are at 1st instruction in program, return signal
99 number (assuming success). */
100 return mywait (statusptr
, 0);
104 attach_inferior (int pid
, char *statusptr
, int *sigptr
)
106 /* myattach should return -1 if attaching is unsupported,
107 0 if it succeeded, and call error() otherwise. */
109 if (myattach (pid
) != 0)
112 fprintf (stderr
, "Attached; pid = %d\n", pid
);
115 /* FIXME - It may be that we should get the SIGNAL_PID from the
116 attach function, so that it can be the main thread instead of
117 whichever we were told to attach to. */
120 *sigptr
= mywait (statusptr
, 0);
122 /* GDB knows to ignore the first SIGSTOP after attaching to a running
123 process using the "attach" command, but this is different; it's
124 just using "target remote". Pretend it's just starting up. */
125 if (*statusptr
== 'T' && *sigptr
== TARGET_SIGNAL_STOP
)
126 *sigptr
= TARGET_SIGNAL_TRAP
;
131 extern int remote_debug
;
133 /* Decode a qXfer read request. Return 0 if everything looks OK,
137 decode_xfer_read (char *buf
, char **annex
, CORE_ADDR
*ofs
, unsigned int *len
)
139 /* Extract and NUL-terminate the annex. */
141 while (*buf
&& *buf
!= ':')
147 /* After the read marker and annex, qXfer looks like a
148 traditional 'm' packet. */
149 decode_m_packet (buf
, ofs
, len
);
154 /* Write the response to a successful qXfer read. Returns the
155 length of the (binary) data stored in BUF, corresponding
156 to as much of DATA/LEN as we could fit. IS_MORE controls
157 the first character of the response. */
159 write_qxfer_response (char *buf
, const void *data
, int len
, int is_more
)
168 return remote_escape_output (data
, len
, (unsigned char *) buf
+ 1, &out_len
,
172 /* Handle all of the extended 'Q' packets. */
174 handle_general_set (char *own_buf
)
176 if (strncmp ("QPassSignals:", own_buf
, strlen ("QPassSignals:")) == 0)
178 int numsigs
= (int) TARGET_SIGNAL_LAST
, i
;
179 const char *p
= own_buf
+ strlen ("QPassSignals:");
182 p
= decode_address_to_semicolon (&cursig
, p
);
183 for (i
= 0; i
< numsigs
; i
++)
189 /* Keep looping, to clear the remaining signals. */
192 p
= decode_address_to_semicolon (&cursig
, p
);
197 strcpy (own_buf
, "OK");
201 /* Otherwise we didn't know what packet it was. Say we didn't
207 get_features_xml (const char *annex
)
209 static int features_supported
= -1;
210 static char *document
;
213 extern const char *const xml_builtin
[][2];
216 /* Look for the annex. */
217 for (i
= 0; xml_builtin
[i
][0] != NULL
; i
++)
218 if (strcmp (annex
, xml_builtin
[i
][0]) == 0)
221 if (xml_builtin
[i
][0] != NULL
)
222 return xml_builtin
[i
][1];
225 if (strcmp (annex
, "target.xml") != 0)
228 if (features_supported
== -1)
230 const char *arch
= NULL
;
231 if (the_target
->arch_string
!= NULL
)
232 arch
= (*the_target
->arch_string
) ();
235 features_supported
= 0;
238 features_supported
= 1;
239 document
= malloc (64 + strlen (arch
));
240 snprintf (document
, 64 + strlen (arch
),
241 "<target><architecture>%s</architecture></target>",
250 monitor_show_help (void)
252 monitor_output ("The following monitor commands are supported:\n");
253 monitor_output (" set debug <0|1>\n");
254 monitor_output (" Enable general debugging messages\n");
255 monitor_output (" set remote-debug <0|1>\n");
256 monitor_output (" Enable remote protocol debugging messages\n");
259 /* Handle all of the extended 'q' packets. */
261 handle_query (char *own_buf
, int packet_len
, int *new_packet_len_p
)
263 static struct inferior_list_entry
*thread_ptr
;
265 /* Reply the current thread id. */
266 if (strcmp ("qC", own_buf
) == 0)
268 thread_ptr
= all_threads
.head
;
269 sprintf (own_buf
, "QC%x",
270 thread_to_gdb_id ((struct thread_info
*)thread_ptr
));
274 if (strcmp ("qSymbol::", own_buf
) == 0)
276 if (the_target
->look_up_symbols
!= NULL
)
277 (*the_target
->look_up_symbols
) ();
279 strcpy (own_buf
, "OK");
283 if (strcmp ("qfThreadInfo", own_buf
) == 0)
285 thread_ptr
= all_threads
.head
;
286 sprintf (own_buf
, "m%x", thread_to_gdb_id ((struct thread_info
*)thread_ptr
));
287 thread_ptr
= thread_ptr
->next
;
291 if (strcmp ("qsThreadInfo", own_buf
) == 0)
293 if (thread_ptr
!= NULL
)
295 sprintf (own_buf
, "m%x", thread_to_gdb_id ((struct thread_info
*)thread_ptr
));
296 thread_ptr
= thread_ptr
->next
;
301 sprintf (own_buf
, "l");
306 if (the_target
->read_offsets
!= NULL
307 && strcmp ("qOffsets", own_buf
) == 0)
309 CORE_ADDR text
, data
;
311 if (the_target
->read_offsets (&text
, &data
))
312 sprintf (own_buf
, "Text=%lX;Data=%lX;Bss=%lX",
313 (long)text
, (long)data
, (long)data
);
320 if (the_target
->qxfer_spu
!= NULL
321 && strncmp ("qXfer:spu:read:", own_buf
, 15) == 0)
327 unsigned char *spu_buf
;
329 strcpy (own_buf
, "E00");
330 if (decode_xfer_read (own_buf
+ 15, &annex
, &ofs
, &len
) < 0)
332 if (len
> PBUFSIZ
- 2)
334 spu_buf
= malloc (len
+ 1);
338 n
= (*the_target
->qxfer_spu
) (annex
, spu_buf
, NULL
, ofs
, len
+ 1);
342 *new_packet_len_p
= write_qxfer_response
343 (own_buf
, spu_buf
, len
, 1);
345 *new_packet_len_p
= write_qxfer_response
346 (own_buf
, spu_buf
, n
, 0);
352 if (the_target
->qxfer_spu
!= NULL
353 && strncmp ("qXfer:spu:write:", own_buf
, 16) == 0)
359 unsigned char *spu_buf
;
361 strcpy (own_buf
, "E00");
362 spu_buf
= malloc (packet_len
- 15);
365 if (decode_xfer_write (own_buf
+ 16, packet_len
- 16, &annex
,
366 &ofs
, &len
, spu_buf
) < 0)
372 n
= (*the_target
->qxfer_spu
)
373 (annex
, NULL
, (unsigned const char *)spu_buf
, ofs
, len
);
377 sprintf (own_buf
, "%x", n
);
383 if (the_target
->read_auxv
!= NULL
384 && strncmp ("qXfer:auxv:read:", own_buf
, 16) == 0)
392 /* Reject any annex; grab the offset and length. */
393 if (decode_xfer_read (own_buf
+ 16, &annex
, &ofs
, &len
) < 0
396 strcpy (own_buf
, "E00");
400 /* Read one extra byte, as an indicator of whether there is
402 if (len
> PBUFSIZ
- 2)
404 data
= malloc (len
+ 1);
405 n
= (*the_target
->read_auxv
) (ofs
, data
, len
+ 1);
409 *new_packet_len_p
= write_qxfer_response (own_buf
, data
, len
, 1);
411 *new_packet_len_p
= write_qxfer_response (own_buf
, data
, n
, 0);
418 if (strncmp ("qXfer:features:read:", own_buf
, 20) == 0)
421 unsigned int len
, total_len
;
422 const char *document
;
425 /* Check for support. */
426 document
= get_features_xml ("target.xml");
427 if (document
== NULL
)
433 /* Grab the annex, offset, and length. */
434 if (decode_xfer_read (own_buf
+ 20, &annex
, &ofs
, &len
) < 0)
436 strcpy (own_buf
, "E00");
440 /* Now grab the correct annex. */
441 document
= get_features_xml (annex
);
442 if (document
== NULL
)
444 strcpy (own_buf
, "E00");
448 total_len
= strlen (document
);
449 if (len
> PBUFSIZ
- 2)
454 else if (len
< total_len
- ofs
)
455 *new_packet_len_p
= write_qxfer_response (own_buf
, document
+ ofs
,
458 *new_packet_len_p
= write_qxfer_response (own_buf
, document
+ ofs
,
464 if (strncmp ("qXfer:libraries:read:", own_buf
, 21) == 0)
467 unsigned int len
, total_len
;
469 struct inferior_list_entry
*dll_ptr
;
472 /* Reject any annex; grab the offset and length. */
473 if (decode_xfer_read (own_buf
+ 21, &annex
, &ofs
, &len
) < 0
476 strcpy (own_buf
, "E00");
480 /* Over-estimate the necessary memory. Assume that every character
481 in the library name must be escaped. */
483 for (dll_ptr
= all_dlls
.head
; dll_ptr
!= NULL
; dll_ptr
= dll_ptr
->next
)
484 total_len
+= 128 + 6 * strlen (((struct dll_info
*) dll_ptr
)->name
);
486 document
= malloc (total_len
);
487 strcpy (document
, "<library-list>\n");
488 p
= document
+ strlen (document
);
490 for (dll_ptr
= all_dlls
.head
; dll_ptr
!= NULL
; dll_ptr
= dll_ptr
->next
)
492 struct dll_info
*dll
= (struct dll_info
*) dll_ptr
;
495 strcpy (p
, " <library name=\"");
497 name
= xml_escape_text (dll
->name
);
501 strcpy (p
, "\"><segment address=\"");
503 sprintf (p
, "0x%lx", (long) dll
->base_addr
);
505 strcpy (p
, "\"/></library>\n");
509 strcpy (p
, "</library-list>\n");
511 total_len
= strlen (document
);
512 if (len
> PBUFSIZ
- 2)
517 else if (len
< total_len
- ofs
)
518 *new_packet_len_p
= write_qxfer_response (own_buf
, document
+ ofs
,
521 *new_packet_len_p
= write_qxfer_response (own_buf
, document
+ ofs
,
528 /* Protocol features query. */
529 if (strncmp ("qSupported", own_buf
, 10) == 0
530 && (own_buf
[10] == ':' || own_buf
[10] == '\0'))
532 sprintf (own_buf
, "PacketSize=%x;QPassSignals+", PBUFSIZ
- 1);
534 /* We do not have any hook to indicate whether the target backend
535 supports qXfer:libraries:read, so always report it. */
536 strcat (own_buf
, ";qXfer:libraries:read+");
538 if (the_target
->read_auxv
!= NULL
)
539 strcat (own_buf
, ";qXfer:auxv:read+");
541 if (the_target
->qxfer_spu
!= NULL
)
542 strcat (own_buf
, ";qXfer:spu:read+;qXfer:spu:write+");
544 if (get_features_xml ("target.xml") != NULL
)
545 strcat (own_buf
, ";qXfer:features:read+");
550 /* Thread-local storage support. */
551 if (the_target
->get_tls_address
!= NULL
552 && strncmp ("qGetTLSAddr:", own_buf
, 12) == 0)
554 char *p
= own_buf
+ 12;
555 CORE_ADDR parts
[3], address
= 0;
558 for (i
= 0; i
< 3; i
++)
566 p2
= strchr (p
, ',');
578 decode_address (&parts
[i
], p
, len
);
582 if (p
!= NULL
|| i
< 3)
586 struct thread_info
*thread
= gdb_id_to_thread (parts
[0]);
591 err
= the_target
->get_tls_address (thread
, parts
[1], parts
[2],
597 sprintf (own_buf
, "%llx", address
);
606 /* Otherwise, pretend we do not understand this packet. */
609 /* Handle "monitor" commands. */
610 if (strncmp ("qRcmd,", own_buf
, 6) == 0)
612 char *mon
= malloc (PBUFSIZ
);
613 int len
= strlen (own_buf
+ 6);
615 if ((len
% 1) != 0 || unhexify (mon
, own_buf
+ 6, len
/ 2) != len
/ 2)
625 if (strcmp (mon
, "set debug 1") == 0)
628 monitor_output ("Debug output enabled.\n");
630 else if (strcmp (mon
, "set debug 0") == 0)
633 monitor_output ("Debug output disabled.\n");
635 else if (strcmp (mon
, "set remote-debug 1") == 0)
638 monitor_output ("Protocol debug output enabled.\n");
640 else if (strcmp (mon
, "set remote-debug 0") == 0)
643 monitor_output ("Protocol debug output disabled.\n");
645 else if (strcmp (mon
, "help") == 0)
646 monitor_show_help ();
649 monitor_output ("Unknown monitor command.\n\n");
650 monitor_show_help ();
658 /* Otherwise we didn't know what packet it was. Say we didn't
663 /* Parse vCont packets. */
665 handle_v_cont (char *own_buf
, char *status
, int *signal
)
669 struct thread_resume
*resume_info
, default_action
;
671 /* Count the number of semicolons in the packet. There should be one
680 /* Allocate room for one extra action, for the default remain-stopped
681 behavior; if no default action is in the list, we'll need the extra
683 resume_info
= malloc ((n
+ 1) * sizeof (resume_info
[0]));
685 default_action
.thread
= -1;
686 default_action
.leave_stopped
= 1;
687 default_action
.step
= 0;
688 default_action
.sig
= 0;
696 resume_info
[i
].leave_stopped
= 0;
698 if (p
[0] == 's' || p
[0] == 'S')
699 resume_info
[i
].step
= 1;
700 else if (p
[0] == 'c' || p
[0] == 'C')
701 resume_info
[i
].step
= 0;
705 if (p
[0] == 'S' || p
[0] == 'C')
708 sig
= strtol (p
+ 1, &q
, 16);
713 if (!target_signal_to_host_p (sig
))
715 resume_info
[i
].sig
= target_signal_to_host (sig
);
719 resume_info
[i
].sig
= 0;
725 resume_info
[i
].thread
= -1;
726 default_action
= resume_info
[i
];
728 /* Note: we don't increment i here, we'll overwrite this entry
729 the next time through. */
731 else if (p
[0] == ':')
733 unsigned int gdb_id
= strtoul (p
+ 1, &q
, 16);
734 unsigned long thread_id
;
739 if (p
[0] != ';' && p
[0] != 0)
742 thread_id
= gdb_id_to_thread_id (gdb_id
);
744 resume_info
[i
].thread
= thread_id
;
752 resume_info
[i
] = default_action
;
754 /* Still used in occasional places in the backend. */
755 if (n
== 1 && resume_info
[0].thread
!= -1)
756 cont_thread
= resume_info
[0].thread
;
759 set_desired_inferior (0);
761 (*the_target
->resume
) (resume_info
);
765 *signal
= mywait (status
, 1);
766 prepare_resume_reply (own_buf
, *status
, *signal
);
775 /* Handle all of the extended 'v' packets. */
777 handle_v_requests (char *own_buf
, char *status
, int *signal
)
779 if (strncmp (own_buf
, "vCont;", 6) == 0)
781 handle_v_cont (own_buf
, status
, signal
);
785 if (strncmp (own_buf
, "vCont?", 6) == 0)
787 strcpy (own_buf
, "vCont;c;C;s;S");
791 /* Otherwise we didn't know what packet it was. Say we didn't
798 myresume (int step
, int sig
)
800 struct thread_resume resume_info
[2];
803 if (step
|| sig
|| (cont_thread
!= 0 && cont_thread
!= -1))
805 resume_info
[0].thread
806 = ((struct inferior_list_entry
*) current_inferior
)->id
;
807 resume_info
[0].step
= step
;
808 resume_info
[0].sig
= sig
;
809 resume_info
[0].leave_stopped
= 0;
812 resume_info
[n
].thread
= -1;
813 resume_info
[n
].step
= 0;
814 resume_info
[n
].sig
= 0;
815 resume_info
[n
].leave_stopped
= (cont_thread
!= 0 && cont_thread
!= -1);
817 (*the_target
->resume
) (resume_info
);
823 gdbserver_version (void)
825 printf ("GNU gdbserver %s\n"
826 "Copyright (C) 2007 Free Software Foundation, Inc.\n"
827 "gdbserver is free software, covered by the GNU General Public License.\n"
828 "This gdbserver was configured as \"%s\"\n",
833 gdbserver_usage (void)
835 printf ("Usage:\tgdbserver COMM PROG [ARGS ...]\n"
836 "\tgdbserver COMM --attach PID\n"
838 "COMM may either be a tty device (for serial debugging), or \n"
839 "HOST:PORT to listen for a TCP connection.\n");
843 main (int argc
, char *argv
[])
845 char ch
, status
, *own_buf
;
846 unsigned char *mem_buf
;
855 if (argc
>= 2 && strcmp (argv
[1], "--version") == 0)
857 gdbserver_version ();
861 if (argc
>= 2 && strcmp (argv
[1], "--help") == 0)
867 if (setjmp (toplevel
))
869 fprintf (stderr
, "Exiting\n");
876 if (argc
>= 3 && strcmp (argv
[2], "--attach") == 0)
879 && argv
[3][0] != '\0'
880 && (pid
= strtoul (argv
[3], &arg_end
, 10)) != 0
889 if (argc
< 3 || bad_attach
)
897 own_buf
= malloc (PBUFSIZ
+ 1);
898 mem_buf
= malloc (PBUFSIZ
);
902 /* Wait till we are at first instruction in program. */
903 signal
= start_inferior (&argv
[2], &status
);
905 /* We are now (hopefully) stopped at the first instruction of
906 the target process. This assumes that the target process was
907 successfully created. */
909 /* Don't report shared library events on the initial connection,
910 even if some libraries are preloaded. */
915 switch (attach_inferior (pid
, &status
, &signal
))
918 error ("Attaching not supported on this target");
926 if (setjmp (toplevel
))
928 fprintf (stderr
, "Killing inferior\n");
933 if (status
== 'W' || status
== 'X')
935 fprintf (stderr
, "No inferior, GDBserver exiting.\n");
941 remote_open (argv
[1]);
949 int new_packet_len
= -1;
951 packet_len
= getpkt (own_buf
);
960 handle_query (own_buf
, packet_len
, &new_packet_len
);
963 handle_general_set (own_buf
);
966 fprintf (stderr
, "Detaching from inferior\n");
967 if (detach_inferior () != 0)
978 /* If we are attached, then we can exit. Otherwise, we
979 need to hang around doing nothing, until the child
989 extended_protocol
= 1;
990 prepare_resume_reply (own_buf
, status
, signal
);
994 /* We can not use the extended protocol if we are
995 attached, because we can not restart the running
996 program. So return unrecognized. */
1001 prepare_resume_reply (own_buf
, status
, signal
);
1004 if (own_buf
[1] == 'c' || own_buf
[1] == 'g' || own_buf
[1] == 's')
1006 unsigned long gdb_id
, thread_id
;
1008 gdb_id
= strtoul (&own_buf
[2], NULL
, 16);
1009 thread_id
= gdb_id_to_thread_id (gdb_id
);
1012 write_enn (own_buf
);
1016 if (own_buf
[1] == 'g')
1018 general_thread
= thread_id
;
1019 set_desired_inferior (1);
1021 else if (own_buf
[1] == 'c')
1022 cont_thread
= thread_id
;
1023 else if (own_buf
[1] == 's')
1024 step_thread
= thread_id
;
1030 /* Silently ignore it so that gdb can extend the protocol
1031 without compatibility headaches. */
1036 set_desired_inferior (1);
1037 registers_to_string (own_buf
);
1040 set_desired_inferior (1);
1041 registers_from_string (&own_buf
[1]);
1045 decode_m_packet (&own_buf
[1], &mem_addr
, &len
);
1046 if (read_inferior_memory (mem_addr
, mem_buf
, len
) == 0)
1047 convert_int_to_ascii (mem_buf
, own_buf
, len
);
1049 write_enn (own_buf
);
1052 decode_M_packet (&own_buf
[1], &mem_addr
, &len
, mem_buf
);
1053 if (write_inferior_memory (mem_addr
, mem_buf
, len
) == 0)
1056 write_enn (own_buf
);
1059 if (decode_X_packet (&own_buf
[1], packet_len
- 1,
1060 &mem_addr
, &len
, mem_buf
) < 0
1061 || write_inferior_memory (mem_addr
, mem_buf
, len
) != 0)
1062 write_enn (own_buf
);
1067 convert_ascii_to_int (own_buf
+ 1, &sig
, 1);
1068 if (target_signal_to_host_p (sig
))
1069 signal
= target_signal_to_host (sig
);
1072 set_desired_inferior (0);
1073 myresume (0, signal
);
1074 signal
= mywait (&status
, 1);
1075 prepare_resume_reply (own_buf
, status
, signal
);
1078 convert_ascii_to_int (own_buf
+ 1, &sig
, 1);
1079 if (target_signal_to_host_p (sig
))
1080 signal
= target_signal_to_host (sig
);
1083 set_desired_inferior (0);
1084 myresume (1, signal
);
1085 signal
= mywait (&status
, 1);
1086 prepare_resume_reply (own_buf
, status
, signal
);
1089 set_desired_inferior (0);
1091 signal
= mywait (&status
, 1);
1092 prepare_resume_reply (own_buf
, status
, signal
);
1095 set_desired_inferior (0);
1097 signal
= mywait (&status
, 1);
1098 prepare_resume_reply (own_buf
, status
, signal
);
1104 CORE_ADDR addr
= strtoul (&own_buf
[3], &lenptr
, 16);
1105 int len
= strtol (lenptr
+ 1, &dataptr
, 16);
1106 char type
= own_buf
[1];
1108 if (the_target
->insert_watchpoint
== NULL
1109 || (type
< '2' || type
> '4'))
1111 /* No watchpoint support or not a watchpoint command;
1112 unrecognized either way. */
1119 res
= (*the_target
->insert_watchpoint
) (type
, addr
, len
);
1126 write_enn (own_buf
);
1134 CORE_ADDR addr
= strtoul (&own_buf
[3], &lenptr
, 16);
1135 int len
= strtol (lenptr
+ 1, &dataptr
, 16);
1136 char type
= own_buf
[1];
1138 if (the_target
->remove_watchpoint
== NULL
1139 || (type
< '2' || type
> '4'))
1141 /* No watchpoint support or not a watchpoint command;
1142 unrecognized either way. */
1149 res
= (*the_target
->remove_watchpoint
) (type
, addr
, len
);
1156 write_enn (own_buf
);
1161 fprintf (stderr
, "Killing inferior\n");
1163 /* When using the extended protocol, we start up a new
1164 debugging session. The traditional protocol will
1166 if (extended_protocol
)
1169 fprintf (stderr
, "GDBserver restarting\n");
1171 /* Wait till we are at 1st instruction in prog. */
1172 signal
= start_inferior (&argv
[2], &status
);
1183 unsigned long gdb_id
, thread_id
;
1185 gdb_id
= strtoul (&own_buf
[1], NULL
, 16);
1186 thread_id
= gdb_id_to_thread_id (gdb_id
);
1189 write_enn (own_buf
);
1193 if (mythread_alive (thread_id
))
1196 write_enn (own_buf
);
1200 /* Restarting the inferior is only supported in the
1201 extended protocol. */
1202 if (extended_protocol
)
1206 fprintf (stderr
, "GDBserver restarting\n");
1208 /* Wait till we are at 1st instruction in prog. */
1209 signal
= start_inferior (&argv
[2], &status
);
1215 /* It is a request we don't understand. Respond with an
1216 empty packet so that gdb knows that we don't support this
1222 /* Extended (long) request. */
1223 handle_v_requests (own_buf
, &status
, &signal
);
1226 /* It is a request we don't understand. Respond with an
1227 empty packet so that gdb knows that we don't support this
1233 if (new_packet_len
!= -1)
1234 putpkt_binary (own_buf
, new_packet_len
);
1240 "\nChild exited with status %d\n", signal
);
1242 fprintf (stderr
, "\nChild terminated with signal = 0x%x (%s)\n",
1243 target_signal_to_host (signal
),
1244 target_signal_to_name (signal
));
1245 if (status
== 'W' || status
== 'X')
1247 if (extended_protocol
)
1249 fprintf (stderr
, "Killing inferior\n");
1252 fprintf (stderr
, "GDBserver restarting\n");
1254 /* Wait till we are at 1st instruction in prog. */
1255 signal
= start_inferior (&argv
[2], &status
);
1261 fprintf (stderr
, "GDBserver exiting\n");
1267 /* We come here when getpkt fails.
1269 For the extended remote protocol we exit (and this is the only
1270 way we gracefully exit!).
1272 For the traditional remote protocol close the connection,
1273 and re-open it at the top of the loop. */
1274 if (extended_protocol
)
1281 fprintf (stderr
, "Remote side has terminated connection. "
1282 "GDBserver will reopen the connection.\n");