1 /* Select target systems and architectures at runtime for GDB.
2 Copyright 1990, 1992-1995, 1998, 1999 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"
39 target_info PARAMS ((char *, int));
42 cleanup_target PARAMS ((struct target_ops *));
45 maybe_kill_then_create_inferior PARAMS ((char *, char *, char **));
48 default_clone_and_follow_inferior PARAMS ((int, int *));
51 maybe_kill_then_attach PARAMS ((char *, int));
54 kill_or_be_killed PARAMS ((int));
57 default_terminal_info PARAMS ((char *, int));
60 nosymbol PARAMS ((char *, CORE_ADDR *));
63 tcomplain PARAMS ((void));
66 nomemory PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
69 return_zero PARAMS ((void));
72 return_one PARAMS ((void));
75 target_ignore PARAMS ((void));
78 target_command PARAMS ((char *, int));
80 static struct target_ops *
81 find_default_run_target PARAMS ((char *));
84 update_current_target PARAMS ((void));
86 static void nosupport_runtime PARAMS ((void));
88 static void normal_target_post_startup_inferior PARAMS ((int pid));
90 /* Transfer LEN bytes between target address MEMADDR and GDB address MYADDR.
91 Returns 0 for success, errno code for failure (which includes partial
92 transfers--if you want a more useful response to partial transfers, try
93 target_read_memory_partial). */
96 target_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len,
97 int write, asection * bfd_section));
99 static void init_dummy_target PARAMS ((void));
102 debug_to_open PARAMS ((char *, int));
105 debug_to_close PARAMS ((int));
108 debug_to_attach PARAMS ((char *, int));
111 debug_to_detach PARAMS ((char *, int));
114 debug_to_resume PARAMS ((int, int, enum target_signal));
117 debug_to_wait PARAMS ((int, struct target_waitstatus *));
120 debug_to_fetch_registers PARAMS ((int));
123 debug_to_store_registers PARAMS ((int));
126 debug_to_prepare_to_store PARAMS ((void));
129 debug_to_xfer_memory PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
132 debug_to_files_info PARAMS ((struct target_ops *));
135 debug_to_insert_breakpoint PARAMS ((CORE_ADDR, char *));
138 debug_to_remove_breakpoint PARAMS ((CORE_ADDR, char *));
141 debug_to_terminal_init PARAMS ((void));
144 debug_to_terminal_inferior PARAMS ((void));
147 debug_to_terminal_ours_for_output PARAMS ((void));
150 debug_to_terminal_ours PARAMS ((void));
153 debug_to_terminal_info PARAMS ((char *, int));
156 debug_to_kill PARAMS ((void));
159 debug_to_load PARAMS ((char *, int));
162 debug_to_lookup_symbol PARAMS ((char *, CORE_ADDR *));
165 debug_to_create_inferior PARAMS ((char *, char *, char **));
168 debug_to_mourn_inferior PARAMS ((void));
171 debug_to_can_run PARAMS ((void));
174 debug_to_notice_signals PARAMS ((int));
177 debug_to_thread_alive PARAMS ((int));
180 debug_to_stop PARAMS ((void));
182 static int debug_to_query PARAMS ((int /*char */ , char *, char *, int *));
184 /* Pointer to array of target architecture structures; the size of the
185 array; the current index into the array; the allocated size of the
187 struct target_ops **target_structs;
188 unsigned target_struct_size;
189 unsigned target_struct_index;
190 unsigned target_struct_allocsize;
191 #define DEFAULT_ALLOCSIZE 10
193 /* The initial current target, so that there is always a semi-valid
196 static struct target_ops dummy_target;
198 /* Top of target stack. */
200 struct target_stack_item *target_stack;
202 /* The target structure we are currently using to talk to a process
203 or file or whatever "inferior" we have. */
205 struct target_ops current_target;
207 /* Command list for target. */
209 static struct cmd_list_element *targetlist = NULL;
211 /* Nonzero if we are debugging an attached outside process
212 rather than an inferior. */
216 /* Non-zero if we want to see trace of target level stuff. */
218 static int targetdebug = 0;
220 static void setup_target_debug PARAMS ((void));
222 /* The user just typed 'target' without the name of a target. */
226 target_command (arg, from_tty)
230 fputs_filtered ("Argument required (target name). Try `help target'\n",
234 /* Add a possible target architecture to the list. */
238 struct target_ops *t;
242 target_struct_allocsize = DEFAULT_ALLOCSIZE;
243 target_structs = (struct target_ops **) xmalloc
244 (target_struct_allocsize * sizeof (*target_structs));
246 if (target_struct_size >= target_struct_allocsize)
248 target_struct_allocsize *= 2;
249 target_structs = (struct target_ops **)
250 xrealloc ((char *) target_structs,
251 target_struct_allocsize * sizeof (*target_structs));
253 target_structs[target_struct_size++] = t;
254 /* cleanup_target (t); */
256 if (targetlist == NULL)
257 add_prefix_cmd ("target", class_run, target_command,
258 "Connect to a target machine or process.\n\
259 The first argument is the type or protocol of the target machine.\n\
260 Remaining arguments are interpreted by the target protocol. For more\n\
261 information on the arguments for a particular protocol, type\n\
262 `help target ' followed by the protocol name.",
263 &targetlist, "target ", 0, &cmdlist);
264 add_cmd (t->to_shortname, no_class, t->to_open, t->to_doc, &targetlist);
276 nomemory (memaddr, myaddr, len, write, t)
281 struct target_ops *t;
283 errno = EIO; /* Can't read/write this location */
284 return 0; /* No bytes handled */
290 error ("You can't do that when your target is `%s'",
291 current_target.to_shortname);
297 error ("You can't do that without a process to debug.");
302 nosymbol (name, addrp)
306 return 1; /* Symbol does not exist in target env */
316 error ("No run-time support for this");
322 default_terminal_info (args, from_tty)
326 printf_unfiltered ("No saved terminal information.\n");
329 /* This is the default target_create_inferior and target_attach function.
330 If the current target is executing, it asks whether to kill it off.
331 If this function returns without calling error(), it has killed off
332 the target, and the operation should be attempted. */
335 kill_or_be_killed (from_tty)
338 if (target_has_execution)
340 printf_unfiltered ("You are already running a program:\n");
341 target_files_info ();
342 if (query ("Kill it? "))
345 if (target_has_execution)
346 error ("Killing the program did not help.");
351 error ("Program not killed.");
358 maybe_kill_then_attach (args, from_tty)
362 kill_or_be_killed (from_tty);
363 target_attach (args, from_tty);
367 maybe_kill_then_create_inferior (exec, args, env)
372 kill_or_be_killed (0);
373 target_create_inferior (exec, args, env);
377 default_clone_and_follow_inferior (child_pid, followed_child)
381 target_clone_and_follow_inferior (child_pid, followed_child);
384 /* Clean up a target struct so it no longer has any zero pointers in it.
385 We default entries, at least to stubs that print error messages. */
389 struct target_ops *t;
392 #define de_fault(field, value) \
393 if (!t->field) t->field = value
395 /* FIELD DEFAULT VALUE */
397 de_fault (to_open, (void (*)PARAMS ((char *, int))) tcomplain);
398 de_fault (to_close, (void (*)PARAMS ((int))) target_ignore);
399 de_fault (to_attach, maybe_kill_then_attach);
400 de_fault (to_post_attach, (void (*)PARAMS ((int))) target_ignore);
401 de_fault (to_require_attach, maybe_kill_then_attach);
402 de_fault (to_detach, (void (*)PARAMS ((char *, int))) target_ignore);
403 de_fault (to_require_detach, (void (*)PARAMS ((int, char *, int))) target_ignore);
404 de_fault (to_resume, (void (*)PARAMS ((int, int, enum target_signal))) noprocess);
405 de_fault (to_wait, (int (*)PARAMS ((int, struct target_waitstatus *))) noprocess);
406 de_fault (to_post_wait, (void (*)PARAMS ((int, int))) target_ignore);
407 de_fault (to_fetch_registers, (void (*)PARAMS ((int))) target_ignore);
408 de_fault (to_store_registers, (void (*)PARAMS ((int))) noprocess);
409 de_fault (to_prepare_to_store, (void (*)PARAMS ((void))) noprocess);
410 de_fault (to_xfer_memory, (int (*)PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *))) nomemory);
411 de_fault (to_files_info, (void (*)PARAMS ((struct target_ops *))) target_ignore);
412 de_fault (to_insert_breakpoint, memory_insert_breakpoint);
413 de_fault (to_remove_breakpoint, memory_remove_breakpoint);
414 de_fault (to_terminal_init, (void (*)PARAMS ((void))) target_ignore);
415 de_fault (to_terminal_inferior, (void (*)PARAMS ((void))) target_ignore);
416 de_fault (to_terminal_ours_for_output, (void (*)PARAMS ((void))) target_ignore);
417 de_fault (to_terminal_ours, (void (*)PARAMS ((void))) target_ignore);
418 de_fault (to_terminal_info, default_terminal_info);
419 de_fault (to_kill, (void (*)PARAMS ((void))) noprocess);
420 de_fault (to_load, (void (*)PARAMS ((char *, int))) tcomplain);
421 de_fault (to_lookup_symbol, (int (*)PARAMS ((char *, CORE_ADDR *))) nosymbol);
422 de_fault (to_create_inferior, maybe_kill_then_create_inferior);
423 de_fault (to_post_startup_inferior, (void (*)PARAMS ((int))) target_ignore);
424 de_fault (to_acknowledge_created_inferior, (void (*)PARAMS ((int))) target_ignore);
425 de_fault (to_clone_and_follow_inferior, default_clone_and_follow_inferior);
426 de_fault (to_post_follow_inferior_by_clone, (void (*)PARAMS ((void))) target_ignore);
427 de_fault (to_insert_fork_catchpoint, (int (*)PARAMS ((int))) tcomplain);
428 de_fault (to_remove_fork_catchpoint, (int (*)PARAMS ((int))) tcomplain);
429 de_fault (to_insert_vfork_catchpoint, (int (*)PARAMS ((int))) tcomplain);
430 de_fault (to_remove_vfork_catchpoint, (int (*)PARAMS ((int))) tcomplain);
431 de_fault (to_has_forked, (int (*)PARAMS ((int, int *))) return_zero);
432 de_fault (to_has_vforked, (int (*)PARAMS ((int, int *))) return_zero);
433 de_fault (to_can_follow_vfork_prior_to_exec, (int (*)PARAMS ((void))) return_zero);
434 de_fault (to_post_follow_vfork, (void (*)PARAMS ((int, int, int, int))) target_ignore);
435 de_fault (to_insert_exec_catchpoint, (int (*)PARAMS ((int))) tcomplain);
436 de_fault (to_remove_exec_catchpoint, (int (*)PARAMS ((int))) tcomplain);
437 de_fault (to_has_execd, (int (*)PARAMS ((int, char **))) return_zero);
438 de_fault (to_reported_exec_events_per_exec_call, (int (*)PARAMS ((void))) return_one);
439 de_fault (to_has_syscall_event, (int (*)PARAMS ((int, enum target_waitkind *, int *))) return_zero);
440 de_fault (to_has_exited, (int (*)PARAMS ((int, int, int *))) return_zero);
441 de_fault (to_mourn_inferior, (void (*)PARAMS ((void))) noprocess);
442 de_fault (to_can_run, return_zero);
443 de_fault (to_notice_signals, (void (*)PARAMS ((int))) target_ignore);
444 de_fault (to_thread_alive, (int (*)PARAMS ((int))) target_ignore);
445 de_fault (to_stop, (void (*)PARAMS ((void))) target_ignore);
446 de_fault (to_query, (int (*)PARAMS ((int /*char */ , char *, char *, int *))) target_ignore);
447 de_fault (to_rcmd, (void (*) (char *, struct gdb_file *)) tcomplain);
448 de_fault (to_enable_exception_callback, (struct symtab_and_line * (*)PARAMS ((enum exception_event_kind, int))) nosupport_runtime);
449 de_fault (to_get_current_exception_event, (struct exception_event_record * (*)PARAMS ((void))) nosupport_runtime);
451 de_fault (to_pid_to_exec_file, (char *(*)PARAMS ((int))) return_zero);
452 de_fault (to_core_file_to_sym_file, (char *(*)PARAMS ((char *))) return_zero);
453 de_fault (to_can_async_p, (int (*) (void)) return_zero);
454 de_fault (to_is_async_p, (int (*) (void)) return_zero);
455 de_fault (to_async, (void (*) (void (*) (int, void*, int), void*)) tcomplain);
459 /* Go through the target stack from top to bottom, copying over zero entries in
460 current_target. In effect, we are doing class inheritance through the
461 pushed target vectors. */
464 update_current_target ()
466 struct target_stack_item *item;
467 struct target_ops *t;
469 /* First, reset current_target */
470 memset (¤t_target, 0, sizeof current_target);
472 for (item = target_stack; item; item = item->next)
474 t = item->target_ops;
476 #define INHERIT(FIELD, TARGET) \
477 if (!current_target.FIELD) \
478 current_target.FIELD = TARGET->FIELD
480 INHERIT (to_shortname, t);
481 INHERIT (to_longname, t);
483 INHERIT (to_open, t);
484 INHERIT (to_close, t);
485 INHERIT (to_attach, t);
486 INHERIT (to_post_attach, t);
487 INHERIT (to_require_attach, t);
488 INHERIT (to_detach, t);
489 INHERIT (to_require_detach, t);
490 INHERIT (to_resume, t);
491 INHERIT (to_wait, t);
492 INHERIT (to_post_wait, t);
493 INHERIT (to_fetch_registers, t);
494 INHERIT (to_store_registers, t);
495 INHERIT (to_prepare_to_store, t);
496 INHERIT (to_xfer_memory, t);
497 INHERIT (to_files_info, t);
498 INHERIT (to_insert_breakpoint, t);
499 INHERIT (to_remove_breakpoint, t);
500 INHERIT (to_terminal_init, t);
501 INHERIT (to_terminal_inferior, t);
502 INHERIT (to_terminal_ours_for_output, t);
503 INHERIT (to_terminal_ours, t);
504 INHERIT (to_terminal_info, t);
505 INHERIT (to_kill, t);
506 INHERIT (to_load, t);
507 INHERIT (to_lookup_symbol, t);
508 INHERIT (to_create_inferior, t);
509 INHERIT (to_post_startup_inferior, t);
510 INHERIT (to_acknowledge_created_inferior, t);
511 INHERIT (to_clone_and_follow_inferior, t);
512 INHERIT (to_post_follow_inferior_by_clone, t);
513 INHERIT (to_insert_fork_catchpoint, t);
514 INHERIT (to_remove_fork_catchpoint, t);
515 INHERIT (to_insert_vfork_catchpoint, t);
516 INHERIT (to_remove_vfork_catchpoint, t);
517 INHERIT (to_has_forked, t);
518 INHERIT (to_has_vforked, t);
519 INHERIT (to_can_follow_vfork_prior_to_exec, t);
520 INHERIT (to_post_follow_vfork, t);
521 INHERIT (to_insert_exec_catchpoint, t);
522 INHERIT (to_remove_exec_catchpoint, t);
523 INHERIT (to_has_execd, t);
524 INHERIT (to_reported_exec_events_per_exec_call, t);
525 INHERIT (to_has_syscall_event, t);
526 INHERIT (to_has_exited, t);
527 INHERIT (to_mourn_inferior, t);
528 INHERIT (to_can_run, t);
529 INHERIT (to_notice_signals, t);
530 INHERIT (to_thread_alive, t);
531 INHERIT (to_find_new_threads, t);
532 INHERIT (to_stop, t);
533 INHERIT (to_query, t);
534 INHERIT (to_rcmd, t);
535 INHERIT (to_enable_exception_callback, t);
536 INHERIT (to_get_current_exception_event, t);
537 INHERIT (to_pid_to_exec_file, t);
538 INHERIT (to_core_file_to_sym_file, t);
539 INHERIT (to_stratum, t);
540 INHERIT (DONT_USE, t);
541 INHERIT (to_has_all_memory, t);
542 INHERIT (to_has_memory, t);
543 INHERIT (to_has_stack, t);
544 INHERIT (to_has_registers, t);
545 INHERIT (to_has_execution, t);
546 INHERIT (to_has_thread_control, t);
547 INHERIT (to_sections, t);
548 INHERIT (to_sections_end, t);
549 INHERIT (to_can_async_p, t);
550 INHERIT (to_is_async_p, t);
551 INHERIT (to_async, t);
552 INHERIT (to_magic, t);
558 /* Push a new target type into the stack of the existing target accessors,
559 possibly superseding some of the existing accessors.
561 Result is zero if the pushed target ended up on top of the stack,
562 nonzero if at least one target is on top of it.
564 Rather than allow an empty stack, we always have the dummy target at
565 the bottom stratum, so we can call the function vectors without
570 struct target_ops *t;
572 struct target_stack_item *cur, *prev, *tmp;
574 /* Check magic number. If wrong, it probably means someone changed
575 the struct definition, but not all the places that initialize one. */
576 if (t->to_magic != OPS_MAGIC)
578 fprintf_unfiltered (gdb_stderr,
579 "Magic number of %s target struct wrong\n",
584 /* Find the proper stratum to install this target in. */
586 for (prev = NULL, cur = target_stack; cur; prev = cur, cur = cur->next)
588 if ((int) (t->to_stratum) >= (int) (cur->target_ops->to_stratum))
592 /* If there's already targets at this stratum, remove them. */
595 while (t->to_stratum == cur->target_ops->to_stratum)
597 /* There's already something on this stratum. Close it off. */
598 if (cur->target_ops->to_close)
599 (cur->target_ops->to_close) (0);
601 prev->next = cur->next; /* Unchain old target_ops */
603 target_stack = cur->next; /* Unchain first on list */
609 /* We have removed all targets in our stratum, now add the new one. */
611 tmp = (struct target_stack_item *)
612 xmalloc (sizeof (struct target_stack_item));
621 update_current_target ();
623 cleanup_target (¤t_target); /* Fill in the gaps */
626 setup_target_debug ();
631 /* Remove a target_ops vector from the stack, wherever it may be.
632 Return how many times it was removed (0 or 1). */
636 struct target_ops *t;
638 struct target_stack_item *cur, *prev;
641 t->to_close (0); /* Let it clean up */
643 /* Look for the specified target. Note that we assume that a target
644 can only occur once in the target stack. */
646 for (cur = target_stack, prev = NULL; cur; prev = cur, cur = cur->next)
647 if (cur->target_ops == t)
651 return 0; /* Didn't find target_ops, quit now */
653 /* Unchain the target */
656 target_stack = cur->next;
658 prev->next = cur->next;
660 free (cur); /* Release the target_stack_item */
662 update_current_target ();
663 cleanup_target (¤t_target);
671 (current_target.to_close) (0); /* Let it clean up */
672 if (unpush_target (target_stack->target_ops) == 1)
675 fprintf_unfiltered (gdb_stderr,
676 "pop_target couldn't find target %s\n",
677 current_target.to_shortname);
682 #define MIN(A, B) (((A) <= (B)) ? (A) : (B))
684 /* target_read_string -- read a null terminated string, up to LEN bytes,
685 from MEMADDR in target. Set *ERRNOP to the errno code, or 0 if successful.
686 Set *STRING to a pointer to malloc'd memory containing the data; the caller
687 is responsible for freeing it. Return the number of bytes successfully
691 target_read_string (memaddr, string, len, errnop)
697 int tlen, origlen, offset, i;
701 int buffer_allocated;
703 unsigned int nbytes_read = 0;
705 /* Small for testing. */
706 buffer_allocated = 4;
707 buffer = xmalloc (buffer_allocated);
714 tlen = MIN (len, 4 - (memaddr & 3));
715 offset = memaddr & 3;
717 errcode = target_xfer_memory (memaddr & ~3, buf, 4, 0, NULL);
720 /* The transfer request might have crossed the boundary to an
721 unallocated region of memory. Retry the transfer, requesting
725 errcode = target_xfer_memory (memaddr, buf, 1, 0, NULL);
730 if (bufptr - buffer + tlen > buffer_allocated)
733 bytes = bufptr - buffer;
734 buffer_allocated *= 2;
735 buffer = xrealloc (buffer, buffer_allocated);
736 bufptr = buffer + bytes;
739 for (i = 0; i < tlen; i++)
741 *bufptr++ = buf[i + offset];
742 if (buf[i + offset] == '\000')
744 nbytes_read += i + 1;
761 /* Read LEN bytes of target memory at address MEMADDR, placing the results in
762 GDB's memory at MYADDR. Returns either 0 for success or an errno value
765 If an error occurs, no guarantee is made about the contents of the data at
766 MYADDR. In particular, the caller should not depend upon partial reads
767 filling the buffer with good data. There is no way for the caller to know
768 how much good data might have been transfered anyway. Callers that can
769 deal with partial reads should call target_read_memory_partial. */
772 target_read_memory (memaddr, myaddr, len)
777 return target_xfer_memory (memaddr, myaddr, len, 0, NULL);
781 target_read_memory_section (memaddr, myaddr, len, bfd_section)
785 asection *bfd_section;
787 return target_xfer_memory (memaddr, myaddr, len, 0, bfd_section);
790 /* Read LEN bytes of target memory at address MEMADDR, placing the results
791 in GDB's memory at MYADDR. Returns a count of the bytes actually read,
792 and optionally an errno value in the location pointed to by ERRNOPTR
793 if ERRNOPTR is non-null. */
796 target_read_memory_partial (memaddr, myaddr, len, errnoptr)
802 int nread; /* Number of bytes actually read. */
803 int errcode; /* Error from last read. */
805 /* First try a complete read. */
806 errcode = target_xfer_memory (memaddr, myaddr, len, 0, NULL);
814 /* Loop, reading one byte at a time until we get as much as we can. */
815 for (errcode = 0, nread = 0; len > 0 && errcode == 0; nread++, len--)
817 errcode = target_xfer_memory (memaddr++, myaddr++, 1, 0, NULL);
819 /* If an error, the last read was unsuccessful, so adjust count. */
825 if (errnoptr != NULL)
833 target_write_memory (memaddr, myaddr, len)
838 return target_xfer_memory (memaddr, myaddr, len, 1, NULL);
841 /* This variable is used to pass section information down to targets. This
842 *should* be done by adding an argument to the target_xfer_memory function
843 of all the targets, but I didn't feel like changing 50+ files. */
845 asection *target_memory_bfd_section = NULL;
847 /* Move memory to or from the targets. Iterate until all of it has
848 been moved, if necessary. The top target gets priority; anything
849 it doesn't want, is offered to the next one down, etc. Note the
850 business with curlen: if an early target says "no, but I have a
851 boundary overlapping this xfer" then we shorten what we offer to
852 the subsequent targets so the early guy will get a chance at the
853 tail before the subsequent ones do.
855 Result is 0 or errno value. */
858 target_xfer_memory (memaddr, myaddr, len, write, bfd_section)
863 asection *bfd_section;
867 struct target_ops *t;
868 struct target_stack_item *item;
870 /* Zero length requests are ok and require no work. */
874 target_memory_bfd_section = bfd_section;
876 /* to_xfer_memory is not guaranteed to set errno, even when it returns
880 /* The quick case is that the top target does it all. */
881 res = current_target.to_xfer_memory
882 (memaddr, myaddr, len, write, ¤t_target);
888 /* If res <= 0 then we call it again in the loop. Ah well. */
892 curlen = len; /* Want to do it all */
893 for (item = target_stack; item; item = item->next)
895 t = item->target_ops;
896 if (!t->to_has_memory)
899 res = t->to_xfer_memory (memaddr, myaddr, curlen, write, t);
901 break; /* Handled all or part of xfer */
902 if (t->to_has_all_memory)
908 /* If this address is for nonexistent memory,
909 read zeros if reading, or do nothing if writing. Return error. */
911 memset (myaddr, 0, len);
922 return 0; /* We managed to cover it all somehow. */
928 target_info (args, from_tty)
932 struct target_ops *t;
933 struct target_stack_item *item;
936 if (symfile_objfile != NULL)
937 printf_unfiltered ("Symbols from \"%s\".\n", symfile_objfile->name);
939 #ifdef FILES_INFO_HOOK
940 if (FILES_INFO_HOOK ())
944 for (item = target_stack; item; item = item->next)
946 t = item->target_ops;
948 if (!t->to_has_memory)
951 if ((int) (t->to_stratum) <= (int) dummy_stratum)
954 printf_unfiltered ("\tWhile running this, GDB does not access memory from...\n");
955 printf_unfiltered ("%s:\n", t->to_longname);
956 (t->to_files_info) (t);
957 has_all_mem = t->to_has_all_memory;
961 /* This is to be called by the open routine before it does
965 target_preopen (from_tty)
970 if (target_has_execution)
973 || query ("A program is being debugged already. Kill it? "))
976 error ("Program not killed.");
979 /* Calling target_kill may remove the target from the stack. But if
980 it doesn't (which seems like a win for UDI), remove it now. */
982 if (target_has_execution)
986 /* Detach a target after doing deferred register stores. */
989 target_detach (args, from_tty)
993 /* Handle any optimized stores to the inferior. */
994 #ifdef DO_DEFERRED_STORES
997 (current_target.to_detach) (args, from_tty);
1001 target_link (modname, t_reloc)
1005 if (STREQ (current_target.to_shortname, "rombug"))
1007 (current_target.to_lookup_symbol) (modname, t_reloc);
1009 error ("Unable to link to %s and get relocation in rombug", modname);
1012 *t_reloc = (CORE_ADDR) - 1;
1015 /* Look through the list of possible targets for a target that can
1016 execute a run or attach command without any other data. This is
1017 used to locate the default process stratum.
1019 Result is always valid (error() is called for errors). */
1021 static struct target_ops *
1022 find_default_run_target (do_mesg)
1025 struct target_ops **t;
1026 struct target_ops *runable = NULL;
1031 for (t = target_structs; t < target_structs + target_struct_size;
1034 if ((*t)->to_can_run && target_can_run (*t))
1042 error ("Don't know how to %s. Try \"help target\".", do_mesg);
1048 find_default_attach (args, from_tty)
1052 struct target_ops *t;
1054 t = find_default_run_target ("attach");
1055 (t->to_attach) (args, from_tty);
1060 find_default_require_attach (args, from_tty)
1064 struct target_ops *t;
1066 t = find_default_run_target ("require_attach");
1067 (t->to_require_attach) (args, from_tty);
1072 find_default_require_detach (pid, args, from_tty)
1077 struct target_ops *t;
1079 t = find_default_run_target ("require_detach");
1080 (t->to_require_detach) (pid, args, from_tty);
1085 find_default_create_inferior (exec_file, allargs, env)
1090 struct target_ops *t;
1092 t = find_default_run_target ("run");
1093 (t->to_create_inferior) (exec_file, allargs, env);
1098 find_default_clone_and_follow_inferior (child_pid, followed_child)
1100 int *followed_child;
1102 struct target_ops *t;
1104 t = find_default_run_target ("run");
1105 (t->to_clone_and_follow_inferior) (child_pid, followed_child);
1122 * Resize the to_sections pointer. Also make sure that anyone that
1123 * was holding on to an old value of it gets updated.
1124 * Returns the old size.
1128 target_resize_to_sections (struct target_ops *target, int num_added)
1130 struct target_ops **t;
1131 struct section_table *old_value;
1134 old_value = target->to_sections;
1136 if (target->to_sections)
1138 old_count = target->to_sections_end - target->to_sections;
1139 target->to_sections = (struct section_table *)
1140 xrealloc ((char *) target->to_sections,
1141 (sizeof (struct section_table)) * (num_added + old_count));
1146 target->to_sections = (struct section_table *)
1147 xmalloc ((sizeof (struct section_table)) * num_added);
1149 target->to_sections_end = target->to_sections + (num_added + old_count);
1151 /* Check to see if anyone else was pointing to this structure.
1152 If old_value was null, then no one was. */
1156 for (t = target_structs; t < target_structs + target_struct_size;
1159 if ((*t)->to_sections == old_value)
1161 (*t)->to_sections = target->to_sections;
1162 (*t)->to_sections_end = target->to_sections_end;
1171 /* Find a single runnable target in the stack and return it. If for
1172 some reason there is more than one, return NULL. */
1177 struct target_ops **t;
1178 struct target_ops *runable = NULL;
1183 for (t = target_structs; t < target_structs + target_struct_size; ++t)
1185 if ((*t)->to_can_run && target_can_run (*t))
1192 return (count == 1 ? runable : NULL);
1198 struct target_ops **t;
1199 struct target_ops *runable = NULL;
1204 for (t = target_structs; t < target_structs + target_struct_size;
1207 if ((*t)->to_stratum == core_stratum)
1214 return (count == 1 ? runable : NULL);
1217 /* The inferior process has died. Long live the inferior! */
1220 generic_mourn_inferior ()
1222 extern int show_breakpoint_hit_counts;
1226 breakpoint_init_inferior (inf_exited);
1227 registers_changed ();
1229 #ifdef CLEAR_DEFERRED_STORES
1230 /* Delete any pending stores to the inferior... */
1231 CLEAR_DEFERRED_STORES;
1234 reopen_exec_file ();
1235 reinit_frame_cache ();
1237 /* It is confusing to the user for ignore counts to stick around
1238 from previous runs of the inferior. So clear them. */
1239 /* However, it is more confusing for the ignore counts to disappear when
1240 using hit counts. So don't clear them if we're counting hits. */
1241 if (!show_breakpoint_hit_counts)
1242 breakpoint_clear_ignore_counts ();
1245 /* This table must match in order and size the signals in enum target_signal
1254 {"SIGHUP", "Hangup"},
1255 {"SIGINT", "Interrupt"},
1256 {"SIGQUIT", "Quit"},
1257 {"SIGILL", "Illegal instruction"},
1258 {"SIGTRAP", "Trace/breakpoint trap"},
1259 {"SIGABRT", "Aborted"},
1260 {"SIGEMT", "Emulation trap"},
1261 {"SIGFPE", "Arithmetic exception"},
1262 {"SIGKILL", "Killed"},
1263 {"SIGBUS", "Bus error"},
1264 {"SIGSEGV", "Segmentation fault"},
1265 {"SIGSYS", "Bad system call"},
1266 {"SIGPIPE", "Broken pipe"},
1267 {"SIGALRM", "Alarm clock"},
1268 {"SIGTERM", "Terminated"},
1269 {"SIGURG", "Urgent I/O condition"},
1270 {"SIGSTOP", "Stopped (signal)"},
1271 {"SIGTSTP", "Stopped (user)"},
1272 {"SIGCONT", "Continued"},
1273 {"SIGCHLD", "Child status changed"},
1274 {"SIGTTIN", "Stopped (tty input)"},
1275 {"SIGTTOU", "Stopped (tty output)"},
1276 {"SIGIO", "I/O possible"},
1277 {"SIGXCPU", "CPU time limit exceeded"},
1278 {"SIGXFSZ", "File size limit exceeded"},
1279 {"SIGVTALRM", "Virtual timer expired"},
1280 {"SIGPROF", "Profiling timer expired"},
1281 {"SIGWINCH", "Window size changed"},
1282 {"SIGLOST", "Resource lost"},
1283 {"SIGUSR1", "User defined signal 1"},
1284 {"SIGUSR2", "User defined signal 2"},
1285 {"SIGPWR", "Power fail/restart"},
1286 {"SIGPOLL", "Pollable event occurred"},
1287 {"SIGWIND", "SIGWIND"},
1288 {"SIGPHONE", "SIGPHONE"},
1289 {"SIGWAITING", "Process's LWPs are blocked"},
1290 {"SIGLWP", "Signal LWP"},
1291 {"SIGDANGER", "Swap space dangerously low"},
1292 {"SIGGRANT", "Monitor mode granted"},
1293 {"SIGRETRACT", "Need to relinquish monitor mode"},
1294 {"SIGMSG", "Monitor mode data available"},
1295 {"SIGSOUND", "Sound completed"},
1296 {"SIGSAK", "Secure attention"},
1297 {"SIGPRIO", "SIGPRIO"},
1298 {"SIG33", "Real-time event 33"},
1299 {"SIG34", "Real-time event 34"},
1300 {"SIG35", "Real-time event 35"},
1301 {"SIG36", "Real-time event 36"},
1302 {"SIG37", "Real-time event 37"},
1303 {"SIG38", "Real-time event 38"},
1304 {"SIG39", "Real-time event 39"},
1305 {"SIG40", "Real-time event 40"},
1306 {"SIG41", "Real-time event 41"},
1307 {"SIG42", "Real-time event 42"},
1308 {"SIG43", "Real-time event 43"},
1309 {"SIG44", "Real-time event 44"},
1310 {"SIG45", "Real-time event 45"},
1311 {"SIG46", "Real-time event 46"},
1312 {"SIG47", "Real-time event 47"},
1313 {"SIG48", "Real-time event 48"},
1314 {"SIG49", "Real-time event 49"},
1315 {"SIG50", "Real-time event 50"},
1316 {"SIG51", "Real-time event 51"},
1317 {"SIG52", "Real-time event 52"},
1318 {"SIG53", "Real-time event 53"},
1319 {"SIG54", "Real-time event 54"},
1320 {"SIG55", "Real-time event 55"},
1321 {"SIG56", "Real-time event 56"},
1322 {"SIG57", "Real-time event 57"},
1323 {"SIG58", "Real-time event 58"},
1324 {"SIG59", "Real-time event 59"},
1325 {"SIG60", "Real-time event 60"},
1326 {"SIG61", "Real-time event 61"},
1327 {"SIG62", "Real-time event 62"},
1328 {"SIG63", "Real-time event 63"},
1329 {"SIGCANCEL", "LWP internal signal"},
1330 {"SIG32", "Real-time event 32"},
1332 #if defined(MACH) || defined(__MACH__)
1333 /* Mach exceptions */
1334 {"EXC_BAD_ACCESS", "Could not access memory"},
1335 {"EXC_BAD_INSTRUCTION", "Illegal instruction/operand"},
1336 {"EXC_ARITHMETIC", "Arithmetic exception"},
1337 {"EXC_EMULATION", "Emulation instruction"},
1338 {"EXC_SOFTWARE", "Software generated exception"},
1339 {"EXC_BREAKPOINT", "Breakpoint"},
1341 {"SIGINFO", "Information request"},
1343 {NULL, "Unknown signal"},
1344 {NULL, "Internal error: printing TARGET_SIGNAL_DEFAULT"},
1346 /* Last entry, used to check whether the table is the right size. */
1347 {NULL, "TARGET_SIGNAL_MAGIC"}
1353 /* Return the string for a signal. */
1355 target_signal_to_string (sig)
1356 enum target_signal sig;
1358 if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST))
1359 return signals[sig].string;
1361 return signals[TARGET_SIGNAL_UNKNOWN].string;
1364 /* Return the name for a signal. */
1366 target_signal_to_name (sig)
1367 enum target_signal sig;
1369 if (sig == TARGET_SIGNAL_UNKNOWN)
1370 /* I think the code which prints this will always print it along with
1371 the string, so no need to be verbose. */
1373 return signals[sig].name;
1376 /* Given a name, return its signal. */
1378 target_signal_from_name (name)
1381 enum target_signal sig;
1383 /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
1384 for TARGET_SIGNAL_SIGCHLD. SIGIOT, on the other hand, is more
1385 questionable; seems like by now people should call it SIGABRT
1388 /* This ugly cast brought to you by the native VAX compiler. */
1389 for (sig = TARGET_SIGNAL_HUP;
1390 signals[sig].name != NULL;
1391 sig = (enum target_signal) ((int) sig + 1))
1392 if (STREQ (name, signals[sig].name))
1394 return TARGET_SIGNAL_UNKNOWN;
1397 /* The following functions are to help certain targets deal
1398 with the signal/waitstatus stuff. They could just as well be in
1399 a file called native-utils.c or unixwaitstatus-utils.c or whatever. */
1401 /* Convert host signal to our signals. */
1403 target_signal_from_host (hostsig)
1406 /* A switch statement would make sense but would require special kludges
1407 to deal with the cases where more than one signal has the same number. */
1410 return TARGET_SIGNAL_0;
1412 #if defined (SIGHUP)
1413 if (hostsig == SIGHUP)
1414 return TARGET_SIGNAL_HUP;
1416 #if defined (SIGINT)
1417 if (hostsig == SIGINT)
1418 return TARGET_SIGNAL_INT;
1420 #if defined (SIGQUIT)
1421 if (hostsig == SIGQUIT)
1422 return TARGET_SIGNAL_QUIT;
1424 #if defined (SIGILL)
1425 if (hostsig == SIGILL)
1426 return TARGET_SIGNAL_ILL;
1428 #if defined (SIGTRAP)
1429 if (hostsig == SIGTRAP)
1430 return TARGET_SIGNAL_TRAP;
1432 #if defined (SIGABRT)
1433 if (hostsig == SIGABRT)
1434 return TARGET_SIGNAL_ABRT;
1436 #if defined (SIGEMT)
1437 if (hostsig == SIGEMT)
1438 return TARGET_SIGNAL_EMT;
1440 #if defined (SIGFPE)
1441 if (hostsig == SIGFPE)
1442 return TARGET_SIGNAL_FPE;
1444 #if defined (SIGKILL)
1445 if (hostsig == SIGKILL)
1446 return TARGET_SIGNAL_KILL;
1448 #if defined (SIGBUS)
1449 if (hostsig == SIGBUS)
1450 return TARGET_SIGNAL_BUS;
1452 #if defined (SIGSEGV)
1453 if (hostsig == SIGSEGV)
1454 return TARGET_SIGNAL_SEGV;
1456 #if defined (SIGSYS)
1457 if (hostsig == SIGSYS)
1458 return TARGET_SIGNAL_SYS;
1460 #if defined (SIGPIPE)
1461 if (hostsig == SIGPIPE)
1462 return TARGET_SIGNAL_PIPE;
1464 #if defined (SIGALRM)
1465 if (hostsig == SIGALRM)
1466 return TARGET_SIGNAL_ALRM;
1468 #if defined (SIGTERM)
1469 if (hostsig == SIGTERM)
1470 return TARGET_SIGNAL_TERM;
1472 #if defined (SIGUSR1)
1473 if (hostsig == SIGUSR1)
1474 return TARGET_SIGNAL_USR1;
1476 #if defined (SIGUSR2)
1477 if (hostsig == SIGUSR2)
1478 return TARGET_SIGNAL_USR2;
1480 #if defined (SIGCLD)
1481 if (hostsig == SIGCLD)
1482 return TARGET_SIGNAL_CHLD;
1484 #if defined (SIGCHLD)
1485 if (hostsig == SIGCHLD)
1486 return TARGET_SIGNAL_CHLD;
1488 #if defined (SIGPWR)
1489 if (hostsig == SIGPWR)
1490 return TARGET_SIGNAL_PWR;
1492 #if defined (SIGWINCH)
1493 if (hostsig == SIGWINCH)
1494 return TARGET_SIGNAL_WINCH;
1496 #if defined (SIGURG)
1497 if (hostsig == SIGURG)
1498 return TARGET_SIGNAL_URG;
1501 if (hostsig == SIGIO)
1502 return TARGET_SIGNAL_IO;
1504 #if defined (SIGPOLL)
1505 if (hostsig == SIGPOLL)
1506 return TARGET_SIGNAL_POLL;
1508 #if defined (SIGSTOP)
1509 if (hostsig == SIGSTOP)
1510 return TARGET_SIGNAL_STOP;
1512 #if defined (SIGTSTP)
1513 if (hostsig == SIGTSTP)
1514 return TARGET_SIGNAL_TSTP;
1516 #if defined (SIGCONT)
1517 if (hostsig == SIGCONT)
1518 return TARGET_SIGNAL_CONT;
1520 #if defined (SIGTTIN)
1521 if (hostsig == SIGTTIN)
1522 return TARGET_SIGNAL_TTIN;
1524 #if defined (SIGTTOU)
1525 if (hostsig == SIGTTOU)
1526 return TARGET_SIGNAL_TTOU;
1528 #if defined (SIGVTALRM)
1529 if (hostsig == SIGVTALRM)
1530 return TARGET_SIGNAL_VTALRM;
1532 #if defined (SIGPROF)
1533 if (hostsig == SIGPROF)
1534 return TARGET_SIGNAL_PROF;
1536 #if defined (SIGXCPU)
1537 if (hostsig == SIGXCPU)
1538 return TARGET_SIGNAL_XCPU;
1540 #if defined (SIGXFSZ)
1541 if (hostsig == SIGXFSZ)
1542 return TARGET_SIGNAL_XFSZ;
1544 #if defined (SIGWIND)
1545 if (hostsig == SIGWIND)
1546 return TARGET_SIGNAL_WIND;
1548 #if defined (SIGPHONE)
1549 if (hostsig == SIGPHONE)
1550 return TARGET_SIGNAL_PHONE;
1552 #if defined (SIGLOST)
1553 if (hostsig == SIGLOST)
1554 return TARGET_SIGNAL_LOST;
1556 #if defined (SIGWAITING)
1557 if (hostsig == SIGWAITING)
1558 return TARGET_SIGNAL_WAITING;
1560 #if defined (SIGCANCEL)
1561 if (hostsig == SIGCANCEL)
1562 return TARGET_SIGNAL_CANCEL;
1564 #if defined (SIGLWP)
1565 if (hostsig == SIGLWP)
1566 return TARGET_SIGNAL_LWP;
1568 #if defined (SIGDANGER)
1569 if (hostsig == SIGDANGER)
1570 return TARGET_SIGNAL_DANGER;
1572 #if defined (SIGGRANT)
1573 if (hostsig == SIGGRANT)
1574 return TARGET_SIGNAL_GRANT;
1576 #if defined (SIGRETRACT)
1577 if (hostsig == SIGRETRACT)
1578 return TARGET_SIGNAL_RETRACT;
1580 #if defined (SIGMSG)
1581 if (hostsig == SIGMSG)
1582 return TARGET_SIGNAL_MSG;
1584 #if defined (SIGSOUND)
1585 if (hostsig == SIGSOUND)
1586 return TARGET_SIGNAL_SOUND;
1588 #if defined (SIGSAK)
1589 if (hostsig == SIGSAK)
1590 return TARGET_SIGNAL_SAK;
1592 #if defined (SIGPRIO)
1593 if (hostsig == SIGPRIO)
1594 return TARGET_SIGNAL_PRIO;
1597 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1598 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1599 if (hostsig == _NSIG + EXC_BAD_ACCESS)
1600 return TARGET_EXC_BAD_ACCESS;
1602 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
1603 if (hostsig == _NSIG + EXC_BAD_INSTRUCTION)
1604 return TARGET_EXC_BAD_INSTRUCTION;
1606 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
1607 if (hostsig == _NSIG + EXC_ARITHMETIC)
1608 return TARGET_EXC_ARITHMETIC;
1610 #if defined (EXC_EMULATION) && defined (_NSIG)
1611 if (hostsig == _NSIG + EXC_EMULATION)
1612 return TARGET_EXC_EMULATION;
1614 #if defined (EXC_SOFTWARE) && defined (_NSIG)
1615 if (hostsig == _NSIG + EXC_SOFTWARE)
1616 return TARGET_EXC_SOFTWARE;
1618 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
1619 if (hostsig == _NSIG + EXC_BREAKPOINT)
1620 return TARGET_EXC_BREAKPOINT;
1623 #if defined (SIGINFO)
1624 if (hostsig == SIGINFO)
1625 return TARGET_SIGNAL_INFO;
1628 #if defined (REALTIME_LO)
1629 if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI)
1631 /* This block of TARGET_SIGNAL_REALTIME value is in order. */
1632 if (33 <= hostsig && hostsig <= 63)
1633 return (enum target_signal)
1634 (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
1635 else if (hostsig == 32)
1636 return TARGET_SIGNAL_REALTIME_32;
1638 error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
1641 return TARGET_SIGNAL_UNKNOWN;
1645 target_signal_to_host (oursig)
1646 enum target_signal oursig;
1650 case TARGET_SIGNAL_0:
1653 #if defined (SIGHUP)
1654 case TARGET_SIGNAL_HUP:
1657 #if defined (SIGINT)
1658 case TARGET_SIGNAL_INT:
1661 #if defined (SIGQUIT)
1662 case TARGET_SIGNAL_QUIT:
1665 #if defined (SIGILL)
1666 case TARGET_SIGNAL_ILL:
1669 #if defined (SIGTRAP)
1670 case TARGET_SIGNAL_TRAP:
1673 #if defined (SIGABRT)
1674 case TARGET_SIGNAL_ABRT:
1677 #if defined (SIGEMT)
1678 case TARGET_SIGNAL_EMT:
1681 #if defined (SIGFPE)
1682 case TARGET_SIGNAL_FPE:
1685 #if defined (SIGKILL)
1686 case TARGET_SIGNAL_KILL:
1689 #if defined (SIGBUS)
1690 case TARGET_SIGNAL_BUS:
1693 #if defined (SIGSEGV)
1694 case TARGET_SIGNAL_SEGV:
1697 #if defined (SIGSYS)
1698 case TARGET_SIGNAL_SYS:
1701 #if defined (SIGPIPE)
1702 case TARGET_SIGNAL_PIPE:
1705 #if defined (SIGALRM)
1706 case TARGET_SIGNAL_ALRM:
1709 #if defined (SIGTERM)
1710 case TARGET_SIGNAL_TERM:
1713 #if defined (SIGUSR1)
1714 case TARGET_SIGNAL_USR1:
1717 #if defined (SIGUSR2)
1718 case TARGET_SIGNAL_USR2:
1721 #if defined (SIGCHLD) || defined (SIGCLD)
1722 case TARGET_SIGNAL_CHLD:
1723 #if defined (SIGCHLD)
1728 #endif /* SIGCLD or SIGCHLD */
1729 #if defined (SIGPWR)
1730 case TARGET_SIGNAL_PWR:
1733 #if defined (SIGWINCH)
1734 case TARGET_SIGNAL_WINCH:
1737 #if defined (SIGURG)
1738 case TARGET_SIGNAL_URG:
1742 case TARGET_SIGNAL_IO:
1745 #if defined (SIGPOLL)
1746 case TARGET_SIGNAL_POLL:
1749 #if defined (SIGSTOP)
1750 case TARGET_SIGNAL_STOP:
1753 #if defined (SIGTSTP)
1754 case TARGET_SIGNAL_TSTP:
1757 #if defined (SIGCONT)
1758 case TARGET_SIGNAL_CONT:
1761 #if defined (SIGTTIN)
1762 case TARGET_SIGNAL_TTIN:
1765 #if defined (SIGTTOU)
1766 case TARGET_SIGNAL_TTOU:
1769 #if defined (SIGVTALRM)
1770 case TARGET_SIGNAL_VTALRM:
1773 #if defined (SIGPROF)
1774 case TARGET_SIGNAL_PROF:
1777 #if defined (SIGXCPU)
1778 case TARGET_SIGNAL_XCPU:
1781 #if defined (SIGXFSZ)
1782 case TARGET_SIGNAL_XFSZ:
1785 #if defined (SIGWIND)
1786 case TARGET_SIGNAL_WIND:
1789 #if defined (SIGPHONE)
1790 case TARGET_SIGNAL_PHONE:
1793 #if defined (SIGLOST)
1794 case TARGET_SIGNAL_LOST:
1797 #if defined (SIGWAITING)
1798 case TARGET_SIGNAL_WAITING:
1801 #if defined (SIGCANCEL)
1802 case TARGET_SIGNAL_CANCEL:
1805 #if defined (SIGLWP)
1806 case TARGET_SIGNAL_LWP:
1809 #if defined (SIGDANGER)
1810 case TARGET_SIGNAL_DANGER:
1813 #if defined (SIGGRANT)
1814 case TARGET_SIGNAL_GRANT:
1817 #if defined (SIGRETRACT)
1818 case TARGET_SIGNAL_RETRACT:
1821 #if defined (SIGMSG)
1822 case TARGET_SIGNAL_MSG:
1825 #if defined (SIGSOUND)
1826 case TARGET_SIGNAL_SOUND:
1829 #if defined (SIGSAK)
1830 case TARGET_SIGNAL_SAK:
1833 #if defined (SIGPRIO)
1834 case TARGET_SIGNAL_PRIO:
1838 case TARGET_SIGNAL_REALTIME_32: return 32; /* by definition */
1840 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1841 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1842 case TARGET_EXC_BAD_ACCESS:
1843 return _NSIG + EXC_BAD_ACCESS;
1845 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
1846 case TARGET_EXC_BAD_INSTRUCTION:
1847 return _NSIG + EXC_BAD_INSTRUCTION;
1849 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
1850 case TARGET_EXC_ARITHMETIC:
1851 return _NSIG + EXC_ARITHMETIC;
1853 #if defined (EXC_EMULATION) && defined (_NSIG)
1854 case TARGET_EXC_EMULATION:
1855 return _NSIG + EXC_EMULATION;
1857 #if defined (EXC_SOFTWARE) && defined (_NSIG)
1858 case TARGET_EXC_SOFTWARE:
1859 return _NSIG + EXC_SOFTWARE;
1861 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
1862 case TARGET_EXC_BREAKPOINT:
1863 return _NSIG + EXC_BREAKPOINT;
1866 #if defined (SIGINFO)
1867 case TARGET_SIGNAL_INFO:
1872 #if defined (REALTIME_LO)
1873 if (oursig >= TARGET_SIGNAL_REALTIME_33
1874 && oursig <= TARGET_SIGNAL_REALTIME_63)
1877 (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + REALTIME_LO;
1878 if (retsig < REALTIME_HI)
1882 /* The user might be trying to do "signal SIGSAK" where this system
1883 doesn't have SIGSAK. */
1884 warning ("Signal %s does not exist on this system.\n",
1885 target_signal_to_name (oursig));
1890 /* Helper function for child_wait and the Lynx derivatives of child_wait.
1891 HOSTSTATUS is the waitstatus from wait() or the equivalent; store our
1892 translation of that in OURSTATUS. */
1894 store_waitstatus (ourstatus, hoststatus)
1895 struct target_waitstatus *ourstatus;
1898 #ifdef CHILD_SPECIAL_WAITSTATUS
1899 /* CHILD_SPECIAL_WAITSTATUS should return nonzero and set *OURSTATUS
1900 if it wants to deal with hoststatus. */
1901 if (CHILD_SPECIAL_WAITSTATUS (ourstatus, hoststatus))
1905 if (WIFEXITED (hoststatus))
1907 ourstatus->kind = TARGET_WAITKIND_EXITED;
1908 ourstatus->value.integer = WEXITSTATUS (hoststatus);
1910 else if (!WIFSTOPPED (hoststatus))
1912 ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
1913 ourstatus->value.sig = target_signal_from_host (WTERMSIG (hoststatus));
1917 ourstatus->kind = TARGET_WAITKIND_STOPPED;
1918 ourstatus->value.sig = target_signal_from_host (WSTOPSIG (hoststatus));
1922 /* In some circumstances we allow a command to specify a numeric
1923 signal. The idea is to keep these circumstances limited so that
1924 users (and scripts) develop portable habits. For comparison,
1925 POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a
1926 numeric signal at all is obscelescent. We are slightly more
1927 lenient and allow 1-15 which should match host signal numbers on
1928 most systems. Use of symbolic signal names is strongly encouraged. */
1931 target_signal_from_command (num)
1934 if (num >= 1 && num <= 15)
1935 return (enum target_signal) num;
1936 error ("Only signals 1-15 are valid as numeric signals.\n\
1937 Use \"info signals\" for a list of symbolic signals.");
1940 /* Returns zero to leave the inferior alone, one to interrupt it. */
1941 int (*target_activity_function) PARAMS ((void));
1942 int target_activity_fd;
1944 /* Convert a normal process ID to a string. Returns the string in a static
1948 normal_pid_to_str (pid)
1951 static char buf[30];
1953 if (STREQ (current_target.to_shortname, "remote"))
1954 sprintf (buf, "thread %d", pid);
1956 sprintf (buf, "process %d", pid);
1961 /* Some targets (such as ttrace-based HPUX) don't allow us to request
1962 notification of inferior events such as fork and vork immediately
1963 after the inferior is created. (This because of how gdb gets an
1964 inferior created via invoking a shell to do it. In such a scenario,
1965 if the shell init file has commands in it, the shell will fork and
1966 exec for each of those commands, and we will see each such fork
1969 This function is used by all targets that allow us to request
1970 notification of forks, etc at inferior creation time; e.g., in
1971 target_acknowledge_forked_child.
1974 normal_target_post_startup_inferior (pid)
1977 /* This space intentionally left blank. */
1980 /* Set up the handful of non-empty slots needed by the dummy target
1984 init_dummy_target ()
1986 dummy_target.to_shortname = "None";
1987 dummy_target.to_longname = "None";
1988 dummy_target.to_doc = "";
1989 dummy_target.to_attach = find_default_attach;
1990 dummy_target.to_require_attach = find_default_require_attach;
1991 dummy_target.to_require_detach = find_default_require_detach;
1992 dummy_target.to_create_inferior = find_default_create_inferior;
1993 dummy_target.to_clone_and_follow_inferior = find_default_clone_and_follow_inferior;
1994 dummy_target.to_stratum = dummy_stratum;
1995 dummy_target.to_magic = OPS_MAGIC;
1999 static struct target_ops debug_target;
2002 debug_to_open (args, from_tty)
2006 debug_target.to_open (args, from_tty);
2008 fprintf_unfiltered (gdb_stdlog, "target_open (%s, %d)\n", args, from_tty);
2012 debug_to_close (quitting)
2015 debug_target.to_close (quitting);
2017 fprintf_unfiltered (gdb_stdlog, "target_close (%d)\n", quitting);
2021 debug_to_attach (args, from_tty)
2025 debug_target.to_attach (args, from_tty);
2027 fprintf_unfiltered (gdb_stdlog, "target_attach (%s, %d)\n", args, from_tty);
2032 debug_to_post_attach (pid)
2035 debug_target.to_post_attach (pid);
2037 fprintf_unfiltered (gdb_stdlog, "target_post_attach (%d)\n", pid);
2041 debug_to_require_attach (args, from_tty)
2045 debug_target.to_require_attach (args, from_tty);
2047 fprintf_unfiltered (gdb_stdlog,
2048 "target_require_attach (%s, %d)\n", args, from_tty);
2052 debug_to_detach (args, from_tty)
2056 debug_target.to_detach (args, from_tty);
2058 fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n", args, from_tty);
2062 debug_to_require_detach (pid, args, from_tty)
2067 debug_target.to_require_detach (pid, args, from_tty);
2069 fprintf_unfiltered (gdb_stdlog,
2070 "target_require_detach (%d, %s, %d)\n", pid, args, from_tty);
2074 debug_to_resume (pid, step, siggnal)
2077 enum target_signal siggnal;
2079 debug_target.to_resume (pid, step, siggnal);
2081 fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n", pid,
2082 step ? "step" : "continue",
2083 target_signal_to_name (siggnal));
2087 debug_to_wait (pid, status)
2089 struct target_waitstatus *status;
2093 retval = debug_target.to_wait (pid, status);
2095 fprintf_unfiltered (gdb_stdlog,
2096 "target_wait (%d, status) = %d, ", pid, retval);
2097 fprintf_unfiltered (gdb_stdlog, "status->kind = ");
2098 switch (status->kind)
2100 case TARGET_WAITKIND_EXITED:
2101 fprintf_unfiltered (gdb_stdlog, "exited, status = %d\n",
2102 status->value.integer);
2104 case TARGET_WAITKIND_STOPPED:
2105 fprintf_unfiltered (gdb_stdlog, "stopped, signal = %s\n",
2106 target_signal_to_name (status->value.sig));
2108 case TARGET_WAITKIND_SIGNALLED:
2109 fprintf_unfiltered (gdb_stdlog, "signalled, signal = %s\n",
2110 target_signal_to_name (status->value.sig));
2112 case TARGET_WAITKIND_LOADED:
2113 fprintf_unfiltered (gdb_stdlog, "loaded\n");
2115 case TARGET_WAITKIND_FORKED:
2116 fprintf_unfiltered (gdb_stdlog, "forked\n");
2118 case TARGET_WAITKIND_VFORKED:
2119 fprintf_unfiltered (gdb_stdlog, "vforked\n");
2121 case TARGET_WAITKIND_EXECD:
2122 fprintf_unfiltered (gdb_stdlog, "execd\n");
2124 case TARGET_WAITKIND_SPURIOUS:
2125 fprintf_unfiltered (gdb_stdlog, "spurious\n");
2128 fprintf_unfiltered (gdb_stdlog, "unknown???\n");
2136 debug_to_post_wait (pid, status)
2140 debug_target.to_post_wait (pid, status);
2142 fprintf_unfiltered (gdb_stdlog, "target_post_wait (%d, %d)\n",
2147 debug_to_fetch_registers (regno)
2150 debug_target.to_fetch_registers (regno);
2152 fprintf_unfiltered (gdb_stdlog, "target_fetch_registers (%s)",
2153 regno != -1 ? REGISTER_NAME (regno) : "-1");
2155 fprintf_unfiltered (gdb_stdlog, " = 0x%lx %ld",
2156 (unsigned long) read_register (regno),
2157 (unsigned long) read_register (regno));
2158 fprintf_unfiltered (gdb_stdlog, "\n");
2162 debug_to_store_registers (regno)
2165 debug_target.to_store_registers (regno);
2167 if (regno >= 0 && regno < NUM_REGS)
2168 fprintf_unfiltered (gdb_stdlog, "target_store_registers (%s) = 0x%lx %ld\n",
2169 REGISTER_NAME (regno),
2170 (unsigned long) read_register (regno),
2171 (unsigned long) read_register (regno));
2173 fprintf_unfiltered (gdb_stdlog, "target_store_registers (%d)\n", regno);
2177 debug_to_prepare_to_store ()
2179 debug_target.to_prepare_to_store ();
2181 fprintf_unfiltered (gdb_stdlog, "target_prepare_to_store ()\n");
2185 debug_to_xfer_memory (memaddr, myaddr, len, write, target)
2190 struct target_ops *target;
2194 retval = debug_target.to_xfer_memory (memaddr, myaddr, len, write, target);
2196 fprintf_unfiltered (gdb_stdlog,
2197 "target_xfer_memory (0x%x, xxx, %d, %s, xxx) = %d",
2198 (unsigned int) memaddr, /* possable truncate long long */
2199 len, write ? "write" : "read", retval);
2207 fputs_unfiltered (", bytes =", gdb_stdlog);
2208 for (i = 0; i < retval; i++)
2210 if ((((long) &(myaddr[i])) & 0xf) == 0)
2211 fprintf_unfiltered (gdb_stdlog, "\n");
2212 fprintf_unfiltered (gdb_stdlog, " %02x", myaddr[i] & 0xff);
2216 fputc_unfiltered ('\n', gdb_stdlog);
2222 debug_to_files_info (target)
2223 struct target_ops *target;
2225 debug_target.to_files_info (target);
2227 fprintf_unfiltered (gdb_stdlog, "target_files_info (xxx)\n");
2231 debug_to_insert_breakpoint (addr, save)
2237 retval = debug_target.to_insert_breakpoint (addr, save);
2239 fprintf_unfiltered (gdb_stdlog,
2240 "target_insert_breakpoint (0x%lx, xxx) = %ld\n",
2241 (unsigned long) addr,
2242 (unsigned long) retval);
2247 debug_to_remove_breakpoint (addr, save)
2253 retval = debug_target.to_remove_breakpoint (addr, save);
2255 fprintf_unfiltered (gdb_stdlog,
2256 "target_remove_breakpoint (0x%lx, xxx) = %ld\n",
2257 (unsigned long) addr,
2258 (unsigned long) retval);
2263 debug_to_terminal_init ()
2265 debug_target.to_terminal_init ();
2267 fprintf_unfiltered (gdb_stdlog, "target_terminal_init ()\n");
2271 debug_to_terminal_inferior ()
2273 debug_target.to_terminal_inferior ();
2275 fprintf_unfiltered (gdb_stdlog, "target_terminal_inferior ()\n");
2279 debug_to_terminal_ours_for_output ()
2281 debug_target.to_terminal_ours_for_output ();
2283 fprintf_unfiltered (gdb_stdlog, "target_terminal_ours_for_output ()\n");
2287 debug_to_terminal_ours ()
2289 debug_target.to_terminal_ours ();
2291 fprintf_unfiltered (gdb_stdlog, "target_terminal_ours ()\n");
2295 debug_to_terminal_info (arg, from_tty)
2299 debug_target.to_terminal_info (arg, from_tty);
2301 fprintf_unfiltered (gdb_stdlog, "target_terminal_info (%s, %d)\n", arg,
2308 debug_target.to_kill ();
2310 fprintf_unfiltered (gdb_stdlog, "target_kill ()\n");
2314 debug_to_load (args, from_tty)
2318 debug_target.to_load (args, from_tty);
2320 fprintf_unfiltered (gdb_stdlog, "target_load (%s, %d)\n", args, from_tty);
2324 debug_to_lookup_symbol (name, addrp)
2330 retval = debug_target.to_lookup_symbol (name, addrp);
2332 fprintf_unfiltered (gdb_stdlog, "target_lookup_symbol (%s, xxx)\n", name);
2338 debug_to_create_inferior (exec_file, args, env)
2343 debug_target.to_create_inferior (exec_file, args, env);
2345 fprintf_unfiltered (gdb_stdlog, "target_create_inferior (%s, %s, xxx)\n",
2350 debug_to_post_startup_inferior (pid)
2353 debug_target.to_post_startup_inferior (pid);
2355 fprintf_unfiltered (gdb_stdlog, "target_post_startup_inferior (%d)\n",
2360 debug_to_acknowledge_created_inferior (pid)
2363 debug_target.to_acknowledge_created_inferior (pid);
2365 fprintf_unfiltered (gdb_stdlog, "target_acknowledge_created_inferior (%d)\n",
2370 debug_to_clone_and_follow_inferior (child_pid, followed_child)
2372 int *followed_child;
2374 debug_target.to_clone_and_follow_inferior (child_pid, followed_child);
2376 fprintf_unfiltered (gdb_stdlog,
2377 "target_clone_and_follow_inferior (%d, %d)\n",
2378 child_pid, *followed_child);
2382 debug_to_post_follow_inferior_by_clone ()
2384 debug_target.to_post_follow_inferior_by_clone ();
2386 fprintf_unfiltered (gdb_stdlog, "target_post_follow_inferior_by_clone ()\n");
2390 debug_to_insert_fork_catchpoint (pid)
2395 retval = debug_target.to_insert_fork_catchpoint (pid);
2397 fprintf_unfiltered (gdb_stdlog, "target_insert_fork_catchpoint (%d) = %d\n",
2404 debug_to_remove_fork_catchpoint (pid)
2409 retval = debug_target.to_remove_fork_catchpoint (pid);
2411 fprintf_unfiltered (gdb_stdlog, "target_remove_fork_catchpoint (%d) = %d\n",
2418 debug_to_insert_vfork_catchpoint (pid)
2423 retval = debug_target.to_insert_vfork_catchpoint (pid);
2425 fprintf_unfiltered (gdb_stdlog, "target_insert_vfork_catchpoint (%d)= %d\n",
2432 debug_to_remove_vfork_catchpoint (pid)
2437 retval = debug_target.to_remove_vfork_catchpoint (pid);
2439 fprintf_unfiltered (gdb_stdlog, "target_remove_vfork_catchpoint (%d) = %d\n",
2446 debug_to_has_forked (pid, child_pid)
2452 has_forked = debug_target.to_has_forked (pid, child_pid);
2454 fprintf_unfiltered (gdb_stdlog, "target_has_forked (%d, %d) = %d\n",
2455 pid, *child_pid, has_forked);
2461 debug_to_has_vforked (pid, child_pid)
2467 has_vforked = debug_target.to_has_vforked (pid, child_pid);
2469 fprintf_unfiltered (gdb_stdlog, "target_has_vforked (%d, %d) = %d\n",
2470 pid, *child_pid, has_vforked);
2476 debug_to_can_follow_vfork_prior_to_exec ()
2478 int can_immediately_follow_vfork;
2480 can_immediately_follow_vfork = debug_target.to_can_follow_vfork_prior_to_exec ();
2482 fprintf_unfiltered (gdb_stdlog, "target_can_follow_vfork_prior_to_exec () = %d\n",
2483 can_immediately_follow_vfork);
2485 return can_immediately_follow_vfork;
2489 debug_to_post_follow_vfork (parent_pid, followed_parent, child_pid, followed_child)
2491 int followed_parent;
2495 debug_target.to_post_follow_vfork (parent_pid, followed_parent, child_pid, followed_child);
2497 fprintf_unfiltered (gdb_stdlog,
2498 "target_post_follow_vfork (%d, %d, %d, %d)\n",
2499 parent_pid, followed_parent, child_pid, followed_child);
2503 debug_to_insert_exec_catchpoint (pid)
2508 retval = debug_target.to_insert_exec_catchpoint (pid);
2510 fprintf_unfiltered (gdb_stdlog, "target_insert_exec_catchpoint (%d) = %d\n",
2517 debug_to_remove_exec_catchpoint (pid)
2522 retval = debug_target.to_remove_exec_catchpoint (pid);
2524 fprintf_unfiltered (gdb_stdlog, "target_remove_exec_catchpoint (%d) = %d\n",
2531 debug_to_has_execd (pid, execd_pathname)
2533 char **execd_pathname;
2537 has_execd = debug_target.to_has_execd (pid, execd_pathname);
2539 fprintf_unfiltered (gdb_stdlog, "target_has_execd (%d, %s) = %d\n",
2540 pid, (*execd_pathname ? *execd_pathname : "<NULL>"),
2547 debug_to_reported_exec_events_per_exec_call ()
2549 int reported_exec_events;
2551 reported_exec_events = debug_target.to_reported_exec_events_per_exec_call ();
2553 fprintf_unfiltered (gdb_stdlog,
2554 "target_reported_exec_events_per_exec_call () = %d\n",
2555 reported_exec_events);
2557 return reported_exec_events;
2561 debug_to_has_syscall_event (pid, kind, syscall_id)
2563 enum target_waitkind *kind;
2566 int has_syscall_event;
2567 char *kind_spelling = "??";
2569 has_syscall_event = debug_target.to_has_syscall_event (pid, kind, syscall_id);
2570 if (has_syscall_event)
2574 case TARGET_WAITKIND_SYSCALL_ENTRY:
2575 kind_spelling = "SYSCALL_ENTRY";
2577 case TARGET_WAITKIND_SYSCALL_RETURN:
2578 kind_spelling = "SYSCALL_RETURN";
2585 fprintf_unfiltered (gdb_stdlog,
2586 "target_has_syscall_event (%d, %s, %d) = %d\n",
2587 pid, kind_spelling, *syscall_id, has_syscall_event);
2589 return has_syscall_event;
2593 debug_to_has_exited (pid, wait_status, exit_status)
2600 has_exited = debug_target.to_has_exited (pid, wait_status, exit_status);
2602 fprintf_unfiltered (gdb_stdlog, "target_has_exited (%d, %d, %d) = %d\n",
2603 pid, wait_status, *exit_status, has_exited);
2609 debug_to_mourn_inferior ()
2611 debug_target.to_mourn_inferior ();
2613 fprintf_unfiltered (gdb_stdlog, "target_mourn_inferior ()\n");
2621 retval = debug_target.to_can_run ();
2623 fprintf_unfiltered (gdb_stdlog, "target_can_run () = %d\n", retval);
2629 debug_to_notice_signals (pid)
2632 debug_target.to_notice_signals (pid);
2634 fprintf_unfiltered (gdb_stdlog, "target_notice_signals (%d)\n", pid);
2638 debug_to_thread_alive (pid)
2643 retval = debug_target.to_thread_alive (pid);
2645 fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n",
2654 debug_target.to_stop ();
2656 fprintf_unfiltered (gdb_stdlog, "target_stop ()\n");
2660 debug_to_query (type, req, resp, siz)
2668 retval = debug_target.to_query (type, req, resp, siz);
2670 fprintf_unfiltered (gdb_stdlog, "target_query (%c, %s, %s, %d) = %d\n", type, req, resp, *siz, retval);
2676 debug_to_rcmd (char *command,
2677 struct gdb_file *outbuf)
2679 debug_target.to_rcmd (command, outbuf);
2680 fprintf_unfiltered (gdb_stdlog, "target_rcmd (%s, ...)\n", command);
2683 static struct symtab_and_line *
2684 debug_to_enable_exception_callback (kind, enable)
2685 enum exception_event_kind kind;
2688 struct symtab_and_line *result;
2689 result = debug_target.to_enable_exception_callback (kind, enable);
2690 fprintf_unfiltered (gdb_stdlog,
2691 "target get_exception_callback_sal (%d, %d)\n",
2696 static struct exception_event_record *
2697 debug_to_get_current_exception_event ()
2699 struct exception_event_record *result;
2700 result = debug_target.to_get_current_exception_event ();
2701 fprintf_unfiltered (gdb_stdlog, "target get_current_exception_event ()\n");
2706 debug_to_pid_to_exec_file (pid)
2711 exec_file = debug_target.to_pid_to_exec_file (pid);
2713 fprintf_unfiltered (gdb_stdlog, "target_pid_to_exec_file (%d) = %s\n",
2720 debug_to_core_file_to_sym_file (core)
2725 sym_file = debug_target.to_core_file_to_sym_file (core);
2727 fprintf_unfiltered (gdb_stdlog, "target_core_file_to_sym_file (%s) = %s\n",
2734 setup_target_debug ()
2736 memcpy (&debug_target, ¤t_target, sizeof debug_target);
2738 current_target.to_open = debug_to_open;
2739 current_target.to_close = debug_to_close;
2740 current_target.to_attach = debug_to_attach;
2741 current_target.to_post_attach = debug_to_post_attach;
2742 current_target.to_require_attach = debug_to_require_attach;
2743 current_target.to_detach = debug_to_detach;
2744 current_target.to_require_detach = debug_to_require_detach;
2745 current_target.to_resume = debug_to_resume;
2746 current_target.to_wait = debug_to_wait;
2747 current_target.to_post_wait = debug_to_post_wait;
2748 current_target.to_fetch_registers = debug_to_fetch_registers;
2749 current_target.to_store_registers = debug_to_store_registers;
2750 current_target.to_prepare_to_store = debug_to_prepare_to_store;
2751 current_target.to_xfer_memory = debug_to_xfer_memory;
2752 current_target.to_files_info = debug_to_files_info;
2753 current_target.to_insert_breakpoint = debug_to_insert_breakpoint;
2754 current_target.to_remove_breakpoint = debug_to_remove_breakpoint;
2755 current_target.to_terminal_init = debug_to_terminal_init;
2756 current_target.to_terminal_inferior = debug_to_terminal_inferior;
2757 current_target.to_terminal_ours_for_output = debug_to_terminal_ours_for_output;
2758 current_target.to_terminal_ours = debug_to_terminal_ours;
2759 current_target.to_terminal_info = debug_to_terminal_info;
2760 current_target.to_kill = debug_to_kill;
2761 current_target.to_load = debug_to_load;
2762 current_target.to_lookup_symbol = debug_to_lookup_symbol;
2763 current_target.to_create_inferior = debug_to_create_inferior;
2764 current_target.to_post_startup_inferior = debug_to_post_startup_inferior;
2765 current_target.to_acknowledge_created_inferior = debug_to_acknowledge_created_inferior;
2766 current_target.to_clone_and_follow_inferior = debug_to_clone_and_follow_inferior;
2767 current_target.to_post_follow_inferior_by_clone = debug_to_post_follow_inferior_by_clone;
2768 current_target.to_insert_fork_catchpoint = debug_to_insert_fork_catchpoint;
2769 current_target.to_remove_fork_catchpoint = debug_to_remove_fork_catchpoint;
2770 current_target.to_insert_vfork_catchpoint = debug_to_insert_vfork_catchpoint;
2771 current_target.to_remove_vfork_catchpoint = debug_to_remove_vfork_catchpoint;
2772 current_target.to_has_forked = debug_to_has_forked;
2773 current_target.to_has_vforked = debug_to_has_vforked;
2774 current_target.to_can_follow_vfork_prior_to_exec = debug_to_can_follow_vfork_prior_to_exec;
2775 current_target.to_post_follow_vfork = debug_to_post_follow_vfork;
2776 current_target.to_insert_exec_catchpoint = debug_to_insert_exec_catchpoint;
2777 current_target.to_remove_exec_catchpoint = debug_to_remove_exec_catchpoint;
2778 current_target.to_has_execd = debug_to_has_execd;
2779 current_target.to_reported_exec_events_per_exec_call = debug_to_reported_exec_events_per_exec_call;
2780 current_target.to_has_syscall_event = debug_to_has_syscall_event;
2781 current_target.to_has_exited = debug_to_has_exited;
2782 current_target.to_mourn_inferior = debug_to_mourn_inferior;
2783 current_target.to_can_run = debug_to_can_run;
2784 current_target.to_notice_signals = debug_to_notice_signals;
2785 current_target.to_thread_alive = debug_to_thread_alive;
2786 current_target.to_stop = debug_to_stop;
2787 current_target.to_query = debug_to_query;
2788 current_target.to_rcmd = debug_to_rcmd;
2789 current_target.to_enable_exception_callback = debug_to_enable_exception_callback;
2790 current_target.to_get_current_exception_event = debug_to_get_current_exception_event;
2791 current_target.to_pid_to_exec_file = debug_to_pid_to_exec_file;
2792 current_target.to_core_file_to_sym_file = debug_to_core_file_to_sym_file;
2797 static char targ_desc[] =
2798 "Names of targets and files being debugged.\n\
2799 Shows the entire stack of targets currently in use (including the exec-file,\n\
2800 core-file, and process, if any), as well as the symbol file name.";
2803 do_monitor_command (char *cmd,
2806 if ((current_target.to_rcmd == (void*) tcomplain)
2807 || (current_target.to_rcmd == debug_to_rcmd
2808 && (debug_target.to_rcmd == (void*) tcomplain)))
2810 error ("\"monitor\" command not supported by this target.\n");
2812 target_rcmd (cmd, gdb_stdtarg);
2816 initialize_targets ()
2818 init_dummy_target ();
2819 push_target (&dummy_target);
2821 add_info ("target", target_info, targ_desc);
2822 add_info ("files", target_info, targ_desc);
2825 add_set_cmd ("targetdebug", class_maintenance, var_zinteger,
2826 (char *) &targetdebug,
2827 "Set target debugging.\n\
2828 When non-zero, target debugging is enabled.", &setlist),
2832 add_com ("monitor", class_obscure, do_monitor_command,
2833 "Send a command to the remote monitor (remote targets only).");
2835 if (!STREQ (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC"))