1 /* Select target systems and architectures at runtime for GDB.
2 Copyright 1990, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 #include "gdb_string.h"
38 target_info PARAMS ((char *, int));
41 cleanup_target PARAMS ((struct target_ops *));
44 maybe_kill_then_create_inferior PARAMS ((char *, char *, char **));
47 default_clone_and_follow_inferior PARAMS ((int, int *));
50 maybe_kill_then_attach PARAMS ((char *, int));
53 kill_or_be_killed PARAMS ((int));
56 default_terminal_info PARAMS ((char *, int));
59 nosymbol PARAMS ((char *, CORE_ADDR *));
62 tcomplain PARAMS ((void));
65 nomemory PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
68 return_zero PARAMS ((void));
71 return_one PARAMS ((void));
74 target_ignore PARAMS ((void));
77 target_command PARAMS ((char *, int));
79 static struct target_ops *
80 find_default_run_target PARAMS ((char *));
83 update_current_target PARAMS ((void));
85 /* Transfer LEN bytes between target address MEMADDR and GDB address MYADDR.
86 Returns 0 for success, errno code for failure (which includes partial
87 transfers--if you want a more useful response to partial transfers, try
88 target_read_memory_partial). */
91 target_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len,
92 int write, asection *bfd_section));
95 debug_to_open PARAMS ((char *, int));
98 debug_to_close PARAMS ((int));
101 debug_to_attach PARAMS ((char *, int));
104 debug_to_detach PARAMS ((char *, int));
107 debug_to_resume PARAMS ((int, int, enum target_signal));
110 debug_to_wait PARAMS ((int, struct target_waitstatus *));
113 debug_to_fetch_registers PARAMS ((int));
116 debug_to_store_registers PARAMS ((int));
119 debug_to_prepare_to_store PARAMS ((void));
122 debug_to_xfer_memory PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
125 debug_to_files_info PARAMS ((struct target_ops *));
128 debug_to_insert_breakpoint PARAMS ((CORE_ADDR, char *));
131 debug_to_remove_breakpoint PARAMS ((CORE_ADDR, char *));
134 debug_to_terminal_init PARAMS ((void));
137 debug_to_terminal_inferior PARAMS ((void));
140 debug_to_terminal_ours_for_output PARAMS ((void));
143 debug_to_terminal_ours PARAMS ((void));
146 debug_to_terminal_info PARAMS ((char *, int));
149 debug_to_kill PARAMS ((void));
152 debug_to_load PARAMS ((char *, int));
155 debug_to_lookup_symbol PARAMS ((char *, CORE_ADDR *));
158 debug_to_create_inferior PARAMS ((char *, char *, char **));
161 debug_to_mourn_inferior PARAMS ((void));
164 debug_to_can_run PARAMS ((void));
167 debug_to_notice_signals PARAMS ((int));
170 debug_to_thread_alive PARAMS ((int));
173 debug_to_stop PARAMS ((void));
175 /* Pointer to array of target architecture structures; the size of the
176 array; the current index into the array; the allocated size of the
178 struct target_ops **target_structs;
179 unsigned target_struct_size;
180 unsigned target_struct_index;
181 unsigned target_struct_allocsize;
182 #define DEFAULT_ALLOCSIZE 10
184 /* The initial current target, so that there is always a semi-valid
187 struct target_ops dummy_target = {
188 "None", /* to_shortname */
189 "None", /* to_longname */
193 find_default_attach, /* to_attach */
194 NULL, /* to_post_attach */
195 find_default_require_attach, /* to_require_attach */
197 find_default_require_detach, /* to_require_detach */
200 NULL, /* to_post_wait */
201 0, /* to_fetch_registers */
202 0, /* to_store_registers */
203 0, /* to_prepare_to_store */
204 0, /* to_xfer_memory */
205 0, /* to_files_info */
206 0, /* to_insert_breakpoint */
207 0, /* to_remove_breakpoint */
208 0, /* to_terminal_init */
209 0, /* to_terminal_inferior */
210 0, /* to_terminal_ours_for_output */
211 0, /* to_terminal_ours */
212 0, /* to_terminal_info */
215 0, /* to_lookup_symbol */
216 find_default_create_inferior, /* to_create_inferior */
217 NULL, /* to_post_startup_inferior */
218 NULL, /* to_acknowledge_created_inferior */
219 find_default_clone_and_follow_inferior, /* to_clone_and_follow_inferior */
220 NULL, /* to_post_follow_inferior_by_clone */
221 NULL, /* to_insert_fork_catchpoint */
222 NULL, /* to_remove_fork_catchpoint */
223 NULL, /* to_insert_vfork_catchpoint */
224 NULL, /* to_remove_vfork_catchpoint */
225 NULL, /* to_has_forked */
226 NULL, /* to_has_vforked */
227 NULL, /* to_can_follow_vfork_prior_to_exec */
228 NULL, /* to_post_follow_vfork */
229 NULL, /* to_insert_exec_catchpoint */
230 NULL, /* to_remove_exec_catchpoint */
231 NULL, /* to_has_execd */
232 NULL, /* to_reported_exec_events_per_exec_call */
233 NULL, /* to_has_syscall_event */
234 NULL, /* to_has_exited */
235 0, /* to_mourn_inferior */
237 0, /* to_notice_signals */
238 0, /* to_thread_alive */
240 NULL, /* to_enable_exception_callback */
241 NULL, /* to_get_current_exception_event */
242 NULL, /* to_pid_to_exec_file */
243 NULL, /* to_core_file_to_sym_file */
244 dummy_stratum, /* to_stratum */
246 0, /* to_has_all_memory */
247 0, /* to_has_memory */
248 0, /* to_has_stack */
249 0, /* to_has_registers */
250 0, /* to_has_execution */
251 tc_none, /* to_has_thread_control */
253 0, /* to_sections_end */
254 OPS_MAGIC, /* to_magic */
257 /* Top of target stack. */
259 struct target_stack_item *target_stack;
261 /* The target structure we are currently using to talk to a process
262 or file or whatever "inferior" we have. */
264 struct target_ops current_target;
266 /* Command list for target. */
268 static struct cmd_list_element *targetlist = NULL;
270 /* Nonzero if we are debugging an attached outside process
271 rather than an inferior. */
275 #ifdef MAINTENANCE_CMDS
276 /* Non-zero if we want to see trace of target level stuff. */
278 static int targetdebug = 0;
280 static void setup_target_debug PARAMS ((void));
284 /* The user just typed 'target' without the name of a target. */
288 target_command (arg, from_tty)
292 fputs_filtered ("Argument required (target name). Try `help target'\n",
296 /* Add a possible target architecture to the list. */
300 struct target_ops *t;
304 target_struct_allocsize = DEFAULT_ALLOCSIZE;
305 target_structs = (struct target_ops **) xmalloc
306 (target_struct_allocsize * sizeof (*target_structs));
308 if (target_struct_size >= target_struct_allocsize)
310 target_struct_allocsize *= 2;
311 target_structs = (struct target_ops **)
312 xrealloc ((char *) target_structs,
313 target_struct_allocsize * sizeof (*target_structs));
315 target_structs[target_struct_size++] = t;
316 /* cleanup_target (t);*/
318 if (targetlist == NULL)
319 add_prefix_cmd ("target", class_run, target_command,
320 "Connect to a target machine or process.\n\
321 The first argument is the type or protocol of the target machine.\n\
322 Remaining arguments are interpreted by the target protocol. For more\n\
323 information on the arguments for a particular protocol, type\n\
324 `help target ' followed by the protocol name.",
325 &targetlist, "target ", 0, &cmdlist);
326 add_cmd (t->to_shortname, no_class, t->to_open, t->to_doc, &targetlist);
338 nomemory (memaddr, myaddr, len, write, t)
343 struct target_ops *t;
345 errno = EIO; /* Can't read/write this location */
346 return 0; /* No bytes handled */
352 error ("You can't do that when your target is `%s'",
353 current_target.to_shortname);
359 error ("You can't do that without a process to debug.");
364 nosymbol (name, addrp)
368 return 1; /* Symbol does not exist in target env */
378 error ("No run-time support for this");
384 default_terminal_info (args, from_tty)
388 printf_unfiltered("No saved terminal information.\n");
391 /* This is the default target_create_inferior and target_attach function.
392 If the current target is executing, it asks whether to kill it off.
393 If this function returns without calling error(), it has killed off
394 the target, and the operation should be attempted. */
397 kill_or_be_killed (from_tty)
400 if (target_has_execution)
402 printf_unfiltered ("You are already running a program:\n");
403 target_files_info ();
404 if (query ("Kill it? ")) {
406 if (target_has_execution)
407 error ("Killing the program did not help.");
410 error ("Program not killed.");
417 maybe_kill_then_attach (args, from_tty)
421 kill_or_be_killed (from_tty);
422 target_attach (args, from_tty);
426 maybe_kill_then_create_inferior (exec, args, env)
431 kill_or_be_killed (0);
432 target_create_inferior (exec, args, env);
436 default_clone_and_follow_inferior (child_pid, followed_child)
440 target_clone_and_follow_inferior (child_pid, followed_child);
443 /* Clean up a target struct so it no longer has any zero pointers in it.
444 We default entries, at least to stubs that print error messages. */
448 struct target_ops *t;
451 #define de_fault(field, value) \
452 if (!t->field) t->field = value
454 /* FIELD DEFAULT VALUE */
456 de_fault (to_open, (void (*) PARAMS((char *, int))) tcomplain);
457 de_fault (to_close, (void (*) PARAMS((int))) target_ignore);
458 de_fault (to_attach, maybe_kill_then_attach);
459 de_fault (to_post_attach, (void (*) PARAMS ((int))) target_ignore);
460 de_fault (to_require_attach, maybe_kill_then_attach);
461 de_fault (to_detach, (void (*) PARAMS((char *, int))) target_ignore);
462 de_fault (to_require_detach, (void (*) PARAMS((int, char *, int))) target_ignore);
463 de_fault (to_resume, (void (*) PARAMS((int, int, enum target_signal))) noprocess);
464 de_fault (to_wait, (int (*) PARAMS((int, struct target_waitstatus *))) noprocess);
465 de_fault (to_post_wait, (void (*) PARAMS ((int, int))) target_ignore);
466 de_fault (to_fetch_registers, (void (*) PARAMS((int))) target_ignore);
467 de_fault (to_store_registers, (void (*) PARAMS((int))) noprocess);
468 de_fault (to_prepare_to_store, (void (*) PARAMS((void))) noprocess);
469 de_fault (to_xfer_memory, (int (*) PARAMS((CORE_ADDR, char *, int, int, struct target_ops *))) nomemory);
470 de_fault (to_files_info, (void (*) PARAMS((struct target_ops *))) target_ignore);
471 de_fault (to_insert_breakpoint, memory_insert_breakpoint);
472 de_fault (to_remove_breakpoint, memory_remove_breakpoint);
473 de_fault (to_terminal_init, (void (*) PARAMS((void))) target_ignore);
474 de_fault (to_terminal_inferior, (void (*) PARAMS ((void))) target_ignore);
475 de_fault (to_terminal_ours_for_output,(void (*) PARAMS ((void))) target_ignore);
476 de_fault (to_terminal_ours, (void (*) PARAMS ((void))) target_ignore);
477 de_fault (to_terminal_info, default_terminal_info);
478 de_fault (to_kill, (void (*) PARAMS((void))) noprocess);
479 de_fault (to_load, (void (*) PARAMS((char *, int))) tcomplain);
480 de_fault (to_lookup_symbol, (int (*) PARAMS ((char *, CORE_ADDR *))) nosymbol);
481 de_fault (to_create_inferior, maybe_kill_then_create_inferior);
482 de_fault (to_post_startup_inferior, (void (*) PARAMS ((int))) target_ignore);
483 de_fault (to_acknowledge_created_inferior, (void (*) PARAMS((int))) target_ignore);
484 de_fault (to_clone_and_follow_inferior, default_clone_and_follow_inferior);
485 de_fault (to_post_follow_inferior_by_clone, (void (*) PARAMS ((void))) target_ignore);
486 de_fault (to_insert_fork_catchpoint, (int (*) PARAMS ((int))) tcomplain);
487 de_fault (to_remove_fork_catchpoint, (int (*) PARAMS ((int))) tcomplain);
488 de_fault (to_insert_vfork_catchpoint, (int (*) PARAMS ((int))) tcomplain);
489 de_fault (to_remove_vfork_catchpoint, (int (*) PARAMS ((int))) tcomplain);
490 de_fault (to_has_forked, (int (*) PARAMS ((int, int *))) return_zero);
491 de_fault (to_has_vforked, (int (*) PARAMS ((int, int *))) return_zero);
492 de_fault (to_can_follow_vfork_prior_to_exec, (int (*) PARAMS ((void ))) return_zero);
493 de_fault (to_post_follow_vfork, (void (*) PARAMS ((int, int, int, int))) target_ignore);
494 de_fault (to_insert_exec_catchpoint, (int (*) PARAMS ((int))) tcomplain);
495 de_fault (to_remove_exec_catchpoint, (int (*) PARAMS ((int))) tcomplain);
496 de_fault (to_has_execd, (int (*) PARAMS ((int, char **))) return_zero);
497 de_fault (to_reported_exec_events_per_exec_call, (int (*) PARAMS ((void))) return_one);
498 de_fault (to_has_syscall_event, (int (*) PARAMS ((int, enum target_waitkind *, int *))) return_zero);
499 de_fault (to_has_exited, (int (*) PARAMS ((int, int, int *))) return_zero);
500 de_fault (to_mourn_inferior, (void (*) PARAMS ((void))) noprocess);
501 de_fault (to_can_run, return_zero);
502 de_fault (to_notice_signals, (void (*) PARAMS((int))) target_ignore);
503 de_fault (to_thread_alive, (int (*) PARAMS((int))) target_ignore);
504 de_fault (to_stop, (void (*) PARAMS((void))) target_ignore);
505 de_fault (to_enable_exception_callback, (struct symtab_and_line * (*) PARAMS((enum exception_event_kind, int))) nosupport_runtime);
506 de_fault (to_get_current_exception_event, (struct exception_event_record * (*) PARAMS((void))) nosupport_runtime);
508 de_fault (to_pid_to_exec_file, (char* (*) PARAMS((int))) return_zero);
509 de_fault (to_core_file_to_sym_file, (char* (*) PARAMS ((char *))) return_zero);
513 /* Go through the target stack from top to bottom, copying over zero entries in
514 current_target. In effect, we are doing class inheritance through the
515 pushed target vectors. */
518 update_current_target ()
520 struct target_stack_item *item;
521 struct target_ops *t;
523 /* First, reset current_target */
524 memset (¤t_target, 0, sizeof current_target);
526 for (item = target_stack; item; item = item->next)
528 t = item->target_ops;
530 #define INHERIT(FIELD, TARGET) \
531 if (!current_target.FIELD) \
532 current_target.FIELD = TARGET->FIELD
534 INHERIT (to_shortname, t);
535 INHERIT (to_longname, t);
537 INHERIT (to_open, t);
538 INHERIT (to_close, t);
539 INHERIT (to_attach, t);
540 INHERIT (to_post_attach, t);
541 INHERIT (to_require_attach, t);
542 INHERIT (to_detach, t);
543 INHERIT (to_require_detach, t);
544 INHERIT (to_resume, t);
545 INHERIT (to_wait, t);
546 INHERIT (to_post_wait, t);
547 INHERIT (to_fetch_registers, t);
548 INHERIT (to_store_registers, t);
549 INHERIT (to_prepare_to_store, t);
550 INHERIT (to_xfer_memory, t);
551 INHERIT (to_files_info, t);
552 INHERIT (to_insert_breakpoint, t);
553 INHERIT (to_remove_breakpoint, t);
554 INHERIT (to_terminal_init, t);
555 INHERIT (to_terminal_inferior, t);
556 INHERIT (to_terminal_ours_for_output, t);
557 INHERIT (to_terminal_ours, t);
558 INHERIT (to_terminal_info, t);
559 INHERIT (to_kill, t);
560 INHERIT (to_load, t);
561 INHERIT (to_lookup_symbol, t);
562 INHERIT (to_create_inferior, t);
563 INHERIT (to_post_startup_inferior, t);
564 INHERIT (to_acknowledge_created_inferior, t);
565 INHERIT (to_clone_and_follow_inferior, t);
566 INHERIT (to_post_follow_inferior_by_clone, t);
567 INHERIT (to_insert_fork_catchpoint, t);
568 INHERIT (to_remove_fork_catchpoint, t);
569 INHERIT (to_insert_vfork_catchpoint, t);
570 INHERIT (to_remove_vfork_catchpoint, t);
571 INHERIT (to_has_forked, t);
572 INHERIT (to_has_vforked, t);
573 INHERIT (to_can_follow_vfork_prior_to_exec, t);
574 INHERIT (to_post_follow_vfork, t);
575 INHERIT (to_insert_exec_catchpoint, t);
576 INHERIT (to_remove_exec_catchpoint, t);
577 INHERIT (to_has_execd, t);
578 INHERIT (to_reported_exec_events_per_exec_call, t);
579 INHERIT (to_has_syscall_event, t);
580 INHERIT (to_has_exited, t);
581 INHERIT (to_mourn_inferior, t);
582 INHERIT (to_can_run, t);
583 INHERIT (to_notice_signals, t);
584 INHERIT (to_thread_alive, t);
585 INHERIT (to_stop, t);
586 INHERIT (to_enable_exception_callback, t);
587 INHERIT (to_get_current_exception_event, t);
588 INHERIT (to_pid_to_exec_file, t);
589 INHERIT (to_core_file_to_sym_file, t);
590 INHERIT (to_stratum, t);
591 INHERIT (DONT_USE, t);
592 INHERIT (to_has_all_memory, t);
593 INHERIT (to_has_memory, t);
594 INHERIT (to_has_stack, t);
595 INHERIT (to_has_registers, t);
596 INHERIT (to_has_execution, t);
597 INHERIT (to_has_thread_control, t);
598 INHERIT (to_sections, t);
599 INHERIT (to_sections_end, t);
600 INHERIT (to_magic, t);
606 /* Push a new target type into the stack of the existing target accessors,
607 possibly superseding some of the existing accessors.
609 Result is zero if the pushed target ended up on top of the stack,
610 nonzero if at least one target is on top of it.
612 Rather than allow an empty stack, we always have the dummy target at
613 the bottom stratum, so we can call the function vectors without
618 struct target_ops *t;
620 struct target_stack_item *cur, *prev, *tmp;
622 /* Check magic number. If wrong, it probably means someone changed
623 the struct definition, but not all the places that initialize one. */
624 if (t->to_magic != OPS_MAGIC)
626 fprintf_unfiltered(gdb_stderr,
627 "Magic number of %s target struct wrong\n",
632 /* Find the proper stratum to install this target in. */
634 for (prev = NULL, cur = target_stack; cur; prev = cur, cur = cur->next)
636 if ((int)(t->to_stratum) >= (int)(cur->target_ops->to_stratum))
640 /* If there's already targets at this stratum, remove them. */
643 while (t->to_stratum == cur->target_ops->to_stratum)
645 /* There's already something on this stratum. Close it off. */
646 if (cur->target_ops->to_close)
647 (cur->target_ops->to_close) (0);
649 prev->next = cur->next; /* Unchain old target_ops */
651 target_stack = cur->next; /* Unchain first on list */
657 /* We have removed all targets in our stratum, now add the new one. */
659 tmp = (struct target_stack_item *)
660 xmalloc (sizeof (struct target_stack_item));
669 update_current_target ();
671 cleanup_target (¤t_target); /* Fill in the gaps */
673 #ifdef MAINTENANCE_CMDS
675 setup_target_debug ();
681 /* Remove a target_ops vector from the stack, wherever it may be.
682 Return how many times it was removed (0 or 1). */
686 struct target_ops *t;
688 struct target_stack_item *cur, *prev;
691 t->to_close (0); /* Let it clean up */
693 /* Look for the specified target. Note that we assume that a target
694 can only occur once in the target stack. */
696 for (cur = target_stack, prev = NULL; cur; prev = cur, cur = cur->next)
697 if (cur->target_ops == t)
701 return 0; /* Didn't find target_ops, quit now */
703 /* Unchain the target */
706 target_stack = cur->next;
708 prev->next = cur->next;
710 free (cur); /* Release the target_stack_item */
712 update_current_target ();
713 cleanup_target (¤t_target);
721 (current_target.to_close)(0); /* Let it clean up */
722 if (unpush_target (target_stack->target_ops) == 1)
725 fprintf_unfiltered(gdb_stderr,
726 "pop_target couldn't find target %s\n",
727 current_target.to_shortname);
732 #define MIN(A, B) (((A) <= (B)) ? (A) : (B))
734 /* target_read_string -- read a null terminated string, up to LEN bytes,
735 from MEMADDR in target. Set *ERRNOP to the errno code, or 0 if successful.
736 Set *STRING to a pointer to malloc'd memory containing the data; the caller
737 is responsible for freeing it. Return the number of bytes successfully
741 target_read_string (memaddr, string, len, errnop)
747 int tlen, origlen, offset, i;
751 int buffer_allocated;
753 unsigned int nbytes_read = 0;
755 /* Small for testing. */
756 buffer_allocated = 4;
757 buffer = xmalloc (buffer_allocated);
764 tlen = MIN (len, 4 - (memaddr & 3));
765 offset = memaddr & 3;
767 errcode = target_xfer_memory (memaddr & ~3, buf, 4, 0, NULL);
770 /* The transfer request might have crossed the boundary to an
771 unallocated region of memory. Retry the transfer, requesting
775 errcode = target_xfer_memory (memaddr, buf, 1, 0, NULL);
780 if (bufptr - buffer + tlen > buffer_allocated)
783 bytes = bufptr - buffer;
784 buffer_allocated *= 2;
785 buffer = xrealloc (buffer, buffer_allocated);
786 bufptr = buffer + bytes;
789 for (i = 0; i < tlen; i++)
791 *bufptr++ = buf[i + offset];
792 if (buf[i + offset] == '\000')
794 nbytes_read += i + 1;
811 /* Read LEN bytes of target memory at address MEMADDR, placing the results in
812 GDB's memory at MYADDR. Returns either 0 for success or an errno value
815 If an error occurs, no guarantee is made about the contents of the data at
816 MYADDR. In particular, the caller should not depend upon partial reads
817 filling the buffer with good data. There is no way for the caller to know
818 how much good data might have been transfered anyway. Callers that can
819 deal with partial reads should call target_read_memory_partial. */
822 target_read_memory (memaddr, myaddr, len)
827 return target_xfer_memory (memaddr, myaddr, len, 0, NULL);
831 target_read_memory_section (memaddr, myaddr, len, bfd_section)
835 asection *bfd_section;
837 return target_xfer_memory (memaddr, myaddr, len, 0, bfd_section);
840 /* Read LEN bytes of target memory at address MEMADDR, placing the results
841 in GDB's memory at MYADDR. Returns a count of the bytes actually read,
842 and optionally an errno value in the location pointed to by ERRNOPTR
843 if ERRNOPTR is non-null. */
846 target_read_memory_partial (memaddr, myaddr, len, errnoptr)
852 int nread; /* Number of bytes actually read. */
853 int errcode; /* Error from last read. */
855 /* First try a complete read. */
856 errcode = target_xfer_memory (memaddr, myaddr, len, 0, NULL);
864 /* Loop, reading one byte at a time until we get as much as we can. */
865 for (errcode = 0, nread = 0; len > 0 && errcode == 0; nread++, len--)
867 errcode = target_xfer_memory (memaddr++, myaddr++, 1, 0, NULL);
869 /* If an error, the last read was unsuccessful, so adjust count. */
875 if (errnoptr != NULL)
883 target_write_memory (memaddr, myaddr, len)
888 return target_xfer_memory (memaddr, myaddr, len, 1, NULL);
891 /* This variable is used to pass section information down to targets. This
892 *should* be done by adding an argument to the target_xfer_memory function
893 of all the targets, but I didn't feel like changing 50+ files. */
895 asection *target_memory_bfd_section = NULL;
897 /* Move memory to or from the targets. Iterate until all of it has
898 been moved, if necessary. The top target gets priority; anything
899 it doesn't want, is offered to the next one down, etc. Note the
900 business with curlen: if an early target says "no, but I have a
901 boundary overlapping this xfer" then we shorten what we offer to
902 the subsequent targets so the early guy will get a chance at the
903 tail before the subsequent ones do.
905 Result is 0 or errno value. */
908 target_xfer_memory (memaddr, myaddr, len, write, bfd_section)
913 asection *bfd_section;
917 struct target_ops *t;
918 struct target_stack_item *item;
920 /* Zero length requests are ok and require no work. */
924 target_memory_bfd_section = bfd_section;
926 /* to_xfer_memory is not guaranteed to set errno, even when it returns
930 /* The quick case is that the top target does it all. */
931 res = current_target.to_xfer_memory
932 (memaddr, myaddr, len, write, ¤t_target);
938 /* If res <= 0 then we call it again in the loop. Ah well. */
942 curlen = len; /* Want to do it all */
943 for (item = target_stack; item; item = item->next)
945 t = item->target_ops;
946 if (!t->to_has_memory)
949 res = t->to_xfer_memory (memaddr, myaddr, curlen, write, t);
951 break; /* Handled all or part of xfer */
952 if (t->to_has_all_memory)
958 /* If this address is for nonexistent memory,
959 read zeros if reading, or do nothing if writing. Return error. */
961 memset (myaddr, 0, len);
972 return 0; /* We managed to cover it all somehow. */
978 target_info (args, from_tty)
982 struct target_ops *t;
983 struct target_stack_item *item;
986 if (symfile_objfile != NULL)
987 printf_unfiltered ("Symbols from \"%s\".\n", symfile_objfile->name);
989 #ifdef FILES_INFO_HOOK
990 if (FILES_INFO_HOOK ())
994 for (item = target_stack; item; item = item->next)
996 t = item->target_ops;
998 if (!t->to_has_memory)
1001 if ((int)(t->to_stratum) <= (int)dummy_stratum)
1004 printf_unfiltered("\tWhile running this, GDB does not access memory from...\n");
1005 printf_unfiltered("%s:\n", t->to_longname);
1006 (t->to_files_info)(t);
1007 has_all_mem = t->to_has_all_memory;
1011 /* This is to be called by the open routine before it does
1015 target_preopen (from_tty)
1020 if (target_has_execution)
1022 if (query ("A program is being debugged already. Kill it? "))
1025 error ("Program not killed.");
1028 /* Calling target_kill may remove the target from the stack. But if
1029 it doesn't (which seems like a win for UDI), remove it now. */
1031 if (target_has_execution)
1035 /* Detach a target after doing deferred register stores. */
1038 target_detach (args, from_tty)
1042 /* Handle any optimized stores to the inferior. */
1043 #ifdef DO_DEFERRED_STORES
1046 (current_target.to_detach) (args, from_tty);
1050 target_link (modname, t_reloc)
1054 if (STREQ(current_target.to_shortname, "rombug"))
1056 (current_target.to_lookup_symbol) (modname, t_reloc);
1058 error("Unable to link to %s and get relocation in rombug", modname);
1061 *t_reloc = (CORE_ADDR)-1;
1064 /* Look through the list of possible targets for a target that can
1065 execute a run or attach command without any other data. This is
1066 used to locate the default process stratum.
1068 Result is always valid (error() is called for errors). */
1070 static struct target_ops *
1071 find_default_run_target (do_mesg)
1074 struct target_ops **t;
1075 struct target_ops *runable = NULL;
1080 for (t = target_structs; t < target_structs + target_struct_size;
1083 if ((*t)->to_can_run && target_can_run(*t))
1091 error ("Don't know how to %s. Try \"help target\".", do_mesg);
1097 find_default_attach (args, from_tty)
1101 struct target_ops *t;
1103 t = find_default_run_target("attach");
1104 (t->to_attach) (args, from_tty);
1109 find_default_require_attach (args, from_tty)
1113 struct target_ops *t;
1115 t = find_default_run_target("require_attach");
1116 (t->to_require_attach) (args, from_tty);
1121 find_default_require_detach (pid, args, from_tty)
1126 struct target_ops *t;
1128 t = find_default_run_target("require_detach");
1129 (t->to_require_detach) (pid, args, from_tty);
1134 find_default_create_inferior (exec_file, allargs, env)
1139 struct target_ops *t;
1141 t = find_default_run_target("run");
1142 (t->to_create_inferior) (exec_file, allargs, env);
1147 find_default_clone_and_follow_inferior (child_pid, followed_child)
1149 int *followed_child;
1151 struct target_ops *t;
1153 t = find_default_run_target("run");
1154 (t->to_clone_and_follow_inferior) (child_pid, followed_child);
1173 struct target_ops **t;
1174 struct target_ops *runable = NULL;
1179 for (t = target_structs; t < target_structs + target_struct_size;
1182 if ((*t)->to_stratum == core_stratum)
1189 return(count == 1 ? runable : NULL);
1192 /* The inferior process has died. Long live the inferior! */
1195 generic_mourn_inferior ()
1197 extern int show_breakpoint_hit_counts;
1201 breakpoint_init_inferior (inf_exited);
1202 registers_changed ();
1204 #ifdef CLEAR_DEFERRED_STORES
1205 /* Delete any pending stores to the inferior... */
1206 CLEAR_DEFERRED_STORES;
1209 reopen_exec_file ();
1210 reinit_frame_cache ();
1212 /* It is confusing to the user for ignore counts to stick around
1213 from previous runs of the inferior. So clear them. */
1214 /* However, it is more confusing for the ignore counts to disappear when
1215 using hit counts. So don't clear them if we're counting hits. */
1216 if (!show_breakpoint_hit_counts)
1217 breakpoint_clear_ignore_counts ();
1220 /* This table must match in order and size the signals in enum target_signal
1228 {"SIGHUP", "Hangup"},
1229 {"SIGINT", "Interrupt"},
1230 {"SIGQUIT", "Quit"},
1231 {"SIGILL", "Illegal instruction"},
1232 {"SIGTRAP", "Trace/breakpoint trap"},
1233 {"SIGABRT", "Aborted"},
1234 {"SIGEMT", "Emulation trap"},
1235 {"SIGFPE", "Arithmetic exception"},
1236 {"SIGKILL", "Killed"},
1237 {"SIGBUS", "Bus error"},
1238 {"SIGSEGV", "Segmentation fault"},
1239 {"SIGSYS", "Bad system call"},
1240 {"SIGPIPE", "Broken pipe"},
1241 {"SIGALRM", "Alarm clock"},
1242 {"SIGTERM", "Terminated"},
1243 {"SIGURG", "Urgent I/O condition"},
1244 {"SIGSTOP", "Stopped (signal)"},
1245 {"SIGTSTP", "Stopped (user)"},
1246 {"SIGCONT", "Continued"},
1247 {"SIGCHLD", "Child status changed"},
1248 {"SIGTTIN", "Stopped (tty input)"},
1249 {"SIGTTOU", "Stopped (tty output)"},
1250 {"SIGIO", "I/O possible"},
1251 {"SIGXCPU", "CPU time limit exceeded"},
1252 {"SIGXFSZ", "File size limit exceeded"},
1253 {"SIGVTALRM", "Virtual timer expired"},
1254 {"SIGPROF", "Profiling timer expired"},
1255 {"SIGWINCH", "Window size changed"},
1256 {"SIGLOST", "Resource lost"},
1257 {"SIGUSR1", "User defined signal 1"},
1258 {"SIGUSR2", "User defined signal 2"},
1259 {"SIGPWR", "Power fail/restart"},
1260 {"SIGPOLL", "Pollable event occurred"},
1261 {"SIGWIND", "SIGWIND"},
1262 {"SIGPHONE", "SIGPHONE"},
1263 {"SIGWAITING", "Process's LWPs are blocked"},
1264 {"SIGLWP", "Signal LWP"},
1265 {"SIGDANGER", "Swap space dangerously low"},
1266 {"SIGGRANT", "Monitor mode granted"},
1267 {"SIGRETRACT", "Need to relinquish monitor mode"},
1268 {"SIGMSG", "Monitor mode data available"},
1269 {"SIGSOUND", "Sound completed"},
1270 {"SIGSAK", "Secure attention"},
1271 {"SIGPRIO", "SIGPRIO"},
1272 {"SIG33", "Real-time event 33"},
1273 {"SIG34", "Real-time event 34"},
1274 {"SIG35", "Real-time event 35"},
1275 {"SIG36", "Real-time event 36"},
1276 {"SIG37", "Real-time event 37"},
1277 {"SIG38", "Real-time event 38"},
1278 {"SIG39", "Real-time event 39"},
1279 {"SIG40", "Real-time event 40"},
1280 {"SIG41", "Real-time event 41"},
1281 {"SIG42", "Real-time event 42"},
1282 {"SIG43", "Real-time event 43"},
1283 {"SIG44", "Real-time event 44"},
1284 {"SIG45", "Real-time event 45"},
1285 {"SIG46", "Real-time event 46"},
1286 {"SIG47", "Real-time event 47"},
1287 {"SIG48", "Real-time event 48"},
1288 {"SIG49", "Real-time event 49"},
1289 {"SIG50", "Real-time event 50"},
1290 {"SIG51", "Real-time event 51"},
1291 {"SIG52", "Real-time event 52"},
1292 {"SIG53", "Real-time event 53"},
1293 {"SIG54", "Real-time event 54"},
1294 {"SIG55", "Real-time event 55"},
1295 {"SIG56", "Real-time event 56"},
1296 {"SIG57", "Real-time event 57"},
1297 {"SIG58", "Real-time event 58"},
1298 {"SIG59", "Real-time event 59"},
1299 {"SIG60", "Real-time event 60"},
1300 {"SIG61", "Real-time event 61"},
1301 {"SIG62", "Real-time event 62"},
1302 {"SIG63", "Real-time event 63"},
1304 #if defined(MACH) || defined(__MACH__)
1305 /* Mach exceptions */
1306 {"EXC_BAD_ACCESS", "Could not access memory"},
1307 {"EXC_BAD_INSTRUCTION", "Illegal instruction/operand"},
1308 {"EXC_ARITHMETIC", "Arithmetic exception"},
1309 {"EXC_EMULATION", "Emulation instruction"},
1310 {"EXC_SOFTWARE", "Software generated exception"},
1311 {"EXC_BREAKPOINT", "Breakpoint"},
1313 {NULL, "Unknown signal"},
1314 {NULL, "Internal error: printing TARGET_SIGNAL_DEFAULT"},
1316 /* Last entry, used to check whether the table is the right size. */
1317 {NULL, "TARGET_SIGNAL_MAGIC"}
1320 /* Return the string for a signal. */
1322 target_signal_to_string (sig)
1323 enum target_signal sig;
1325 return signals[sig].string;
1328 /* Return the name for a signal. */
1330 target_signal_to_name (sig)
1331 enum target_signal sig;
1333 if (sig == TARGET_SIGNAL_UNKNOWN)
1334 /* I think the code which prints this will always print it along with
1335 the string, so no need to be verbose. */
1337 return signals[sig].name;
1340 /* Given a name, return its signal. */
1342 target_signal_from_name (name)
1345 enum target_signal sig;
1347 /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
1348 for TARGET_SIGNAL_SIGCHLD. SIGIOT, on the other hand, is more
1349 questionable; seems like by now people should call it SIGABRT
1352 /* This ugly cast brought to you by the native VAX compiler. */
1353 for (sig = TARGET_SIGNAL_HUP;
1354 signals[sig].name != NULL;
1355 sig = (enum target_signal)((int)sig + 1))
1356 if (STREQ (name, signals[sig].name))
1358 return TARGET_SIGNAL_UNKNOWN;
1361 /* The following functions are to help certain targets deal
1362 with the signal/waitstatus stuff. They could just as well be in
1363 a file called native-utils.c or unixwaitstatus-utils.c or whatever. */
1365 /* Convert host signal to our signals. */
1367 target_signal_from_host (hostsig)
1370 /* A switch statement would make sense but would require special kludges
1371 to deal with the cases where more than one signal has the same number. */
1373 if (hostsig == 0) return TARGET_SIGNAL_0;
1375 #if defined (SIGHUP)
1376 if (hostsig == SIGHUP) return TARGET_SIGNAL_HUP;
1378 #if defined (SIGINT)
1379 if (hostsig == SIGINT) return TARGET_SIGNAL_INT;
1381 #if defined (SIGQUIT)
1382 if (hostsig == SIGQUIT) return TARGET_SIGNAL_QUIT;
1384 #if defined (SIGILL)
1385 if (hostsig == SIGILL) return TARGET_SIGNAL_ILL;
1387 #if defined (SIGTRAP)
1388 if (hostsig == SIGTRAP) return TARGET_SIGNAL_TRAP;
1390 #if defined (SIGABRT)
1391 if (hostsig == SIGABRT) return TARGET_SIGNAL_ABRT;
1393 #if defined (SIGEMT)
1394 if (hostsig == SIGEMT) return TARGET_SIGNAL_EMT;
1396 #if defined (SIGFPE)
1397 if (hostsig == SIGFPE) return TARGET_SIGNAL_FPE;
1399 #if defined (SIGKILL)
1400 if (hostsig == SIGKILL) return TARGET_SIGNAL_KILL;
1402 #if defined (SIGBUS)
1403 if (hostsig == SIGBUS) return TARGET_SIGNAL_BUS;
1405 #if defined (SIGSEGV)
1406 if (hostsig == SIGSEGV) return TARGET_SIGNAL_SEGV;
1408 #if defined (SIGSYS)
1409 if (hostsig == SIGSYS) return TARGET_SIGNAL_SYS;
1411 #if defined (SIGPIPE)
1412 if (hostsig == SIGPIPE) return TARGET_SIGNAL_PIPE;
1414 #if defined (SIGALRM)
1415 if (hostsig == SIGALRM) return TARGET_SIGNAL_ALRM;
1417 #if defined (SIGTERM)
1418 if (hostsig == SIGTERM) return TARGET_SIGNAL_TERM;
1420 #if defined (SIGUSR1)
1421 if (hostsig == SIGUSR1) return TARGET_SIGNAL_USR1;
1423 #if defined (SIGUSR2)
1424 if (hostsig == SIGUSR2) return TARGET_SIGNAL_USR2;
1426 #if defined (SIGCLD)
1427 if (hostsig == SIGCLD) return TARGET_SIGNAL_CHLD;
1429 #if defined (SIGCHLD)
1430 if (hostsig == SIGCHLD) return TARGET_SIGNAL_CHLD;
1432 #if defined (SIGPWR)
1433 if (hostsig == SIGPWR) return TARGET_SIGNAL_PWR;
1435 #if defined (SIGWINCH)
1436 if (hostsig == SIGWINCH) return TARGET_SIGNAL_WINCH;
1438 #if defined (SIGURG)
1439 if (hostsig == SIGURG) return TARGET_SIGNAL_URG;
1442 if (hostsig == SIGIO) return TARGET_SIGNAL_IO;
1444 #if defined (SIGPOLL)
1445 if (hostsig == SIGPOLL) return TARGET_SIGNAL_POLL;
1447 #if defined (SIGSTOP)
1448 if (hostsig == SIGSTOP) return TARGET_SIGNAL_STOP;
1450 #if defined (SIGTSTP)
1451 if (hostsig == SIGTSTP) return TARGET_SIGNAL_TSTP;
1453 #if defined (SIGCONT)
1454 if (hostsig == SIGCONT) return TARGET_SIGNAL_CONT;
1456 #if defined (SIGTTIN)
1457 if (hostsig == SIGTTIN) return TARGET_SIGNAL_TTIN;
1459 #if defined (SIGTTOU)
1460 if (hostsig == SIGTTOU) return TARGET_SIGNAL_TTOU;
1462 #if defined (SIGVTALRM)
1463 if (hostsig == SIGVTALRM) return TARGET_SIGNAL_VTALRM;
1465 #if defined (SIGPROF)
1466 if (hostsig == SIGPROF) return TARGET_SIGNAL_PROF;
1468 #if defined (SIGXCPU)
1469 if (hostsig == SIGXCPU) return TARGET_SIGNAL_XCPU;
1471 #if defined (SIGXFSZ)
1472 if (hostsig == SIGXFSZ) return TARGET_SIGNAL_XFSZ;
1474 #if defined (SIGWIND)
1475 if (hostsig == SIGWIND) return TARGET_SIGNAL_WIND;
1477 #if defined (SIGPHONE)
1478 if (hostsig == SIGPHONE) return TARGET_SIGNAL_PHONE;
1480 #if defined (SIGLOST)
1481 if (hostsig == SIGLOST) return TARGET_SIGNAL_LOST;
1483 #if defined (SIGWAITING)
1484 if (hostsig == SIGWAITING) return TARGET_SIGNAL_WAITING;
1486 #if defined (SIGLWP)
1487 if (hostsig == SIGLWP) return TARGET_SIGNAL_LWP;
1489 #if defined (SIGDANGER)
1490 if (hostsig == SIGDANGER) return TARGET_SIGNAL_DANGER;
1492 #if defined (SIGGRANT)
1493 if (hostsig == SIGGRANT) return TARGET_SIGNAL_GRANT;
1495 #if defined (SIGRETRACT)
1496 if (hostsig == SIGRETRACT) return TARGET_SIGNAL_RETRACT;
1498 #if defined (SIGMSG)
1499 if (hostsig == SIGMSG) return TARGET_SIGNAL_MSG;
1501 #if defined (SIGSOUND)
1502 if (hostsig == SIGSOUND) return TARGET_SIGNAL_SOUND;
1504 #if defined (SIGSAK)
1505 if (hostsig == SIGSAK) return TARGET_SIGNAL_SAK;
1507 #if defined (SIGPRIO)
1508 if (hostsig == SIGPRIO) return TARGET_SIGNAL_PRIO;
1511 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1512 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1513 if (hostsig == _NSIG + EXC_BAD_ACCESS) return TARGET_EXC_BAD_ACCESS;
1515 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
1516 if (hostsig == _NSIG + EXC_BAD_INSTRUCTION) return TARGET_EXC_BAD_INSTRUCTION;
1518 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
1519 if (hostsig == _NSIG + EXC_ARITHMETIC) return TARGET_EXC_ARITHMETIC;
1521 #if defined (EXC_EMULATION) && defined (_NSIG)
1522 if (hostsig == _NSIG + EXC_EMULATION) return TARGET_EXC_EMULATION;
1524 #if defined (EXC_SOFTWARE) && defined (_NSIG)
1525 if (hostsig == _NSIG + EXC_SOFTWARE) return TARGET_EXC_SOFTWARE;
1527 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
1528 if (hostsig == _NSIG + EXC_BREAKPOINT) return TARGET_EXC_BREAKPOINT;
1531 #if defined (REALTIME_LO)
1532 if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI)
1533 return (enum target_signal)
1534 (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
1536 return TARGET_SIGNAL_UNKNOWN;
1540 target_signal_to_host (oursig)
1541 enum target_signal oursig;
1545 case TARGET_SIGNAL_0: return 0;
1547 #if defined (SIGHUP)
1548 case TARGET_SIGNAL_HUP: return SIGHUP;
1550 #if defined (SIGINT)
1551 case TARGET_SIGNAL_INT: return SIGINT;
1553 #if defined (SIGQUIT)
1554 case TARGET_SIGNAL_QUIT: return SIGQUIT;
1556 #if defined (SIGILL)
1557 case TARGET_SIGNAL_ILL: return SIGILL;
1559 #if defined (SIGTRAP)
1560 case TARGET_SIGNAL_TRAP: return SIGTRAP;
1562 #if defined (SIGABRT)
1563 case TARGET_SIGNAL_ABRT: return SIGABRT;
1565 #if defined (SIGEMT)
1566 case TARGET_SIGNAL_EMT: return SIGEMT;
1568 #if defined (SIGFPE)
1569 case TARGET_SIGNAL_FPE: return SIGFPE;
1571 #if defined (SIGKILL)
1572 case TARGET_SIGNAL_KILL: return SIGKILL;
1574 #if defined (SIGBUS)
1575 case TARGET_SIGNAL_BUS: return SIGBUS;
1577 #if defined (SIGSEGV)
1578 case TARGET_SIGNAL_SEGV: return SIGSEGV;
1580 #if defined (SIGSYS)
1581 case TARGET_SIGNAL_SYS: return SIGSYS;
1583 #if defined (SIGPIPE)
1584 case TARGET_SIGNAL_PIPE: return SIGPIPE;
1586 #if defined (SIGALRM)
1587 case TARGET_SIGNAL_ALRM: return SIGALRM;
1589 #if defined (SIGTERM)
1590 case TARGET_SIGNAL_TERM: return SIGTERM;
1592 #if defined (SIGUSR1)
1593 case TARGET_SIGNAL_USR1: return SIGUSR1;
1595 #if defined (SIGUSR2)
1596 case TARGET_SIGNAL_USR2: return SIGUSR2;
1598 #if defined (SIGCHLD) || defined (SIGCLD)
1599 case TARGET_SIGNAL_CHLD:
1600 #if defined (SIGCHLD)
1605 #endif /* SIGCLD or SIGCHLD */
1606 #if defined (SIGPWR)
1607 case TARGET_SIGNAL_PWR: return SIGPWR;
1609 #if defined (SIGWINCH)
1610 case TARGET_SIGNAL_WINCH: return SIGWINCH;
1612 #if defined (SIGURG)
1613 case TARGET_SIGNAL_URG: return SIGURG;
1616 case TARGET_SIGNAL_IO: return SIGIO;
1618 #if defined (SIGPOLL)
1619 case TARGET_SIGNAL_POLL: return SIGPOLL;
1621 #if defined (SIGSTOP)
1622 case TARGET_SIGNAL_STOP: return SIGSTOP;
1624 #if defined (SIGTSTP)
1625 case TARGET_SIGNAL_TSTP: return SIGTSTP;
1627 #if defined (SIGCONT)
1628 case TARGET_SIGNAL_CONT: return SIGCONT;
1630 #if defined (SIGTTIN)
1631 case TARGET_SIGNAL_TTIN: return SIGTTIN;
1633 #if defined (SIGTTOU)
1634 case TARGET_SIGNAL_TTOU: return SIGTTOU;
1636 #if defined (SIGVTALRM)
1637 case TARGET_SIGNAL_VTALRM: return SIGVTALRM;
1639 #if defined (SIGPROF)
1640 case TARGET_SIGNAL_PROF: return SIGPROF;
1642 #if defined (SIGXCPU)
1643 case TARGET_SIGNAL_XCPU: return SIGXCPU;
1645 #if defined (SIGXFSZ)
1646 case TARGET_SIGNAL_XFSZ: return SIGXFSZ;
1648 #if defined (SIGWIND)
1649 case TARGET_SIGNAL_WIND: return SIGWIND;
1651 #if defined (SIGPHONE)
1652 case TARGET_SIGNAL_PHONE: return SIGPHONE;
1654 #if defined (SIGLOST)
1655 case TARGET_SIGNAL_LOST: return SIGLOST;
1657 #if defined (SIGWAITING)
1658 case TARGET_SIGNAL_WAITING: return SIGWAITING;
1660 #if defined (SIGLWP)
1661 case TARGET_SIGNAL_LWP: return SIGLWP;
1663 #if defined (SIGDANGER)
1664 case TARGET_SIGNAL_DANGER: return SIGDANGER;
1666 #if defined (SIGGRANT)
1667 case TARGET_SIGNAL_GRANT: return SIGGRANT;
1669 #if defined (SIGRETRACT)
1670 case TARGET_SIGNAL_RETRACT: return SIGRETRACT;
1672 #if defined (SIGMSG)
1673 case TARGET_SIGNAL_MSG: return SIGMSG;
1675 #if defined (SIGSOUND)
1676 case TARGET_SIGNAL_SOUND: return SIGSOUND;
1678 #if defined (SIGSAK)
1679 case TARGET_SIGNAL_SAK: return SIGSAK;
1681 #if defined (SIGPRIO)
1682 case TARGET_SIGNAL_PRIO: return SIGPRIO;
1685 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1686 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1687 case TARGET_EXC_BAD_ACCESS: return _NSIG + EXC_BAD_ACCESS;
1689 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
1690 case TARGET_EXC_BAD_INSTRUCTION: return _NSIG + EXC_BAD_INSTRUCTION;
1692 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
1693 case TARGET_EXC_ARITHMETIC: return _NSIG + EXC_ARITHMETIC;
1695 #if defined (EXC_EMULATION) && defined (_NSIG)
1696 case TARGET_EXC_EMULATION: return _NSIG + EXC_EMULATION;
1698 #if defined (EXC_SOFTWARE) && defined (_NSIG)
1699 case TARGET_EXC_SOFTWARE: return _NSIG + EXC_SOFTWARE;
1701 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
1702 case TARGET_EXC_BREAKPOINT: return _NSIG + EXC_BREAKPOINT;
1706 #if defined (REALTIME_LO)
1707 if (oursig >= TARGET_SIGNAL_REALTIME_33
1708 && oursig <= TARGET_SIGNAL_REALTIME_63)
1711 (int)oursig - (int)TARGET_SIGNAL_REALTIME_33 + REALTIME_LO;
1712 if (retsig < REALTIME_HI)
1716 /* The user might be trying to do "signal SIGSAK" where this system
1717 doesn't have SIGSAK. */
1718 warning ("Signal %s does not exist on this system.\n",
1719 target_signal_to_name (oursig));
1724 /* Helper function for child_wait and the Lynx derivatives of child_wait.
1725 HOSTSTATUS is the waitstatus from wait() or the equivalent; store our
1726 translation of that in OURSTATUS. */
1728 store_waitstatus (ourstatus, hoststatus)
1729 struct target_waitstatus *ourstatus;
1732 #ifdef CHILD_SPECIAL_WAITSTATUS
1733 /* CHILD_SPECIAL_WAITSTATUS should return nonzero and set *OURSTATUS
1734 if it wants to deal with hoststatus. */
1735 if (CHILD_SPECIAL_WAITSTATUS (ourstatus, hoststatus))
1739 if (WIFEXITED (hoststatus))
1741 ourstatus->kind = TARGET_WAITKIND_EXITED;
1742 ourstatus->value.integer = WEXITSTATUS (hoststatus);
1744 else if (!WIFSTOPPED (hoststatus))
1746 ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
1747 ourstatus->value.sig = target_signal_from_host (WTERMSIG (hoststatus));
1751 ourstatus->kind = TARGET_WAITKIND_STOPPED;
1752 ourstatus->value.sig = target_signal_from_host (WSTOPSIG (hoststatus));
1756 /* In some circumstances we allow a command to specify a numeric
1757 signal. The idea is to keep these circumstances limited so that
1758 users (and scripts) develop portable habits. For comparison,
1759 POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a
1760 numeric signal at all is obscelescent. We are slightly more
1761 lenient and allow 1-15 which should match host signal numbers on
1762 most systems. Use of symbolic signal names is strongly encouraged. */
1765 target_signal_from_command (num)
1768 if (num >= 1 && num <= 15)
1769 return (enum target_signal)num;
1770 error ("Only signals 1-15 are valid as numeric signals.\n\
1771 Use \"info signals\" for a list of symbolic signals.");
1774 /* Returns zero to leave the inferior alone, one to interrupt it. */
1775 int (*target_activity_function) PARAMS ((void));
1776 int target_activity_fd;
1778 /* Convert a normal process ID to a string. Returns the string in a static
1782 normal_pid_to_str (pid)
1785 static char buf[30];
1787 if (STREQ (current_target.to_shortname, "remote"))
1788 sprintf (buf, "thread %d\0", pid);
1790 sprintf (buf, "process %d\0", pid);
1795 /* Some targets (such as ttrace-based HPUX) don't allow us to request
1796 notification of inferior events such as fork and vork immediately
1797 after the inferior is created. (This because of how gdb gets an
1798 inferior created via invoking a shell to do it. In such a scenario,
1799 if the shell init file has commands in it, the shell will fork and
1800 exec for each of those commands, and we will see each such fork
1803 This function is used by all targets that allow us to request
1804 notification of forks, etc at inferior creation time; e.g., in
1805 target_acknowledge_forked_child.
1808 normal_target_post_startup_inferior (pid)
1811 /* This space intentionally left blank. */
1815 #ifdef MAINTENANCE_CMDS
1816 static struct target_ops debug_target;
1819 debug_to_open (args, from_tty)
1823 debug_target.to_open (args, from_tty);
1825 fprintf_unfiltered (gdb_stderr, "target_open (%s, %d)\n", args, from_tty);
1829 debug_to_close (quitting)
1832 debug_target.to_close (quitting);
1834 fprintf_unfiltered (gdb_stderr, "target_close (%d)\n", quitting);
1838 debug_to_attach (args, from_tty)
1842 debug_target.to_attach (args, from_tty);
1844 fprintf_unfiltered (gdb_stderr, "target_attach (%s, %d)\n", args, from_tty);
1849 debug_to_post_attach (pid)
1852 debug_target.to_post_attach (pid);
1854 fprintf_unfiltered (gdb_stderr, "target_post_attach (%d)\n", pid);
1858 debug_to_require_attach (args, from_tty)
1862 debug_target.to_require_attach (args, from_tty);
1864 fprintf_unfiltered (gdb_stderr,
1865 "target_require_attach (%s, %d)\n", args, from_tty);
1869 debug_to_detach (args, from_tty)
1873 debug_target.to_detach (args, from_tty);
1875 fprintf_unfiltered (gdb_stderr, "target_detach (%s, %d)\n", args, from_tty);
1879 debug_to_require_detach (pid, args, from_tty)
1884 debug_target.to_require_detach (pid, args, from_tty);
1886 fprintf_unfiltered (gdb_stderr,
1887 "target_require_detach (%d, %s, %d)\n", pid, args, from_tty);
1891 debug_to_resume (pid, step, siggnal)
1894 enum target_signal siggnal;
1896 debug_target.to_resume (pid, step, siggnal);
1898 fprintf_unfiltered (gdb_stderr, "target_resume (%d, %s, %s)\n", pid,
1899 step ? "step" : "continue",
1900 target_signal_to_name (siggnal));
1904 debug_to_wait (pid, status)
1906 struct target_waitstatus *status;
1910 retval = debug_target.to_wait (pid, status);
1912 fprintf_unfiltered (gdb_stderr,
1913 "target_wait (%d, status) = %d, ", pid, retval);
1914 fprintf_unfiltered (gdb_stderr, "status->kind = ");
1915 switch (status->kind)
1917 case TARGET_WAITKIND_EXITED:
1918 fprintf_unfiltered (gdb_stderr, "exited, status = %d\n",
1919 status->value.integer);
1921 case TARGET_WAITKIND_STOPPED:
1922 fprintf_unfiltered (gdb_stderr, "stopped, signal = %s\n",
1923 target_signal_to_name (status->value.sig));
1925 case TARGET_WAITKIND_SIGNALLED:
1926 fprintf_unfiltered (gdb_stderr, "signalled, signal = %s\n",
1927 target_signal_to_name (status->value.sig));
1929 case TARGET_WAITKIND_LOADED:
1930 fprintf_unfiltered (gdb_stderr, "loaded\n");
1932 case TARGET_WAITKIND_FORKED:
1933 fprintf_unfiltered (gdb_stderr, "forked\n");
1935 case TARGET_WAITKIND_VFORKED:
1936 fprintf_unfiltered (gdb_stderr, "vforked\n");
1938 case TARGET_WAITKIND_EXECD:
1939 fprintf_unfiltered (gdb_stderr, "execd\n");
1941 case TARGET_WAITKIND_SPURIOUS:
1942 fprintf_unfiltered (gdb_stderr, "spurious\n");
1945 fprintf_unfiltered (gdb_stderr, "unknown???\n");
1953 debug_to_post_wait (pid, status)
1957 debug_target.to_post_wait (pid, status);
1959 fprintf_unfiltered (gdb_stderr, "target_post_wait (%d, %d)\n",
1964 debug_to_fetch_registers (regno)
1967 debug_target.to_fetch_registers (regno);
1969 fprintf_unfiltered (gdb_stderr, "target_fetch_registers (%s)",
1970 regno != -1 ? REGISTER_NAME (regno) : "-1");
1972 fprintf_unfiltered (gdb_stderr, " = 0x%x %d",
1973 (unsigned long) read_register (regno),
1974 read_register (regno));
1975 fprintf_unfiltered (gdb_stderr, "\n");
1979 debug_to_store_registers (regno)
1982 debug_target.to_store_registers (regno);
1984 if (regno >= 0 && regno < NUM_REGS)
1985 fprintf_unfiltered (gdb_stderr, "target_store_registers (%s) = 0x%x %d\n",
1986 REGISTER_NAME (regno),
1987 (unsigned long) read_register (regno),
1988 (unsigned long) read_register (regno));
1990 fprintf_unfiltered (gdb_stderr, "target_store_registers (%d)\n", regno);
1994 debug_to_prepare_to_store ()
1996 debug_target.to_prepare_to_store ();
1998 fprintf_unfiltered (gdb_stderr, "target_prepare_to_store ()\n");
2002 debug_to_xfer_memory (memaddr, myaddr, len, write, target)
2007 struct target_ops *target;
2011 retval = debug_target.to_xfer_memory (memaddr, myaddr, len, write, target);
2013 fprintf_unfiltered (gdb_stderr,
2014 "target_xfer_memory (0x%x, xxx, %d, %s, xxx) = %d",
2015 (unsigned int) memaddr, /* possable truncate long long */
2016 len, write ? "write" : "read", retval);
2024 fputs_unfiltered (", bytes =", gdb_stderr);
2025 for (i = 0; i < retval; i++)
2027 if ((((long) &(myaddr[i])) & 0xf) == 0)
2028 fprintf_unfiltered (gdb_stderr, "\n");
2029 fprintf_unfiltered (gdb_stderr, " %02x", myaddr[i] & 0xff);
2033 fputc_unfiltered ('\n', gdb_stderr);
2039 debug_to_files_info (target)
2040 struct target_ops *target;
2042 debug_target.to_files_info (target);
2044 fprintf_unfiltered (gdb_stderr, "target_files_info (xxx)\n");
2048 debug_to_insert_breakpoint (addr, save)
2054 retval = debug_target.to_insert_breakpoint (addr, save);
2056 fprintf_unfiltered (gdb_stderr,
2057 "target_insert_breakpoint (0x%x, xxx) = %d\n",
2058 (unsigned long) addr, retval);
2063 debug_to_remove_breakpoint (addr, save)
2069 retval = debug_target.to_remove_breakpoint (addr, save);
2071 fprintf_unfiltered (gdb_stderr,
2072 "target_remove_breakpoint (0x%x, xxx) = %d\n",
2073 (unsigned long)addr, retval);
2078 debug_to_terminal_init ()
2080 debug_target.to_terminal_init ();
2082 fprintf_unfiltered (gdb_stderr, "target_terminal_init ()\n");
2086 debug_to_terminal_inferior ()
2088 debug_target.to_terminal_inferior ();
2090 fprintf_unfiltered (gdb_stderr, "target_terminal_inferior ()\n");
2094 debug_to_terminal_ours_for_output ()
2096 debug_target.to_terminal_ours_for_output ();
2098 fprintf_unfiltered (gdb_stderr, "target_terminal_ours_for_output ()\n");
2102 debug_to_terminal_ours ()
2104 debug_target.to_terminal_ours ();
2106 fprintf_unfiltered (gdb_stderr, "target_terminal_ours ()\n");
2110 debug_to_terminal_info (arg, from_tty)
2114 debug_target.to_terminal_info (arg, from_tty);
2116 fprintf_unfiltered (gdb_stderr, "target_terminal_info (%s, %d)\n", arg,
2123 debug_target.to_kill ();
2125 fprintf_unfiltered (gdb_stderr, "target_kill ()\n");
2129 debug_to_load (args, from_tty)
2133 debug_target.to_load (args, from_tty);
2135 fprintf_unfiltered (gdb_stderr, "target_load (%s, %d)\n", args, from_tty);
2139 debug_to_lookup_symbol (name, addrp)
2145 retval = debug_target.to_lookup_symbol (name, addrp);
2147 fprintf_unfiltered (gdb_stderr, "target_lookup_symbol (%s, xxx)\n", name);
2153 debug_to_create_inferior (exec_file, args, env)
2158 debug_target.to_create_inferior (exec_file, args, env);
2160 fprintf_unfiltered (gdb_stderr, "target_create_inferior (%s, %s, xxx)\n",
2165 debug_to_post_startup_inferior (pid)
2168 debug_target.to_post_startup_inferior (pid);
2170 fprintf_unfiltered (gdb_stderr, "target_post_startup_inferior (%d)\n",
2175 debug_to_acknowledge_created_inferior (pid)
2178 debug_target.to_acknowledge_created_inferior (pid);
2180 fprintf_unfiltered (gdb_stderr, "target_acknowledge_created_inferior (%d)\n",
2185 debug_to_clone_and_follow_inferior (child_pid, followed_child)
2187 int *followed_child;
2189 debug_target.to_clone_and_follow_inferior (child_pid, followed_child);
2191 fprintf_unfiltered (gdb_stderr,
2192 "target_clone_and_follow_inferior (%d, %d)\n",
2193 child_pid, *followed_child);
2197 debug_to_post_follow_inferior_by_clone ()
2199 debug_target.to_post_follow_inferior_by_clone ();
2201 fprintf_unfiltered (gdb_stderr, "target_post_follow_inferior_by_clone ()\n");
2205 debug_to_insert_fork_catchpoint (pid)
2210 retval = debug_target.to_insert_fork_catchpoint (pid);
2212 fprintf_unfiltered (gdb_stderr, "target_insert_fork_catchpoint (%d) = %d\n",
2219 debug_to_remove_fork_catchpoint (pid)
2224 retval = debug_target.to_remove_fork_catchpoint (pid);
2226 fprintf_unfiltered (gdb_stderr, "target_remove_fork_catchpoint (%d) = %d\n",
2233 debug_to_insert_vfork_catchpoint (pid)
2238 retval = debug_target.to_insert_vfork_catchpoint (pid);
2240 fprintf_unfiltered (gdb_stderr, "target_insert_vfork_catchpoint (%d)= %d\n",
2247 debug_to_remove_vfork_catchpoint (pid)
2252 retval = debug_target.to_remove_vfork_catchpoint (pid);
2254 fprintf_unfiltered (gdb_stderr, "target_remove_vfork_catchpoint (%d) = %d\n",
2261 debug_to_has_forked (pid, child_pid)
2267 has_forked = debug_target.to_has_forked (pid, child_pid);
2269 fprintf_unfiltered (gdb_stderr, "target_has_forked (%d, %d) = %d\n",
2270 pid, *child_pid, has_forked);
2276 debug_to_has_vforked (pid, child_pid)
2282 has_vforked = debug_target.to_has_vforked (pid, child_pid);
2284 fprintf_unfiltered (gdb_stderr, "target_has_vforked (%d, %d) = %d\n",
2285 pid, *child_pid, has_vforked);
2291 debug_to_can_follow_vfork_prior_to_exec ()
2293 int can_immediately_follow_vfork;
2295 can_immediately_follow_vfork = debug_target.to_can_follow_vfork_prior_to_exec ();
2297 fprintf_unfiltered (gdb_stderr, "target_can_follow_vfork_prior_to_exec () = %d\n",
2298 can_immediately_follow_vfork);
2300 return can_immediately_follow_vfork;
2304 debug_to_post_follow_vfork (parent_pid, followed_parent, child_pid, followed_child)
2306 int followed_parent;
2310 debug_target.to_post_follow_vfork (parent_pid, followed_parent, child_pid, followed_child);
2312 fprintf_unfiltered (gdb_stderr,
2313 "target_post_follow_vfork (%d, %d, %d, %d)\n",
2314 parent_pid, followed_parent, child_pid, followed_child);
2318 debug_to_insert_exec_catchpoint (pid)
2323 retval = debug_target.to_insert_exec_catchpoint (pid);
2325 fprintf_unfiltered (gdb_stderr, "target_insert_exec_catchpoint (%d) = %d\n",
2332 debug_to_remove_exec_catchpoint (pid)
2337 retval = debug_target.to_remove_exec_catchpoint (pid);
2339 fprintf_unfiltered (gdb_stderr, "target_remove_exec_catchpoint (%d) = %d\n",
2346 debug_to_has_execd (pid, execd_pathname)
2348 char ** execd_pathname;
2352 has_execd = debug_target.to_has_execd (pid, execd_pathname);
2354 fprintf_unfiltered (gdb_stderr, "target_has_execd (%d, %s) = %d\n",
2355 pid, *execd_pathname, has_execd);
2361 debug_to_reported_exec_events_per_exec_call ()
2363 int reported_exec_events;
2365 reported_exec_events = debug_target.to_reported_exec_events_per_exec_call ();
2367 fprintf_unfiltered (gdb_stderr,
2368 "target_reported_exec_events_per_exec_call () = %d\n",
2369 reported_exec_events);
2371 return reported_exec_events;
2375 debug_to_has_syscall_event (pid, kind, syscall_id)
2377 enum target_waitkind * kind;
2380 int has_syscall_event;
2381 char * kind_spelling = "??";
2383 has_syscall_event = debug_target.to_has_syscall_event (pid, kind, syscall_id);
2384 if (has_syscall_event)
2388 case TARGET_WAITKIND_SYSCALL_ENTRY:
2389 kind_spelling = "SYSCALL_ENTRY";
2391 case TARGET_WAITKIND_SYSCALL_RETURN:
2392 kind_spelling = "SYSCALL_RETURN";
2399 fprintf_unfiltered (gdb_stderr,
2400 "target_has_syscall_event (%d, %s, %d) = %d\n",
2401 pid, kind_spelling, *syscall_id, has_syscall_event);
2403 return has_syscall_event;
2407 debug_to_has_exited (pid, wait_status, exit_status)
2414 has_exited = debug_target.to_has_exited (pid, wait_status, exit_status);
2416 fprintf_unfiltered (gdb_stderr, "target_has_exited (%d, %d, %d) = %d\n",
2417 pid, wait_status, *exit_status, has_exited);
2423 debug_to_mourn_inferior ()
2425 debug_target.to_mourn_inferior ();
2427 fprintf_unfiltered (gdb_stderr, "target_mourn_inferior ()\n");
2435 retval = debug_target.to_can_run ();
2437 fprintf_unfiltered (gdb_stderr, "target_can_run () = %d\n", retval);
2443 debug_to_notice_signals (pid)
2446 debug_target.to_notice_signals (pid);
2448 fprintf_unfiltered (gdb_stderr, "target_notice_signals (%d)\n", pid);
2452 debug_to_thread_alive (pid)
2457 retval = debug_target.to_thread_alive (pid);
2459 fprintf_unfiltered (gdb_stderr, "target_thread_alive (%d) = %d\n",
2468 debug_target.to_stop ();
2470 fprintf_unfiltered (gdb_stderr, "target_stop ()\n");
2473 static struct symtab_and_line *
2474 debug_to_enable_exception_callback (kind, enable)
2475 enum exception_event_kind kind;
2478 debug_target.to_enable_exception_callback (kind, enable);
2480 fprintf_unfiltered (gdb_stderr,
2481 "target get_exception_callback_sal (%d, %d)\n",
2485 static struct exception_event_record *
2486 debug_to_get_current_exception_event ()
2488 debug_target.to_get_current_exception_event();
2490 fprintf_unfiltered (gdb_stderr, "target get_current_exception_event ()\n");
2494 debug_to_pid_to_exec_file (pid)
2499 exec_file = debug_target.to_pid_to_exec_file (pid);
2501 fprintf_unfiltered (gdb_stderr, "target_pid_to_exec_file (%d) = %s\n",
2508 debug_to_core_file_to_sym_file (core)
2513 sym_file = debug_target.to_core_file_to_sym_file (core);
2515 fprintf_unfiltered (gdb_stderr, "target_core_file_to_sym_file (%s) = %s\n",
2522 setup_target_debug ()
2524 memcpy (&debug_target, ¤t_target, sizeof debug_target);
2526 current_target.to_open = debug_to_open;
2527 current_target.to_close = debug_to_close;
2528 current_target.to_attach = debug_to_attach;
2529 current_target.to_post_attach = debug_to_post_attach;
2530 current_target.to_require_attach = debug_to_require_attach;
2531 current_target.to_detach = debug_to_detach;
2532 current_target.to_require_detach = debug_to_require_detach;
2533 current_target.to_resume = debug_to_resume;
2534 current_target.to_wait = debug_to_wait;
2535 current_target.to_post_wait = debug_to_post_wait;
2536 current_target.to_fetch_registers = debug_to_fetch_registers;
2537 current_target.to_store_registers = debug_to_store_registers;
2538 current_target.to_prepare_to_store = debug_to_prepare_to_store;
2539 current_target.to_xfer_memory = debug_to_xfer_memory;
2540 current_target.to_files_info = debug_to_files_info;
2541 current_target.to_insert_breakpoint = debug_to_insert_breakpoint;
2542 current_target.to_remove_breakpoint = debug_to_remove_breakpoint;
2543 current_target.to_terminal_init = debug_to_terminal_init;
2544 current_target.to_terminal_inferior = debug_to_terminal_inferior;
2545 current_target.to_terminal_ours_for_output = debug_to_terminal_ours_for_output;
2546 current_target.to_terminal_ours = debug_to_terminal_ours;
2547 current_target.to_terminal_info = debug_to_terminal_info;
2548 current_target.to_kill = debug_to_kill;
2549 current_target.to_load = debug_to_load;
2550 current_target.to_lookup_symbol = debug_to_lookup_symbol;
2551 current_target.to_create_inferior = debug_to_create_inferior;
2552 current_target.to_post_startup_inferior = debug_to_post_startup_inferior;
2553 current_target.to_acknowledge_created_inferior = debug_to_acknowledge_created_inferior;
2554 current_target.to_clone_and_follow_inferior = debug_to_clone_and_follow_inferior;
2555 current_target.to_post_follow_inferior_by_clone = debug_to_post_follow_inferior_by_clone;
2556 current_target.to_insert_fork_catchpoint = debug_to_insert_fork_catchpoint;
2557 current_target.to_remove_fork_catchpoint = debug_to_remove_fork_catchpoint;
2558 current_target.to_insert_vfork_catchpoint = debug_to_insert_vfork_catchpoint;
2559 current_target.to_remove_vfork_catchpoint = debug_to_remove_vfork_catchpoint;
2560 current_target.to_has_forked = debug_to_has_forked;
2561 current_target.to_has_vforked = debug_to_has_vforked;
2562 current_target.to_can_follow_vfork_prior_to_exec = debug_to_can_follow_vfork_prior_to_exec;
2563 current_target.to_post_follow_vfork = debug_to_post_follow_vfork;
2564 current_target.to_insert_exec_catchpoint = debug_to_insert_exec_catchpoint;
2565 current_target.to_remove_exec_catchpoint = debug_to_remove_exec_catchpoint;
2566 current_target.to_has_execd = debug_to_has_execd;
2567 current_target.to_reported_exec_events_per_exec_call = debug_to_reported_exec_events_per_exec_call;
2568 current_target.to_has_syscall_event = debug_to_has_syscall_event;
2569 current_target.to_has_exited = debug_to_has_exited;
2570 current_target.to_mourn_inferior = debug_to_mourn_inferior;
2571 current_target.to_can_run = debug_to_can_run;
2572 current_target.to_notice_signals = debug_to_notice_signals;
2573 current_target.to_thread_alive = debug_to_thread_alive;
2574 current_target.to_stop = debug_to_stop;
2575 current_target.to_enable_exception_callback = debug_to_enable_exception_callback;
2576 current_target.to_get_current_exception_event = debug_to_get_current_exception_event;
2577 current_target.to_pid_to_exec_file = debug_to_pid_to_exec_file;
2578 current_target.to_core_file_to_sym_file = debug_to_core_file_to_sym_file;
2581 #endif /* MAINTENANCE_CMDS */
2583 static char targ_desc[] =
2584 "Names of targets and files being debugged.\n\
2585 Shows the entire stack of targets currently in use (including the exec-file,\n\
2586 core-file, and process, if any), as well as the symbol file name.";
2589 initialize_targets ()
2591 push_target (&dummy_target);
2593 add_info ("target", target_info, targ_desc);
2594 add_info ("files", target_info, targ_desc);
2596 #ifdef MAINTENANCE_CMDS
2598 add_set_cmd ("targetdebug", class_maintenance, var_zinteger,
2599 (char *)&targetdebug,
2600 "Set target debugging.\n\
2601 When non-zero, target debugging is enabled.", &setlist),
2605 if (!STREQ (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC"))