1 /* Select target systems and architectures at runtime for GDB.
2 Copyright 1990, 1992-1995, 1998-2000 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,
20 Boston, MA 02111-1307, USA. */
25 #include "gdb_string.h"
38 static void target_info (char *, int);
40 static void cleanup_target (struct target_ops *);
42 static void maybe_kill_then_create_inferior (char *, char *, char **);
44 static void default_clone_and_follow_inferior (int, int *);
46 static void maybe_kill_then_attach (char *, int);
48 static void kill_or_be_killed (int);
50 static void default_terminal_info (char *, int);
52 static int nosymbol (char *, CORE_ADDR *);
54 static void tcomplain (void);
56 static int nomemory (CORE_ADDR, char *, int, int, struct target_ops *);
58 static int return_zero (void);
60 static int return_one (void);
62 void target_ignore (void);
64 static void target_command (char *, int);
66 static struct target_ops *find_default_run_target (char *);
68 static void update_current_target (void);
70 static void nosupport_runtime (void);
72 static void normal_target_post_startup_inferior (int pid);
74 /* Transfer LEN bytes between target address MEMADDR and GDB address
75 MYADDR. Returns 0 for success, errno code for failure (which
76 includes partial transfers -- if you want a more useful response to
77 partial transfers, try either target_read_memory_partial or
78 target_write_memory_partial). */
81 target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write);
83 static void init_dummy_target (void);
85 static void debug_to_open (char *, int);
87 static void debug_to_close (int);
89 static void debug_to_attach (char *, int);
91 static void debug_to_detach (char *, int);
93 static void debug_to_resume (int, int, enum target_signal);
95 static int debug_to_wait (int, struct target_waitstatus *);
97 static void debug_to_fetch_registers (int);
99 static void debug_to_store_registers (int);
101 static void debug_to_prepare_to_store (void);
104 debug_to_xfer_memory (CORE_ADDR, char *, int, int, struct target_ops *);
106 static void debug_to_files_info (struct target_ops *);
108 static int debug_to_insert_breakpoint (CORE_ADDR, char *);
110 static int debug_to_remove_breakpoint (CORE_ADDR, char *);
112 static void debug_to_terminal_init (void);
114 static void debug_to_terminal_inferior (void);
116 static void debug_to_terminal_ours_for_output (void);
118 static void debug_to_terminal_ours (void);
120 static void debug_to_terminal_info (char *, int);
122 static void debug_to_kill (void);
124 static void debug_to_load (char *, int);
126 static int debug_to_lookup_symbol (char *, CORE_ADDR *);
128 static void debug_to_create_inferior (char *, char *, char **);
130 static void debug_to_mourn_inferior (void);
132 static int debug_to_can_run (void);
134 static void debug_to_notice_signals (int);
136 static int debug_to_thread_alive (int);
138 static void debug_to_stop (void);
140 static int debug_to_query (int /*char */ , char *, char *, int *);
142 /* Pointer to array of target architecture structures; the size of the
143 array; the current index into the array; the allocated size of the
145 struct target_ops **target_structs;
146 unsigned target_struct_size;
147 unsigned target_struct_index;
148 unsigned target_struct_allocsize;
149 #define DEFAULT_ALLOCSIZE 10
151 /* The initial current target, so that there is always a semi-valid
154 static struct target_ops dummy_target;
156 /* Top of target stack. */
158 struct target_stack_item *target_stack;
160 /* The target structure we are currently using to talk to a process
161 or file or whatever "inferior" we have. */
163 struct target_ops current_target;
165 /* Command list for target. */
167 static struct cmd_list_element *targetlist = NULL;
169 /* Nonzero if we are debugging an attached outside process
170 rather than an inferior. */
174 /* Non-zero if we want to see trace of target level stuff. */
176 static int targetdebug = 0;
178 static void setup_target_debug (void);
180 /* The user just typed 'target' without the name of a target. */
184 target_command (arg, from_tty)
188 fputs_filtered ("Argument required (target name). Try `help target'\n",
192 /* Add a possible target architecture to the list. */
196 struct target_ops *t;
200 target_struct_allocsize = DEFAULT_ALLOCSIZE;
201 target_structs = (struct target_ops **) xmalloc
202 (target_struct_allocsize * sizeof (*target_structs));
204 if (target_struct_size >= target_struct_allocsize)
206 target_struct_allocsize *= 2;
207 target_structs = (struct target_ops **)
208 xrealloc ((char *) target_structs,
209 target_struct_allocsize * sizeof (*target_structs));
211 target_structs[target_struct_size++] = t;
212 /* cleanup_target (t); */
214 if (targetlist == NULL)
215 add_prefix_cmd ("target", class_run, target_command,
216 "Connect to a target machine or process.\n\
217 The first argument is the type or protocol of the target machine.\n\
218 Remaining arguments are interpreted by the target protocol. For more\n\
219 information on the arguments for a particular protocol, type\n\
220 `help target ' followed by the protocol name.",
221 &targetlist, "target ", 0, &cmdlist);
222 add_cmd (t->to_shortname, no_class, t->to_open, t->to_doc, &targetlist);
233 target_load (char *arg, int from_tty)
235 (*current_target.to_load) (arg, from_tty);
240 nomemory (memaddr, myaddr, len, write, t)
245 struct target_ops *t;
247 errno = EIO; /* Can't read/write this location */
248 return 0; /* No bytes handled */
254 error ("You can't do that when your target is `%s'",
255 current_target.to_shortname);
261 error ("You can't do that without a process to debug.");
266 nosymbol (name, addrp)
270 return 1; /* Symbol does not exist in target env */
280 error ("No run-time support for this");
286 default_terminal_info (args, from_tty)
290 printf_unfiltered ("No saved terminal information.\n");
293 /* This is the default target_create_inferior and target_attach function.
294 If the current target is executing, it asks whether to kill it off.
295 If this function returns without calling error(), it has killed off
296 the target, and the operation should be attempted. */
299 kill_or_be_killed (from_tty)
302 if (target_has_execution)
304 printf_unfiltered ("You are already running a program:\n");
305 target_files_info ();
306 if (query ("Kill it? "))
309 if (target_has_execution)
310 error ("Killing the program did not help.");
315 error ("Program not killed.");
322 maybe_kill_then_attach (args, from_tty)
326 kill_or_be_killed (from_tty);
327 target_attach (args, from_tty);
331 maybe_kill_then_create_inferior (exec, args, env)
336 kill_or_be_killed (0);
337 target_create_inferior (exec, args, env);
341 default_clone_and_follow_inferior (child_pid, followed_child)
345 target_clone_and_follow_inferior (child_pid, followed_child);
348 /* Clean up a target struct so it no longer has any zero pointers in it.
349 We default entries, at least to stubs that print error messages. */
353 struct target_ops *t;
356 #define de_fault(field, value) \
361 (void (*) (char *, int))
367 maybe_kill_then_attach);
368 de_fault (to_post_attach,
371 de_fault (to_require_attach,
372 maybe_kill_then_attach);
374 (void (*) (char *, int))
376 de_fault (to_require_detach,
377 (void (*) (int, char *, int))
380 (void (*) (int, int, enum target_signal))
383 (int (*) (int, struct target_waitstatus *))
385 de_fault (to_post_wait,
386 (void (*) (int, int))
388 de_fault (to_fetch_registers,
391 de_fault (to_store_registers,
394 de_fault (to_prepare_to_store,
397 de_fault (to_xfer_memory,
398 (int (*) (CORE_ADDR, char *, int, int, struct target_ops *))
400 de_fault (to_files_info,
401 (void (*) (struct target_ops *))
403 de_fault (to_insert_breakpoint,
404 memory_insert_breakpoint);
405 de_fault (to_remove_breakpoint,
406 memory_remove_breakpoint);
407 de_fault (to_terminal_init,
410 de_fault (to_terminal_inferior,
413 de_fault (to_terminal_ours_for_output,
416 de_fault (to_terminal_ours,
419 de_fault (to_terminal_info,
420 default_terminal_info);
425 (void (*) (char *, int))
427 de_fault (to_lookup_symbol,
428 (int (*) (char *, CORE_ADDR *))
430 de_fault (to_create_inferior,
431 maybe_kill_then_create_inferior);
432 de_fault (to_post_startup_inferior,
435 de_fault (to_acknowledge_created_inferior,
438 de_fault (to_clone_and_follow_inferior,
439 default_clone_and_follow_inferior);
440 de_fault (to_post_follow_inferior_by_clone,
443 de_fault (to_insert_fork_catchpoint,
446 de_fault (to_remove_fork_catchpoint,
449 de_fault (to_insert_vfork_catchpoint,
452 de_fault (to_remove_vfork_catchpoint,
455 de_fault (to_has_forked,
456 (int (*) (int, int *))
458 de_fault (to_has_vforked,
459 (int (*) (int, int *))
461 de_fault (to_can_follow_vfork_prior_to_exec,
464 de_fault (to_post_follow_vfork,
465 (void (*) (int, int, int, int))
467 de_fault (to_insert_exec_catchpoint,
470 de_fault (to_remove_exec_catchpoint,
473 de_fault (to_has_execd,
474 (int (*) (int, char **))
476 de_fault (to_reported_exec_events_per_exec_call,
479 de_fault (to_has_syscall_event,
480 (int (*) (int, enum target_waitkind *, int *))
482 de_fault (to_has_exited,
483 (int (*) (int, int, int *))
485 de_fault (to_mourn_inferior,
488 de_fault (to_can_run,
490 de_fault (to_notice_signals,
493 de_fault (to_thread_alive,
496 de_fault (to_find_new_threads,
499 de_fault (to_extra_thread_info,
500 (char *(*) (struct thread_info *))
506 (int (*) (int, char *, char *, int *))
509 (void (*) (char *, struct ui_file *))
511 de_fault (to_enable_exception_callback,
512 (struct symtab_and_line * (*) (enum exception_event_kind, int))
514 de_fault (to_get_current_exception_event,
515 (struct exception_event_record * (*) (void))
517 de_fault (to_pid_to_exec_file,
520 de_fault (to_core_file_to_sym_file,
523 de_fault (to_can_async_p,
526 de_fault (to_is_async_p,
530 (void (*) (void (*) (enum inferior_event_type, void*), void*))
535 /* Go through the target stack from top to bottom, copying over zero entries in
536 current_target. In effect, we are doing class inheritance through the
537 pushed target vectors. */
540 update_current_target ()
542 struct target_stack_item *item;
543 struct target_ops *t;
545 /* First, reset current_target */
546 memset (¤t_target, 0, sizeof current_target);
548 for (item = target_stack; item; item = item->next)
550 t = item->target_ops;
552 #define INHERIT(FIELD, TARGET) \
553 if (!current_target.FIELD) \
554 current_target.FIELD = TARGET->FIELD
556 INHERIT (to_shortname, t);
557 INHERIT (to_longname, t);
559 INHERIT (to_open, t);
560 INHERIT (to_close, t);
561 INHERIT (to_attach, t);
562 INHERIT (to_post_attach, t);
563 INHERIT (to_require_attach, t);
564 INHERIT (to_detach, t);
565 INHERIT (to_require_detach, t);
566 INHERIT (to_resume, t);
567 INHERIT (to_wait, t);
568 INHERIT (to_post_wait, t);
569 INHERIT (to_fetch_registers, t);
570 INHERIT (to_store_registers, t);
571 INHERIT (to_prepare_to_store, t);
572 INHERIT (to_xfer_memory, t);
573 INHERIT (to_files_info, t);
574 INHERIT (to_insert_breakpoint, t);
575 INHERIT (to_remove_breakpoint, t);
576 INHERIT (to_terminal_init, t);
577 INHERIT (to_terminal_inferior, t);
578 INHERIT (to_terminal_ours_for_output, t);
579 INHERIT (to_terminal_ours, t);
580 INHERIT (to_terminal_info, t);
581 INHERIT (to_kill, t);
582 INHERIT (to_load, t);
583 INHERIT (to_lookup_symbol, t);
584 INHERIT (to_create_inferior, t);
585 INHERIT (to_post_startup_inferior, t);
586 INHERIT (to_acknowledge_created_inferior, t);
587 INHERIT (to_clone_and_follow_inferior, t);
588 INHERIT (to_post_follow_inferior_by_clone, t);
589 INHERIT (to_insert_fork_catchpoint, t);
590 INHERIT (to_remove_fork_catchpoint, t);
591 INHERIT (to_insert_vfork_catchpoint, t);
592 INHERIT (to_remove_vfork_catchpoint, t);
593 INHERIT (to_has_forked, t);
594 INHERIT (to_has_vforked, t);
595 INHERIT (to_can_follow_vfork_prior_to_exec, t);
596 INHERIT (to_post_follow_vfork, t);
597 INHERIT (to_insert_exec_catchpoint, t);
598 INHERIT (to_remove_exec_catchpoint, t);
599 INHERIT (to_has_execd, t);
600 INHERIT (to_reported_exec_events_per_exec_call, t);
601 INHERIT (to_has_syscall_event, t);
602 INHERIT (to_has_exited, t);
603 INHERIT (to_mourn_inferior, t);
604 INHERIT (to_can_run, t);
605 INHERIT (to_notice_signals, t);
606 INHERIT (to_thread_alive, t);
607 INHERIT (to_find_new_threads, t);
608 INHERIT (to_pid_to_str, t);
609 INHERIT (to_extra_thread_info, t);
610 INHERIT (to_stop, t);
611 INHERIT (to_query, t);
612 INHERIT (to_rcmd, t);
613 INHERIT (to_enable_exception_callback, t);
614 INHERIT (to_get_current_exception_event, t);
615 INHERIT (to_pid_to_exec_file, t);
616 INHERIT (to_core_file_to_sym_file, t);
617 INHERIT (to_stratum, t);
618 INHERIT (DONT_USE, t);
619 INHERIT (to_has_all_memory, t);
620 INHERIT (to_has_memory, t);
621 INHERIT (to_has_stack, t);
622 INHERIT (to_has_registers, t);
623 INHERIT (to_has_execution, t);
624 INHERIT (to_has_thread_control, t);
625 INHERIT (to_sections, t);
626 INHERIT (to_sections_end, t);
627 INHERIT (to_can_async_p, t);
628 INHERIT (to_is_async_p, t);
629 INHERIT (to_async, t);
630 INHERIT (to_async_mask_value, t);
631 INHERIT (to_magic, t);
637 /* Push a new target type into the stack of the existing target accessors,
638 possibly superseding some of the existing accessors.
640 Result is zero if the pushed target ended up on top of the stack,
641 nonzero if at least one target is on top of it.
643 Rather than allow an empty stack, we always have the dummy target at
644 the bottom stratum, so we can call the function vectors without
649 struct target_ops *t;
651 struct target_stack_item *cur, *prev, *tmp;
653 /* Check magic number. If wrong, it probably means someone changed
654 the struct definition, but not all the places that initialize one. */
655 if (t->to_magic != OPS_MAGIC)
657 fprintf_unfiltered (gdb_stderr,
658 "Magic number of %s target struct wrong\n",
663 /* Find the proper stratum to install this target in. */
665 for (prev = NULL, cur = target_stack; cur; prev = cur, cur = cur->next)
667 if ((int) (t->to_stratum) >= (int) (cur->target_ops->to_stratum))
671 /* If there's already targets at this stratum, remove them. */
674 while (t->to_stratum == cur->target_ops->to_stratum)
676 /* There's already something on this stratum. Close it off. */
677 if (cur->target_ops->to_close)
678 (cur->target_ops->to_close) (0);
680 prev->next = cur->next; /* Unchain old target_ops */
682 target_stack = cur->next; /* Unchain first on list */
688 /* We have removed all targets in our stratum, now add the new one. */
690 tmp = (struct target_stack_item *)
691 xmalloc (sizeof (struct target_stack_item));
700 update_current_target ();
702 cleanup_target (¤t_target); /* Fill in the gaps */
705 setup_target_debug ();
710 /* Remove a target_ops vector from the stack, wherever it may be.
711 Return how many times it was removed (0 or 1). */
715 struct target_ops *t;
717 struct target_stack_item *cur, *prev;
720 t->to_close (0); /* Let it clean up */
722 /* Look for the specified target. Note that we assume that a target
723 can only occur once in the target stack. */
725 for (cur = target_stack, prev = NULL; cur; prev = cur, cur = cur->next)
726 if (cur->target_ops == t)
730 return 0; /* Didn't find target_ops, quit now */
732 /* Unchain the target */
735 target_stack = cur->next;
737 prev->next = cur->next;
739 free (cur); /* Release the target_stack_item */
741 update_current_target ();
742 cleanup_target (¤t_target);
750 (current_target.to_close) (0); /* Let it clean up */
751 if (unpush_target (target_stack->target_ops) == 1)
754 fprintf_unfiltered (gdb_stderr,
755 "pop_target couldn't find target %s\n",
756 current_target.to_shortname);
761 #define MIN(A, B) (((A) <= (B)) ? (A) : (B))
763 /* target_read_string -- read a null terminated string, up to LEN bytes,
764 from MEMADDR in target. Set *ERRNOP to the errno code, or 0 if successful.
765 Set *STRING to a pointer to malloc'd memory containing the data; the caller
766 is responsible for freeing it. Return the number of bytes successfully
770 target_read_string (memaddr, string, len, errnop)
776 int tlen, origlen, offset, i;
780 int buffer_allocated;
782 unsigned int nbytes_read = 0;
784 /* Small for testing. */
785 buffer_allocated = 4;
786 buffer = xmalloc (buffer_allocated);
793 tlen = MIN (len, 4 - (memaddr & 3));
794 offset = memaddr & 3;
796 errcode = target_xfer_memory (memaddr & ~3, buf, 4, 0);
799 /* The transfer request might have crossed the boundary to an
800 unallocated region of memory. Retry the transfer, requesting
804 errcode = target_xfer_memory (memaddr, buf, 1, 0);
809 if (bufptr - buffer + tlen > buffer_allocated)
812 bytes = bufptr - buffer;
813 buffer_allocated *= 2;
814 buffer = xrealloc (buffer, buffer_allocated);
815 bufptr = buffer + bytes;
818 for (i = 0; i < tlen; i++)
820 *bufptr++ = buf[i + offset];
821 if (buf[i + offset] == '\000')
823 nbytes_read += i + 1;
840 /* Read LEN bytes of target memory at address MEMADDR, placing the results in
841 GDB's memory at MYADDR. Returns either 0 for success or an errno value
844 If an error occurs, no guarantee is made about the contents of the data at
845 MYADDR. In particular, the caller should not depend upon partial reads
846 filling the buffer with good data. There is no way for the caller to know
847 how much good data might have been transfered anyway. Callers that can
848 deal with partial reads should call target_read_memory_partial. */
851 target_read_memory (memaddr, myaddr, len)
856 return target_xfer_memory (memaddr, myaddr, len, 0);
860 target_write_memory (memaddr, myaddr, len)
865 return target_xfer_memory (memaddr, myaddr, len, 1);
868 /* Move memory to or from the targets. Iterate until all of it has
869 been moved, if necessary. The top target gets priority; anything
870 it doesn't want, is offered to the next one down, etc. Note the
871 business with curlen: if an early target says "no, but I have a
872 boundary overlapping this xfer" then we shorten what we offer to
873 the subsequent targets so the early guy will get a chance at the
874 tail before the subsequent ones do.
876 Result is 0 or errno value. */
879 target_xfer_memory (memaddr, myaddr, len, write)
887 struct target_ops *t;
888 struct target_stack_item *item;
890 /* Zero length requests are ok and require no work. */
894 /* to_xfer_memory is not guaranteed to set errno, even when it returns
898 /* The quick case is that the top target does it all. */
899 res = current_target.to_xfer_memory
900 (memaddr, myaddr, len, write, ¤t_target);
906 /* If res <= 0 then we call it again in the loop. Ah well. */
910 curlen = len; /* Want to do it all */
911 for (item = target_stack; item; item = item->next)
913 t = item->target_ops;
914 if (!t->to_has_memory)
917 res = t->to_xfer_memory (memaddr, myaddr, curlen, write, t);
919 break; /* Handled all or part of xfer */
920 if (t->to_has_all_memory)
926 /* If this address is for nonexistent memory,
927 read zeros if reading, or do nothing if writing. Return error. */
929 memset (myaddr, 0, len);
940 return 0; /* We managed to cover it all somehow. */
944 /* Perform a partial memory transfer. */
947 target_xfer_memory_partial (CORE_ADDR memaddr, char *buf, int len,
948 int write_p, int *err)
953 struct target_ops *t;
954 struct target_stack_item *item;
956 /* Zero length requests are ok and require no work. */
963 /* The quick case is that the top target does it all. */
964 res = current_target.to_xfer_memory (memaddr, buf, len, write_p, ¤t_target);
971 /* xfer memory doesn't always reliably set errno. */
974 /* Try all levels of the target stack to see one can handle it. */
975 for (item = target_stack; item; item = item->next)
977 t = item->target_ops;
978 if (!t->to_has_memory)
980 res = t->to_xfer_memory (memaddr, buf, len, write_p, t);
983 /* Handled all or part of xfer */
987 if (t->to_has_all_memory)
991 /* Total failure. Return error. */
1002 target_read_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err)
1004 return target_xfer_memory_partial (memaddr, buf, len, 0, err);
1008 target_write_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err)
1010 return target_xfer_memory_partial (memaddr, buf, len, 1, err);
1015 target_info (args, from_tty)
1019 struct target_ops *t;
1020 struct target_stack_item *item;
1021 int has_all_mem = 0;
1023 if (symfile_objfile != NULL)
1024 printf_unfiltered ("Symbols from \"%s\".\n", symfile_objfile->name);
1026 #ifdef FILES_INFO_HOOK
1027 if (FILES_INFO_HOOK ())
1031 for (item = target_stack; item; item = item->next)
1033 t = item->target_ops;
1035 if (!t->to_has_memory)
1038 if ((int) (t->to_stratum) <= (int) dummy_stratum)
1041 printf_unfiltered ("\tWhile running this, GDB does not access memory from...\n");
1042 printf_unfiltered ("%s:\n", t->to_longname);
1043 (t->to_files_info) (t);
1044 has_all_mem = t->to_has_all_memory;
1048 /* This is to be called by the open routine before it does
1052 target_preopen (from_tty)
1057 if (target_has_execution)
1060 || query ("A program is being debugged already. Kill it? "))
1063 error ("Program not killed.");
1066 /* Calling target_kill may remove the target from the stack. But if
1067 it doesn't (which seems like a win for UDI), remove it now. */
1069 if (target_has_execution)
1073 /* Detach a target after doing deferred register stores. */
1076 target_detach (args, from_tty)
1080 /* Handle any optimized stores to the inferior. */
1081 #ifdef DO_DEFERRED_STORES
1084 (current_target.to_detach) (args, from_tty);
1088 target_link (modname, t_reloc)
1092 if (STREQ (current_target.to_shortname, "rombug"))
1094 (current_target.to_lookup_symbol) (modname, t_reloc);
1096 error ("Unable to link to %s and get relocation in rombug", modname);
1099 *t_reloc = (CORE_ADDR) -1;
1103 target_async_mask (int mask)
1105 int saved_async_masked_status = target_async_mask_value;
1106 target_async_mask_value = mask;
1107 return saved_async_masked_status;
1110 /* Look through the list of possible targets for a target that can
1111 execute a run or attach command without any other data. This is
1112 used to locate the default process stratum.
1114 Result is always valid (error() is called for errors). */
1116 static struct target_ops *
1117 find_default_run_target (do_mesg)
1120 struct target_ops **t;
1121 struct target_ops *runable = NULL;
1126 for (t = target_structs; t < target_structs + target_struct_size;
1129 if ((*t)->to_can_run && target_can_run (*t))
1137 error ("Don't know how to %s. Try \"help target\".", do_mesg);
1143 find_default_attach (args, from_tty)
1147 struct target_ops *t;
1149 t = find_default_run_target ("attach");
1150 (t->to_attach) (args, from_tty);
1155 find_default_require_attach (args, from_tty)
1159 struct target_ops *t;
1161 t = find_default_run_target ("require_attach");
1162 (t->to_require_attach) (args, from_tty);
1167 find_default_require_detach (pid, args, from_tty)
1172 struct target_ops *t;
1174 t = find_default_run_target ("require_detach");
1175 (t->to_require_detach) (pid, args, from_tty);
1180 find_default_create_inferior (exec_file, allargs, env)
1185 struct target_ops *t;
1187 t = find_default_run_target ("run");
1188 (t->to_create_inferior) (exec_file, allargs, env);
1193 find_default_clone_and_follow_inferior (child_pid, followed_child)
1195 int *followed_child;
1197 struct target_ops *t;
1199 t = find_default_run_target ("run");
1200 (t->to_clone_and_follow_inferior) (child_pid, followed_child);
1217 * Resize the to_sections pointer. Also make sure that anyone that
1218 * was holding on to an old value of it gets updated.
1219 * Returns the old size.
1223 target_resize_to_sections (struct target_ops *target, int num_added)
1225 struct target_ops **t;
1226 struct section_table *old_value;
1229 old_value = target->to_sections;
1231 if (target->to_sections)
1233 old_count = target->to_sections_end - target->to_sections;
1234 target->to_sections = (struct section_table *)
1235 xrealloc ((char *) target->to_sections,
1236 (sizeof (struct section_table)) * (num_added + old_count));
1241 target->to_sections = (struct section_table *)
1242 xmalloc ((sizeof (struct section_table)) * num_added);
1244 target->to_sections_end = target->to_sections + (num_added + old_count);
1246 /* Check to see if anyone else was pointing to this structure.
1247 If old_value was null, then no one was. */
1251 for (t = target_structs; t < target_structs + target_struct_size;
1254 if ((*t)->to_sections == old_value)
1256 (*t)->to_sections = target->to_sections;
1257 (*t)->to_sections_end = target->to_sections_end;
1266 /* Remove all target sections taken from ABFD.
1268 Scan the current target stack for targets whose section tables
1269 refer to sections from BFD, and remove those sections. We use this
1270 when we notice that the inferior has unloaded a shared object, for
1273 remove_target_sections (bfd *abfd)
1275 struct target_ops **t;
1277 for (t = target_structs; t < target_structs + target_struct_size; t++)
1279 struct section_table *src, *dest;
1281 dest = (*t)->to_sections;
1282 for (src = (*t)->to_sections; src < (*t)->to_sections_end; src++)
1283 if (src->bfd != abfd)
1285 /* Keep this section. */
1286 if (dest < src) *dest = *src;
1290 /* If we've dropped any sections, resize the section table. */
1292 target_resize_to_sections (*t, dest - src);
1299 /* Find a single runnable target in the stack and return it. If for
1300 some reason there is more than one, return NULL. */
1305 struct target_ops **t;
1306 struct target_ops *runable = NULL;
1311 for (t = target_structs; t < target_structs + target_struct_size; ++t)
1313 if ((*t)->to_can_run && target_can_run (*t))
1320 return (count == 1 ? runable : NULL);
1323 /* Find a single core_stratum target in the list of targets and return it.
1324 If for some reason there is more than one, return NULL. */
1329 struct target_ops **t;
1330 struct target_ops *runable = NULL;
1335 for (t = target_structs; t < target_structs + target_struct_size;
1338 if ((*t)->to_stratum == core_stratum)
1345 return (count == 1 ? runable : NULL);
1349 * Find the next target down the stack from the specified target.
1353 find_target_beneath (t)
1354 struct target_ops *t;
1356 struct target_stack_item *cur;
1358 for (cur = target_stack; cur; cur = cur->next)
1359 if (cur->target_ops == t)
1362 if (cur == NULL || cur->next == NULL)
1365 return cur->next->target_ops;
1369 /* The inferior process has died. Long live the inferior! */
1372 generic_mourn_inferior ()
1374 extern int show_breakpoint_hit_counts;
1378 breakpoint_init_inferior (inf_exited);
1379 registers_changed ();
1381 #ifdef CLEAR_DEFERRED_STORES
1382 /* Delete any pending stores to the inferior... */
1383 CLEAR_DEFERRED_STORES;
1386 reopen_exec_file ();
1387 reinit_frame_cache ();
1389 /* It is confusing to the user for ignore counts to stick around
1390 from previous runs of the inferior. So clear them. */
1391 /* However, it is more confusing for the ignore counts to disappear when
1392 using hit counts. So don't clear them if we're counting hits. */
1393 if (!show_breakpoint_hit_counts)
1394 breakpoint_clear_ignore_counts ();
1397 /* This table must match in order and size the signals in enum target_signal
1406 {"SIGHUP", "Hangup"},
1407 {"SIGINT", "Interrupt"},
1408 {"SIGQUIT", "Quit"},
1409 {"SIGILL", "Illegal instruction"},
1410 {"SIGTRAP", "Trace/breakpoint trap"},
1411 {"SIGABRT", "Aborted"},
1412 {"SIGEMT", "Emulation trap"},
1413 {"SIGFPE", "Arithmetic exception"},
1414 {"SIGKILL", "Killed"},
1415 {"SIGBUS", "Bus error"},
1416 {"SIGSEGV", "Segmentation fault"},
1417 {"SIGSYS", "Bad system call"},
1418 {"SIGPIPE", "Broken pipe"},
1419 {"SIGALRM", "Alarm clock"},
1420 {"SIGTERM", "Terminated"},
1421 {"SIGURG", "Urgent I/O condition"},
1422 {"SIGSTOP", "Stopped (signal)"},
1423 {"SIGTSTP", "Stopped (user)"},
1424 {"SIGCONT", "Continued"},
1425 {"SIGCHLD", "Child status changed"},
1426 {"SIGTTIN", "Stopped (tty input)"},
1427 {"SIGTTOU", "Stopped (tty output)"},
1428 {"SIGIO", "I/O possible"},
1429 {"SIGXCPU", "CPU time limit exceeded"},
1430 {"SIGXFSZ", "File size limit exceeded"},
1431 {"SIGVTALRM", "Virtual timer expired"},
1432 {"SIGPROF", "Profiling timer expired"},
1433 {"SIGWINCH", "Window size changed"},
1434 {"SIGLOST", "Resource lost"},
1435 {"SIGUSR1", "User defined signal 1"},
1436 {"SIGUSR2", "User defined signal 2"},
1437 {"SIGPWR", "Power fail/restart"},
1438 {"SIGPOLL", "Pollable event occurred"},
1439 {"SIGWIND", "SIGWIND"},
1440 {"SIGPHONE", "SIGPHONE"},
1441 {"SIGWAITING", "Process's LWPs are blocked"},
1442 {"SIGLWP", "Signal LWP"},
1443 {"SIGDANGER", "Swap space dangerously low"},
1444 {"SIGGRANT", "Monitor mode granted"},
1445 {"SIGRETRACT", "Need to relinquish monitor mode"},
1446 {"SIGMSG", "Monitor mode data available"},
1447 {"SIGSOUND", "Sound completed"},
1448 {"SIGSAK", "Secure attention"},
1449 {"SIGPRIO", "SIGPRIO"},
1450 {"SIG33", "Real-time event 33"},
1451 {"SIG34", "Real-time event 34"},
1452 {"SIG35", "Real-time event 35"},
1453 {"SIG36", "Real-time event 36"},
1454 {"SIG37", "Real-time event 37"},
1455 {"SIG38", "Real-time event 38"},
1456 {"SIG39", "Real-time event 39"},
1457 {"SIG40", "Real-time event 40"},
1458 {"SIG41", "Real-time event 41"},
1459 {"SIG42", "Real-time event 42"},
1460 {"SIG43", "Real-time event 43"},
1461 {"SIG44", "Real-time event 44"},
1462 {"SIG45", "Real-time event 45"},
1463 {"SIG46", "Real-time event 46"},
1464 {"SIG47", "Real-time event 47"},
1465 {"SIG48", "Real-time event 48"},
1466 {"SIG49", "Real-time event 49"},
1467 {"SIG50", "Real-time event 50"},
1468 {"SIG51", "Real-time event 51"},
1469 {"SIG52", "Real-time event 52"},
1470 {"SIG53", "Real-time event 53"},
1471 {"SIG54", "Real-time event 54"},
1472 {"SIG55", "Real-time event 55"},
1473 {"SIG56", "Real-time event 56"},
1474 {"SIG57", "Real-time event 57"},
1475 {"SIG58", "Real-time event 58"},
1476 {"SIG59", "Real-time event 59"},
1477 {"SIG60", "Real-time event 60"},
1478 {"SIG61", "Real-time event 61"},
1479 {"SIG62", "Real-time event 62"},
1480 {"SIG63", "Real-time event 63"},
1481 {"SIGCANCEL", "LWP internal signal"},
1482 {"SIG32", "Real-time event 32"},
1484 #if defined(MACH) || defined(__MACH__)
1485 /* Mach exceptions */
1486 {"EXC_BAD_ACCESS", "Could not access memory"},
1487 {"EXC_BAD_INSTRUCTION", "Illegal instruction/operand"},
1488 {"EXC_ARITHMETIC", "Arithmetic exception"},
1489 {"EXC_EMULATION", "Emulation instruction"},
1490 {"EXC_SOFTWARE", "Software generated exception"},
1491 {"EXC_BREAKPOINT", "Breakpoint"},
1493 {"SIGINFO", "Information request"},
1495 {NULL, "Unknown signal"},
1496 {NULL, "Internal error: printing TARGET_SIGNAL_DEFAULT"},
1498 /* Last entry, used to check whether the table is the right size. */
1499 {NULL, "TARGET_SIGNAL_MAGIC"}
1505 /* Return the string for a signal. */
1507 target_signal_to_string (sig)
1508 enum target_signal sig;
1510 if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST))
1511 return signals[sig].string;
1513 return signals[TARGET_SIGNAL_UNKNOWN].string;
1516 /* Return the name for a signal. */
1518 target_signal_to_name (sig)
1519 enum target_signal sig;
1521 if (sig == TARGET_SIGNAL_UNKNOWN)
1522 /* I think the code which prints this will always print it along with
1523 the string, so no need to be verbose. */
1525 return signals[sig].name;
1528 /* Given a name, return its signal. */
1530 target_signal_from_name (name)
1533 enum target_signal sig;
1535 /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
1536 for TARGET_SIGNAL_SIGCHLD. SIGIOT, on the other hand, is more
1537 questionable; seems like by now people should call it SIGABRT
1540 /* This ugly cast brought to you by the native VAX compiler. */
1541 for (sig = TARGET_SIGNAL_HUP;
1542 signals[sig].name != NULL;
1543 sig = (enum target_signal) ((int) sig + 1))
1544 if (STREQ (name, signals[sig].name))
1546 return TARGET_SIGNAL_UNKNOWN;
1549 /* The following functions are to help certain targets deal
1550 with the signal/waitstatus stuff. They could just as well be in
1551 a file called native-utils.c or unixwaitstatus-utils.c or whatever. */
1553 /* Convert host signal to our signals. */
1555 target_signal_from_host (hostsig)
1558 /* A switch statement would make sense but would require special kludges
1559 to deal with the cases where more than one signal has the same number. */
1562 return TARGET_SIGNAL_0;
1564 #if defined (SIGHUP)
1565 if (hostsig == SIGHUP)
1566 return TARGET_SIGNAL_HUP;
1568 #if defined (SIGINT)
1569 if (hostsig == SIGINT)
1570 return TARGET_SIGNAL_INT;
1572 #if defined (SIGQUIT)
1573 if (hostsig == SIGQUIT)
1574 return TARGET_SIGNAL_QUIT;
1576 #if defined (SIGILL)
1577 if (hostsig == SIGILL)
1578 return TARGET_SIGNAL_ILL;
1580 #if defined (SIGTRAP)
1581 if (hostsig == SIGTRAP)
1582 return TARGET_SIGNAL_TRAP;
1584 #if defined (SIGABRT)
1585 if (hostsig == SIGABRT)
1586 return TARGET_SIGNAL_ABRT;
1588 #if defined (SIGEMT)
1589 if (hostsig == SIGEMT)
1590 return TARGET_SIGNAL_EMT;
1592 #if defined (SIGFPE)
1593 if (hostsig == SIGFPE)
1594 return TARGET_SIGNAL_FPE;
1596 #if defined (SIGKILL)
1597 if (hostsig == SIGKILL)
1598 return TARGET_SIGNAL_KILL;
1600 #if defined (SIGBUS)
1601 if (hostsig == SIGBUS)
1602 return TARGET_SIGNAL_BUS;
1604 #if defined (SIGSEGV)
1605 if (hostsig == SIGSEGV)
1606 return TARGET_SIGNAL_SEGV;
1608 #if defined (SIGSYS)
1609 if (hostsig == SIGSYS)
1610 return TARGET_SIGNAL_SYS;
1612 #if defined (SIGPIPE)
1613 if (hostsig == SIGPIPE)
1614 return TARGET_SIGNAL_PIPE;
1616 #if defined (SIGALRM)
1617 if (hostsig == SIGALRM)
1618 return TARGET_SIGNAL_ALRM;
1620 #if defined (SIGTERM)
1621 if (hostsig == SIGTERM)
1622 return TARGET_SIGNAL_TERM;
1624 #if defined (SIGUSR1)
1625 if (hostsig == SIGUSR1)
1626 return TARGET_SIGNAL_USR1;
1628 #if defined (SIGUSR2)
1629 if (hostsig == SIGUSR2)
1630 return TARGET_SIGNAL_USR2;
1632 #if defined (SIGCLD)
1633 if (hostsig == SIGCLD)
1634 return TARGET_SIGNAL_CHLD;
1636 #if defined (SIGCHLD)
1637 if (hostsig == SIGCHLD)
1638 return TARGET_SIGNAL_CHLD;
1640 #if defined (SIGPWR)
1641 if (hostsig == SIGPWR)
1642 return TARGET_SIGNAL_PWR;
1644 #if defined (SIGWINCH)
1645 if (hostsig == SIGWINCH)
1646 return TARGET_SIGNAL_WINCH;
1648 #if defined (SIGURG)
1649 if (hostsig == SIGURG)
1650 return TARGET_SIGNAL_URG;
1653 if (hostsig == SIGIO)
1654 return TARGET_SIGNAL_IO;
1656 #if defined (SIGPOLL)
1657 if (hostsig == SIGPOLL)
1658 return TARGET_SIGNAL_POLL;
1660 #if defined (SIGSTOP)
1661 if (hostsig == SIGSTOP)
1662 return TARGET_SIGNAL_STOP;
1664 #if defined (SIGTSTP)
1665 if (hostsig == SIGTSTP)
1666 return TARGET_SIGNAL_TSTP;
1668 #if defined (SIGCONT)
1669 if (hostsig == SIGCONT)
1670 return TARGET_SIGNAL_CONT;
1672 #if defined (SIGTTIN)
1673 if (hostsig == SIGTTIN)
1674 return TARGET_SIGNAL_TTIN;
1676 #if defined (SIGTTOU)
1677 if (hostsig == SIGTTOU)
1678 return TARGET_SIGNAL_TTOU;
1680 #if defined (SIGVTALRM)
1681 if (hostsig == SIGVTALRM)
1682 return TARGET_SIGNAL_VTALRM;
1684 #if defined (SIGPROF)
1685 if (hostsig == SIGPROF)
1686 return TARGET_SIGNAL_PROF;
1688 #if defined (SIGXCPU)
1689 if (hostsig == SIGXCPU)
1690 return TARGET_SIGNAL_XCPU;
1692 #if defined (SIGXFSZ)
1693 if (hostsig == SIGXFSZ)
1694 return TARGET_SIGNAL_XFSZ;
1696 #if defined (SIGWIND)
1697 if (hostsig == SIGWIND)
1698 return TARGET_SIGNAL_WIND;
1700 #if defined (SIGPHONE)
1701 if (hostsig == SIGPHONE)
1702 return TARGET_SIGNAL_PHONE;
1704 #if defined (SIGLOST)
1705 if (hostsig == SIGLOST)
1706 return TARGET_SIGNAL_LOST;
1708 #if defined (SIGWAITING)
1709 if (hostsig == SIGWAITING)
1710 return TARGET_SIGNAL_WAITING;
1712 #if defined (SIGCANCEL)
1713 if (hostsig == SIGCANCEL)
1714 return TARGET_SIGNAL_CANCEL;
1716 #if defined (SIGLWP)
1717 if (hostsig == SIGLWP)
1718 return TARGET_SIGNAL_LWP;
1720 #if defined (SIGDANGER)
1721 if (hostsig == SIGDANGER)
1722 return TARGET_SIGNAL_DANGER;
1724 #if defined (SIGGRANT)
1725 if (hostsig == SIGGRANT)
1726 return TARGET_SIGNAL_GRANT;
1728 #if defined (SIGRETRACT)
1729 if (hostsig == SIGRETRACT)
1730 return TARGET_SIGNAL_RETRACT;
1732 #if defined (SIGMSG)
1733 if (hostsig == SIGMSG)
1734 return TARGET_SIGNAL_MSG;
1736 #if defined (SIGSOUND)
1737 if (hostsig == SIGSOUND)
1738 return TARGET_SIGNAL_SOUND;
1740 #if defined (SIGSAK)
1741 if (hostsig == SIGSAK)
1742 return TARGET_SIGNAL_SAK;
1744 #if defined (SIGPRIO)
1745 if (hostsig == SIGPRIO)
1746 return TARGET_SIGNAL_PRIO;
1749 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1750 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1751 if (hostsig == _NSIG + EXC_BAD_ACCESS)
1752 return TARGET_EXC_BAD_ACCESS;
1754 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
1755 if (hostsig == _NSIG + EXC_BAD_INSTRUCTION)
1756 return TARGET_EXC_BAD_INSTRUCTION;
1758 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
1759 if (hostsig == _NSIG + EXC_ARITHMETIC)
1760 return TARGET_EXC_ARITHMETIC;
1762 #if defined (EXC_EMULATION) && defined (_NSIG)
1763 if (hostsig == _NSIG + EXC_EMULATION)
1764 return TARGET_EXC_EMULATION;
1766 #if defined (EXC_SOFTWARE) && defined (_NSIG)
1767 if (hostsig == _NSIG + EXC_SOFTWARE)
1768 return TARGET_EXC_SOFTWARE;
1770 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
1771 if (hostsig == _NSIG + EXC_BREAKPOINT)
1772 return TARGET_EXC_BREAKPOINT;
1775 #if defined (SIGINFO)
1776 if (hostsig == SIGINFO)
1777 return TARGET_SIGNAL_INFO;
1780 #if defined (REALTIME_LO)
1781 if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI)
1783 /* This block of TARGET_SIGNAL_REALTIME value is in order. */
1784 if (33 <= hostsig && hostsig <= 63)
1785 return (enum target_signal)
1786 (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
1787 else if (hostsig == 32)
1788 return TARGET_SIGNAL_REALTIME_32;
1790 error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
1793 return TARGET_SIGNAL_UNKNOWN;
1796 /* Convert a OURSIG (an enum target_signal) to the form used by the
1797 target operating system (refered to as the ``host'') or zero if the
1798 equivalent host signal is not available. Set/clear OURSIG_OK
1802 do_target_signal_to_host (enum target_signal oursig,
1808 case TARGET_SIGNAL_0:
1811 #if defined (SIGHUP)
1812 case TARGET_SIGNAL_HUP:
1815 #if defined (SIGINT)
1816 case TARGET_SIGNAL_INT:
1819 #if defined (SIGQUIT)
1820 case TARGET_SIGNAL_QUIT:
1823 #if defined (SIGILL)
1824 case TARGET_SIGNAL_ILL:
1827 #if defined (SIGTRAP)
1828 case TARGET_SIGNAL_TRAP:
1831 #if defined (SIGABRT)
1832 case TARGET_SIGNAL_ABRT:
1835 #if defined (SIGEMT)
1836 case TARGET_SIGNAL_EMT:
1839 #if defined (SIGFPE)
1840 case TARGET_SIGNAL_FPE:
1843 #if defined (SIGKILL)
1844 case TARGET_SIGNAL_KILL:
1847 #if defined (SIGBUS)
1848 case TARGET_SIGNAL_BUS:
1851 #if defined (SIGSEGV)
1852 case TARGET_SIGNAL_SEGV:
1855 #if defined (SIGSYS)
1856 case TARGET_SIGNAL_SYS:
1859 #if defined (SIGPIPE)
1860 case TARGET_SIGNAL_PIPE:
1863 #if defined (SIGALRM)
1864 case TARGET_SIGNAL_ALRM:
1867 #if defined (SIGTERM)
1868 case TARGET_SIGNAL_TERM:
1871 #if defined (SIGUSR1)
1872 case TARGET_SIGNAL_USR1:
1875 #if defined (SIGUSR2)
1876 case TARGET_SIGNAL_USR2:
1879 #if defined (SIGCHLD) || defined (SIGCLD)
1880 case TARGET_SIGNAL_CHLD:
1881 #if defined (SIGCHLD)
1886 #endif /* SIGCLD or SIGCHLD */
1887 #if defined (SIGPWR)
1888 case TARGET_SIGNAL_PWR:
1891 #if defined (SIGWINCH)
1892 case TARGET_SIGNAL_WINCH:
1895 #if defined (SIGURG)
1896 case TARGET_SIGNAL_URG:
1900 case TARGET_SIGNAL_IO:
1903 #if defined (SIGPOLL)
1904 case TARGET_SIGNAL_POLL:
1907 #if defined (SIGSTOP)
1908 case TARGET_SIGNAL_STOP:
1911 #if defined (SIGTSTP)
1912 case TARGET_SIGNAL_TSTP:
1915 #if defined (SIGCONT)
1916 case TARGET_SIGNAL_CONT:
1919 #if defined (SIGTTIN)
1920 case TARGET_SIGNAL_TTIN:
1923 #if defined (SIGTTOU)
1924 case TARGET_SIGNAL_TTOU:
1927 #if defined (SIGVTALRM)
1928 case TARGET_SIGNAL_VTALRM:
1931 #if defined (SIGPROF)
1932 case TARGET_SIGNAL_PROF:
1935 #if defined (SIGXCPU)
1936 case TARGET_SIGNAL_XCPU:
1939 #if defined (SIGXFSZ)
1940 case TARGET_SIGNAL_XFSZ:
1943 #if defined (SIGWIND)
1944 case TARGET_SIGNAL_WIND:
1947 #if defined (SIGPHONE)
1948 case TARGET_SIGNAL_PHONE:
1951 #if defined (SIGLOST)
1952 case TARGET_SIGNAL_LOST:
1955 #if defined (SIGWAITING)
1956 case TARGET_SIGNAL_WAITING:
1959 #if defined (SIGCANCEL)
1960 case TARGET_SIGNAL_CANCEL:
1963 #if defined (SIGLWP)
1964 case TARGET_SIGNAL_LWP:
1967 #if defined (SIGDANGER)
1968 case TARGET_SIGNAL_DANGER:
1971 #if defined (SIGGRANT)
1972 case TARGET_SIGNAL_GRANT:
1975 #if defined (SIGRETRACT)
1976 case TARGET_SIGNAL_RETRACT:
1979 #if defined (SIGMSG)
1980 case TARGET_SIGNAL_MSG:
1983 #if defined (SIGSOUND)
1984 case TARGET_SIGNAL_SOUND:
1987 #if defined (SIGSAK)
1988 case TARGET_SIGNAL_SAK:
1991 #if defined (SIGPRIO)
1992 case TARGET_SIGNAL_PRIO:
1996 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1997 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1998 case TARGET_EXC_BAD_ACCESS:
1999 return _NSIG + EXC_BAD_ACCESS;
2001 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
2002 case TARGET_EXC_BAD_INSTRUCTION:
2003 return _NSIG + EXC_BAD_INSTRUCTION;
2005 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
2006 case TARGET_EXC_ARITHMETIC:
2007 return _NSIG + EXC_ARITHMETIC;
2009 #if defined (EXC_EMULATION) && defined (_NSIG)
2010 case TARGET_EXC_EMULATION:
2011 return _NSIG + EXC_EMULATION;
2013 #if defined (EXC_SOFTWARE) && defined (_NSIG)
2014 case TARGET_EXC_SOFTWARE:
2015 return _NSIG + EXC_SOFTWARE;
2017 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
2018 case TARGET_EXC_BREAKPOINT:
2019 return _NSIG + EXC_BREAKPOINT;
2022 #if defined (SIGINFO)
2023 case TARGET_SIGNAL_INFO:
2028 #if defined (REALTIME_LO)
2029 if (oursig >= TARGET_SIGNAL_REALTIME_33
2030 && oursig <= TARGET_SIGNAL_REALTIME_63)
2032 /* This block of signals is continuous, and
2033 TARGET_SIGNAL_REALTIME_33 is 33 by definition. */
2035 (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
2036 if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
2039 #if (REALTIME_LO < 33)
2040 else if (oursig == TARGET_SIGNAL_REALTIME_32)
2042 /* TARGET_SIGNAL_REALTIME_32 isn't contiguous with
2043 TARGET_SIGNAL_REALTIME_33. It is 32 by definition. */
2054 target_signal_to_host_p (enum target_signal oursig)
2057 do_target_signal_to_host (oursig, &oursig_ok);
2062 target_signal_to_host (enum target_signal oursig)
2065 int targ_signo = do_target_signal_to_host (oursig, &oursig_ok);
2068 /* The user might be trying to do "signal SIGSAK" where this system
2069 doesn't have SIGSAK. */
2070 warning ("Signal %s does not exist on this system.\n",
2071 target_signal_to_name (oursig));
2078 /* Helper function for child_wait and the Lynx derivatives of child_wait.
2079 HOSTSTATUS is the waitstatus from wait() or the equivalent; store our
2080 translation of that in OURSTATUS. */
2082 store_waitstatus (ourstatus, hoststatus)
2083 struct target_waitstatus *ourstatus;
2086 #ifdef CHILD_SPECIAL_WAITSTATUS
2087 /* CHILD_SPECIAL_WAITSTATUS should return nonzero and set *OURSTATUS
2088 if it wants to deal with hoststatus. */
2089 if (CHILD_SPECIAL_WAITSTATUS (ourstatus, hoststatus))
2093 if (WIFEXITED (hoststatus))
2095 ourstatus->kind = TARGET_WAITKIND_EXITED;
2096 ourstatus->value.integer = WEXITSTATUS (hoststatus);
2098 else if (!WIFSTOPPED (hoststatus))
2100 ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
2101 ourstatus->value.sig = target_signal_from_host (WTERMSIG (hoststatus));
2105 ourstatus->kind = TARGET_WAITKIND_STOPPED;
2106 ourstatus->value.sig = target_signal_from_host (WSTOPSIG (hoststatus));
2110 /* In some circumstances we allow a command to specify a numeric
2111 signal. The idea is to keep these circumstances limited so that
2112 users (and scripts) develop portable habits. For comparison,
2113 POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a
2114 numeric signal at all is obscelescent. We are slightly more
2115 lenient and allow 1-15 which should match host signal numbers on
2116 most systems. Use of symbolic signal names is strongly encouraged. */
2119 target_signal_from_command (num)
2122 if (num >= 1 && num <= 15)
2123 return (enum target_signal) num;
2124 error ("Only signals 1-15 are valid as numeric signals.\n\
2125 Use \"info signals\" for a list of symbolic signals.");
2128 /* Returns zero to leave the inferior alone, one to interrupt it. */
2129 int (*target_activity_function) (void);
2130 int target_activity_fd;
2132 /* Convert a normal process ID to a string. Returns the string in a static
2136 normal_pid_to_str (pid)
2139 static char buf[30];
2141 if (STREQ (current_target.to_shortname, "remote"))
2142 sprintf (buf, "thread %d", pid);
2144 sprintf (buf, "process %d", pid);
2149 /* Some targets (such as ttrace-based HPUX) don't allow us to request
2150 notification of inferior events such as fork and vork immediately
2151 after the inferior is created. (This because of how gdb gets an
2152 inferior created via invoking a shell to do it. In such a scenario,
2153 if the shell init file has commands in it, the shell will fork and
2154 exec for each of those commands, and we will see each such fork
2157 This function is used by all targets that allow us to request
2158 notification of forks, etc at inferior creation time; e.g., in
2159 target_acknowledge_forked_child.
2162 normal_target_post_startup_inferior (pid)
2165 /* This space intentionally left blank. */
2168 /* Set up the handful of non-empty slots needed by the dummy target
2172 init_dummy_target ()
2174 dummy_target.to_shortname = "None";
2175 dummy_target.to_longname = "None";
2176 dummy_target.to_doc = "";
2177 dummy_target.to_attach = find_default_attach;
2178 dummy_target.to_require_attach = find_default_require_attach;
2179 dummy_target.to_require_detach = find_default_require_detach;
2180 dummy_target.to_create_inferior = find_default_create_inferior;
2181 dummy_target.to_clone_and_follow_inferior = find_default_clone_and_follow_inferior;
2182 dummy_target.to_pid_to_str = normal_pid_to_str;
2183 dummy_target.to_stratum = dummy_stratum;
2184 dummy_target.to_magic = OPS_MAGIC;
2188 static struct target_ops debug_target;
2191 debug_to_open (args, from_tty)
2195 debug_target.to_open (args, from_tty);
2197 fprintf_unfiltered (gdb_stdlog, "target_open (%s, %d)\n", args, from_tty);
2201 debug_to_close (quitting)
2204 debug_target.to_close (quitting);
2206 fprintf_unfiltered (gdb_stdlog, "target_close (%d)\n", quitting);
2210 debug_to_attach (args, from_tty)
2214 debug_target.to_attach (args, from_tty);
2216 fprintf_unfiltered (gdb_stdlog, "target_attach (%s, %d)\n", args, from_tty);
2221 debug_to_post_attach (pid)
2224 debug_target.to_post_attach (pid);
2226 fprintf_unfiltered (gdb_stdlog, "target_post_attach (%d)\n", pid);
2230 debug_to_require_attach (args, from_tty)
2234 debug_target.to_require_attach (args, from_tty);
2236 fprintf_unfiltered (gdb_stdlog,
2237 "target_require_attach (%s, %d)\n", args, from_tty);
2241 debug_to_detach (args, from_tty)
2245 debug_target.to_detach (args, from_tty);
2247 fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n", args, from_tty);
2251 debug_to_require_detach (pid, args, from_tty)
2256 debug_target.to_require_detach (pid, args, from_tty);
2258 fprintf_unfiltered (gdb_stdlog,
2259 "target_require_detach (%d, %s, %d)\n", pid, args, from_tty);
2263 debug_to_resume (pid, step, siggnal)
2266 enum target_signal siggnal;
2268 debug_target.to_resume (pid, step, siggnal);
2270 fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n", pid,
2271 step ? "step" : "continue",
2272 target_signal_to_name (siggnal));
2276 debug_to_wait (pid, status)
2278 struct target_waitstatus *status;
2282 retval = debug_target.to_wait (pid, status);
2284 fprintf_unfiltered (gdb_stdlog,
2285 "target_wait (%d, status) = %d, ", pid, retval);
2286 fprintf_unfiltered (gdb_stdlog, "status->kind = ");
2287 switch (status->kind)
2289 case TARGET_WAITKIND_EXITED:
2290 fprintf_unfiltered (gdb_stdlog, "exited, status = %d\n",
2291 status->value.integer);
2293 case TARGET_WAITKIND_STOPPED:
2294 fprintf_unfiltered (gdb_stdlog, "stopped, signal = %s\n",
2295 target_signal_to_name (status->value.sig));
2297 case TARGET_WAITKIND_SIGNALLED:
2298 fprintf_unfiltered (gdb_stdlog, "signalled, signal = %s\n",
2299 target_signal_to_name (status->value.sig));
2301 case TARGET_WAITKIND_LOADED:
2302 fprintf_unfiltered (gdb_stdlog, "loaded\n");
2304 case TARGET_WAITKIND_FORKED:
2305 fprintf_unfiltered (gdb_stdlog, "forked\n");
2307 case TARGET_WAITKIND_VFORKED:
2308 fprintf_unfiltered (gdb_stdlog, "vforked\n");
2310 case TARGET_WAITKIND_EXECD:
2311 fprintf_unfiltered (gdb_stdlog, "execd\n");
2313 case TARGET_WAITKIND_SPURIOUS:
2314 fprintf_unfiltered (gdb_stdlog, "spurious\n");
2317 fprintf_unfiltered (gdb_stdlog, "unknown???\n");
2325 debug_to_post_wait (pid, status)
2329 debug_target.to_post_wait (pid, status);
2331 fprintf_unfiltered (gdb_stdlog, "target_post_wait (%d, %d)\n",
2336 debug_to_fetch_registers (regno)
2339 debug_target.to_fetch_registers (regno);
2341 fprintf_unfiltered (gdb_stdlog, "target_fetch_registers (%s)",
2342 regno != -1 ? REGISTER_NAME (regno) : "-1");
2344 fprintf_unfiltered (gdb_stdlog, " = 0x%lx %ld",
2345 (unsigned long) read_register (regno),
2346 (unsigned long) read_register (regno));
2347 fprintf_unfiltered (gdb_stdlog, "\n");
2351 debug_to_store_registers (regno)
2354 debug_target.to_store_registers (regno);
2356 if (regno >= 0 && regno < NUM_REGS)
2357 fprintf_unfiltered (gdb_stdlog, "target_store_registers (%s) = 0x%lx %ld\n",
2358 REGISTER_NAME (regno),
2359 (unsigned long) read_register (regno),
2360 (unsigned long) read_register (regno));
2362 fprintf_unfiltered (gdb_stdlog, "target_store_registers (%d)\n", regno);
2366 debug_to_prepare_to_store ()
2368 debug_target.to_prepare_to_store ();
2370 fprintf_unfiltered (gdb_stdlog, "target_prepare_to_store ()\n");
2374 debug_to_xfer_memory (memaddr, myaddr, len, write, target)
2379 struct target_ops *target;
2383 retval = debug_target.to_xfer_memory (memaddr, myaddr, len, write, target);
2385 fprintf_unfiltered (gdb_stdlog,
2386 "target_xfer_memory (0x%x, xxx, %d, %s, xxx) = %d",
2387 (unsigned int) memaddr, /* possable truncate long long */
2388 len, write ? "write" : "read", retval);
2396 fputs_unfiltered (", bytes =", gdb_stdlog);
2397 for (i = 0; i < retval; i++)
2399 if ((((long) &(myaddr[i])) & 0xf) == 0)
2400 fprintf_unfiltered (gdb_stdlog, "\n");
2401 fprintf_unfiltered (gdb_stdlog, " %02x", myaddr[i] & 0xff);
2405 fputc_unfiltered ('\n', gdb_stdlog);
2411 debug_to_files_info (target)
2412 struct target_ops *target;
2414 debug_target.to_files_info (target);
2416 fprintf_unfiltered (gdb_stdlog, "target_files_info (xxx)\n");
2420 debug_to_insert_breakpoint (addr, save)
2426 retval = debug_target.to_insert_breakpoint (addr, save);
2428 fprintf_unfiltered (gdb_stdlog,
2429 "target_insert_breakpoint (0x%lx, xxx) = %ld\n",
2430 (unsigned long) addr,
2431 (unsigned long) retval);
2436 debug_to_remove_breakpoint (addr, save)
2442 retval = debug_target.to_remove_breakpoint (addr, save);
2444 fprintf_unfiltered (gdb_stdlog,
2445 "target_remove_breakpoint (0x%lx, xxx) = %ld\n",
2446 (unsigned long) addr,
2447 (unsigned long) retval);
2452 debug_to_terminal_init ()
2454 debug_target.to_terminal_init ();
2456 fprintf_unfiltered (gdb_stdlog, "target_terminal_init ()\n");
2460 debug_to_terminal_inferior ()
2462 debug_target.to_terminal_inferior ();
2464 fprintf_unfiltered (gdb_stdlog, "target_terminal_inferior ()\n");
2468 debug_to_terminal_ours_for_output ()
2470 debug_target.to_terminal_ours_for_output ();
2472 fprintf_unfiltered (gdb_stdlog, "target_terminal_ours_for_output ()\n");
2476 debug_to_terminal_ours ()
2478 debug_target.to_terminal_ours ();
2480 fprintf_unfiltered (gdb_stdlog, "target_terminal_ours ()\n");
2484 debug_to_terminal_info (arg, from_tty)
2488 debug_target.to_terminal_info (arg, from_tty);
2490 fprintf_unfiltered (gdb_stdlog, "target_terminal_info (%s, %d)\n", arg,
2497 debug_target.to_kill ();
2499 fprintf_unfiltered (gdb_stdlog, "target_kill ()\n");
2503 debug_to_load (args, from_tty)
2507 debug_target.to_load (args, from_tty);
2509 fprintf_unfiltered (gdb_stdlog, "target_load (%s, %d)\n", args, from_tty);
2513 debug_to_lookup_symbol (name, addrp)
2519 retval = debug_target.to_lookup_symbol (name, addrp);
2521 fprintf_unfiltered (gdb_stdlog, "target_lookup_symbol (%s, xxx)\n", name);
2527 debug_to_create_inferior (exec_file, args, env)
2532 debug_target.to_create_inferior (exec_file, args, env);
2534 fprintf_unfiltered (gdb_stdlog, "target_create_inferior (%s, %s, xxx)\n",
2539 debug_to_post_startup_inferior (pid)
2542 debug_target.to_post_startup_inferior (pid);
2544 fprintf_unfiltered (gdb_stdlog, "target_post_startup_inferior (%d)\n",
2549 debug_to_acknowledge_created_inferior (pid)
2552 debug_target.to_acknowledge_created_inferior (pid);
2554 fprintf_unfiltered (gdb_stdlog, "target_acknowledge_created_inferior (%d)\n",
2559 debug_to_clone_and_follow_inferior (child_pid, followed_child)
2561 int *followed_child;
2563 debug_target.to_clone_and_follow_inferior (child_pid, followed_child);
2565 fprintf_unfiltered (gdb_stdlog,
2566 "target_clone_and_follow_inferior (%d, %d)\n",
2567 child_pid, *followed_child);
2571 debug_to_post_follow_inferior_by_clone ()
2573 debug_target.to_post_follow_inferior_by_clone ();
2575 fprintf_unfiltered (gdb_stdlog, "target_post_follow_inferior_by_clone ()\n");
2579 debug_to_insert_fork_catchpoint (pid)
2584 retval = debug_target.to_insert_fork_catchpoint (pid);
2586 fprintf_unfiltered (gdb_stdlog, "target_insert_fork_catchpoint (%d) = %d\n",
2593 debug_to_remove_fork_catchpoint (pid)
2598 retval = debug_target.to_remove_fork_catchpoint (pid);
2600 fprintf_unfiltered (gdb_stdlog, "target_remove_fork_catchpoint (%d) = %d\n",
2607 debug_to_insert_vfork_catchpoint (pid)
2612 retval = debug_target.to_insert_vfork_catchpoint (pid);
2614 fprintf_unfiltered (gdb_stdlog, "target_insert_vfork_catchpoint (%d)= %d\n",
2621 debug_to_remove_vfork_catchpoint (pid)
2626 retval = debug_target.to_remove_vfork_catchpoint (pid);
2628 fprintf_unfiltered (gdb_stdlog, "target_remove_vfork_catchpoint (%d) = %d\n",
2635 debug_to_has_forked (pid, child_pid)
2641 has_forked = debug_target.to_has_forked (pid, child_pid);
2643 fprintf_unfiltered (gdb_stdlog, "target_has_forked (%d, %d) = %d\n",
2644 pid, *child_pid, has_forked);
2650 debug_to_has_vforked (pid, child_pid)
2656 has_vforked = debug_target.to_has_vforked (pid, child_pid);
2658 fprintf_unfiltered (gdb_stdlog, "target_has_vforked (%d, %d) = %d\n",
2659 pid, *child_pid, has_vforked);
2665 debug_to_can_follow_vfork_prior_to_exec ()
2667 int can_immediately_follow_vfork;
2669 can_immediately_follow_vfork = debug_target.to_can_follow_vfork_prior_to_exec ();
2671 fprintf_unfiltered (gdb_stdlog, "target_can_follow_vfork_prior_to_exec () = %d\n",
2672 can_immediately_follow_vfork);
2674 return can_immediately_follow_vfork;
2678 debug_to_post_follow_vfork (parent_pid, followed_parent, child_pid, followed_child)
2680 int followed_parent;
2684 debug_target.to_post_follow_vfork (parent_pid, followed_parent, child_pid, followed_child);
2686 fprintf_unfiltered (gdb_stdlog,
2687 "target_post_follow_vfork (%d, %d, %d, %d)\n",
2688 parent_pid, followed_parent, child_pid, followed_child);
2692 debug_to_insert_exec_catchpoint (pid)
2697 retval = debug_target.to_insert_exec_catchpoint (pid);
2699 fprintf_unfiltered (gdb_stdlog, "target_insert_exec_catchpoint (%d) = %d\n",
2706 debug_to_remove_exec_catchpoint (pid)
2711 retval = debug_target.to_remove_exec_catchpoint (pid);
2713 fprintf_unfiltered (gdb_stdlog, "target_remove_exec_catchpoint (%d) = %d\n",
2720 debug_to_has_execd (pid, execd_pathname)
2722 char **execd_pathname;
2726 has_execd = debug_target.to_has_execd (pid, execd_pathname);
2728 fprintf_unfiltered (gdb_stdlog, "target_has_execd (%d, %s) = %d\n",
2729 pid, (*execd_pathname ? *execd_pathname : "<NULL>"),
2736 debug_to_reported_exec_events_per_exec_call ()
2738 int reported_exec_events;
2740 reported_exec_events = debug_target.to_reported_exec_events_per_exec_call ();
2742 fprintf_unfiltered (gdb_stdlog,
2743 "target_reported_exec_events_per_exec_call () = %d\n",
2744 reported_exec_events);
2746 return reported_exec_events;
2750 debug_to_has_syscall_event (pid, kind, syscall_id)
2752 enum target_waitkind *kind;
2755 int has_syscall_event;
2756 char *kind_spelling = "??";
2758 has_syscall_event = debug_target.to_has_syscall_event (pid, kind, syscall_id);
2759 if (has_syscall_event)
2763 case TARGET_WAITKIND_SYSCALL_ENTRY:
2764 kind_spelling = "SYSCALL_ENTRY";
2766 case TARGET_WAITKIND_SYSCALL_RETURN:
2767 kind_spelling = "SYSCALL_RETURN";
2774 fprintf_unfiltered (gdb_stdlog,
2775 "target_has_syscall_event (%d, %s, %d) = %d\n",
2776 pid, kind_spelling, *syscall_id, has_syscall_event);
2778 return has_syscall_event;
2782 debug_to_has_exited (pid, wait_status, exit_status)
2789 has_exited = debug_target.to_has_exited (pid, wait_status, exit_status);
2791 fprintf_unfiltered (gdb_stdlog, "target_has_exited (%d, %d, %d) = %d\n",
2792 pid, wait_status, *exit_status, has_exited);
2798 debug_to_mourn_inferior ()
2800 debug_target.to_mourn_inferior ();
2802 fprintf_unfiltered (gdb_stdlog, "target_mourn_inferior ()\n");
2810 retval = debug_target.to_can_run ();
2812 fprintf_unfiltered (gdb_stdlog, "target_can_run () = %d\n", retval);
2818 debug_to_notice_signals (pid)
2821 debug_target.to_notice_signals (pid);
2823 fprintf_unfiltered (gdb_stdlog, "target_notice_signals (%d)\n", pid);
2827 debug_to_thread_alive (pid)
2832 retval = debug_target.to_thread_alive (pid);
2834 fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n",
2841 debug_to_find_new_threads ()
2843 debug_target.to_find_new_threads ();
2845 fputs_unfiltered ("target_find_new_threads ()\n", gdb_stdlog);
2851 debug_target.to_stop ();
2853 fprintf_unfiltered (gdb_stdlog, "target_stop ()\n");
2857 debug_to_query (type, req, resp, siz)
2865 retval = debug_target.to_query (type, req, resp, siz);
2867 fprintf_unfiltered (gdb_stdlog, "target_query (%c, %s, %s, %d) = %d\n", type, req, resp, *siz, retval);
2873 debug_to_rcmd (char *command,
2874 struct ui_file *outbuf)
2876 debug_target.to_rcmd (command, outbuf);
2877 fprintf_unfiltered (gdb_stdlog, "target_rcmd (%s, ...)\n", command);
2880 static struct symtab_and_line *
2881 debug_to_enable_exception_callback (kind, enable)
2882 enum exception_event_kind kind;
2885 struct symtab_and_line *result;
2886 result = debug_target.to_enable_exception_callback (kind, enable);
2887 fprintf_unfiltered (gdb_stdlog,
2888 "target get_exception_callback_sal (%d, %d)\n",
2893 static struct exception_event_record *
2894 debug_to_get_current_exception_event ()
2896 struct exception_event_record *result;
2897 result = debug_target.to_get_current_exception_event ();
2898 fprintf_unfiltered (gdb_stdlog, "target get_current_exception_event ()\n");
2903 debug_to_pid_to_exec_file (pid)
2908 exec_file = debug_target.to_pid_to_exec_file (pid);
2910 fprintf_unfiltered (gdb_stdlog, "target_pid_to_exec_file (%d) = %s\n",
2917 debug_to_core_file_to_sym_file (core)
2922 sym_file = debug_target.to_core_file_to_sym_file (core);
2924 fprintf_unfiltered (gdb_stdlog, "target_core_file_to_sym_file (%s) = %s\n",
2931 setup_target_debug ()
2933 memcpy (&debug_target, ¤t_target, sizeof debug_target);
2935 current_target.to_open = debug_to_open;
2936 current_target.to_close = debug_to_close;
2937 current_target.to_attach = debug_to_attach;
2938 current_target.to_post_attach = debug_to_post_attach;
2939 current_target.to_require_attach = debug_to_require_attach;
2940 current_target.to_detach = debug_to_detach;
2941 current_target.to_require_detach = debug_to_require_detach;
2942 current_target.to_resume = debug_to_resume;
2943 current_target.to_wait = debug_to_wait;
2944 current_target.to_post_wait = debug_to_post_wait;
2945 current_target.to_fetch_registers = debug_to_fetch_registers;
2946 current_target.to_store_registers = debug_to_store_registers;
2947 current_target.to_prepare_to_store = debug_to_prepare_to_store;
2948 current_target.to_xfer_memory = debug_to_xfer_memory;
2949 current_target.to_files_info = debug_to_files_info;
2950 current_target.to_insert_breakpoint = debug_to_insert_breakpoint;
2951 current_target.to_remove_breakpoint = debug_to_remove_breakpoint;
2952 current_target.to_terminal_init = debug_to_terminal_init;
2953 current_target.to_terminal_inferior = debug_to_terminal_inferior;
2954 current_target.to_terminal_ours_for_output = debug_to_terminal_ours_for_output;
2955 current_target.to_terminal_ours = debug_to_terminal_ours;
2956 current_target.to_terminal_info = debug_to_terminal_info;
2957 current_target.to_kill = debug_to_kill;
2958 current_target.to_load = debug_to_load;
2959 current_target.to_lookup_symbol = debug_to_lookup_symbol;
2960 current_target.to_create_inferior = debug_to_create_inferior;
2961 current_target.to_post_startup_inferior = debug_to_post_startup_inferior;
2962 current_target.to_acknowledge_created_inferior = debug_to_acknowledge_created_inferior;
2963 current_target.to_clone_and_follow_inferior = debug_to_clone_and_follow_inferior;
2964 current_target.to_post_follow_inferior_by_clone = debug_to_post_follow_inferior_by_clone;
2965 current_target.to_insert_fork_catchpoint = debug_to_insert_fork_catchpoint;
2966 current_target.to_remove_fork_catchpoint = debug_to_remove_fork_catchpoint;
2967 current_target.to_insert_vfork_catchpoint = debug_to_insert_vfork_catchpoint;
2968 current_target.to_remove_vfork_catchpoint = debug_to_remove_vfork_catchpoint;
2969 current_target.to_has_forked = debug_to_has_forked;
2970 current_target.to_has_vforked = debug_to_has_vforked;
2971 current_target.to_can_follow_vfork_prior_to_exec = debug_to_can_follow_vfork_prior_to_exec;
2972 current_target.to_post_follow_vfork = debug_to_post_follow_vfork;
2973 current_target.to_insert_exec_catchpoint = debug_to_insert_exec_catchpoint;
2974 current_target.to_remove_exec_catchpoint = debug_to_remove_exec_catchpoint;
2975 current_target.to_has_execd = debug_to_has_execd;
2976 current_target.to_reported_exec_events_per_exec_call = debug_to_reported_exec_events_per_exec_call;
2977 current_target.to_has_syscall_event = debug_to_has_syscall_event;
2978 current_target.to_has_exited = debug_to_has_exited;
2979 current_target.to_mourn_inferior = debug_to_mourn_inferior;
2980 current_target.to_can_run = debug_to_can_run;
2981 current_target.to_notice_signals = debug_to_notice_signals;
2982 current_target.to_thread_alive = debug_to_thread_alive;
2983 current_target.to_find_new_threads = debug_to_find_new_threads;
2984 current_target.to_stop = debug_to_stop;
2985 current_target.to_query = debug_to_query;
2986 current_target.to_rcmd = debug_to_rcmd;
2987 current_target.to_enable_exception_callback = debug_to_enable_exception_callback;
2988 current_target.to_get_current_exception_event = debug_to_get_current_exception_event;
2989 current_target.to_pid_to_exec_file = debug_to_pid_to_exec_file;
2990 current_target.to_core_file_to_sym_file = debug_to_core_file_to_sym_file;
2995 static char targ_desc[] =
2996 "Names of targets and files being debugged.\n\
2997 Shows the entire stack of targets currently in use (including the exec-file,\n\
2998 core-file, and process, if any), as well as the symbol file name.";
3001 do_monitor_command (char *cmd,
3004 if ((current_target.to_rcmd
3005 == (void (*) (char *, struct ui_file *)) tcomplain)
3006 || (current_target.to_rcmd == debug_to_rcmd
3007 && (debug_target.to_rcmd
3008 == (void (*) (char *, struct ui_file *)) tcomplain)))
3010 error ("\"monitor\" command not supported by this target.\n");
3012 target_rcmd (cmd, gdb_stdtarg);
3016 initialize_targets ()
3018 init_dummy_target ();
3019 push_target (&dummy_target);
3021 add_info ("target", target_info, targ_desc);
3022 add_info ("files", target_info, targ_desc);
3025 add_set_cmd ("target", class_maintenance, var_zinteger,
3026 (char *) &targetdebug,
3027 "Set target debugging.\n\
3028 When non-zero, target debugging is enabled.", &setdebuglist),
3032 add_com ("monitor", class_obscure, do_monitor_command,
3033 "Send a command to the remote monitor (remote targets only).");
3035 if (!STREQ (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC"))