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"
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
91 MYADDR. Returns 0 for success, errno code for failure (which
92 includes partial transfers -- if you want a more useful response to
93 partial transfers, try either target_read_memory_partial or
94 target_write_memory_partial). */
97 target_xfer_memory
PARAMS ((CORE_ADDR memaddr
, char *myaddr
, int len
,
100 static void init_dummy_target
PARAMS ((void));
103 debug_to_open
PARAMS ((char *, int));
106 debug_to_close
PARAMS ((int));
109 debug_to_attach
PARAMS ((char *, int));
112 debug_to_detach
PARAMS ((char *, int));
115 debug_to_resume
PARAMS ((int, int, enum target_signal
));
118 debug_to_wait
PARAMS ((int, struct target_waitstatus
*));
121 debug_to_fetch_registers
PARAMS ((int));
124 debug_to_store_registers
PARAMS ((int));
127 debug_to_prepare_to_store
PARAMS ((void));
130 debug_to_xfer_memory
PARAMS ((CORE_ADDR
, char *, int, int, struct target_ops
*));
133 debug_to_files_info
PARAMS ((struct target_ops
*));
136 debug_to_insert_breakpoint
PARAMS ((CORE_ADDR
, char *));
139 debug_to_remove_breakpoint
PARAMS ((CORE_ADDR
, char *));
142 debug_to_terminal_init
PARAMS ((void));
145 debug_to_terminal_inferior
PARAMS ((void));
148 debug_to_terminal_ours_for_output
PARAMS ((void));
151 debug_to_terminal_ours
PARAMS ((void));
154 debug_to_terminal_info
PARAMS ((char *, int));
157 debug_to_kill
PARAMS ((void));
160 debug_to_load
PARAMS ((char *, int));
163 debug_to_lookup_symbol
PARAMS ((char *, CORE_ADDR
*));
166 debug_to_create_inferior
PARAMS ((char *, char *, char **));
169 debug_to_mourn_inferior
PARAMS ((void));
172 debug_to_can_run
PARAMS ((void));
175 debug_to_notice_signals
PARAMS ((int));
178 debug_to_thread_alive
PARAMS ((int));
181 debug_to_stop
PARAMS ((void));
183 static int debug_to_query
PARAMS ((int /*char */ , char *, char *, int *));
185 /* Pointer to array of target architecture structures; the size of the
186 array; the current index into the array; the allocated size of the
188 struct target_ops
**target_structs
;
189 unsigned target_struct_size
;
190 unsigned target_struct_index
;
191 unsigned target_struct_allocsize
;
192 #define DEFAULT_ALLOCSIZE 10
194 /* The initial current target, so that there is always a semi-valid
197 static struct target_ops dummy_target
;
199 /* Top of target stack. */
201 struct target_stack_item
*target_stack
;
203 /* The target structure we are currently using to talk to a process
204 or file or whatever "inferior" we have. */
206 struct target_ops current_target
;
208 /* Command list for target. */
210 static struct cmd_list_element
*targetlist
= NULL
;
212 /* Nonzero if we are debugging an attached outside process
213 rather than an inferior. */
217 /* Non-zero if we want to see trace of target level stuff. */
219 static int targetdebug
= 0;
221 static void setup_target_debug
PARAMS ((void));
223 /* The user just typed 'target' without the name of a target. */
227 target_command (arg
, from_tty
)
231 fputs_filtered ("Argument required (target name). Try `help target'\n",
235 /* Add a possible target architecture to the list. */
239 struct target_ops
*t
;
243 target_struct_allocsize
= DEFAULT_ALLOCSIZE
;
244 target_structs
= (struct target_ops
**) xmalloc
245 (target_struct_allocsize
* sizeof (*target_structs
));
247 if (target_struct_size
>= target_struct_allocsize
)
249 target_struct_allocsize
*= 2;
250 target_structs
= (struct target_ops
**)
251 xrealloc ((char *) target_structs
,
252 target_struct_allocsize
* sizeof (*target_structs
));
254 target_structs
[target_struct_size
++] = t
;
255 /* cleanup_target (t); */
257 if (targetlist
== NULL
)
258 add_prefix_cmd ("target", class_run
, target_command
,
259 "Connect to a target machine or process.\n\
260 The first argument is the type or protocol of the target machine.\n\
261 Remaining arguments are interpreted by the target protocol. For more\n\
262 information on the arguments for a particular protocol, type\n\
263 `help target ' followed by the protocol name.",
264 &targetlist
, "target ", 0, &cmdlist
);
265 add_cmd (t
->to_shortname
, no_class
, t
->to_open
, t
->to_doc
, &targetlist
);
276 target_load (char *arg
, int from_tty
)
278 (*current_target
.to_load
) (arg
, from_tty
);
283 nomemory (memaddr
, myaddr
, len
, write
, t
)
288 struct target_ops
*t
;
290 errno
= EIO
; /* Can't read/write this location */
291 return 0; /* No bytes handled */
297 error ("You can't do that when your target is `%s'",
298 current_target
.to_shortname
);
304 error ("You can't do that without a process to debug.");
309 nosymbol (name
, addrp
)
313 return 1; /* Symbol does not exist in target env */
323 error ("No run-time support for this");
329 default_terminal_info (args
, from_tty
)
333 printf_unfiltered ("No saved terminal information.\n");
336 /* This is the default target_create_inferior and target_attach function.
337 If the current target is executing, it asks whether to kill it off.
338 If this function returns without calling error(), it has killed off
339 the target, and the operation should be attempted. */
342 kill_or_be_killed (from_tty
)
345 if (target_has_execution
)
347 printf_unfiltered ("You are already running a program:\n");
348 target_files_info ();
349 if (query ("Kill it? "))
352 if (target_has_execution
)
353 error ("Killing the program did not help.");
358 error ("Program not killed.");
365 maybe_kill_then_attach (args
, from_tty
)
369 kill_or_be_killed (from_tty
);
370 target_attach (args
, from_tty
);
374 maybe_kill_then_create_inferior (exec
, args
, env
)
379 kill_or_be_killed (0);
380 target_create_inferior (exec
, args
, env
);
384 default_clone_and_follow_inferior (child_pid
, followed_child
)
388 target_clone_and_follow_inferior (child_pid
, followed_child
);
391 /* Clean up a target struct so it no longer has any zero pointers in it.
392 We default entries, at least to stubs that print error messages. */
396 struct target_ops
*t
;
399 #define de_fault(field, value) \
404 (void (*) (char *, int))
410 maybe_kill_then_attach
);
411 de_fault (to_post_attach
,
414 de_fault (to_require_attach
,
415 maybe_kill_then_attach
);
417 (void (*) (char *, int))
419 de_fault (to_require_detach
,
420 (void (*) (int, char *, int))
423 (void (*) (int, int, enum target_signal
))
426 (int (*) (int, struct target_waitstatus
*))
428 de_fault (to_post_wait
,
429 (void (*) (int, int))
431 de_fault (to_fetch_registers
,
434 de_fault (to_store_registers
,
437 de_fault (to_prepare_to_store
,
440 de_fault (to_xfer_memory
,
441 (int (*) (CORE_ADDR
, char *, int, int, struct target_ops
*))
443 de_fault (to_files_info
,
444 (void (*) (struct target_ops
*))
446 de_fault (to_insert_breakpoint
,
447 memory_insert_breakpoint
);
448 de_fault (to_remove_breakpoint
,
449 memory_remove_breakpoint
);
450 de_fault (to_terminal_init
,
453 de_fault (to_terminal_inferior
,
456 de_fault (to_terminal_ours_for_output
,
459 de_fault (to_terminal_ours
,
462 de_fault (to_terminal_info
,
463 default_terminal_info
);
468 (void (*) (char *, int))
470 de_fault (to_lookup_symbol
,
471 (int (*) (char *, CORE_ADDR
*))
473 de_fault (to_create_inferior
,
474 maybe_kill_then_create_inferior
);
475 de_fault (to_post_startup_inferior
,
478 de_fault (to_acknowledge_created_inferior
,
481 de_fault (to_clone_and_follow_inferior
,
482 default_clone_and_follow_inferior
);
483 de_fault (to_post_follow_inferior_by_clone
,
486 de_fault (to_insert_fork_catchpoint
,
489 de_fault (to_remove_fork_catchpoint
,
492 de_fault (to_insert_vfork_catchpoint
,
495 de_fault (to_remove_vfork_catchpoint
,
498 de_fault (to_has_forked
,
499 (int (*) (int, int *))
501 de_fault (to_has_vforked
,
502 (int (*) (int, int *))
504 de_fault (to_can_follow_vfork_prior_to_exec
,
507 de_fault (to_post_follow_vfork
,
508 (void (*) (int, int, int, int))
510 de_fault (to_insert_exec_catchpoint
,
513 de_fault (to_remove_exec_catchpoint
,
516 de_fault (to_has_execd
,
517 (int (*) (int, char **))
519 de_fault (to_reported_exec_events_per_exec_call
,
522 de_fault (to_has_syscall_event
,
523 (int (*) (int, enum target_waitkind
*, int *))
525 de_fault (to_has_exited
,
526 (int (*) (int, int, int *))
528 de_fault (to_mourn_inferior
,
531 de_fault (to_can_run
,
533 de_fault (to_notice_signals
,
536 de_fault (to_thread_alive
,
539 de_fault (to_find_new_threads
,
542 de_fault (to_extra_thread_info
,
543 (char *(*) (struct thread_info
*))
549 (int (*) (int, char *, char *, int *))
552 (void (*) (char *, struct ui_file
*))
554 de_fault (to_enable_exception_callback
,
555 (struct symtab_and_line
* (*) (enum exception_event_kind
, int))
557 de_fault (to_get_current_exception_event
,
558 (struct exception_event_record
* (*) (void))
560 de_fault (to_pid_to_exec_file
,
563 de_fault (to_core_file_to_sym_file
,
566 de_fault (to_can_async_p
,
569 de_fault (to_is_async_p
,
573 (void (*) (void (*) (enum inferior_event_type
, void*), void*))
578 /* Go through the target stack from top to bottom, copying over zero entries in
579 current_target. In effect, we are doing class inheritance through the
580 pushed target vectors. */
583 update_current_target ()
585 struct target_stack_item
*item
;
586 struct target_ops
*t
;
588 /* First, reset current_target */
589 memset (¤t_target
, 0, sizeof current_target
);
591 for (item
= target_stack
; item
; item
= item
->next
)
593 t
= item
->target_ops
;
595 #define INHERIT(FIELD, TARGET) \
596 if (!current_target.FIELD) \
597 current_target.FIELD = TARGET->FIELD
599 INHERIT (to_shortname
, t
);
600 INHERIT (to_longname
, t
);
602 INHERIT (to_open
, t
);
603 INHERIT (to_close
, t
);
604 INHERIT (to_attach
, t
);
605 INHERIT (to_post_attach
, t
);
606 INHERIT (to_require_attach
, t
);
607 INHERIT (to_detach
, t
);
608 INHERIT (to_require_detach
, t
);
609 INHERIT (to_resume
, t
);
610 INHERIT (to_wait
, t
);
611 INHERIT (to_post_wait
, t
);
612 INHERIT (to_fetch_registers
, t
);
613 INHERIT (to_store_registers
, t
);
614 INHERIT (to_prepare_to_store
, t
);
615 INHERIT (to_xfer_memory
, t
);
616 INHERIT (to_files_info
, t
);
617 INHERIT (to_insert_breakpoint
, t
);
618 INHERIT (to_remove_breakpoint
, t
);
619 INHERIT (to_terminal_init
, t
);
620 INHERIT (to_terminal_inferior
, t
);
621 INHERIT (to_terminal_ours_for_output
, t
);
622 INHERIT (to_terminal_ours
, t
);
623 INHERIT (to_terminal_info
, t
);
624 INHERIT (to_kill
, t
);
625 INHERIT (to_load
, t
);
626 INHERIT (to_lookup_symbol
, t
);
627 INHERIT (to_create_inferior
, t
);
628 INHERIT (to_post_startup_inferior
, t
);
629 INHERIT (to_acknowledge_created_inferior
, t
);
630 INHERIT (to_clone_and_follow_inferior
, t
);
631 INHERIT (to_post_follow_inferior_by_clone
, t
);
632 INHERIT (to_insert_fork_catchpoint
, t
);
633 INHERIT (to_remove_fork_catchpoint
, t
);
634 INHERIT (to_insert_vfork_catchpoint
, t
);
635 INHERIT (to_remove_vfork_catchpoint
, t
);
636 INHERIT (to_has_forked
, t
);
637 INHERIT (to_has_vforked
, t
);
638 INHERIT (to_can_follow_vfork_prior_to_exec
, t
);
639 INHERIT (to_post_follow_vfork
, t
);
640 INHERIT (to_insert_exec_catchpoint
, t
);
641 INHERIT (to_remove_exec_catchpoint
, t
);
642 INHERIT (to_has_execd
, t
);
643 INHERIT (to_reported_exec_events_per_exec_call
, t
);
644 INHERIT (to_has_syscall_event
, t
);
645 INHERIT (to_has_exited
, t
);
646 INHERIT (to_mourn_inferior
, t
);
647 INHERIT (to_can_run
, t
);
648 INHERIT (to_notice_signals
, t
);
649 INHERIT (to_thread_alive
, t
);
650 INHERIT (to_find_new_threads
, t
);
651 INHERIT (to_pid_to_str
, t
);
652 INHERIT (to_extra_thread_info
, t
);
653 INHERIT (to_stop
, t
);
654 INHERIT (to_query
, t
);
655 INHERIT (to_rcmd
, t
);
656 INHERIT (to_enable_exception_callback
, t
);
657 INHERIT (to_get_current_exception_event
, t
);
658 INHERIT (to_pid_to_exec_file
, t
);
659 INHERIT (to_core_file_to_sym_file
, t
);
660 INHERIT (to_stratum
, t
);
661 INHERIT (DONT_USE
, t
);
662 INHERIT (to_has_all_memory
, t
);
663 INHERIT (to_has_memory
, t
);
664 INHERIT (to_has_stack
, t
);
665 INHERIT (to_has_registers
, t
);
666 INHERIT (to_has_execution
, t
);
667 INHERIT (to_has_thread_control
, t
);
668 INHERIT (to_sections
, t
);
669 INHERIT (to_sections_end
, t
);
670 INHERIT (to_can_async_p
, t
);
671 INHERIT (to_is_async_p
, t
);
672 INHERIT (to_async
, t
);
673 INHERIT (to_async_mask_value
, t
);
674 INHERIT (to_magic
, t
);
680 /* Push a new target type into the stack of the existing target accessors,
681 possibly superseding some of the existing accessors.
683 Result is zero if the pushed target ended up on top of the stack,
684 nonzero if at least one target is on top of it.
686 Rather than allow an empty stack, we always have the dummy target at
687 the bottom stratum, so we can call the function vectors without
692 struct target_ops
*t
;
694 struct target_stack_item
*cur
, *prev
, *tmp
;
696 /* Check magic number. If wrong, it probably means someone changed
697 the struct definition, but not all the places that initialize one. */
698 if (t
->to_magic
!= OPS_MAGIC
)
700 fprintf_unfiltered (gdb_stderr
,
701 "Magic number of %s target struct wrong\n",
706 /* Find the proper stratum to install this target in. */
708 for (prev
= NULL
, cur
= target_stack
; cur
; prev
= cur
, cur
= cur
->next
)
710 if ((int) (t
->to_stratum
) >= (int) (cur
->target_ops
->to_stratum
))
714 /* If there's already targets at this stratum, remove them. */
717 while (t
->to_stratum
== cur
->target_ops
->to_stratum
)
719 /* There's already something on this stratum. Close it off. */
720 if (cur
->target_ops
->to_close
)
721 (cur
->target_ops
->to_close
) (0);
723 prev
->next
= cur
->next
; /* Unchain old target_ops */
725 target_stack
= cur
->next
; /* Unchain first on list */
731 /* We have removed all targets in our stratum, now add the new one. */
733 tmp
= (struct target_stack_item
*)
734 xmalloc (sizeof (struct target_stack_item
));
743 update_current_target ();
745 cleanup_target (¤t_target
); /* Fill in the gaps */
748 setup_target_debug ();
753 /* Remove a target_ops vector from the stack, wherever it may be.
754 Return how many times it was removed (0 or 1). */
758 struct target_ops
*t
;
760 struct target_stack_item
*cur
, *prev
;
763 t
->to_close (0); /* Let it clean up */
765 /* Look for the specified target. Note that we assume that a target
766 can only occur once in the target stack. */
768 for (cur
= target_stack
, prev
= NULL
; cur
; prev
= cur
, cur
= cur
->next
)
769 if (cur
->target_ops
== t
)
773 return 0; /* Didn't find target_ops, quit now */
775 /* Unchain the target */
778 target_stack
= cur
->next
;
780 prev
->next
= cur
->next
;
782 free (cur
); /* Release the target_stack_item */
784 update_current_target ();
785 cleanup_target (¤t_target
);
793 (current_target
.to_close
) (0); /* Let it clean up */
794 if (unpush_target (target_stack
->target_ops
) == 1)
797 fprintf_unfiltered (gdb_stderr
,
798 "pop_target couldn't find target %s\n",
799 current_target
.to_shortname
);
804 #define MIN(A, B) (((A) <= (B)) ? (A) : (B))
806 /* target_read_string -- read a null terminated string, up to LEN bytes,
807 from MEMADDR in target. Set *ERRNOP to the errno code, or 0 if successful.
808 Set *STRING to a pointer to malloc'd memory containing the data; the caller
809 is responsible for freeing it. Return the number of bytes successfully
813 target_read_string (memaddr
, string
, len
, errnop
)
819 int tlen
, origlen
, offset
, i
;
823 int buffer_allocated
;
825 unsigned int nbytes_read
= 0;
827 /* Small for testing. */
828 buffer_allocated
= 4;
829 buffer
= xmalloc (buffer_allocated
);
836 tlen
= MIN (len
, 4 - (memaddr
& 3));
837 offset
= memaddr
& 3;
839 errcode
= target_xfer_memory (memaddr
& ~3, buf
, 4, 0);
842 /* The transfer request might have crossed the boundary to an
843 unallocated region of memory. Retry the transfer, requesting
847 errcode
= target_xfer_memory (memaddr
, buf
, 1, 0);
852 if (bufptr
- buffer
+ tlen
> buffer_allocated
)
855 bytes
= bufptr
- buffer
;
856 buffer_allocated
*= 2;
857 buffer
= xrealloc (buffer
, buffer_allocated
);
858 bufptr
= buffer
+ bytes
;
861 for (i
= 0; i
< tlen
; i
++)
863 *bufptr
++ = buf
[i
+ offset
];
864 if (buf
[i
+ offset
] == '\000')
866 nbytes_read
+= i
+ 1;
883 /* Read LEN bytes of target memory at address MEMADDR, placing the results in
884 GDB's memory at MYADDR. Returns either 0 for success or an errno value
887 If an error occurs, no guarantee is made about the contents of the data at
888 MYADDR. In particular, the caller should not depend upon partial reads
889 filling the buffer with good data. There is no way for the caller to know
890 how much good data might have been transfered anyway. Callers that can
891 deal with partial reads should call target_read_memory_partial. */
894 target_read_memory (memaddr
, myaddr
, len
)
899 return target_xfer_memory (memaddr
, myaddr
, len
, 0);
903 target_write_memory (memaddr
, myaddr
, len
)
908 return target_xfer_memory (memaddr
, myaddr
, len
, 1);
911 /* Move memory to or from the targets. Iterate until all of it has
912 been moved, if necessary. The top target gets priority; anything
913 it doesn't want, is offered to the next one down, etc. Note the
914 business with curlen: if an early target says "no, but I have a
915 boundary overlapping this xfer" then we shorten what we offer to
916 the subsequent targets so the early guy will get a chance at the
917 tail before the subsequent ones do.
919 Result is 0 or errno value. */
922 target_xfer_memory (memaddr
, myaddr
, len
, write
)
930 struct target_ops
*t
;
931 struct target_stack_item
*item
;
933 /* Zero length requests are ok and require no work. */
937 /* to_xfer_memory is not guaranteed to set errno, even when it returns
941 /* The quick case is that the top target does it all. */
942 res
= current_target
.to_xfer_memory
943 (memaddr
, myaddr
, len
, write
, ¤t_target
);
949 /* If res <= 0 then we call it again in the loop. Ah well. */
953 curlen
= len
; /* Want to do it all */
954 for (item
= target_stack
; item
; item
= item
->next
)
956 t
= item
->target_ops
;
957 if (!t
->to_has_memory
)
960 res
= t
->to_xfer_memory (memaddr
, myaddr
, curlen
, write
, t
);
962 break; /* Handled all or part of xfer */
963 if (t
->to_has_all_memory
)
969 /* If this address is for nonexistent memory,
970 read zeros if reading, or do nothing if writing. Return error. */
972 memset (myaddr
, 0, len
);
983 return 0; /* We managed to cover it all somehow. */
987 /* Perform a partial memory transfer. */
990 target_xfer_memory_partial (CORE_ADDR memaddr
, char *buf
, int len
,
991 int write_p
, int *err
)
996 struct target_ops
*t
;
997 struct target_stack_item
*item
;
999 /* Zero length requests are ok and require no work. */
1006 /* The quick case is that the top target does it all. */
1007 res
= current_target
.to_xfer_memory (memaddr
, buf
, len
, write_p
, ¤t_target
);
1014 /* xfer memory doesn't always reliably set errno. */
1017 /* Try all levels of the target stack to see one can handle it. */
1018 for (item
= target_stack
; item
; item
= item
->next
)
1020 t
= item
->target_ops
;
1021 if (!t
->to_has_memory
)
1023 res
= t
->to_xfer_memory (memaddr
, buf
, len
, write_p
, t
);
1026 /* Handled all or part of xfer */
1030 if (t
->to_has_all_memory
)
1034 /* Total failure. Return error. */
1045 target_read_memory_partial (CORE_ADDR memaddr
, char *buf
, int len
, int *err
)
1047 return target_xfer_memory_partial (memaddr
, buf
, len
, 0, err
);
1051 target_write_memory_partial (CORE_ADDR memaddr
, char *buf
, int len
, int *err
)
1053 return target_xfer_memory_partial (memaddr
, buf
, len
, 1, err
);
1058 target_info (args
, from_tty
)
1062 struct target_ops
*t
;
1063 struct target_stack_item
*item
;
1064 int has_all_mem
= 0;
1066 if (symfile_objfile
!= NULL
)
1067 printf_unfiltered ("Symbols from \"%s\".\n", symfile_objfile
->name
);
1069 #ifdef FILES_INFO_HOOK
1070 if (FILES_INFO_HOOK ())
1074 for (item
= target_stack
; item
; item
= item
->next
)
1076 t
= item
->target_ops
;
1078 if (!t
->to_has_memory
)
1081 if ((int) (t
->to_stratum
) <= (int) dummy_stratum
)
1084 printf_unfiltered ("\tWhile running this, GDB does not access memory from...\n");
1085 printf_unfiltered ("%s:\n", t
->to_longname
);
1086 (t
->to_files_info
) (t
);
1087 has_all_mem
= t
->to_has_all_memory
;
1091 /* This is to be called by the open routine before it does
1095 target_preopen (from_tty
)
1100 if (target_has_execution
)
1103 || query ("A program is being debugged already. Kill it? "))
1106 error ("Program not killed.");
1109 /* Calling target_kill may remove the target from the stack. But if
1110 it doesn't (which seems like a win for UDI), remove it now. */
1112 if (target_has_execution
)
1116 /* Detach a target after doing deferred register stores. */
1119 target_detach (args
, from_tty
)
1123 /* Handle any optimized stores to the inferior. */
1124 #ifdef DO_DEFERRED_STORES
1127 (current_target
.to_detach
) (args
, from_tty
);
1131 target_link (modname
, t_reloc
)
1135 if (STREQ (current_target
.to_shortname
, "rombug"))
1137 (current_target
.to_lookup_symbol
) (modname
, t_reloc
);
1139 error ("Unable to link to %s and get relocation in rombug", modname
);
1142 *t_reloc
= (CORE_ADDR
) -1;
1146 target_async_mask (int mask
)
1148 int saved_async_masked_status
= target_async_mask_value
;
1149 target_async_mask_value
= mask
;
1150 return saved_async_masked_status
;
1153 /* Look through the list of possible targets for a target that can
1154 execute a run or attach command without any other data. This is
1155 used to locate the default process stratum.
1157 Result is always valid (error() is called for errors). */
1159 static struct target_ops
*
1160 find_default_run_target (do_mesg
)
1163 struct target_ops
**t
;
1164 struct target_ops
*runable
= NULL
;
1169 for (t
= target_structs
; t
< target_structs
+ target_struct_size
;
1172 if ((*t
)->to_can_run
&& target_can_run (*t
))
1180 error ("Don't know how to %s. Try \"help target\".", do_mesg
);
1186 find_default_attach (args
, from_tty
)
1190 struct target_ops
*t
;
1192 t
= find_default_run_target ("attach");
1193 (t
->to_attach
) (args
, from_tty
);
1198 find_default_require_attach (args
, from_tty
)
1202 struct target_ops
*t
;
1204 t
= find_default_run_target ("require_attach");
1205 (t
->to_require_attach
) (args
, from_tty
);
1210 find_default_require_detach (pid
, args
, from_tty
)
1215 struct target_ops
*t
;
1217 t
= find_default_run_target ("require_detach");
1218 (t
->to_require_detach
) (pid
, args
, from_tty
);
1223 find_default_create_inferior (exec_file
, allargs
, env
)
1228 struct target_ops
*t
;
1230 t
= find_default_run_target ("run");
1231 (t
->to_create_inferior
) (exec_file
, allargs
, env
);
1236 find_default_clone_and_follow_inferior (child_pid
, followed_child
)
1238 int *followed_child
;
1240 struct target_ops
*t
;
1242 t
= find_default_run_target ("run");
1243 (t
->to_clone_and_follow_inferior
) (child_pid
, followed_child
);
1260 * Resize the to_sections pointer. Also make sure that anyone that
1261 * was holding on to an old value of it gets updated.
1262 * Returns the old size.
1266 target_resize_to_sections (struct target_ops
*target
, int num_added
)
1268 struct target_ops
**t
;
1269 struct section_table
*old_value
;
1272 old_value
= target
->to_sections
;
1274 if (target
->to_sections
)
1276 old_count
= target
->to_sections_end
- target
->to_sections
;
1277 target
->to_sections
= (struct section_table
*)
1278 xrealloc ((char *) target
->to_sections
,
1279 (sizeof (struct section_table
)) * (num_added
+ old_count
));
1284 target
->to_sections
= (struct section_table
*)
1285 xmalloc ((sizeof (struct section_table
)) * num_added
);
1287 target
->to_sections_end
= target
->to_sections
+ (num_added
+ old_count
);
1289 /* Check to see if anyone else was pointing to this structure.
1290 If old_value was null, then no one was. */
1294 for (t
= target_structs
; t
< target_structs
+ target_struct_size
;
1297 if ((*t
)->to_sections
== old_value
)
1299 (*t
)->to_sections
= target
->to_sections
;
1300 (*t
)->to_sections_end
= target
->to_sections_end
;
1309 /* Remove all target sections taken from ABFD.
1311 Scan the current target stack for targets whose section tables
1312 refer to sections from BFD, and remove those sections. We use this
1313 when we notice that the inferior has unloaded a shared object, for
1316 remove_target_sections (bfd
*abfd
)
1318 struct target_ops
**t
;
1320 for (t
= target_structs
; t
< target_structs
+ target_struct_size
; t
++)
1322 struct section_table
*src
, *dest
;
1324 dest
= (*t
)->to_sections
;
1325 for (src
= (*t
)->to_sections
; src
< (*t
)->to_sections_end
; src
++)
1326 if (src
->bfd
!= abfd
)
1328 /* Keep this section. */
1329 if (dest
< src
) *dest
= *src
;
1333 /* If we've dropped any sections, resize the section table. */
1335 target_resize_to_sections (*t
, dest
- src
);
1342 /* Find a single runnable target in the stack and return it. If for
1343 some reason there is more than one, return NULL. */
1348 struct target_ops
**t
;
1349 struct target_ops
*runable
= NULL
;
1354 for (t
= target_structs
; t
< target_structs
+ target_struct_size
; ++t
)
1356 if ((*t
)->to_can_run
&& target_can_run (*t
))
1363 return (count
== 1 ? runable
: NULL
);
1366 /* Find a single core_stratum target in the list of targets and return it.
1367 If for some reason there is more than one, return NULL. */
1372 struct target_ops
**t
;
1373 struct target_ops
*runable
= NULL
;
1378 for (t
= target_structs
; t
< target_structs
+ target_struct_size
;
1381 if ((*t
)->to_stratum
== core_stratum
)
1388 return (count
== 1 ? runable
: NULL
);
1392 * Find the next target down the stack from the specified target.
1396 find_target_beneath (t
)
1397 struct target_ops
*t
;
1399 struct target_stack_item
*cur
;
1401 for (cur
= target_stack
; cur
; cur
= cur
->next
)
1402 if (cur
->target_ops
== t
)
1405 if (cur
== NULL
|| cur
->next
== NULL
)
1408 return cur
->next
->target_ops
;
1412 /* The inferior process has died. Long live the inferior! */
1415 generic_mourn_inferior ()
1417 extern int show_breakpoint_hit_counts
;
1421 breakpoint_init_inferior (inf_exited
);
1422 registers_changed ();
1424 #ifdef CLEAR_DEFERRED_STORES
1425 /* Delete any pending stores to the inferior... */
1426 CLEAR_DEFERRED_STORES
;
1429 reopen_exec_file ();
1430 reinit_frame_cache ();
1432 /* It is confusing to the user for ignore counts to stick around
1433 from previous runs of the inferior. So clear them. */
1434 /* However, it is more confusing for the ignore counts to disappear when
1435 using hit counts. So don't clear them if we're counting hits. */
1436 if (!show_breakpoint_hit_counts
)
1437 breakpoint_clear_ignore_counts ();
1440 /* This table must match in order and size the signals in enum target_signal
1449 {"SIGHUP", "Hangup"},
1450 {"SIGINT", "Interrupt"},
1451 {"SIGQUIT", "Quit"},
1452 {"SIGILL", "Illegal instruction"},
1453 {"SIGTRAP", "Trace/breakpoint trap"},
1454 {"SIGABRT", "Aborted"},
1455 {"SIGEMT", "Emulation trap"},
1456 {"SIGFPE", "Arithmetic exception"},
1457 {"SIGKILL", "Killed"},
1458 {"SIGBUS", "Bus error"},
1459 {"SIGSEGV", "Segmentation fault"},
1460 {"SIGSYS", "Bad system call"},
1461 {"SIGPIPE", "Broken pipe"},
1462 {"SIGALRM", "Alarm clock"},
1463 {"SIGTERM", "Terminated"},
1464 {"SIGURG", "Urgent I/O condition"},
1465 {"SIGSTOP", "Stopped (signal)"},
1466 {"SIGTSTP", "Stopped (user)"},
1467 {"SIGCONT", "Continued"},
1468 {"SIGCHLD", "Child status changed"},
1469 {"SIGTTIN", "Stopped (tty input)"},
1470 {"SIGTTOU", "Stopped (tty output)"},
1471 {"SIGIO", "I/O possible"},
1472 {"SIGXCPU", "CPU time limit exceeded"},
1473 {"SIGXFSZ", "File size limit exceeded"},
1474 {"SIGVTALRM", "Virtual timer expired"},
1475 {"SIGPROF", "Profiling timer expired"},
1476 {"SIGWINCH", "Window size changed"},
1477 {"SIGLOST", "Resource lost"},
1478 {"SIGUSR1", "User defined signal 1"},
1479 {"SIGUSR2", "User defined signal 2"},
1480 {"SIGPWR", "Power fail/restart"},
1481 {"SIGPOLL", "Pollable event occurred"},
1482 {"SIGWIND", "SIGWIND"},
1483 {"SIGPHONE", "SIGPHONE"},
1484 {"SIGWAITING", "Process's LWPs are blocked"},
1485 {"SIGLWP", "Signal LWP"},
1486 {"SIGDANGER", "Swap space dangerously low"},
1487 {"SIGGRANT", "Monitor mode granted"},
1488 {"SIGRETRACT", "Need to relinquish monitor mode"},
1489 {"SIGMSG", "Monitor mode data available"},
1490 {"SIGSOUND", "Sound completed"},
1491 {"SIGSAK", "Secure attention"},
1492 {"SIGPRIO", "SIGPRIO"},
1493 {"SIG33", "Real-time event 33"},
1494 {"SIG34", "Real-time event 34"},
1495 {"SIG35", "Real-time event 35"},
1496 {"SIG36", "Real-time event 36"},
1497 {"SIG37", "Real-time event 37"},
1498 {"SIG38", "Real-time event 38"},
1499 {"SIG39", "Real-time event 39"},
1500 {"SIG40", "Real-time event 40"},
1501 {"SIG41", "Real-time event 41"},
1502 {"SIG42", "Real-time event 42"},
1503 {"SIG43", "Real-time event 43"},
1504 {"SIG44", "Real-time event 44"},
1505 {"SIG45", "Real-time event 45"},
1506 {"SIG46", "Real-time event 46"},
1507 {"SIG47", "Real-time event 47"},
1508 {"SIG48", "Real-time event 48"},
1509 {"SIG49", "Real-time event 49"},
1510 {"SIG50", "Real-time event 50"},
1511 {"SIG51", "Real-time event 51"},
1512 {"SIG52", "Real-time event 52"},
1513 {"SIG53", "Real-time event 53"},
1514 {"SIG54", "Real-time event 54"},
1515 {"SIG55", "Real-time event 55"},
1516 {"SIG56", "Real-time event 56"},
1517 {"SIG57", "Real-time event 57"},
1518 {"SIG58", "Real-time event 58"},
1519 {"SIG59", "Real-time event 59"},
1520 {"SIG60", "Real-time event 60"},
1521 {"SIG61", "Real-time event 61"},
1522 {"SIG62", "Real-time event 62"},
1523 {"SIG63", "Real-time event 63"},
1524 {"SIGCANCEL", "LWP internal signal"},
1525 {"SIG32", "Real-time event 32"},
1527 #if defined(MACH) || defined(__MACH__)
1528 /* Mach exceptions */
1529 {"EXC_BAD_ACCESS", "Could not access memory"},
1530 {"EXC_BAD_INSTRUCTION", "Illegal instruction/operand"},
1531 {"EXC_ARITHMETIC", "Arithmetic exception"},
1532 {"EXC_EMULATION", "Emulation instruction"},
1533 {"EXC_SOFTWARE", "Software generated exception"},
1534 {"EXC_BREAKPOINT", "Breakpoint"},
1536 {"SIGINFO", "Information request"},
1538 {NULL
, "Unknown signal"},
1539 {NULL
, "Internal error: printing TARGET_SIGNAL_DEFAULT"},
1541 /* Last entry, used to check whether the table is the right size. */
1542 {NULL
, "TARGET_SIGNAL_MAGIC"}
1548 /* Return the string for a signal. */
1550 target_signal_to_string (sig
)
1551 enum target_signal sig
;
1553 if ((sig
>= TARGET_SIGNAL_FIRST
) && (sig
<= TARGET_SIGNAL_LAST
))
1554 return signals
[sig
].string
;
1556 return signals
[TARGET_SIGNAL_UNKNOWN
].string
;
1559 /* Return the name for a signal. */
1561 target_signal_to_name (sig
)
1562 enum target_signal sig
;
1564 if (sig
== TARGET_SIGNAL_UNKNOWN
)
1565 /* I think the code which prints this will always print it along with
1566 the string, so no need to be verbose. */
1568 return signals
[sig
].name
;
1571 /* Given a name, return its signal. */
1573 target_signal_from_name (name
)
1576 enum target_signal sig
;
1578 /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
1579 for TARGET_SIGNAL_SIGCHLD. SIGIOT, on the other hand, is more
1580 questionable; seems like by now people should call it SIGABRT
1583 /* This ugly cast brought to you by the native VAX compiler. */
1584 for (sig
= TARGET_SIGNAL_HUP
;
1585 signals
[sig
].name
!= NULL
;
1586 sig
= (enum target_signal
) ((int) sig
+ 1))
1587 if (STREQ (name
, signals
[sig
].name
))
1589 return TARGET_SIGNAL_UNKNOWN
;
1592 /* The following functions are to help certain targets deal
1593 with the signal/waitstatus stuff. They could just as well be in
1594 a file called native-utils.c or unixwaitstatus-utils.c or whatever. */
1596 /* Convert host signal to our signals. */
1598 target_signal_from_host (hostsig
)
1601 /* A switch statement would make sense but would require special kludges
1602 to deal with the cases where more than one signal has the same number. */
1605 return TARGET_SIGNAL_0
;
1607 #if defined (SIGHUP)
1608 if (hostsig
== SIGHUP
)
1609 return TARGET_SIGNAL_HUP
;
1611 #if defined (SIGINT)
1612 if (hostsig
== SIGINT
)
1613 return TARGET_SIGNAL_INT
;
1615 #if defined (SIGQUIT)
1616 if (hostsig
== SIGQUIT
)
1617 return TARGET_SIGNAL_QUIT
;
1619 #if defined (SIGILL)
1620 if (hostsig
== SIGILL
)
1621 return TARGET_SIGNAL_ILL
;
1623 #if defined (SIGTRAP)
1624 if (hostsig
== SIGTRAP
)
1625 return TARGET_SIGNAL_TRAP
;
1627 #if defined (SIGABRT)
1628 if (hostsig
== SIGABRT
)
1629 return TARGET_SIGNAL_ABRT
;
1631 #if defined (SIGEMT)
1632 if (hostsig
== SIGEMT
)
1633 return TARGET_SIGNAL_EMT
;
1635 #if defined (SIGFPE)
1636 if (hostsig
== SIGFPE
)
1637 return TARGET_SIGNAL_FPE
;
1639 #if defined (SIGKILL)
1640 if (hostsig
== SIGKILL
)
1641 return TARGET_SIGNAL_KILL
;
1643 #if defined (SIGBUS)
1644 if (hostsig
== SIGBUS
)
1645 return TARGET_SIGNAL_BUS
;
1647 #if defined (SIGSEGV)
1648 if (hostsig
== SIGSEGV
)
1649 return TARGET_SIGNAL_SEGV
;
1651 #if defined (SIGSYS)
1652 if (hostsig
== SIGSYS
)
1653 return TARGET_SIGNAL_SYS
;
1655 #if defined (SIGPIPE)
1656 if (hostsig
== SIGPIPE
)
1657 return TARGET_SIGNAL_PIPE
;
1659 #if defined (SIGALRM)
1660 if (hostsig
== SIGALRM
)
1661 return TARGET_SIGNAL_ALRM
;
1663 #if defined (SIGTERM)
1664 if (hostsig
== SIGTERM
)
1665 return TARGET_SIGNAL_TERM
;
1667 #if defined (SIGUSR1)
1668 if (hostsig
== SIGUSR1
)
1669 return TARGET_SIGNAL_USR1
;
1671 #if defined (SIGUSR2)
1672 if (hostsig
== SIGUSR2
)
1673 return TARGET_SIGNAL_USR2
;
1675 #if defined (SIGCLD)
1676 if (hostsig
== SIGCLD
)
1677 return TARGET_SIGNAL_CHLD
;
1679 #if defined (SIGCHLD)
1680 if (hostsig
== SIGCHLD
)
1681 return TARGET_SIGNAL_CHLD
;
1683 #if defined (SIGPWR)
1684 if (hostsig
== SIGPWR
)
1685 return TARGET_SIGNAL_PWR
;
1687 #if defined (SIGWINCH)
1688 if (hostsig
== SIGWINCH
)
1689 return TARGET_SIGNAL_WINCH
;
1691 #if defined (SIGURG)
1692 if (hostsig
== SIGURG
)
1693 return TARGET_SIGNAL_URG
;
1696 if (hostsig
== SIGIO
)
1697 return TARGET_SIGNAL_IO
;
1699 #if defined (SIGPOLL)
1700 if (hostsig
== SIGPOLL
)
1701 return TARGET_SIGNAL_POLL
;
1703 #if defined (SIGSTOP)
1704 if (hostsig
== SIGSTOP
)
1705 return TARGET_SIGNAL_STOP
;
1707 #if defined (SIGTSTP)
1708 if (hostsig
== SIGTSTP
)
1709 return TARGET_SIGNAL_TSTP
;
1711 #if defined (SIGCONT)
1712 if (hostsig
== SIGCONT
)
1713 return TARGET_SIGNAL_CONT
;
1715 #if defined (SIGTTIN)
1716 if (hostsig
== SIGTTIN
)
1717 return TARGET_SIGNAL_TTIN
;
1719 #if defined (SIGTTOU)
1720 if (hostsig
== SIGTTOU
)
1721 return TARGET_SIGNAL_TTOU
;
1723 #if defined (SIGVTALRM)
1724 if (hostsig
== SIGVTALRM
)
1725 return TARGET_SIGNAL_VTALRM
;
1727 #if defined (SIGPROF)
1728 if (hostsig
== SIGPROF
)
1729 return TARGET_SIGNAL_PROF
;
1731 #if defined (SIGXCPU)
1732 if (hostsig
== SIGXCPU
)
1733 return TARGET_SIGNAL_XCPU
;
1735 #if defined (SIGXFSZ)
1736 if (hostsig
== SIGXFSZ
)
1737 return TARGET_SIGNAL_XFSZ
;
1739 #if defined (SIGWIND)
1740 if (hostsig
== SIGWIND
)
1741 return TARGET_SIGNAL_WIND
;
1743 #if defined (SIGPHONE)
1744 if (hostsig
== SIGPHONE
)
1745 return TARGET_SIGNAL_PHONE
;
1747 #if defined (SIGLOST)
1748 if (hostsig
== SIGLOST
)
1749 return TARGET_SIGNAL_LOST
;
1751 #if defined (SIGWAITING)
1752 if (hostsig
== SIGWAITING
)
1753 return TARGET_SIGNAL_WAITING
;
1755 #if defined (SIGCANCEL)
1756 if (hostsig
== SIGCANCEL
)
1757 return TARGET_SIGNAL_CANCEL
;
1759 #if defined (SIGLWP)
1760 if (hostsig
== SIGLWP
)
1761 return TARGET_SIGNAL_LWP
;
1763 #if defined (SIGDANGER)
1764 if (hostsig
== SIGDANGER
)
1765 return TARGET_SIGNAL_DANGER
;
1767 #if defined (SIGGRANT)
1768 if (hostsig
== SIGGRANT
)
1769 return TARGET_SIGNAL_GRANT
;
1771 #if defined (SIGRETRACT)
1772 if (hostsig
== SIGRETRACT
)
1773 return TARGET_SIGNAL_RETRACT
;
1775 #if defined (SIGMSG)
1776 if (hostsig
== SIGMSG
)
1777 return TARGET_SIGNAL_MSG
;
1779 #if defined (SIGSOUND)
1780 if (hostsig
== SIGSOUND
)
1781 return TARGET_SIGNAL_SOUND
;
1783 #if defined (SIGSAK)
1784 if (hostsig
== SIGSAK
)
1785 return TARGET_SIGNAL_SAK
;
1787 #if defined (SIGPRIO)
1788 if (hostsig
== SIGPRIO
)
1789 return TARGET_SIGNAL_PRIO
;
1792 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1793 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1794 if (hostsig
== _NSIG
+ EXC_BAD_ACCESS
)
1795 return TARGET_EXC_BAD_ACCESS
;
1797 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
1798 if (hostsig
== _NSIG
+ EXC_BAD_INSTRUCTION
)
1799 return TARGET_EXC_BAD_INSTRUCTION
;
1801 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
1802 if (hostsig
== _NSIG
+ EXC_ARITHMETIC
)
1803 return TARGET_EXC_ARITHMETIC
;
1805 #if defined (EXC_EMULATION) && defined (_NSIG)
1806 if (hostsig
== _NSIG
+ EXC_EMULATION
)
1807 return TARGET_EXC_EMULATION
;
1809 #if defined (EXC_SOFTWARE) && defined (_NSIG)
1810 if (hostsig
== _NSIG
+ EXC_SOFTWARE
)
1811 return TARGET_EXC_SOFTWARE
;
1813 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
1814 if (hostsig
== _NSIG
+ EXC_BREAKPOINT
)
1815 return TARGET_EXC_BREAKPOINT
;
1818 #if defined (SIGINFO)
1819 if (hostsig
== SIGINFO
)
1820 return TARGET_SIGNAL_INFO
;
1823 #if defined (REALTIME_LO)
1824 if (hostsig
>= REALTIME_LO
&& hostsig
< REALTIME_HI
)
1826 /* This block of TARGET_SIGNAL_REALTIME value is in order. */
1827 if (33 <= hostsig
&& hostsig
<= 63)
1828 return (enum target_signal
)
1829 (hostsig
- 33 + (int) TARGET_SIGNAL_REALTIME_33
);
1830 else if (hostsig
== 32)
1831 return TARGET_SIGNAL_REALTIME_32
;
1833 error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
1836 return TARGET_SIGNAL_UNKNOWN
;
1839 /* Convert a OURSIG (an enum target_signal) to the form used by the
1840 target operating system (refered to as the ``host'') or zero if the
1841 equivalent host signal is not available. Set/clear OURSIG_OK
1845 do_target_signal_to_host (enum target_signal oursig
,
1851 case TARGET_SIGNAL_0
:
1854 #if defined (SIGHUP)
1855 case TARGET_SIGNAL_HUP
:
1858 #if defined (SIGINT)
1859 case TARGET_SIGNAL_INT
:
1862 #if defined (SIGQUIT)
1863 case TARGET_SIGNAL_QUIT
:
1866 #if defined (SIGILL)
1867 case TARGET_SIGNAL_ILL
:
1870 #if defined (SIGTRAP)
1871 case TARGET_SIGNAL_TRAP
:
1874 #if defined (SIGABRT)
1875 case TARGET_SIGNAL_ABRT
:
1878 #if defined (SIGEMT)
1879 case TARGET_SIGNAL_EMT
:
1882 #if defined (SIGFPE)
1883 case TARGET_SIGNAL_FPE
:
1886 #if defined (SIGKILL)
1887 case TARGET_SIGNAL_KILL
:
1890 #if defined (SIGBUS)
1891 case TARGET_SIGNAL_BUS
:
1894 #if defined (SIGSEGV)
1895 case TARGET_SIGNAL_SEGV
:
1898 #if defined (SIGSYS)
1899 case TARGET_SIGNAL_SYS
:
1902 #if defined (SIGPIPE)
1903 case TARGET_SIGNAL_PIPE
:
1906 #if defined (SIGALRM)
1907 case TARGET_SIGNAL_ALRM
:
1910 #if defined (SIGTERM)
1911 case TARGET_SIGNAL_TERM
:
1914 #if defined (SIGUSR1)
1915 case TARGET_SIGNAL_USR1
:
1918 #if defined (SIGUSR2)
1919 case TARGET_SIGNAL_USR2
:
1922 #if defined (SIGCHLD) || defined (SIGCLD)
1923 case TARGET_SIGNAL_CHLD
:
1924 #if defined (SIGCHLD)
1929 #endif /* SIGCLD or SIGCHLD */
1930 #if defined (SIGPWR)
1931 case TARGET_SIGNAL_PWR
:
1934 #if defined (SIGWINCH)
1935 case TARGET_SIGNAL_WINCH
:
1938 #if defined (SIGURG)
1939 case TARGET_SIGNAL_URG
:
1943 case TARGET_SIGNAL_IO
:
1946 #if defined (SIGPOLL)
1947 case TARGET_SIGNAL_POLL
:
1950 #if defined (SIGSTOP)
1951 case TARGET_SIGNAL_STOP
:
1954 #if defined (SIGTSTP)
1955 case TARGET_SIGNAL_TSTP
:
1958 #if defined (SIGCONT)
1959 case TARGET_SIGNAL_CONT
:
1962 #if defined (SIGTTIN)
1963 case TARGET_SIGNAL_TTIN
:
1966 #if defined (SIGTTOU)
1967 case TARGET_SIGNAL_TTOU
:
1970 #if defined (SIGVTALRM)
1971 case TARGET_SIGNAL_VTALRM
:
1974 #if defined (SIGPROF)
1975 case TARGET_SIGNAL_PROF
:
1978 #if defined (SIGXCPU)
1979 case TARGET_SIGNAL_XCPU
:
1982 #if defined (SIGXFSZ)
1983 case TARGET_SIGNAL_XFSZ
:
1986 #if defined (SIGWIND)
1987 case TARGET_SIGNAL_WIND
:
1990 #if defined (SIGPHONE)
1991 case TARGET_SIGNAL_PHONE
:
1994 #if defined (SIGLOST)
1995 case TARGET_SIGNAL_LOST
:
1998 #if defined (SIGWAITING)
1999 case TARGET_SIGNAL_WAITING
:
2002 #if defined (SIGCANCEL)
2003 case TARGET_SIGNAL_CANCEL
:
2006 #if defined (SIGLWP)
2007 case TARGET_SIGNAL_LWP
:
2010 #if defined (SIGDANGER)
2011 case TARGET_SIGNAL_DANGER
:
2014 #if defined (SIGGRANT)
2015 case TARGET_SIGNAL_GRANT
:
2018 #if defined (SIGRETRACT)
2019 case TARGET_SIGNAL_RETRACT
:
2022 #if defined (SIGMSG)
2023 case TARGET_SIGNAL_MSG
:
2026 #if defined (SIGSOUND)
2027 case TARGET_SIGNAL_SOUND
:
2030 #if defined (SIGSAK)
2031 case TARGET_SIGNAL_SAK
:
2034 #if defined (SIGPRIO)
2035 case TARGET_SIGNAL_PRIO
:
2039 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
2040 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
2041 case TARGET_EXC_BAD_ACCESS
:
2042 return _NSIG
+ EXC_BAD_ACCESS
;
2044 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
2045 case TARGET_EXC_BAD_INSTRUCTION
:
2046 return _NSIG
+ EXC_BAD_INSTRUCTION
;
2048 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
2049 case TARGET_EXC_ARITHMETIC
:
2050 return _NSIG
+ EXC_ARITHMETIC
;
2052 #if defined (EXC_EMULATION) && defined (_NSIG)
2053 case TARGET_EXC_EMULATION
:
2054 return _NSIG
+ EXC_EMULATION
;
2056 #if defined (EXC_SOFTWARE) && defined (_NSIG)
2057 case TARGET_EXC_SOFTWARE
:
2058 return _NSIG
+ EXC_SOFTWARE
;
2060 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
2061 case TARGET_EXC_BREAKPOINT
:
2062 return _NSIG
+ EXC_BREAKPOINT
;
2065 #if defined (SIGINFO)
2066 case TARGET_SIGNAL_INFO
:
2071 #if defined (REALTIME_LO)
2072 if (oursig
>= TARGET_SIGNAL_REALTIME_33
2073 && oursig
<= TARGET_SIGNAL_REALTIME_63
)
2075 /* This block of signals is continuous, and
2076 TARGET_SIGNAL_REALTIME_33 is 33 by definition. */
2078 (int) oursig
- (int) TARGET_SIGNAL_REALTIME_33
+ 33;
2079 if (retsig
>= REALTIME_LO
&& retsig
< REALTIME_HI
)
2082 #if (REALTIME_LO < 33)
2083 else if (oursig
== TARGET_SIGNAL_REALTIME_32
)
2085 /* TARGET_SIGNAL_REALTIME_32 isn't contiguous with
2086 TARGET_SIGNAL_REALTIME_33. It is 32 by definition. */
2097 target_signal_to_host_p (enum target_signal oursig
)
2100 do_target_signal_to_host (oursig
, &oursig_ok
);
2105 target_signal_to_host (enum target_signal oursig
)
2108 int targ_signo
= do_target_signal_to_host (oursig
, &oursig_ok
);
2111 /* The user might be trying to do "signal SIGSAK" where this system
2112 doesn't have SIGSAK. */
2113 warning ("Signal %s does not exist on this system.\n",
2114 target_signal_to_name (oursig
));
2121 /* Helper function for child_wait and the Lynx derivatives of child_wait.
2122 HOSTSTATUS is the waitstatus from wait() or the equivalent; store our
2123 translation of that in OURSTATUS. */
2125 store_waitstatus (ourstatus
, hoststatus
)
2126 struct target_waitstatus
*ourstatus
;
2129 #ifdef CHILD_SPECIAL_WAITSTATUS
2130 /* CHILD_SPECIAL_WAITSTATUS should return nonzero and set *OURSTATUS
2131 if it wants to deal with hoststatus. */
2132 if (CHILD_SPECIAL_WAITSTATUS (ourstatus
, hoststatus
))
2136 if (WIFEXITED (hoststatus
))
2138 ourstatus
->kind
= TARGET_WAITKIND_EXITED
;
2139 ourstatus
->value
.integer
= WEXITSTATUS (hoststatus
);
2141 else if (!WIFSTOPPED (hoststatus
))
2143 ourstatus
->kind
= TARGET_WAITKIND_SIGNALLED
;
2144 ourstatus
->value
.sig
= target_signal_from_host (WTERMSIG (hoststatus
));
2148 ourstatus
->kind
= TARGET_WAITKIND_STOPPED
;
2149 ourstatus
->value
.sig
= target_signal_from_host (WSTOPSIG (hoststatus
));
2153 /* In some circumstances we allow a command to specify a numeric
2154 signal. The idea is to keep these circumstances limited so that
2155 users (and scripts) develop portable habits. For comparison,
2156 POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a
2157 numeric signal at all is obscelescent. We are slightly more
2158 lenient and allow 1-15 which should match host signal numbers on
2159 most systems. Use of symbolic signal names is strongly encouraged. */
2162 target_signal_from_command (num
)
2165 if (num
>= 1 && num
<= 15)
2166 return (enum target_signal
) num
;
2167 error ("Only signals 1-15 are valid as numeric signals.\n\
2168 Use \"info signals\" for a list of symbolic signals.");
2171 /* Returns zero to leave the inferior alone, one to interrupt it. */
2172 int (*target_activity_function
) PARAMS ((void));
2173 int target_activity_fd
;
2175 /* Convert a normal process ID to a string. Returns the string in a static
2179 normal_pid_to_str (pid
)
2182 static char buf
[30];
2184 if (STREQ (current_target
.to_shortname
, "remote"))
2185 sprintf (buf
, "thread %d", pid
);
2187 sprintf (buf
, "process %d", pid
);
2192 /* Some targets (such as ttrace-based HPUX) don't allow us to request
2193 notification of inferior events such as fork and vork immediately
2194 after the inferior is created. (This because of how gdb gets an
2195 inferior created via invoking a shell to do it. In such a scenario,
2196 if the shell init file has commands in it, the shell will fork and
2197 exec for each of those commands, and we will see each such fork
2200 This function is used by all targets that allow us to request
2201 notification of forks, etc at inferior creation time; e.g., in
2202 target_acknowledge_forked_child.
2205 normal_target_post_startup_inferior (pid
)
2208 /* This space intentionally left blank. */
2211 /* Set up the handful of non-empty slots needed by the dummy target
2215 init_dummy_target ()
2217 dummy_target
.to_shortname
= "None";
2218 dummy_target
.to_longname
= "None";
2219 dummy_target
.to_doc
= "";
2220 dummy_target
.to_attach
= find_default_attach
;
2221 dummy_target
.to_require_attach
= find_default_require_attach
;
2222 dummy_target
.to_require_detach
= find_default_require_detach
;
2223 dummy_target
.to_create_inferior
= find_default_create_inferior
;
2224 dummy_target
.to_clone_and_follow_inferior
= find_default_clone_and_follow_inferior
;
2225 dummy_target
.to_pid_to_str
= normal_pid_to_str
;
2226 dummy_target
.to_stratum
= dummy_stratum
;
2227 dummy_target
.to_magic
= OPS_MAGIC
;
2231 static struct target_ops debug_target
;
2234 debug_to_open (args
, from_tty
)
2238 debug_target
.to_open (args
, from_tty
);
2240 fprintf_unfiltered (gdb_stdlog
, "target_open (%s, %d)\n", args
, from_tty
);
2244 debug_to_close (quitting
)
2247 debug_target
.to_close (quitting
);
2249 fprintf_unfiltered (gdb_stdlog
, "target_close (%d)\n", quitting
);
2253 debug_to_attach (args
, from_tty
)
2257 debug_target
.to_attach (args
, from_tty
);
2259 fprintf_unfiltered (gdb_stdlog
, "target_attach (%s, %d)\n", args
, from_tty
);
2264 debug_to_post_attach (pid
)
2267 debug_target
.to_post_attach (pid
);
2269 fprintf_unfiltered (gdb_stdlog
, "target_post_attach (%d)\n", pid
);
2273 debug_to_require_attach (args
, from_tty
)
2277 debug_target
.to_require_attach (args
, from_tty
);
2279 fprintf_unfiltered (gdb_stdlog
,
2280 "target_require_attach (%s, %d)\n", args
, from_tty
);
2284 debug_to_detach (args
, from_tty
)
2288 debug_target
.to_detach (args
, from_tty
);
2290 fprintf_unfiltered (gdb_stdlog
, "target_detach (%s, %d)\n", args
, from_tty
);
2294 debug_to_require_detach (pid
, args
, from_tty
)
2299 debug_target
.to_require_detach (pid
, args
, from_tty
);
2301 fprintf_unfiltered (gdb_stdlog
,
2302 "target_require_detach (%d, %s, %d)\n", pid
, args
, from_tty
);
2306 debug_to_resume (pid
, step
, siggnal
)
2309 enum target_signal siggnal
;
2311 debug_target
.to_resume (pid
, step
, siggnal
);
2313 fprintf_unfiltered (gdb_stdlog
, "target_resume (%d, %s, %s)\n", pid
,
2314 step
? "step" : "continue",
2315 target_signal_to_name (siggnal
));
2319 debug_to_wait (pid
, status
)
2321 struct target_waitstatus
*status
;
2325 retval
= debug_target
.to_wait (pid
, status
);
2327 fprintf_unfiltered (gdb_stdlog
,
2328 "target_wait (%d, status) = %d, ", pid
, retval
);
2329 fprintf_unfiltered (gdb_stdlog
, "status->kind = ");
2330 switch (status
->kind
)
2332 case TARGET_WAITKIND_EXITED
:
2333 fprintf_unfiltered (gdb_stdlog
, "exited, status = %d\n",
2334 status
->value
.integer
);
2336 case TARGET_WAITKIND_STOPPED
:
2337 fprintf_unfiltered (gdb_stdlog
, "stopped, signal = %s\n",
2338 target_signal_to_name (status
->value
.sig
));
2340 case TARGET_WAITKIND_SIGNALLED
:
2341 fprintf_unfiltered (gdb_stdlog
, "signalled, signal = %s\n",
2342 target_signal_to_name (status
->value
.sig
));
2344 case TARGET_WAITKIND_LOADED
:
2345 fprintf_unfiltered (gdb_stdlog
, "loaded\n");
2347 case TARGET_WAITKIND_FORKED
:
2348 fprintf_unfiltered (gdb_stdlog
, "forked\n");
2350 case TARGET_WAITKIND_VFORKED
:
2351 fprintf_unfiltered (gdb_stdlog
, "vforked\n");
2353 case TARGET_WAITKIND_EXECD
:
2354 fprintf_unfiltered (gdb_stdlog
, "execd\n");
2356 case TARGET_WAITKIND_SPURIOUS
:
2357 fprintf_unfiltered (gdb_stdlog
, "spurious\n");
2360 fprintf_unfiltered (gdb_stdlog
, "unknown???\n");
2368 debug_to_post_wait (pid
, status
)
2372 debug_target
.to_post_wait (pid
, status
);
2374 fprintf_unfiltered (gdb_stdlog
, "target_post_wait (%d, %d)\n",
2379 debug_to_fetch_registers (regno
)
2382 debug_target
.to_fetch_registers (regno
);
2384 fprintf_unfiltered (gdb_stdlog
, "target_fetch_registers (%s)",
2385 regno
!= -1 ? REGISTER_NAME (regno
) : "-1");
2387 fprintf_unfiltered (gdb_stdlog
, " = 0x%lx %ld",
2388 (unsigned long) read_register (regno
),
2389 (unsigned long) read_register (regno
));
2390 fprintf_unfiltered (gdb_stdlog
, "\n");
2394 debug_to_store_registers (regno
)
2397 debug_target
.to_store_registers (regno
);
2399 if (regno
>= 0 && regno
< NUM_REGS
)
2400 fprintf_unfiltered (gdb_stdlog
, "target_store_registers (%s) = 0x%lx %ld\n",
2401 REGISTER_NAME (regno
),
2402 (unsigned long) read_register (regno
),
2403 (unsigned long) read_register (regno
));
2405 fprintf_unfiltered (gdb_stdlog
, "target_store_registers (%d)\n", regno
);
2409 debug_to_prepare_to_store ()
2411 debug_target
.to_prepare_to_store ();
2413 fprintf_unfiltered (gdb_stdlog
, "target_prepare_to_store ()\n");
2417 debug_to_xfer_memory (memaddr
, myaddr
, len
, write
, target
)
2422 struct target_ops
*target
;
2426 retval
= debug_target
.to_xfer_memory (memaddr
, myaddr
, len
, write
, target
);
2428 fprintf_unfiltered (gdb_stdlog
,
2429 "target_xfer_memory (0x%x, xxx, %d, %s, xxx) = %d",
2430 (unsigned int) memaddr
, /* possable truncate long long */
2431 len
, write
? "write" : "read", retval
);
2439 fputs_unfiltered (", bytes =", gdb_stdlog
);
2440 for (i
= 0; i
< retval
; i
++)
2442 if ((((long) &(myaddr
[i
])) & 0xf) == 0)
2443 fprintf_unfiltered (gdb_stdlog
, "\n");
2444 fprintf_unfiltered (gdb_stdlog
, " %02x", myaddr
[i
] & 0xff);
2448 fputc_unfiltered ('\n', gdb_stdlog
);
2454 debug_to_files_info (target
)
2455 struct target_ops
*target
;
2457 debug_target
.to_files_info (target
);
2459 fprintf_unfiltered (gdb_stdlog
, "target_files_info (xxx)\n");
2463 debug_to_insert_breakpoint (addr
, save
)
2469 retval
= debug_target
.to_insert_breakpoint (addr
, save
);
2471 fprintf_unfiltered (gdb_stdlog
,
2472 "target_insert_breakpoint (0x%lx, xxx) = %ld\n",
2473 (unsigned long) addr
,
2474 (unsigned long) retval
);
2479 debug_to_remove_breakpoint (addr
, save
)
2485 retval
= debug_target
.to_remove_breakpoint (addr
, save
);
2487 fprintf_unfiltered (gdb_stdlog
,
2488 "target_remove_breakpoint (0x%lx, xxx) = %ld\n",
2489 (unsigned long) addr
,
2490 (unsigned long) retval
);
2495 debug_to_terminal_init ()
2497 debug_target
.to_terminal_init ();
2499 fprintf_unfiltered (gdb_stdlog
, "target_terminal_init ()\n");
2503 debug_to_terminal_inferior ()
2505 debug_target
.to_terminal_inferior ();
2507 fprintf_unfiltered (gdb_stdlog
, "target_terminal_inferior ()\n");
2511 debug_to_terminal_ours_for_output ()
2513 debug_target
.to_terminal_ours_for_output ();
2515 fprintf_unfiltered (gdb_stdlog
, "target_terminal_ours_for_output ()\n");
2519 debug_to_terminal_ours ()
2521 debug_target
.to_terminal_ours ();
2523 fprintf_unfiltered (gdb_stdlog
, "target_terminal_ours ()\n");
2527 debug_to_terminal_info (arg
, from_tty
)
2531 debug_target
.to_terminal_info (arg
, from_tty
);
2533 fprintf_unfiltered (gdb_stdlog
, "target_terminal_info (%s, %d)\n", arg
,
2540 debug_target
.to_kill ();
2542 fprintf_unfiltered (gdb_stdlog
, "target_kill ()\n");
2546 debug_to_load (args
, from_tty
)
2550 debug_target
.to_load (args
, from_tty
);
2552 fprintf_unfiltered (gdb_stdlog
, "target_load (%s, %d)\n", args
, from_tty
);
2556 debug_to_lookup_symbol (name
, addrp
)
2562 retval
= debug_target
.to_lookup_symbol (name
, addrp
);
2564 fprintf_unfiltered (gdb_stdlog
, "target_lookup_symbol (%s, xxx)\n", name
);
2570 debug_to_create_inferior (exec_file
, args
, env
)
2575 debug_target
.to_create_inferior (exec_file
, args
, env
);
2577 fprintf_unfiltered (gdb_stdlog
, "target_create_inferior (%s, %s, xxx)\n",
2582 debug_to_post_startup_inferior (pid
)
2585 debug_target
.to_post_startup_inferior (pid
);
2587 fprintf_unfiltered (gdb_stdlog
, "target_post_startup_inferior (%d)\n",
2592 debug_to_acknowledge_created_inferior (pid
)
2595 debug_target
.to_acknowledge_created_inferior (pid
);
2597 fprintf_unfiltered (gdb_stdlog
, "target_acknowledge_created_inferior (%d)\n",
2602 debug_to_clone_and_follow_inferior (child_pid
, followed_child
)
2604 int *followed_child
;
2606 debug_target
.to_clone_and_follow_inferior (child_pid
, followed_child
);
2608 fprintf_unfiltered (gdb_stdlog
,
2609 "target_clone_and_follow_inferior (%d, %d)\n",
2610 child_pid
, *followed_child
);
2614 debug_to_post_follow_inferior_by_clone ()
2616 debug_target
.to_post_follow_inferior_by_clone ();
2618 fprintf_unfiltered (gdb_stdlog
, "target_post_follow_inferior_by_clone ()\n");
2622 debug_to_insert_fork_catchpoint (pid
)
2627 retval
= debug_target
.to_insert_fork_catchpoint (pid
);
2629 fprintf_unfiltered (gdb_stdlog
, "target_insert_fork_catchpoint (%d) = %d\n",
2636 debug_to_remove_fork_catchpoint (pid
)
2641 retval
= debug_target
.to_remove_fork_catchpoint (pid
);
2643 fprintf_unfiltered (gdb_stdlog
, "target_remove_fork_catchpoint (%d) = %d\n",
2650 debug_to_insert_vfork_catchpoint (pid
)
2655 retval
= debug_target
.to_insert_vfork_catchpoint (pid
);
2657 fprintf_unfiltered (gdb_stdlog
, "target_insert_vfork_catchpoint (%d)= %d\n",
2664 debug_to_remove_vfork_catchpoint (pid
)
2669 retval
= debug_target
.to_remove_vfork_catchpoint (pid
);
2671 fprintf_unfiltered (gdb_stdlog
, "target_remove_vfork_catchpoint (%d) = %d\n",
2678 debug_to_has_forked (pid
, child_pid
)
2684 has_forked
= debug_target
.to_has_forked (pid
, child_pid
);
2686 fprintf_unfiltered (gdb_stdlog
, "target_has_forked (%d, %d) = %d\n",
2687 pid
, *child_pid
, has_forked
);
2693 debug_to_has_vforked (pid
, child_pid
)
2699 has_vforked
= debug_target
.to_has_vforked (pid
, child_pid
);
2701 fprintf_unfiltered (gdb_stdlog
, "target_has_vforked (%d, %d) = %d\n",
2702 pid
, *child_pid
, has_vforked
);
2708 debug_to_can_follow_vfork_prior_to_exec ()
2710 int can_immediately_follow_vfork
;
2712 can_immediately_follow_vfork
= debug_target
.to_can_follow_vfork_prior_to_exec ();
2714 fprintf_unfiltered (gdb_stdlog
, "target_can_follow_vfork_prior_to_exec () = %d\n",
2715 can_immediately_follow_vfork
);
2717 return can_immediately_follow_vfork
;
2721 debug_to_post_follow_vfork (parent_pid
, followed_parent
, child_pid
, followed_child
)
2723 int followed_parent
;
2727 debug_target
.to_post_follow_vfork (parent_pid
, followed_parent
, child_pid
, followed_child
);
2729 fprintf_unfiltered (gdb_stdlog
,
2730 "target_post_follow_vfork (%d, %d, %d, %d)\n",
2731 parent_pid
, followed_parent
, child_pid
, followed_child
);
2735 debug_to_insert_exec_catchpoint (pid
)
2740 retval
= debug_target
.to_insert_exec_catchpoint (pid
);
2742 fprintf_unfiltered (gdb_stdlog
, "target_insert_exec_catchpoint (%d) = %d\n",
2749 debug_to_remove_exec_catchpoint (pid
)
2754 retval
= debug_target
.to_remove_exec_catchpoint (pid
);
2756 fprintf_unfiltered (gdb_stdlog
, "target_remove_exec_catchpoint (%d) = %d\n",
2763 debug_to_has_execd (pid
, execd_pathname
)
2765 char **execd_pathname
;
2769 has_execd
= debug_target
.to_has_execd (pid
, execd_pathname
);
2771 fprintf_unfiltered (gdb_stdlog
, "target_has_execd (%d, %s) = %d\n",
2772 pid
, (*execd_pathname
? *execd_pathname
: "<NULL>"),
2779 debug_to_reported_exec_events_per_exec_call ()
2781 int reported_exec_events
;
2783 reported_exec_events
= debug_target
.to_reported_exec_events_per_exec_call ();
2785 fprintf_unfiltered (gdb_stdlog
,
2786 "target_reported_exec_events_per_exec_call () = %d\n",
2787 reported_exec_events
);
2789 return reported_exec_events
;
2793 debug_to_has_syscall_event (pid
, kind
, syscall_id
)
2795 enum target_waitkind
*kind
;
2798 int has_syscall_event
;
2799 char *kind_spelling
= "??";
2801 has_syscall_event
= debug_target
.to_has_syscall_event (pid
, kind
, syscall_id
);
2802 if (has_syscall_event
)
2806 case TARGET_WAITKIND_SYSCALL_ENTRY
:
2807 kind_spelling
= "SYSCALL_ENTRY";
2809 case TARGET_WAITKIND_SYSCALL_RETURN
:
2810 kind_spelling
= "SYSCALL_RETURN";
2817 fprintf_unfiltered (gdb_stdlog
,
2818 "target_has_syscall_event (%d, %s, %d) = %d\n",
2819 pid
, kind_spelling
, *syscall_id
, has_syscall_event
);
2821 return has_syscall_event
;
2825 debug_to_has_exited (pid
, wait_status
, exit_status
)
2832 has_exited
= debug_target
.to_has_exited (pid
, wait_status
, exit_status
);
2834 fprintf_unfiltered (gdb_stdlog
, "target_has_exited (%d, %d, %d) = %d\n",
2835 pid
, wait_status
, *exit_status
, has_exited
);
2841 debug_to_mourn_inferior ()
2843 debug_target
.to_mourn_inferior ();
2845 fprintf_unfiltered (gdb_stdlog
, "target_mourn_inferior ()\n");
2853 retval
= debug_target
.to_can_run ();
2855 fprintf_unfiltered (gdb_stdlog
, "target_can_run () = %d\n", retval
);
2861 debug_to_notice_signals (pid
)
2864 debug_target
.to_notice_signals (pid
);
2866 fprintf_unfiltered (gdb_stdlog
, "target_notice_signals (%d)\n", pid
);
2870 debug_to_thread_alive (pid
)
2875 retval
= debug_target
.to_thread_alive (pid
);
2877 fprintf_unfiltered (gdb_stdlog
, "target_thread_alive (%d) = %d\n",
2884 debug_to_find_new_threads ()
2886 debug_target
.to_find_new_threads ();
2888 fputs_unfiltered ("target_find_new_threads ()\n", gdb_stdlog
);
2894 debug_target
.to_stop ();
2896 fprintf_unfiltered (gdb_stdlog
, "target_stop ()\n");
2900 debug_to_query (type
, req
, resp
, siz
)
2908 retval
= debug_target
.to_query (type
, req
, resp
, siz
);
2910 fprintf_unfiltered (gdb_stdlog
, "target_query (%c, %s, %s, %d) = %d\n", type
, req
, resp
, *siz
, retval
);
2916 debug_to_rcmd (char *command
,
2917 struct ui_file
*outbuf
)
2919 debug_target
.to_rcmd (command
, outbuf
);
2920 fprintf_unfiltered (gdb_stdlog
, "target_rcmd (%s, ...)\n", command
);
2923 static struct symtab_and_line
*
2924 debug_to_enable_exception_callback (kind
, enable
)
2925 enum exception_event_kind kind
;
2928 struct symtab_and_line
*result
;
2929 result
= debug_target
.to_enable_exception_callback (kind
, enable
);
2930 fprintf_unfiltered (gdb_stdlog
,
2931 "target get_exception_callback_sal (%d, %d)\n",
2936 static struct exception_event_record
*
2937 debug_to_get_current_exception_event ()
2939 struct exception_event_record
*result
;
2940 result
= debug_target
.to_get_current_exception_event ();
2941 fprintf_unfiltered (gdb_stdlog
, "target get_current_exception_event ()\n");
2946 debug_to_pid_to_exec_file (pid
)
2951 exec_file
= debug_target
.to_pid_to_exec_file (pid
);
2953 fprintf_unfiltered (gdb_stdlog
, "target_pid_to_exec_file (%d) = %s\n",
2960 debug_to_core_file_to_sym_file (core
)
2965 sym_file
= debug_target
.to_core_file_to_sym_file (core
);
2967 fprintf_unfiltered (gdb_stdlog
, "target_core_file_to_sym_file (%s) = %s\n",
2974 setup_target_debug ()
2976 memcpy (&debug_target
, ¤t_target
, sizeof debug_target
);
2978 current_target
.to_open
= debug_to_open
;
2979 current_target
.to_close
= debug_to_close
;
2980 current_target
.to_attach
= debug_to_attach
;
2981 current_target
.to_post_attach
= debug_to_post_attach
;
2982 current_target
.to_require_attach
= debug_to_require_attach
;
2983 current_target
.to_detach
= debug_to_detach
;
2984 current_target
.to_require_detach
= debug_to_require_detach
;
2985 current_target
.to_resume
= debug_to_resume
;
2986 current_target
.to_wait
= debug_to_wait
;
2987 current_target
.to_post_wait
= debug_to_post_wait
;
2988 current_target
.to_fetch_registers
= debug_to_fetch_registers
;
2989 current_target
.to_store_registers
= debug_to_store_registers
;
2990 current_target
.to_prepare_to_store
= debug_to_prepare_to_store
;
2991 current_target
.to_xfer_memory
= debug_to_xfer_memory
;
2992 current_target
.to_files_info
= debug_to_files_info
;
2993 current_target
.to_insert_breakpoint
= debug_to_insert_breakpoint
;
2994 current_target
.to_remove_breakpoint
= debug_to_remove_breakpoint
;
2995 current_target
.to_terminal_init
= debug_to_terminal_init
;
2996 current_target
.to_terminal_inferior
= debug_to_terminal_inferior
;
2997 current_target
.to_terminal_ours_for_output
= debug_to_terminal_ours_for_output
;
2998 current_target
.to_terminal_ours
= debug_to_terminal_ours
;
2999 current_target
.to_terminal_info
= debug_to_terminal_info
;
3000 current_target
.to_kill
= debug_to_kill
;
3001 current_target
.to_load
= debug_to_load
;
3002 current_target
.to_lookup_symbol
= debug_to_lookup_symbol
;
3003 current_target
.to_create_inferior
= debug_to_create_inferior
;
3004 current_target
.to_post_startup_inferior
= debug_to_post_startup_inferior
;
3005 current_target
.to_acknowledge_created_inferior
= debug_to_acknowledge_created_inferior
;
3006 current_target
.to_clone_and_follow_inferior
= debug_to_clone_and_follow_inferior
;
3007 current_target
.to_post_follow_inferior_by_clone
= debug_to_post_follow_inferior_by_clone
;
3008 current_target
.to_insert_fork_catchpoint
= debug_to_insert_fork_catchpoint
;
3009 current_target
.to_remove_fork_catchpoint
= debug_to_remove_fork_catchpoint
;
3010 current_target
.to_insert_vfork_catchpoint
= debug_to_insert_vfork_catchpoint
;
3011 current_target
.to_remove_vfork_catchpoint
= debug_to_remove_vfork_catchpoint
;
3012 current_target
.to_has_forked
= debug_to_has_forked
;
3013 current_target
.to_has_vforked
= debug_to_has_vforked
;
3014 current_target
.to_can_follow_vfork_prior_to_exec
= debug_to_can_follow_vfork_prior_to_exec
;
3015 current_target
.to_post_follow_vfork
= debug_to_post_follow_vfork
;
3016 current_target
.to_insert_exec_catchpoint
= debug_to_insert_exec_catchpoint
;
3017 current_target
.to_remove_exec_catchpoint
= debug_to_remove_exec_catchpoint
;
3018 current_target
.to_has_execd
= debug_to_has_execd
;
3019 current_target
.to_reported_exec_events_per_exec_call
= debug_to_reported_exec_events_per_exec_call
;
3020 current_target
.to_has_syscall_event
= debug_to_has_syscall_event
;
3021 current_target
.to_has_exited
= debug_to_has_exited
;
3022 current_target
.to_mourn_inferior
= debug_to_mourn_inferior
;
3023 current_target
.to_can_run
= debug_to_can_run
;
3024 current_target
.to_notice_signals
= debug_to_notice_signals
;
3025 current_target
.to_thread_alive
= debug_to_thread_alive
;
3026 current_target
.to_find_new_threads
= debug_to_find_new_threads
;
3027 current_target
.to_stop
= debug_to_stop
;
3028 current_target
.to_query
= debug_to_query
;
3029 current_target
.to_rcmd
= debug_to_rcmd
;
3030 current_target
.to_enable_exception_callback
= debug_to_enable_exception_callback
;
3031 current_target
.to_get_current_exception_event
= debug_to_get_current_exception_event
;
3032 current_target
.to_pid_to_exec_file
= debug_to_pid_to_exec_file
;
3033 current_target
.to_core_file_to_sym_file
= debug_to_core_file_to_sym_file
;
3038 static char targ_desc
[] =
3039 "Names of targets and files being debugged.\n\
3040 Shows the entire stack of targets currently in use (including the exec-file,\n\
3041 core-file, and process, if any), as well as the symbol file name.";
3044 do_monitor_command (char *cmd
,
3047 if ((current_target
.to_rcmd
3048 == (void (*) (char *, struct ui_file
*)) tcomplain
)
3049 || (current_target
.to_rcmd
== debug_to_rcmd
3050 && (debug_target
.to_rcmd
3051 == (void (*) (char *, struct ui_file
*)) tcomplain
)))
3053 error ("\"monitor\" command not supported by this target.\n");
3055 target_rcmd (cmd
, gdb_stdtarg
);
3059 initialize_targets ()
3061 init_dummy_target ();
3062 push_target (&dummy_target
);
3064 add_info ("target", target_info
, targ_desc
);
3065 add_info ("files", target_info
, targ_desc
);
3068 add_set_cmd ("target", class_maintenance
, var_zinteger
,
3069 (char *) &targetdebug
,
3070 "Set target debugging.\n\
3071 When non-zero, target debugging is enabled.", &setdebuglist
),
3075 add_com ("monitor", class_obscure
, do_monitor_command
,
3076 "Send a command to the remote monitor (remote targets only).");
3078 if (!STREQ (signals
[TARGET_SIGNAL_LAST
].string
, "TARGET_SIGNAL_MAGIC"))