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 (char *arg, int from_tty)
186 fputs_filtered ("Argument required (target name). Try `help target'\n",
190 /* Add a possible target architecture to the list. */
193 add_target (struct target_ops *t)
197 target_struct_allocsize = DEFAULT_ALLOCSIZE;
198 target_structs = (struct target_ops **) xmalloc
199 (target_struct_allocsize * sizeof (*target_structs));
201 if (target_struct_size >= target_struct_allocsize)
203 target_struct_allocsize *= 2;
204 target_structs = (struct target_ops **)
205 xrealloc ((char *) target_structs,
206 target_struct_allocsize * sizeof (*target_structs));
208 target_structs[target_struct_size++] = t;
209 /* cleanup_target (t); */
211 if (targetlist == NULL)
212 add_prefix_cmd ("target", class_run, target_command,
213 "Connect to a target machine or process.\n\
214 The first argument is the type or protocol of the target machine.\n\
215 Remaining arguments are interpreted by the target protocol. For more\n\
216 information on the arguments for a particular protocol, type\n\
217 `help target ' followed by the protocol name.",
218 &targetlist, "target ", 0, &cmdlist);
219 add_cmd (t->to_shortname, no_class, t->to_open, t->to_doc, &targetlist);
230 target_load (char *arg, int from_tty)
232 (*current_target.to_load) (arg, from_tty);
237 nomemory (CORE_ADDR memaddr, char *myaddr, int len, int write,
238 struct target_ops *t)
240 errno = EIO; /* Can't read/write this location */
241 return 0; /* No bytes handled */
247 error ("You can't do that when your target is `%s'",
248 current_target.to_shortname);
254 error ("You can't do that without a process to debug.");
259 nosymbol (char *name, CORE_ADDR *addrp)
261 return 1; /* Symbol does not exist in target env */
266 nosupport_runtime (void)
271 error ("No run-time support for this");
277 default_terminal_info (char *args, int from_tty)
279 printf_unfiltered ("No saved terminal information.\n");
282 /* This is the default target_create_inferior and target_attach function.
283 If the current target is executing, it asks whether to kill it off.
284 If this function returns without calling error(), it has killed off
285 the target, and the operation should be attempted. */
288 kill_or_be_killed (int from_tty)
290 if (target_has_execution)
292 printf_unfiltered ("You are already running a program:\n");
293 target_files_info ();
294 if (query ("Kill it? "))
297 if (target_has_execution)
298 error ("Killing the program did not help.");
303 error ("Program not killed.");
310 maybe_kill_then_attach (char *args, int from_tty)
312 kill_or_be_killed (from_tty);
313 target_attach (args, from_tty);
317 maybe_kill_then_create_inferior (char *exec, char *args, char **env)
319 kill_or_be_killed (0);
320 target_create_inferior (exec, args, env);
324 default_clone_and_follow_inferior (int child_pid, int *followed_child)
326 target_clone_and_follow_inferior (child_pid, followed_child);
329 /* Clean up a target struct so it no longer has any zero pointers in it.
330 We default entries, at least to stubs that print error messages. */
333 cleanup_target (struct target_ops *t)
336 #define de_fault(field, value) \
341 (void (*) (char *, int))
347 maybe_kill_then_attach);
348 de_fault (to_post_attach,
351 de_fault (to_require_attach,
352 maybe_kill_then_attach);
354 (void (*) (char *, int))
356 de_fault (to_require_detach,
357 (void (*) (int, char *, int))
360 (void (*) (int, int, enum target_signal))
363 (int (*) (int, struct target_waitstatus *))
365 de_fault (to_post_wait,
366 (void (*) (int, int))
368 de_fault (to_fetch_registers,
371 de_fault (to_store_registers,
374 de_fault (to_prepare_to_store,
377 de_fault (to_xfer_memory,
378 (int (*) (CORE_ADDR, char *, int, int, struct target_ops *))
380 de_fault (to_files_info,
381 (void (*) (struct target_ops *))
383 de_fault (to_insert_breakpoint,
384 memory_insert_breakpoint);
385 de_fault (to_remove_breakpoint,
386 memory_remove_breakpoint);
387 de_fault (to_terminal_init,
390 de_fault (to_terminal_inferior,
393 de_fault (to_terminal_ours_for_output,
396 de_fault (to_terminal_ours,
399 de_fault (to_terminal_info,
400 default_terminal_info);
405 (void (*) (char *, int))
407 de_fault (to_lookup_symbol,
408 (int (*) (char *, CORE_ADDR *))
410 de_fault (to_create_inferior,
411 maybe_kill_then_create_inferior);
412 de_fault (to_post_startup_inferior,
415 de_fault (to_acknowledge_created_inferior,
418 de_fault (to_clone_and_follow_inferior,
419 default_clone_and_follow_inferior);
420 de_fault (to_post_follow_inferior_by_clone,
423 de_fault (to_insert_fork_catchpoint,
426 de_fault (to_remove_fork_catchpoint,
429 de_fault (to_insert_vfork_catchpoint,
432 de_fault (to_remove_vfork_catchpoint,
435 de_fault (to_has_forked,
436 (int (*) (int, int *))
438 de_fault (to_has_vforked,
439 (int (*) (int, int *))
441 de_fault (to_can_follow_vfork_prior_to_exec,
444 de_fault (to_post_follow_vfork,
445 (void (*) (int, int, int, int))
447 de_fault (to_insert_exec_catchpoint,
450 de_fault (to_remove_exec_catchpoint,
453 de_fault (to_has_execd,
454 (int (*) (int, char **))
456 de_fault (to_reported_exec_events_per_exec_call,
459 de_fault (to_has_syscall_event,
460 (int (*) (int, enum target_waitkind *, int *))
462 de_fault (to_has_exited,
463 (int (*) (int, int, int *))
465 de_fault (to_mourn_inferior,
468 de_fault (to_can_run,
470 de_fault (to_notice_signals,
473 de_fault (to_thread_alive,
476 de_fault (to_find_new_threads,
479 de_fault (to_extra_thread_info,
480 (char *(*) (struct thread_info *))
486 (int (*) (int, char *, char *, int *))
489 (void (*) (char *, struct ui_file *))
491 de_fault (to_enable_exception_callback,
492 (struct symtab_and_line * (*) (enum exception_event_kind, int))
494 de_fault (to_get_current_exception_event,
495 (struct exception_event_record * (*) (void))
497 de_fault (to_pid_to_exec_file,
500 de_fault (to_core_file_to_sym_file,
503 de_fault (to_can_async_p,
506 de_fault (to_is_async_p,
510 (void (*) (void (*) (enum inferior_event_type, void*), void*))
515 /* Go through the target stack from top to bottom, copying over zero entries in
516 current_target. In effect, we are doing class inheritance through the
517 pushed target vectors. */
520 update_current_target (void)
522 struct target_stack_item *item;
523 struct target_ops *t;
525 /* First, reset current_target */
526 memset (¤t_target, 0, sizeof current_target);
528 for (item = target_stack; item; item = item->next)
530 t = item->target_ops;
532 #define INHERIT(FIELD, TARGET) \
533 if (!current_target.FIELD) \
534 current_target.FIELD = TARGET->FIELD
536 INHERIT (to_shortname, t);
537 INHERIT (to_longname, t);
539 INHERIT (to_open, t);
540 INHERIT (to_close, t);
541 INHERIT (to_attach, t);
542 INHERIT (to_post_attach, t);
543 INHERIT (to_require_attach, t);
544 INHERIT (to_detach, t);
545 INHERIT (to_require_detach, t);
546 INHERIT (to_resume, t);
547 INHERIT (to_wait, t);
548 INHERIT (to_post_wait, t);
549 INHERIT (to_fetch_registers, t);
550 INHERIT (to_store_registers, t);
551 INHERIT (to_prepare_to_store, t);
552 INHERIT (to_xfer_memory, t);
553 INHERIT (to_files_info, t);
554 INHERIT (to_insert_breakpoint, t);
555 INHERIT (to_remove_breakpoint, t);
556 INHERIT (to_terminal_init, t);
557 INHERIT (to_terminal_inferior, t);
558 INHERIT (to_terminal_ours_for_output, t);
559 INHERIT (to_terminal_ours, t);
560 INHERIT (to_terminal_info, t);
561 INHERIT (to_kill, t);
562 INHERIT (to_load, t);
563 INHERIT (to_lookup_symbol, t);
564 INHERIT (to_create_inferior, t);
565 INHERIT (to_post_startup_inferior, t);
566 INHERIT (to_acknowledge_created_inferior, t);
567 INHERIT (to_clone_and_follow_inferior, t);
568 INHERIT (to_post_follow_inferior_by_clone, t);
569 INHERIT (to_insert_fork_catchpoint, t);
570 INHERIT (to_remove_fork_catchpoint, t);
571 INHERIT (to_insert_vfork_catchpoint, t);
572 INHERIT (to_remove_vfork_catchpoint, t);
573 INHERIT (to_has_forked, t);
574 INHERIT (to_has_vforked, t);
575 INHERIT (to_can_follow_vfork_prior_to_exec, t);
576 INHERIT (to_post_follow_vfork, t);
577 INHERIT (to_insert_exec_catchpoint, t);
578 INHERIT (to_remove_exec_catchpoint, t);
579 INHERIT (to_has_execd, t);
580 INHERIT (to_reported_exec_events_per_exec_call, t);
581 INHERIT (to_has_syscall_event, t);
582 INHERIT (to_has_exited, t);
583 INHERIT (to_mourn_inferior, t);
584 INHERIT (to_can_run, t);
585 INHERIT (to_notice_signals, t);
586 INHERIT (to_thread_alive, t);
587 INHERIT (to_find_new_threads, t);
588 INHERIT (to_pid_to_str, t);
589 INHERIT (to_extra_thread_info, t);
590 INHERIT (to_stop, t);
591 INHERIT (to_query, t);
592 INHERIT (to_rcmd, t);
593 INHERIT (to_enable_exception_callback, t);
594 INHERIT (to_get_current_exception_event, t);
595 INHERIT (to_pid_to_exec_file, t);
596 INHERIT (to_core_file_to_sym_file, t);
597 INHERIT (to_stratum, t);
598 INHERIT (DONT_USE, t);
599 INHERIT (to_has_all_memory, t);
600 INHERIT (to_has_memory, t);
601 INHERIT (to_has_stack, t);
602 INHERIT (to_has_registers, t);
603 INHERIT (to_has_execution, t);
604 INHERIT (to_has_thread_control, t);
605 INHERIT (to_sections, t);
606 INHERIT (to_sections_end, t);
607 INHERIT (to_can_async_p, t);
608 INHERIT (to_is_async_p, t);
609 INHERIT (to_async, t);
610 INHERIT (to_async_mask_value, t);
611 INHERIT (to_magic, t);
617 /* Push a new target type into the stack of the existing target accessors,
618 possibly superseding some of the existing accessors.
620 Result is zero if the pushed target ended up on top of the stack,
621 nonzero if at least one target is on top of it.
623 Rather than allow an empty stack, we always have the dummy target at
624 the bottom stratum, so we can call the function vectors without
628 push_target (struct target_ops *t)
630 struct target_stack_item *cur, *prev, *tmp;
632 /* Check magic number. If wrong, it probably means someone changed
633 the struct definition, but not all the places that initialize one. */
634 if (t->to_magic != OPS_MAGIC)
636 fprintf_unfiltered (gdb_stderr,
637 "Magic number of %s target struct wrong\n",
642 /* Find the proper stratum to install this target in. */
644 for (prev = NULL, cur = target_stack; cur; prev = cur, cur = cur->next)
646 if ((int) (t->to_stratum) >= (int) (cur->target_ops->to_stratum))
650 /* If there's already targets at this stratum, remove them. */
653 while (t->to_stratum == cur->target_ops->to_stratum)
655 /* There's already something on this stratum. Close it off. */
656 if (cur->target_ops->to_close)
657 (cur->target_ops->to_close) (0);
659 prev->next = cur->next; /* Unchain old target_ops */
661 target_stack = cur->next; /* Unchain first on list */
667 /* We have removed all targets in our stratum, now add the new one. */
669 tmp = (struct target_stack_item *)
670 xmalloc (sizeof (struct target_stack_item));
679 update_current_target ();
681 cleanup_target (¤t_target); /* Fill in the gaps */
684 setup_target_debug ();
689 /* Remove a target_ops vector from the stack, wherever it may be.
690 Return how many times it was removed (0 or 1). */
693 unpush_target (struct target_ops *t)
695 struct target_stack_item *cur, *prev;
698 t->to_close (0); /* Let it clean up */
700 /* Look for the specified target. Note that we assume that a target
701 can only occur once in the target stack. */
703 for (cur = target_stack, prev = NULL; cur; prev = cur, cur = cur->next)
704 if (cur->target_ops == t)
708 return 0; /* Didn't find target_ops, quit now */
710 /* Unchain the target */
713 target_stack = cur->next;
715 prev->next = cur->next;
717 free (cur); /* Release the target_stack_item */
719 update_current_target ();
720 cleanup_target (¤t_target);
728 (current_target.to_close) (0); /* Let it clean up */
729 if (unpush_target (target_stack->target_ops) == 1)
732 fprintf_unfiltered (gdb_stderr,
733 "pop_target couldn't find target %s\n",
734 current_target.to_shortname);
739 #define MIN(A, B) (((A) <= (B)) ? (A) : (B))
741 /* target_read_string -- read a null terminated string, up to LEN bytes,
742 from MEMADDR in target. Set *ERRNOP to the errno code, or 0 if successful.
743 Set *STRING to a pointer to malloc'd memory containing the data; the caller
744 is responsible for freeing it. Return the number of bytes successfully
748 target_read_string (CORE_ADDR memaddr, char **string, int len, int *errnop)
750 int tlen, origlen, offset, i;
754 int buffer_allocated;
756 unsigned int nbytes_read = 0;
758 /* Small for testing. */
759 buffer_allocated = 4;
760 buffer = xmalloc (buffer_allocated);
767 tlen = MIN (len, 4 - (memaddr & 3));
768 offset = memaddr & 3;
770 errcode = target_xfer_memory (memaddr & ~3, buf, 4, 0);
773 /* The transfer request might have crossed the boundary to an
774 unallocated region of memory. Retry the transfer, requesting
778 errcode = target_xfer_memory (memaddr, buf, 1, 0);
783 if (bufptr - buffer + tlen > buffer_allocated)
786 bytes = bufptr - buffer;
787 buffer_allocated *= 2;
788 buffer = xrealloc (buffer, buffer_allocated);
789 bufptr = buffer + bytes;
792 for (i = 0; i < tlen; i++)
794 *bufptr++ = buf[i + offset];
795 if (buf[i + offset] == '\000')
797 nbytes_read += i + 1;
814 /* Read LEN bytes of target memory at address MEMADDR, placing the results in
815 GDB's memory at MYADDR. Returns either 0 for success or an errno value
818 If an error occurs, no guarantee is made about the contents of the data at
819 MYADDR. In particular, the caller should not depend upon partial reads
820 filling the buffer with good data. There is no way for the caller to know
821 how much good data might have been transfered anyway. Callers that can
822 deal with partial reads should call target_read_memory_partial. */
825 target_read_memory (CORE_ADDR memaddr, char *myaddr, int len)
827 return target_xfer_memory (memaddr, myaddr, len, 0);
831 target_write_memory (CORE_ADDR memaddr, char *myaddr, int len)
833 return target_xfer_memory (memaddr, myaddr, len, 1);
836 /* Move memory to or from the targets. Iterate until all of it has
837 been moved, if necessary. The top target gets priority; anything
838 it doesn't want, is offered to the next one down, etc. Note the
839 business with curlen: if an early target says "no, but I have a
840 boundary overlapping this xfer" then we shorten what we offer to
841 the subsequent targets so the early guy will get a chance at the
842 tail before the subsequent ones do.
844 Result is 0 or errno value. */
847 target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
851 struct target_ops *t;
852 struct target_stack_item *item;
854 /* Zero length requests are ok and require no work. */
858 /* to_xfer_memory is not guaranteed to set errno, even when it returns
862 /* The quick case is that the top target does it all. */
863 res = current_target.to_xfer_memory
864 (memaddr, myaddr, len, write, ¤t_target);
870 /* If res <= 0 then we call it again in the loop. Ah well. */
874 curlen = len; /* Want to do it all */
875 for (item = target_stack; item; item = item->next)
877 t = item->target_ops;
878 if (!t->to_has_memory)
881 res = t->to_xfer_memory (memaddr, myaddr, curlen, write, t);
883 break; /* Handled all or part of xfer */
884 if (t->to_has_all_memory)
890 /* If this address is for nonexistent memory,
891 read zeros if reading, or do nothing if writing. Return error. */
893 memset (myaddr, 0, len);
904 return 0; /* We managed to cover it all somehow. */
908 /* Perform a partial memory transfer. */
911 target_xfer_memory_partial (CORE_ADDR memaddr, char *buf, int len,
912 int write_p, int *err)
917 struct target_ops *t;
918 struct target_stack_item *item;
920 /* Zero length requests are ok and require no work. */
927 /* The quick case is that the top target does it all. */
928 res = current_target.to_xfer_memory (memaddr, buf, len, write_p, ¤t_target);
935 /* xfer memory doesn't always reliably set errno. */
938 /* Try all levels of the target stack to see one can handle it. */
939 for (item = target_stack; item; item = item->next)
941 t = item->target_ops;
942 if (!t->to_has_memory)
944 res = t->to_xfer_memory (memaddr, buf, len, write_p, t);
947 /* Handled all or part of xfer */
951 if (t->to_has_all_memory)
955 /* Total failure. Return error. */
966 target_read_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err)
968 return target_xfer_memory_partial (memaddr, buf, len, 0, err);
972 target_write_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err)
974 return target_xfer_memory_partial (memaddr, buf, len, 1, err);
979 target_info (char *args, int from_tty)
981 struct target_ops *t;
982 struct target_stack_item *item;
985 if (symfile_objfile != NULL)
986 printf_unfiltered ("Symbols from \"%s\".\n", symfile_objfile->name);
988 #ifdef FILES_INFO_HOOK
989 if (FILES_INFO_HOOK ())
993 for (item = target_stack; item; item = item->next)
995 t = item->target_ops;
997 if (!t->to_has_memory)
1000 if ((int) (t->to_stratum) <= (int) dummy_stratum)
1003 printf_unfiltered ("\tWhile running this, GDB does not access memory from...\n");
1004 printf_unfiltered ("%s:\n", t->to_longname);
1005 (t->to_files_info) (t);
1006 has_all_mem = t->to_has_all_memory;
1010 /* This is to be called by the open routine before it does
1014 target_preopen (int from_tty)
1018 if (target_has_execution)
1021 || query ("A program is being debugged already. Kill it? "))
1024 error ("Program not killed.");
1027 /* Calling target_kill may remove the target from the stack. But if
1028 it doesn't (which seems like a win for UDI), remove it now. */
1030 if (target_has_execution)
1034 /* Detach a target after doing deferred register stores. */
1037 target_detach (char *args, int from_tty)
1039 /* Handle any optimized stores to the inferior. */
1040 #ifdef DO_DEFERRED_STORES
1043 (current_target.to_detach) (args, from_tty);
1047 target_link (char *modname, CORE_ADDR *t_reloc)
1049 if (STREQ (current_target.to_shortname, "rombug"))
1051 (current_target.to_lookup_symbol) (modname, t_reloc);
1053 error ("Unable to link to %s and get relocation in rombug", modname);
1056 *t_reloc = (CORE_ADDR) -1;
1060 target_async_mask (int mask)
1062 int saved_async_masked_status = target_async_mask_value;
1063 target_async_mask_value = mask;
1064 return saved_async_masked_status;
1067 /* Look through the list of possible targets for a target that can
1068 execute a run or attach command without any other data. This is
1069 used to locate the default process stratum.
1071 Result is always valid (error() is called for errors). */
1073 static struct target_ops *
1074 find_default_run_target (char *do_mesg)
1076 struct target_ops **t;
1077 struct target_ops *runable = NULL;
1082 for (t = target_structs; t < target_structs + target_struct_size;
1085 if ((*t)->to_can_run && target_can_run (*t))
1093 error ("Don't know how to %s. Try \"help target\".", do_mesg);
1099 find_default_attach (char *args, int 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 (char *args, int from_tty)
1111 struct target_ops *t;
1113 t = find_default_run_target ("require_attach");
1114 (t->to_require_attach) (args, from_tty);
1119 find_default_require_detach (int pid, char *args, int from_tty)
1121 struct target_ops *t;
1123 t = find_default_run_target ("require_detach");
1124 (t->to_require_detach) (pid, args, from_tty);
1129 find_default_create_inferior (char *exec_file, char *allargs, char **env)
1131 struct target_ops *t;
1133 t = find_default_run_target ("run");
1134 (t->to_create_inferior) (exec_file, allargs, env);
1139 find_default_clone_and_follow_inferior (int child_pid, int *followed_child)
1141 struct target_ops *t;
1143 t = find_default_run_target ("run");
1144 (t->to_clone_and_follow_inferior) (child_pid, followed_child);
1161 * Resize the to_sections pointer. Also make sure that anyone that
1162 * was holding on to an old value of it gets updated.
1163 * Returns the old size.
1167 target_resize_to_sections (struct target_ops *target, int num_added)
1169 struct target_ops **t;
1170 struct section_table *old_value;
1173 old_value = target->to_sections;
1175 if (target->to_sections)
1177 old_count = target->to_sections_end - target->to_sections;
1178 target->to_sections = (struct section_table *)
1179 xrealloc ((char *) target->to_sections,
1180 (sizeof (struct section_table)) * (num_added + old_count));
1185 target->to_sections = (struct section_table *)
1186 xmalloc ((sizeof (struct section_table)) * num_added);
1188 target->to_sections_end = target->to_sections + (num_added + old_count);
1190 /* Check to see if anyone else was pointing to this structure.
1191 If old_value was null, then no one was. */
1195 for (t = target_structs; t < target_structs + target_struct_size;
1198 if ((*t)->to_sections == old_value)
1200 (*t)->to_sections = target->to_sections;
1201 (*t)->to_sections_end = target->to_sections_end;
1210 /* Remove all target sections taken from ABFD.
1212 Scan the current target stack for targets whose section tables
1213 refer to sections from BFD, and remove those sections. We use this
1214 when we notice that the inferior has unloaded a shared object, for
1217 remove_target_sections (bfd *abfd)
1219 struct target_ops **t;
1221 for (t = target_structs; t < target_structs + target_struct_size; t++)
1223 struct section_table *src, *dest;
1225 dest = (*t)->to_sections;
1226 for (src = (*t)->to_sections; src < (*t)->to_sections_end; src++)
1227 if (src->bfd != abfd)
1229 /* Keep this section. */
1230 if (dest < src) *dest = *src;
1234 /* If we've dropped any sections, resize the section table. */
1236 target_resize_to_sections (*t, dest - src);
1243 /* Find a single runnable target in the stack and return it. If for
1244 some reason there is more than one, return NULL. */
1247 find_run_target (void)
1249 struct target_ops **t;
1250 struct target_ops *runable = NULL;
1255 for (t = target_structs; t < target_structs + target_struct_size; ++t)
1257 if ((*t)->to_can_run && target_can_run (*t))
1264 return (count == 1 ? runable : NULL);
1267 /* Find a single core_stratum target in the list of targets and return it.
1268 If for some reason there is more than one, return NULL. */
1271 find_core_target (void)
1273 struct target_ops **t;
1274 struct target_ops *runable = NULL;
1279 for (t = target_structs; t < target_structs + target_struct_size;
1282 if ((*t)->to_stratum == core_stratum)
1289 return (count == 1 ? runable : NULL);
1293 * Find the next target down the stack from the specified target.
1297 find_target_beneath (struct target_ops *t)
1299 struct target_stack_item *cur;
1301 for (cur = target_stack; cur; cur = cur->next)
1302 if (cur->target_ops == t)
1305 if (cur == NULL || cur->next == NULL)
1308 return cur->next->target_ops;
1312 /* The inferior process has died. Long live the inferior! */
1315 generic_mourn_inferior (void)
1317 extern int show_breakpoint_hit_counts;
1321 breakpoint_init_inferior (inf_exited);
1322 registers_changed ();
1324 #ifdef CLEAR_DEFERRED_STORES
1325 /* Delete any pending stores to the inferior... */
1326 CLEAR_DEFERRED_STORES;
1329 reopen_exec_file ();
1330 reinit_frame_cache ();
1332 /* It is confusing to the user for ignore counts to stick around
1333 from previous runs of the inferior. So clear them. */
1334 /* However, it is more confusing for the ignore counts to disappear when
1335 using hit counts. So don't clear them if we're counting hits. */
1336 if (!show_breakpoint_hit_counts)
1337 breakpoint_clear_ignore_counts ();
1343 /* This table must match in order and size the signals in enum target_signal
1352 {"SIGHUP", "Hangup"},
1353 {"SIGINT", "Interrupt"},
1354 {"SIGQUIT", "Quit"},
1355 {"SIGILL", "Illegal instruction"},
1356 {"SIGTRAP", "Trace/breakpoint trap"},
1357 {"SIGABRT", "Aborted"},
1358 {"SIGEMT", "Emulation trap"},
1359 {"SIGFPE", "Arithmetic exception"},
1360 {"SIGKILL", "Killed"},
1361 {"SIGBUS", "Bus error"},
1362 {"SIGSEGV", "Segmentation fault"},
1363 {"SIGSYS", "Bad system call"},
1364 {"SIGPIPE", "Broken pipe"},
1365 {"SIGALRM", "Alarm clock"},
1366 {"SIGTERM", "Terminated"},
1367 {"SIGURG", "Urgent I/O condition"},
1368 {"SIGSTOP", "Stopped (signal)"},
1369 {"SIGTSTP", "Stopped (user)"},
1370 {"SIGCONT", "Continued"},
1371 {"SIGCHLD", "Child status changed"},
1372 {"SIGTTIN", "Stopped (tty input)"},
1373 {"SIGTTOU", "Stopped (tty output)"},
1374 {"SIGIO", "I/O possible"},
1375 {"SIGXCPU", "CPU time limit exceeded"},
1376 {"SIGXFSZ", "File size limit exceeded"},
1377 {"SIGVTALRM", "Virtual timer expired"},
1378 {"SIGPROF", "Profiling timer expired"},
1379 {"SIGWINCH", "Window size changed"},
1380 {"SIGLOST", "Resource lost"},
1381 {"SIGUSR1", "User defined signal 1"},
1382 {"SIGUSR2", "User defined signal 2"},
1383 {"SIGPWR", "Power fail/restart"},
1384 {"SIGPOLL", "Pollable event occurred"},
1385 {"SIGWIND", "SIGWIND"},
1386 {"SIGPHONE", "SIGPHONE"},
1387 {"SIGWAITING", "Process's LWPs are blocked"},
1388 {"SIGLWP", "Signal LWP"},
1389 {"SIGDANGER", "Swap space dangerously low"},
1390 {"SIGGRANT", "Monitor mode granted"},
1391 {"SIGRETRACT", "Need to relinquish monitor mode"},
1392 {"SIGMSG", "Monitor mode data available"},
1393 {"SIGSOUND", "Sound completed"},
1394 {"SIGSAK", "Secure attention"},
1395 {"SIGPRIO", "SIGPRIO"},
1396 {"SIG33", "Real-time event 33"},
1397 {"SIG34", "Real-time event 34"},
1398 {"SIG35", "Real-time event 35"},
1399 {"SIG36", "Real-time event 36"},
1400 {"SIG37", "Real-time event 37"},
1401 {"SIG38", "Real-time event 38"},
1402 {"SIG39", "Real-time event 39"},
1403 {"SIG40", "Real-time event 40"},
1404 {"SIG41", "Real-time event 41"},
1405 {"SIG42", "Real-time event 42"},
1406 {"SIG43", "Real-time event 43"},
1407 {"SIG44", "Real-time event 44"},
1408 {"SIG45", "Real-time event 45"},
1409 {"SIG46", "Real-time event 46"},
1410 {"SIG47", "Real-time event 47"},
1411 {"SIG48", "Real-time event 48"},
1412 {"SIG49", "Real-time event 49"},
1413 {"SIG50", "Real-time event 50"},
1414 {"SIG51", "Real-time event 51"},
1415 {"SIG52", "Real-time event 52"},
1416 {"SIG53", "Real-time event 53"},
1417 {"SIG54", "Real-time event 54"},
1418 {"SIG55", "Real-time event 55"},
1419 {"SIG56", "Real-time event 56"},
1420 {"SIG57", "Real-time event 57"},
1421 {"SIG58", "Real-time event 58"},
1422 {"SIG59", "Real-time event 59"},
1423 {"SIG60", "Real-time event 60"},
1424 {"SIG61", "Real-time event 61"},
1425 {"SIG62", "Real-time event 62"},
1426 {"SIG63", "Real-time event 63"},
1427 {"SIGCANCEL", "LWP internal signal"},
1428 {"SIG32", "Real-time event 32"},
1430 #if defined(MACH) || defined(__MACH__)
1431 /* Mach exceptions */
1432 {"EXC_BAD_ACCESS", "Could not access memory"},
1433 {"EXC_BAD_INSTRUCTION", "Illegal instruction/operand"},
1434 {"EXC_ARITHMETIC", "Arithmetic exception"},
1435 {"EXC_EMULATION", "Emulation instruction"},
1436 {"EXC_SOFTWARE", "Software generated exception"},
1437 {"EXC_BREAKPOINT", "Breakpoint"},
1439 {"SIGINFO", "Information request"},
1441 {NULL, "Unknown signal"},
1442 {NULL, "Internal error: printing TARGET_SIGNAL_DEFAULT"},
1444 /* Last entry, used to check whether the table is the right size. */
1445 {NULL, "TARGET_SIGNAL_MAGIC"}
1451 /* Return the string for a signal. */
1453 target_signal_to_string (enum target_signal sig)
1455 if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST))
1456 return signals[sig].string;
1458 return signals[TARGET_SIGNAL_UNKNOWN].string;
1461 /* Return the name for a signal. */
1463 target_signal_to_name (enum target_signal sig)
1465 if (sig == TARGET_SIGNAL_UNKNOWN)
1466 /* I think the code which prints this will always print it along with
1467 the string, so no need to be verbose. */
1469 return signals[sig].name;
1472 /* Given a name, return its signal. */
1474 target_signal_from_name (char *name)
1476 enum target_signal sig;
1478 /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
1479 for TARGET_SIGNAL_SIGCHLD. SIGIOT, on the other hand, is more
1480 questionable; seems like by now people should call it SIGABRT
1483 /* This ugly cast brought to you by the native VAX compiler. */
1484 for (sig = TARGET_SIGNAL_HUP;
1485 signals[sig].name != NULL;
1486 sig = (enum target_signal) ((int) sig + 1))
1487 if (STREQ (name, signals[sig].name))
1489 return TARGET_SIGNAL_UNKNOWN;
1492 /* The following functions are to help certain targets deal
1493 with the signal/waitstatus stuff. They could just as well be in
1494 a file called native-utils.c or unixwaitstatus-utils.c or whatever. */
1496 /* Convert host signal to our signals. */
1498 target_signal_from_host (int hostsig)
1500 /* A switch statement would make sense but would require special kludges
1501 to deal with the cases where more than one signal has the same number. */
1504 return TARGET_SIGNAL_0;
1506 #if defined (SIGHUP)
1507 if (hostsig == SIGHUP)
1508 return TARGET_SIGNAL_HUP;
1510 #if defined (SIGINT)
1511 if (hostsig == SIGINT)
1512 return TARGET_SIGNAL_INT;
1514 #if defined (SIGQUIT)
1515 if (hostsig == SIGQUIT)
1516 return TARGET_SIGNAL_QUIT;
1518 #if defined (SIGILL)
1519 if (hostsig == SIGILL)
1520 return TARGET_SIGNAL_ILL;
1522 #if defined (SIGTRAP)
1523 if (hostsig == SIGTRAP)
1524 return TARGET_SIGNAL_TRAP;
1526 #if defined (SIGABRT)
1527 if (hostsig == SIGABRT)
1528 return TARGET_SIGNAL_ABRT;
1530 #if defined (SIGEMT)
1531 if (hostsig == SIGEMT)
1532 return TARGET_SIGNAL_EMT;
1534 #if defined (SIGFPE)
1535 if (hostsig == SIGFPE)
1536 return TARGET_SIGNAL_FPE;
1538 #if defined (SIGKILL)
1539 if (hostsig == SIGKILL)
1540 return TARGET_SIGNAL_KILL;
1542 #if defined (SIGBUS)
1543 if (hostsig == SIGBUS)
1544 return TARGET_SIGNAL_BUS;
1546 #if defined (SIGSEGV)
1547 if (hostsig == SIGSEGV)
1548 return TARGET_SIGNAL_SEGV;
1550 #if defined (SIGSYS)
1551 if (hostsig == SIGSYS)
1552 return TARGET_SIGNAL_SYS;
1554 #if defined (SIGPIPE)
1555 if (hostsig == SIGPIPE)
1556 return TARGET_SIGNAL_PIPE;
1558 #if defined (SIGALRM)
1559 if (hostsig == SIGALRM)
1560 return TARGET_SIGNAL_ALRM;
1562 #if defined (SIGTERM)
1563 if (hostsig == SIGTERM)
1564 return TARGET_SIGNAL_TERM;
1566 #if defined (SIGUSR1)
1567 if (hostsig == SIGUSR1)
1568 return TARGET_SIGNAL_USR1;
1570 #if defined (SIGUSR2)
1571 if (hostsig == SIGUSR2)
1572 return TARGET_SIGNAL_USR2;
1574 #if defined (SIGCLD)
1575 if (hostsig == SIGCLD)
1576 return TARGET_SIGNAL_CHLD;
1578 #if defined (SIGCHLD)
1579 if (hostsig == SIGCHLD)
1580 return TARGET_SIGNAL_CHLD;
1582 #if defined (SIGPWR)
1583 if (hostsig == SIGPWR)
1584 return TARGET_SIGNAL_PWR;
1586 #if defined (SIGWINCH)
1587 if (hostsig == SIGWINCH)
1588 return TARGET_SIGNAL_WINCH;
1590 #if defined (SIGURG)
1591 if (hostsig == SIGURG)
1592 return TARGET_SIGNAL_URG;
1595 if (hostsig == SIGIO)
1596 return TARGET_SIGNAL_IO;
1598 #if defined (SIGPOLL)
1599 if (hostsig == SIGPOLL)
1600 return TARGET_SIGNAL_POLL;
1602 #if defined (SIGSTOP)
1603 if (hostsig == SIGSTOP)
1604 return TARGET_SIGNAL_STOP;
1606 #if defined (SIGTSTP)
1607 if (hostsig == SIGTSTP)
1608 return TARGET_SIGNAL_TSTP;
1610 #if defined (SIGCONT)
1611 if (hostsig == SIGCONT)
1612 return TARGET_SIGNAL_CONT;
1614 #if defined (SIGTTIN)
1615 if (hostsig == SIGTTIN)
1616 return TARGET_SIGNAL_TTIN;
1618 #if defined (SIGTTOU)
1619 if (hostsig == SIGTTOU)
1620 return TARGET_SIGNAL_TTOU;
1622 #if defined (SIGVTALRM)
1623 if (hostsig == SIGVTALRM)
1624 return TARGET_SIGNAL_VTALRM;
1626 #if defined (SIGPROF)
1627 if (hostsig == SIGPROF)
1628 return TARGET_SIGNAL_PROF;
1630 #if defined (SIGXCPU)
1631 if (hostsig == SIGXCPU)
1632 return TARGET_SIGNAL_XCPU;
1634 #if defined (SIGXFSZ)
1635 if (hostsig == SIGXFSZ)
1636 return TARGET_SIGNAL_XFSZ;
1638 #if defined (SIGWIND)
1639 if (hostsig == SIGWIND)
1640 return TARGET_SIGNAL_WIND;
1642 #if defined (SIGPHONE)
1643 if (hostsig == SIGPHONE)
1644 return TARGET_SIGNAL_PHONE;
1646 #if defined (SIGLOST)
1647 if (hostsig == SIGLOST)
1648 return TARGET_SIGNAL_LOST;
1650 #if defined (SIGWAITING)
1651 if (hostsig == SIGWAITING)
1652 return TARGET_SIGNAL_WAITING;
1654 #if defined (SIGCANCEL)
1655 if (hostsig == SIGCANCEL)
1656 return TARGET_SIGNAL_CANCEL;
1658 #if defined (SIGLWP)
1659 if (hostsig == SIGLWP)
1660 return TARGET_SIGNAL_LWP;
1662 #if defined (SIGDANGER)
1663 if (hostsig == SIGDANGER)
1664 return TARGET_SIGNAL_DANGER;
1666 #if defined (SIGGRANT)
1667 if (hostsig == SIGGRANT)
1668 return TARGET_SIGNAL_GRANT;
1670 #if defined (SIGRETRACT)
1671 if (hostsig == SIGRETRACT)
1672 return TARGET_SIGNAL_RETRACT;
1674 #if defined (SIGMSG)
1675 if (hostsig == SIGMSG)
1676 return TARGET_SIGNAL_MSG;
1678 #if defined (SIGSOUND)
1679 if (hostsig == SIGSOUND)
1680 return TARGET_SIGNAL_SOUND;
1682 #if defined (SIGSAK)
1683 if (hostsig == SIGSAK)
1684 return TARGET_SIGNAL_SAK;
1686 #if defined (SIGPRIO)
1687 if (hostsig == SIGPRIO)
1688 return TARGET_SIGNAL_PRIO;
1691 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1692 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1693 if (hostsig == _NSIG + EXC_BAD_ACCESS)
1694 return TARGET_EXC_BAD_ACCESS;
1696 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
1697 if (hostsig == _NSIG + EXC_BAD_INSTRUCTION)
1698 return TARGET_EXC_BAD_INSTRUCTION;
1700 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
1701 if (hostsig == _NSIG + EXC_ARITHMETIC)
1702 return TARGET_EXC_ARITHMETIC;
1704 #if defined (EXC_EMULATION) && defined (_NSIG)
1705 if (hostsig == _NSIG + EXC_EMULATION)
1706 return TARGET_EXC_EMULATION;
1708 #if defined (EXC_SOFTWARE) && defined (_NSIG)
1709 if (hostsig == _NSIG + EXC_SOFTWARE)
1710 return TARGET_EXC_SOFTWARE;
1712 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
1713 if (hostsig == _NSIG + EXC_BREAKPOINT)
1714 return TARGET_EXC_BREAKPOINT;
1717 #if defined (SIGINFO)
1718 if (hostsig == SIGINFO)
1719 return TARGET_SIGNAL_INFO;
1722 #if defined (REALTIME_LO)
1723 if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI)
1725 /* This block of TARGET_SIGNAL_REALTIME value is in order. */
1726 if (33 <= hostsig && hostsig <= 63)
1727 return (enum target_signal)
1728 (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
1729 else if (hostsig == 32)
1730 return TARGET_SIGNAL_REALTIME_32;
1732 error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
1736 #if defined (SIGRTMIN)
1737 if (hostsig >= SIGRTMIN && hostsig <= SIGRTMAX)
1739 /* This block of TARGET_SIGNAL_REALTIME value is in order. */
1740 if (33 <= hostsig && hostsig <= 63)
1741 return (enum target_signal)
1742 (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
1744 error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
1747 return TARGET_SIGNAL_UNKNOWN;
1750 /* Convert a OURSIG (an enum target_signal) to the form used by the
1751 target operating system (refered to as the ``host'') or zero if the
1752 equivalent host signal is not available. Set/clear OURSIG_OK
1756 do_target_signal_to_host (enum target_signal oursig,
1762 case TARGET_SIGNAL_0:
1765 #if defined (SIGHUP)
1766 case TARGET_SIGNAL_HUP:
1769 #if defined (SIGINT)
1770 case TARGET_SIGNAL_INT:
1773 #if defined (SIGQUIT)
1774 case TARGET_SIGNAL_QUIT:
1777 #if defined (SIGILL)
1778 case TARGET_SIGNAL_ILL:
1781 #if defined (SIGTRAP)
1782 case TARGET_SIGNAL_TRAP:
1785 #if defined (SIGABRT)
1786 case TARGET_SIGNAL_ABRT:
1789 #if defined (SIGEMT)
1790 case TARGET_SIGNAL_EMT:
1793 #if defined (SIGFPE)
1794 case TARGET_SIGNAL_FPE:
1797 #if defined (SIGKILL)
1798 case TARGET_SIGNAL_KILL:
1801 #if defined (SIGBUS)
1802 case TARGET_SIGNAL_BUS:
1805 #if defined (SIGSEGV)
1806 case TARGET_SIGNAL_SEGV:
1809 #if defined (SIGSYS)
1810 case TARGET_SIGNAL_SYS:
1813 #if defined (SIGPIPE)
1814 case TARGET_SIGNAL_PIPE:
1817 #if defined (SIGALRM)
1818 case TARGET_SIGNAL_ALRM:
1821 #if defined (SIGTERM)
1822 case TARGET_SIGNAL_TERM:
1825 #if defined (SIGUSR1)
1826 case TARGET_SIGNAL_USR1:
1829 #if defined (SIGUSR2)
1830 case TARGET_SIGNAL_USR2:
1833 #if defined (SIGCHLD) || defined (SIGCLD)
1834 case TARGET_SIGNAL_CHLD:
1835 #if defined (SIGCHLD)
1840 #endif /* SIGCLD or SIGCHLD */
1841 #if defined (SIGPWR)
1842 case TARGET_SIGNAL_PWR:
1845 #if defined (SIGWINCH)
1846 case TARGET_SIGNAL_WINCH:
1849 #if defined (SIGURG)
1850 case TARGET_SIGNAL_URG:
1854 case TARGET_SIGNAL_IO:
1857 #if defined (SIGPOLL)
1858 case TARGET_SIGNAL_POLL:
1861 #if defined (SIGSTOP)
1862 case TARGET_SIGNAL_STOP:
1865 #if defined (SIGTSTP)
1866 case TARGET_SIGNAL_TSTP:
1869 #if defined (SIGCONT)
1870 case TARGET_SIGNAL_CONT:
1873 #if defined (SIGTTIN)
1874 case TARGET_SIGNAL_TTIN:
1877 #if defined (SIGTTOU)
1878 case TARGET_SIGNAL_TTOU:
1881 #if defined (SIGVTALRM)
1882 case TARGET_SIGNAL_VTALRM:
1885 #if defined (SIGPROF)
1886 case TARGET_SIGNAL_PROF:
1889 #if defined (SIGXCPU)
1890 case TARGET_SIGNAL_XCPU:
1893 #if defined (SIGXFSZ)
1894 case TARGET_SIGNAL_XFSZ:
1897 #if defined (SIGWIND)
1898 case TARGET_SIGNAL_WIND:
1901 #if defined (SIGPHONE)
1902 case TARGET_SIGNAL_PHONE:
1905 #if defined (SIGLOST)
1906 case TARGET_SIGNAL_LOST:
1909 #if defined (SIGWAITING)
1910 case TARGET_SIGNAL_WAITING:
1913 #if defined (SIGCANCEL)
1914 case TARGET_SIGNAL_CANCEL:
1917 #if defined (SIGLWP)
1918 case TARGET_SIGNAL_LWP:
1921 #if defined (SIGDANGER)
1922 case TARGET_SIGNAL_DANGER:
1925 #if defined (SIGGRANT)
1926 case TARGET_SIGNAL_GRANT:
1929 #if defined (SIGRETRACT)
1930 case TARGET_SIGNAL_RETRACT:
1933 #if defined (SIGMSG)
1934 case TARGET_SIGNAL_MSG:
1937 #if defined (SIGSOUND)
1938 case TARGET_SIGNAL_SOUND:
1941 #if defined (SIGSAK)
1942 case TARGET_SIGNAL_SAK:
1945 #if defined (SIGPRIO)
1946 case TARGET_SIGNAL_PRIO:
1950 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1951 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1952 case TARGET_EXC_BAD_ACCESS:
1953 return _NSIG + EXC_BAD_ACCESS;
1955 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
1956 case TARGET_EXC_BAD_INSTRUCTION:
1957 return _NSIG + EXC_BAD_INSTRUCTION;
1959 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
1960 case TARGET_EXC_ARITHMETIC:
1961 return _NSIG + EXC_ARITHMETIC;
1963 #if defined (EXC_EMULATION) && defined (_NSIG)
1964 case TARGET_EXC_EMULATION:
1965 return _NSIG + EXC_EMULATION;
1967 #if defined (EXC_SOFTWARE) && defined (_NSIG)
1968 case TARGET_EXC_SOFTWARE:
1969 return _NSIG + EXC_SOFTWARE;
1971 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
1972 case TARGET_EXC_BREAKPOINT:
1973 return _NSIG + EXC_BREAKPOINT;
1976 #if defined (SIGINFO)
1977 case TARGET_SIGNAL_INFO:
1982 #if defined (REALTIME_LO)
1983 if (oursig >= TARGET_SIGNAL_REALTIME_33
1984 && oursig <= TARGET_SIGNAL_REALTIME_63)
1986 /* This block of signals is continuous, and
1987 TARGET_SIGNAL_REALTIME_33 is 33 by definition. */
1989 (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
1990 if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
1993 #if (REALTIME_LO < 33)
1994 else if (oursig == TARGET_SIGNAL_REALTIME_32)
1996 /* TARGET_SIGNAL_REALTIME_32 isn't contiguous with
1997 TARGET_SIGNAL_REALTIME_33. It is 32 by definition. */
2003 #if defined (SIGRTMIN)
2004 if (oursig >= TARGET_SIGNAL_REALTIME_33
2005 && oursig <= TARGET_SIGNAL_REALTIME_63)
2007 /* This block of signals is continuous, and
2008 TARGET_SIGNAL_REALTIME_33 is 33 by definition. */
2010 (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
2011 if (retsig >= SIGRTMIN && retsig <= SIGRTMAX)
2021 target_signal_to_host_p (enum target_signal oursig)
2024 do_target_signal_to_host (oursig, &oursig_ok);
2029 target_signal_to_host (enum target_signal oursig)
2032 int targ_signo = do_target_signal_to_host (oursig, &oursig_ok);
2035 /* The user might be trying to do "signal SIGSAK" where this system
2036 doesn't have SIGSAK. */
2037 warning ("Signal %s does not exist on this system.\n",
2038 target_signal_to_name (oursig));
2045 /* Helper function for child_wait and the Lynx derivatives of child_wait.
2046 HOSTSTATUS is the waitstatus from wait() or the equivalent; store our
2047 translation of that in OURSTATUS. */
2049 store_waitstatus (struct target_waitstatus *ourstatus, int hoststatus)
2051 #ifdef CHILD_SPECIAL_WAITSTATUS
2052 /* CHILD_SPECIAL_WAITSTATUS should return nonzero and set *OURSTATUS
2053 if it wants to deal with hoststatus. */
2054 if (CHILD_SPECIAL_WAITSTATUS (ourstatus, hoststatus))
2058 if (WIFEXITED (hoststatus))
2060 ourstatus->kind = TARGET_WAITKIND_EXITED;
2061 ourstatus->value.integer = WEXITSTATUS (hoststatus);
2063 else if (!WIFSTOPPED (hoststatus))
2065 ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
2066 ourstatus->value.sig = target_signal_from_host (WTERMSIG (hoststatus));
2070 ourstatus->kind = TARGET_WAITKIND_STOPPED;
2071 ourstatus->value.sig = target_signal_from_host (WSTOPSIG (hoststatus));
2075 /* In some circumstances we allow a command to specify a numeric
2076 signal. The idea is to keep these circumstances limited so that
2077 users (and scripts) develop portable habits. For comparison,
2078 POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a
2079 numeric signal at all is obscelescent. We are slightly more
2080 lenient and allow 1-15 which should match host signal numbers on
2081 most systems. Use of symbolic signal names is strongly encouraged. */
2084 target_signal_from_command (int num)
2086 if (num >= 1 && num <= 15)
2087 return (enum target_signal) num;
2088 error ("Only signals 1-15 are valid as numeric signals.\n\
2089 Use \"info signals\" for a list of symbolic signals.");
2092 /* Returns zero to leave the inferior alone, one to interrupt it. */
2093 int (*target_activity_function) (void);
2094 int target_activity_fd;
2096 /* Convert a normal process ID to a string. Returns the string in a static
2100 normal_pid_to_str (int pid)
2102 static char buf[30];
2104 if (STREQ (current_target.to_shortname, "remote"))
2105 sprintf (buf, "thread %d", pid);
2107 sprintf (buf, "process %d", pid);
2112 /* Some targets (such as ttrace-based HPUX) don't allow us to request
2113 notification of inferior events such as fork and vork immediately
2114 after the inferior is created. (This because of how gdb gets an
2115 inferior created via invoking a shell to do it. In such a scenario,
2116 if the shell init file has commands in it, the shell will fork and
2117 exec for each of those commands, and we will see each such fork
2120 This function is used by all targets that allow us to request
2121 notification of forks, etc at inferior creation time; e.g., in
2122 target_acknowledge_forked_child.
2125 normal_target_post_startup_inferior (int pid)
2127 /* This space intentionally left blank. */
2130 /* Set up the handful of non-empty slots needed by the dummy target
2134 init_dummy_target (void)
2136 dummy_target.to_shortname = "None";
2137 dummy_target.to_longname = "None";
2138 dummy_target.to_doc = "";
2139 dummy_target.to_attach = find_default_attach;
2140 dummy_target.to_require_attach = find_default_require_attach;
2141 dummy_target.to_require_detach = find_default_require_detach;
2142 dummy_target.to_create_inferior = find_default_create_inferior;
2143 dummy_target.to_clone_and_follow_inferior = find_default_clone_and_follow_inferior;
2144 dummy_target.to_pid_to_str = normal_pid_to_str;
2145 dummy_target.to_stratum = dummy_stratum;
2146 dummy_target.to_magic = OPS_MAGIC;
2150 static struct target_ops debug_target;
2153 debug_to_open (char *args, int from_tty)
2155 debug_target.to_open (args, from_tty);
2157 fprintf_unfiltered (gdb_stdlog, "target_open (%s, %d)\n", args, from_tty);
2161 debug_to_close (int quitting)
2163 debug_target.to_close (quitting);
2165 fprintf_unfiltered (gdb_stdlog, "target_close (%d)\n", quitting);
2169 debug_to_attach (char *args, int from_tty)
2171 debug_target.to_attach (args, from_tty);
2173 fprintf_unfiltered (gdb_stdlog, "target_attach (%s, %d)\n", args, from_tty);
2178 debug_to_post_attach (int pid)
2180 debug_target.to_post_attach (pid);
2182 fprintf_unfiltered (gdb_stdlog, "target_post_attach (%d)\n", pid);
2186 debug_to_require_attach (char *args, int from_tty)
2188 debug_target.to_require_attach (args, from_tty);
2190 fprintf_unfiltered (gdb_stdlog,
2191 "target_require_attach (%s, %d)\n", args, from_tty);
2195 debug_to_detach (char *args, int from_tty)
2197 debug_target.to_detach (args, from_tty);
2199 fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n", args, from_tty);
2203 debug_to_require_detach (int pid, char *args, int from_tty)
2205 debug_target.to_require_detach (pid, args, from_tty);
2207 fprintf_unfiltered (gdb_stdlog,
2208 "target_require_detach (%d, %s, %d)\n", pid, args, from_tty);
2212 debug_to_resume (int pid, int step, enum target_signal siggnal)
2214 debug_target.to_resume (pid, step, siggnal);
2216 fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n", pid,
2217 step ? "step" : "continue",
2218 target_signal_to_name (siggnal));
2222 debug_to_wait (int pid, struct target_waitstatus *status)
2226 retval = debug_target.to_wait (pid, status);
2228 fprintf_unfiltered (gdb_stdlog,
2229 "target_wait (%d, status) = %d, ", pid, retval);
2230 fprintf_unfiltered (gdb_stdlog, "status->kind = ");
2231 switch (status->kind)
2233 case TARGET_WAITKIND_EXITED:
2234 fprintf_unfiltered (gdb_stdlog, "exited, status = %d\n",
2235 status->value.integer);
2237 case TARGET_WAITKIND_STOPPED:
2238 fprintf_unfiltered (gdb_stdlog, "stopped, signal = %s\n",
2239 target_signal_to_name (status->value.sig));
2241 case TARGET_WAITKIND_SIGNALLED:
2242 fprintf_unfiltered (gdb_stdlog, "signalled, signal = %s\n",
2243 target_signal_to_name (status->value.sig));
2245 case TARGET_WAITKIND_LOADED:
2246 fprintf_unfiltered (gdb_stdlog, "loaded\n");
2248 case TARGET_WAITKIND_FORKED:
2249 fprintf_unfiltered (gdb_stdlog, "forked\n");
2251 case TARGET_WAITKIND_VFORKED:
2252 fprintf_unfiltered (gdb_stdlog, "vforked\n");
2254 case TARGET_WAITKIND_EXECD:
2255 fprintf_unfiltered (gdb_stdlog, "execd\n");
2257 case TARGET_WAITKIND_SPURIOUS:
2258 fprintf_unfiltered (gdb_stdlog, "spurious\n");
2261 fprintf_unfiltered (gdb_stdlog, "unknown???\n");
2269 debug_to_post_wait (int pid, int status)
2271 debug_target.to_post_wait (pid, status);
2273 fprintf_unfiltered (gdb_stdlog, "target_post_wait (%d, %d)\n",
2278 debug_to_fetch_registers (int regno)
2280 debug_target.to_fetch_registers (regno);
2282 fprintf_unfiltered (gdb_stdlog, "target_fetch_registers (%s)",
2283 regno != -1 ? REGISTER_NAME (regno) : "-1");
2285 fprintf_unfiltered (gdb_stdlog, " = 0x%lx %ld",
2286 (unsigned long) read_register (regno),
2287 (unsigned long) read_register (regno));
2288 fprintf_unfiltered (gdb_stdlog, "\n");
2292 debug_to_store_registers (int regno)
2294 debug_target.to_store_registers (regno);
2296 if (regno >= 0 && regno < NUM_REGS)
2297 fprintf_unfiltered (gdb_stdlog, "target_store_registers (%s) = 0x%lx %ld\n",
2298 REGISTER_NAME (regno),
2299 (unsigned long) read_register (regno),
2300 (unsigned long) read_register (regno));
2302 fprintf_unfiltered (gdb_stdlog, "target_store_registers (%d)\n", regno);
2306 debug_to_prepare_to_store (void)
2308 debug_target.to_prepare_to_store ();
2310 fprintf_unfiltered (gdb_stdlog, "target_prepare_to_store ()\n");
2314 debug_to_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
2315 struct target_ops *target)
2319 retval = debug_target.to_xfer_memory (memaddr, myaddr, len, write, target);
2321 fprintf_unfiltered (gdb_stdlog,
2322 "target_xfer_memory (0x%x, xxx, %d, %s, xxx) = %d",
2323 (unsigned int) memaddr, /* possable truncate long long */
2324 len, write ? "write" : "read", retval);
2332 fputs_unfiltered (", bytes =", gdb_stdlog);
2333 for (i = 0; i < retval; i++)
2335 if ((((long) &(myaddr[i])) & 0xf) == 0)
2336 fprintf_unfiltered (gdb_stdlog, "\n");
2337 fprintf_unfiltered (gdb_stdlog, " %02x", myaddr[i] & 0xff);
2341 fputc_unfiltered ('\n', gdb_stdlog);
2347 debug_to_files_info (struct target_ops *target)
2349 debug_target.to_files_info (target);
2351 fprintf_unfiltered (gdb_stdlog, "target_files_info (xxx)\n");
2355 debug_to_insert_breakpoint (CORE_ADDR addr, char *save)
2359 retval = debug_target.to_insert_breakpoint (addr, save);
2361 fprintf_unfiltered (gdb_stdlog,
2362 "target_insert_breakpoint (0x%lx, xxx) = %ld\n",
2363 (unsigned long) addr,
2364 (unsigned long) retval);
2369 debug_to_remove_breakpoint (CORE_ADDR addr, char *save)
2373 retval = debug_target.to_remove_breakpoint (addr, save);
2375 fprintf_unfiltered (gdb_stdlog,
2376 "target_remove_breakpoint (0x%lx, xxx) = %ld\n",
2377 (unsigned long) addr,
2378 (unsigned long) retval);
2383 debug_to_terminal_init (void)
2385 debug_target.to_terminal_init ();
2387 fprintf_unfiltered (gdb_stdlog, "target_terminal_init ()\n");
2391 debug_to_terminal_inferior (void)
2393 debug_target.to_terminal_inferior ();
2395 fprintf_unfiltered (gdb_stdlog, "target_terminal_inferior ()\n");
2399 debug_to_terminal_ours_for_output (void)
2401 debug_target.to_terminal_ours_for_output ();
2403 fprintf_unfiltered (gdb_stdlog, "target_terminal_ours_for_output ()\n");
2407 debug_to_terminal_ours (void)
2409 debug_target.to_terminal_ours ();
2411 fprintf_unfiltered (gdb_stdlog, "target_terminal_ours ()\n");
2415 debug_to_terminal_info (char *arg, int from_tty)
2417 debug_target.to_terminal_info (arg, from_tty);
2419 fprintf_unfiltered (gdb_stdlog, "target_terminal_info (%s, %d)\n", arg,
2424 debug_to_kill (void)
2426 debug_target.to_kill ();
2428 fprintf_unfiltered (gdb_stdlog, "target_kill ()\n");
2432 debug_to_load (char *args, int from_tty)
2434 debug_target.to_load (args, from_tty);
2436 fprintf_unfiltered (gdb_stdlog, "target_load (%s, %d)\n", args, from_tty);
2440 debug_to_lookup_symbol (char *name, CORE_ADDR *addrp)
2444 retval = debug_target.to_lookup_symbol (name, addrp);
2446 fprintf_unfiltered (gdb_stdlog, "target_lookup_symbol (%s, xxx)\n", name);
2452 debug_to_create_inferior (char *exec_file, char *args, char **env)
2454 debug_target.to_create_inferior (exec_file, args, env);
2456 fprintf_unfiltered (gdb_stdlog, "target_create_inferior (%s, %s, xxx)\n",
2461 debug_to_post_startup_inferior (int pid)
2463 debug_target.to_post_startup_inferior (pid);
2465 fprintf_unfiltered (gdb_stdlog, "target_post_startup_inferior (%d)\n",
2470 debug_to_acknowledge_created_inferior (int pid)
2472 debug_target.to_acknowledge_created_inferior (pid);
2474 fprintf_unfiltered (gdb_stdlog, "target_acknowledge_created_inferior (%d)\n",
2479 debug_to_clone_and_follow_inferior (int child_pid, int *followed_child)
2481 debug_target.to_clone_and_follow_inferior (child_pid, followed_child);
2483 fprintf_unfiltered (gdb_stdlog,
2484 "target_clone_and_follow_inferior (%d, %d)\n",
2485 child_pid, *followed_child);
2489 debug_to_post_follow_inferior_by_clone (void)
2491 debug_target.to_post_follow_inferior_by_clone ();
2493 fprintf_unfiltered (gdb_stdlog, "target_post_follow_inferior_by_clone ()\n");
2497 debug_to_insert_fork_catchpoint (int pid)
2501 retval = debug_target.to_insert_fork_catchpoint (pid);
2503 fprintf_unfiltered (gdb_stdlog, "target_insert_fork_catchpoint (%d) = %d\n",
2510 debug_to_remove_fork_catchpoint (int pid)
2514 retval = debug_target.to_remove_fork_catchpoint (pid);
2516 fprintf_unfiltered (gdb_stdlog, "target_remove_fork_catchpoint (%d) = %d\n",
2523 debug_to_insert_vfork_catchpoint (int pid)
2527 retval = debug_target.to_insert_vfork_catchpoint (pid);
2529 fprintf_unfiltered (gdb_stdlog, "target_insert_vfork_catchpoint (%d)= %d\n",
2536 debug_to_remove_vfork_catchpoint (int pid)
2540 retval = debug_target.to_remove_vfork_catchpoint (pid);
2542 fprintf_unfiltered (gdb_stdlog, "target_remove_vfork_catchpoint (%d) = %d\n",
2549 debug_to_has_forked (int pid, int *child_pid)
2553 has_forked = debug_target.to_has_forked (pid, child_pid);
2555 fprintf_unfiltered (gdb_stdlog, "target_has_forked (%d, %d) = %d\n",
2556 pid, *child_pid, has_forked);
2562 debug_to_has_vforked (int pid, int *child_pid)
2566 has_vforked = debug_target.to_has_vforked (pid, child_pid);
2568 fprintf_unfiltered (gdb_stdlog, "target_has_vforked (%d, %d) = %d\n",
2569 pid, *child_pid, has_vforked);
2575 debug_to_can_follow_vfork_prior_to_exec (void)
2577 int can_immediately_follow_vfork;
2579 can_immediately_follow_vfork = debug_target.to_can_follow_vfork_prior_to_exec ();
2581 fprintf_unfiltered (gdb_stdlog, "target_can_follow_vfork_prior_to_exec () = %d\n",
2582 can_immediately_follow_vfork);
2584 return can_immediately_follow_vfork;
2588 debug_to_post_follow_vfork (int parent_pid, int followed_parent, int child_pid,
2591 debug_target.to_post_follow_vfork (parent_pid, followed_parent, child_pid, followed_child);
2593 fprintf_unfiltered (gdb_stdlog,
2594 "target_post_follow_vfork (%d, %d, %d, %d)\n",
2595 parent_pid, followed_parent, child_pid, followed_child);
2599 debug_to_insert_exec_catchpoint (int pid)
2603 retval = debug_target.to_insert_exec_catchpoint (pid);
2605 fprintf_unfiltered (gdb_stdlog, "target_insert_exec_catchpoint (%d) = %d\n",
2612 debug_to_remove_exec_catchpoint (int pid)
2616 retval = debug_target.to_remove_exec_catchpoint (pid);
2618 fprintf_unfiltered (gdb_stdlog, "target_remove_exec_catchpoint (%d) = %d\n",
2625 debug_to_has_execd (int pid, char **execd_pathname)
2629 has_execd = debug_target.to_has_execd (pid, execd_pathname);
2631 fprintf_unfiltered (gdb_stdlog, "target_has_execd (%d, %s) = %d\n",
2632 pid, (*execd_pathname ? *execd_pathname : "<NULL>"),
2639 debug_to_reported_exec_events_per_exec_call (void)
2641 int reported_exec_events;
2643 reported_exec_events = debug_target.to_reported_exec_events_per_exec_call ();
2645 fprintf_unfiltered (gdb_stdlog,
2646 "target_reported_exec_events_per_exec_call () = %d\n",
2647 reported_exec_events);
2649 return reported_exec_events;
2653 debug_to_has_syscall_event (int pid, enum target_waitkind *kind,
2656 int has_syscall_event;
2657 char *kind_spelling = "??";
2659 has_syscall_event = debug_target.to_has_syscall_event (pid, kind, syscall_id);
2660 if (has_syscall_event)
2664 case TARGET_WAITKIND_SYSCALL_ENTRY:
2665 kind_spelling = "SYSCALL_ENTRY";
2667 case TARGET_WAITKIND_SYSCALL_RETURN:
2668 kind_spelling = "SYSCALL_RETURN";
2675 fprintf_unfiltered (gdb_stdlog,
2676 "target_has_syscall_event (%d, %s, %d) = %d\n",
2677 pid, kind_spelling, *syscall_id, has_syscall_event);
2679 return has_syscall_event;
2683 debug_to_has_exited (int pid, int wait_status, int *exit_status)
2687 has_exited = debug_target.to_has_exited (pid, wait_status, exit_status);
2689 fprintf_unfiltered (gdb_stdlog, "target_has_exited (%d, %d, %d) = %d\n",
2690 pid, wait_status, *exit_status, has_exited);
2696 debug_to_mourn_inferior (void)
2698 debug_target.to_mourn_inferior ();
2700 fprintf_unfiltered (gdb_stdlog, "target_mourn_inferior ()\n");
2704 debug_to_can_run (void)
2708 retval = debug_target.to_can_run ();
2710 fprintf_unfiltered (gdb_stdlog, "target_can_run () = %d\n", retval);
2716 debug_to_notice_signals (int pid)
2718 debug_target.to_notice_signals (pid);
2720 fprintf_unfiltered (gdb_stdlog, "target_notice_signals (%d)\n", pid);
2724 debug_to_thread_alive (int pid)
2728 retval = debug_target.to_thread_alive (pid);
2730 fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n",
2737 debug_to_find_new_threads (void)
2739 debug_target.to_find_new_threads ();
2741 fputs_unfiltered ("target_find_new_threads ()\n", gdb_stdlog);
2745 debug_to_stop (void)
2747 debug_target.to_stop ();
2749 fprintf_unfiltered (gdb_stdlog, "target_stop ()\n");
2753 debug_to_query (int type, char *req, char *resp, int *siz)
2757 retval = debug_target.to_query (type, req, resp, siz);
2759 fprintf_unfiltered (gdb_stdlog, "target_query (%c, %s, %s, %d) = %d\n", type, req, resp, *siz, retval);
2765 debug_to_rcmd (char *command,
2766 struct ui_file *outbuf)
2768 debug_target.to_rcmd (command, outbuf);
2769 fprintf_unfiltered (gdb_stdlog, "target_rcmd (%s, ...)\n", command);
2772 static struct symtab_and_line *
2773 debug_to_enable_exception_callback (enum exception_event_kind kind, int enable)
2775 struct symtab_and_line *result;
2776 result = debug_target.to_enable_exception_callback (kind, enable);
2777 fprintf_unfiltered (gdb_stdlog,
2778 "target get_exception_callback_sal (%d, %d)\n",
2783 static struct exception_event_record *
2784 debug_to_get_current_exception_event (void)
2786 struct exception_event_record *result;
2787 result = debug_target.to_get_current_exception_event ();
2788 fprintf_unfiltered (gdb_stdlog, "target get_current_exception_event ()\n");
2793 debug_to_pid_to_exec_file (int pid)
2797 exec_file = debug_target.to_pid_to_exec_file (pid);
2799 fprintf_unfiltered (gdb_stdlog, "target_pid_to_exec_file (%d) = %s\n",
2806 debug_to_core_file_to_sym_file (char *core)
2810 sym_file = debug_target.to_core_file_to_sym_file (core);
2812 fprintf_unfiltered (gdb_stdlog, "target_core_file_to_sym_file (%s) = %s\n",
2819 setup_target_debug (void)
2821 memcpy (&debug_target, ¤t_target, sizeof debug_target);
2823 current_target.to_open = debug_to_open;
2824 current_target.to_close = debug_to_close;
2825 current_target.to_attach = debug_to_attach;
2826 current_target.to_post_attach = debug_to_post_attach;
2827 current_target.to_require_attach = debug_to_require_attach;
2828 current_target.to_detach = debug_to_detach;
2829 current_target.to_require_detach = debug_to_require_detach;
2830 current_target.to_resume = debug_to_resume;
2831 current_target.to_wait = debug_to_wait;
2832 current_target.to_post_wait = debug_to_post_wait;
2833 current_target.to_fetch_registers = debug_to_fetch_registers;
2834 current_target.to_store_registers = debug_to_store_registers;
2835 current_target.to_prepare_to_store = debug_to_prepare_to_store;
2836 current_target.to_xfer_memory = debug_to_xfer_memory;
2837 current_target.to_files_info = debug_to_files_info;
2838 current_target.to_insert_breakpoint = debug_to_insert_breakpoint;
2839 current_target.to_remove_breakpoint = debug_to_remove_breakpoint;
2840 current_target.to_terminal_init = debug_to_terminal_init;
2841 current_target.to_terminal_inferior = debug_to_terminal_inferior;
2842 current_target.to_terminal_ours_for_output = debug_to_terminal_ours_for_output;
2843 current_target.to_terminal_ours = debug_to_terminal_ours;
2844 current_target.to_terminal_info = debug_to_terminal_info;
2845 current_target.to_kill = debug_to_kill;
2846 current_target.to_load = debug_to_load;
2847 current_target.to_lookup_symbol = debug_to_lookup_symbol;
2848 current_target.to_create_inferior = debug_to_create_inferior;
2849 current_target.to_post_startup_inferior = debug_to_post_startup_inferior;
2850 current_target.to_acknowledge_created_inferior = debug_to_acknowledge_created_inferior;
2851 current_target.to_clone_and_follow_inferior = debug_to_clone_and_follow_inferior;
2852 current_target.to_post_follow_inferior_by_clone = debug_to_post_follow_inferior_by_clone;
2853 current_target.to_insert_fork_catchpoint = debug_to_insert_fork_catchpoint;
2854 current_target.to_remove_fork_catchpoint = debug_to_remove_fork_catchpoint;
2855 current_target.to_insert_vfork_catchpoint = debug_to_insert_vfork_catchpoint;
2856 current_target.to_remove_vfork_catchpoint = debug_to_remove_vfork_catchpoint;
2857 current_target.to_has_forked = debug_to_has_forked;
2858 current_target.to_has_vforked = debug_to_has_vforked;
2859 current_target.to_can_follow_vfork_prior_to_exec = debug_to_can_follow_vfork_prior_to_exec;
2860 current_target.to_post_follow_vfork = debug_to_post_follow_vfork;
2861 current_target.to_insert_exec_catchpoint = debug_to_insert_exec_catchpoint;
2862 current_target.to_remove_exec_catchpoint = debug_to_remove_exec_catchpoint;
2863 current_target.to_has_execd = debug_to_has_execd;
2864 current_target.to_reported_exec_events_per_exec_call = debug_to_reported_exec_events_per_exec_call;
2865 current_target.to_has_syscall_event = debug_to_has_syscall_event;
2866 current_target.to_has_exited = debug_to_has_exited;
2867 current_target.to_mourn_inferior = debug_to_mourn_inferior;
2868 current_target.to_can_run = debug_to_can_run;
2869 current_target.to_notice_signals = debug_to_notice_signals;
2870 current_target.to_thread_alive = debug_to_thread_alive;
2871 current_target.to_find_new_threads = debug_to_find_new_threads;
2872 current_target.to_stop = debug_to_stop;
2873 current_target.to_query = debug_to_query;
2874 current_target.to_rcmd = debug_to_rcmd;
2875 current_target.to_enable_exception_callback = debug_to_enable_exception_callback;
2876 current_target.to_get_current_exception_event = debug_to_get_current_exception_event;
2877 current_target.to_pid_to_exec_file = debug_to_pid_to_exec_file;
2878 current_target.to_core_file_to_sym_file = debug_to_core_file_to_sym_file;
2883 static char targ_desc[] =
2884 "Names of targets and files being debugged.\n\
2885 Shows the entire stack of targets currently in use (including the exec-file,\n\
2886 core-file, and process, if any), as well as the symbol file name.";
2889 do_monitor_command (char *cmd,
2892 if ((current_target.to_rcmd
2893 == (void (*) (char *, struct ui_file *)) tcomplain)
2894 || (current_target.to_rcmd == debug_to_rcmd
2895 && (debug_target.to_rcmd
2896 == (void (*) (char *, struct ui_file *)) tcomplain)))
2898 error ("\"monitor\" command not supported by this target.\n");
2900 target_rcmd (cmd, gdb_stdtarg);
2904 initialize_targets (void)
2906 init_dummy_target ();
2907 push_target (&dummy_target);
2909 add_info ("target", target_info, targ_desc);
2910 add_info ("files", target_info, targ_desc);
2913 add_set_cmd ("target", class_maintenance, var_zinteger,
2914 (char *) &targetdebug,
2915 "Set target debugging.\n\
2916 When non-zero, target debugging is enabled.", &setdebuglist),
2920 add_com ("monitor", class_obscure, do_monitor_command,
2921 "Send a command to the remote monitor (remote targets only).");
2923 if (!STREQ (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC"))