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_enable_exception_callback
, (struct symtab_and_line
* (*)PARAMS ((enum exception_event_kind
, int))) nosupport_runtime
);
448 de_fault (to_get_current_exception_event
, (struct exception_event_record
* (*)PARAMS ((void))) nosupport_runtime
);
450 de_fault (to_pid_to_exec_file
, (char *(*)PARAMS ((int))) return_zero
);
451 de_fault (to_core_file_to_sym_file
, (char *(*)PARAMS ((char *))) return_zero
);
455 /* Go through the target stack from top to bottom, copying over zero entries in
456 current_target. In effect, we are doing class inheritance through the
457 pushed target vectors. */
460 update_current_target ()
462 struct target_stack_item
*item
;
463 struct target_ops
*t
;
465 /* First, reset current_target */
466 memset (¤t_target
, 0, sizeof current_target
);
468 for (item
= target_stack
; item
; item
= item
->next
)
470 t
= item
->target_ops
;
472 #define INHERIT(FIELD, TARGET) \
473 if (!current_target.FIELD) \
474 current_target.FIELD = TARGET->FIELD
476 INHERIT (to_shortname
, t
);
477 INHERIT (to_longname
, t
);
479 INHERIT (to_open
, t
);
480 INHERIT (to_close
, t
);
481 INHERIT (to_attach
, t
);
482 INHERIT (to_post_attach
, t
);
483 INHERIT (to_require_attach
, t
);
484 INHERIT (to_detach
, t
);
485 INHERIT (to_require_detach
, t
);
486 INHERIT (to_resume
, t
);
487 INHERIT (to_wait
, t
);
488 INHERIT (to_post_wait
, t
);
489 INHERIT (to_fetch_registers
, t
);
490 INHERIT (to_store_registers
, t
);
491 INHERIT (to_prepare_to_store
, t
);
492 INHERIT (to_xfer_memory
, t
);
493 INHERIT (to_files_info
, t
);
494 INHERIT (to_insert_breakpoint
, t
);
495 INHERIT (to_remove_breakpoint
, t
);
496 INHERIT (to_terminal_init
, t
);
497 INHERIT (to_terminal_inferior
, t
);
498 INHERIT (to_terminal_ours_for_output
, t
);
499 INHERIT (to_terminal_ours
, t
);
500 INHERIT (to_terminal_info
, t
);
501 INHERIT (to_kill
, t
);
502 INHERIT (to_load
, t
);
503 INHERIT (to_lookup_symbol
, t
);
504 INHERIT (to_create_inferior
, t
);
505 INHERIT (to_post_startup_inferior
, t
);
506 INHERIT (to_acknowledge_created_inferior
, t
);
507 INHERIT (to_clone_and_follow_inferior
, t
);
508 INHERIT (to_post_follow_inferior_by_clone
, t
);
509 INHERIT (to_insert_fork_catchpoint
, t
);
510 INHERIT (to_remove_fork_catchpoint
, t
);
511 INHERIT (to_insert_vfork_catchpoint
, t
);
512 INHERIT (to_remove_vfork_catchpoint
, t
);
513 INHERIT (to_has_forked
, t
);
514 INHERIT (to_has_vforked
, t
);
515 INHERIT (to_can_follow_vfork_prior_to_exec
, t
);
516 INHERIT (to_post_follow_vfork
, t
);
517 INHERIT (to_insert_exec_catchpoint
, t
);
518 INHERIT (to_remove_exec_catchpoint
, t
);
519 INHERIT (to_has_execd
, t
);
520 INHERIT (to_reported_exec_events_per_exec_call
, t
);
521 INHERIT (to_has_syscall_event
, t
);
522 INHERIT (to_has_exited
, t
);
523 INHERIT (to_mourn_inferior
, t
);
524 INHERIT (to_can_run
, t
);
525 INHERIT (to_notice_signals
, t
);
526 INHERIT (to_thread_alive
, t
);
527 INHERIT (to_find_new_threads
, t
);
528 INHERIT (to_stop
, t
);
529 INHERIT (to_query
, t
);
530 INHERIT (to_enable_exception_callback
, t
);
531 INHERIT (to_get_current_exception_event
, t
);
532 INHERIT (to_pid_to_exec_file
, t
);
533 INHERIT (to_core_file_to_sym_file
, t
);
534 INHERIT (to_stratum
, t
);
535 INHERIT (DONT_USE
, t
);
536 INHERIT (to_has_all_memory
, t
);
537 INHERIT (to_has_memory
, t
);
538 INHERIT (to_has_stack
, t
);
539 INHERIT (to_has_registers
, t
);
540 INHERIT (to_has_execution
, t
);
541 INHERIT (to_has_thread_control
, t
);
542 INHERIT (to_has_async_exec
, t
);
543 INHERIT (to_sections
, t
);
544 INHERIT (to_sections_end
, t
);
545 INHERIT (to_magic
, t
);
551 /* Push a new target type into the stack of the existing target accessors,
552 possibly superseding some of the existing accessors.
554 Result is zero if the pushed target ended up on top of the stack,
555 nonzero if at least one target is on top of it.
557 Rather than allow an empty stack, we always have the dummy target at
558 the bottom stratum, so we can call the function vectors without
563 struct target_ops
*t
;
565 struct target_stack_item
*cur
, *prev
, *tmp
;
567 /* Check magic number. If wrong, it probably means someone changed
568 the struct definition, but not all the places that initialize one. */
569 if (t
->to_magic
!= OPS_MAGIC
)
571 fprintf_unfiltered (gdb_stderr
,
572 "Magic number of %s target struct wrong\n",
577 /* Find the proper stratum to install this target in. */
579 for (prev
= NULL
, cur
= target_stack
; cur
; prev
= cur
, cur
= cur
->next
)
581 if ((int) (t
->to_stratum
) >= (int) (cur
->target_ops
->to_stratum
))
585 /* If there's already targets at this stratum, remove them. */
588 while (t
->to_stratum
== cur
->target_ops
->to_stratum
)
590 /* There's already something on this stratum. Close it off. */
591 if (cur
->target_ops
->to_close
)
592 (cur
->target_ops
->to_close
) (0);
594 prev
->next
= cur
->next
; /* Unchain old target_ops */
596 target_stack
= cur
->next
; /* Unchain first on list */
602 /* We have removed all targets in our stratum, now add the new one. */
604 tmp
= (struct target_stack_item
*)
605 xmalloc (sizeof (struct target_stack_item
));
614 update_current_target ();
616 cleanup_target (¤t_target
); /* Fill in the gaps */
619 setup_target_debug ();
624 /* Remove a target_ops vector from the stack, wherever it may be.
625 Return how many times it was removed (0 or 1). */
629 struct target_ops
*t
;
631 struct target_stack_item
*cur
, *prev
;
634 t
->to_close (0); /* Let it clean up */
636 /* Look for the specified target. Note that we assume that a target
637 can only occur once in the target stack. */
639 for (cur
= target_stack
, prev
= NULL
; cur
; prev
= cur
, cur
= cur
->next
)
640 if (cur
->target_ops
== t
)
644 return 0; /* Didn't find target_ops, quit now */
646 /* Unchain the target */
649 target_stack
= cur
->next
;
651 prev
->next
= cur
->next
;
653 free (cur
); /* Release the target_stack_item */
655 update_current_target ();
656 cleanup_target (¤t_target
);
664 (current_target
.to_close
) (0); /* Let it clean up */
665 if (unpush_target (target_stack
->target_ops
) == 1)
668 fprintf_unfiltered (gdb_stderr
,
669 "pop_target couldn't find target %s\n",
670 current_target
.to_shortname
);
675 #define MIN(A, B) (((A) <= (B)) ? (A) : (B))
677 /* target_read_string -- read a null terminated string, up to LEN bytes,
678 from MEMADDR in target. Set *ERRNOP to the errno code, or 0 if successful.
679 Set *STRING to a pointer to malloc'd memory containing the data; the caller
680 is responsible for freeing it. Return the number of bytes successfully
684 target_read_string (memaddr
, string
, len
, errnop
)
690 int tlen
, origlen
, offset
, i
;
694 int buffer_allocated
;
696 unsigned int nbytes_read
= 0;
698 /* Small for testing. */
699 buffer_allocated
= 4;
700 buffer
= xmalloc (buffer_allocated
);
707 tlen
= MIN (len
, 4 - (memaddr
& 3));
708 offset
= memaddr
& 3;
710 errcode
= target_xfer_memory (memaddr
& ~3, buf
, 4, 0, NULL
);
713 /* The transfer request might have crossed the boundary to an
714 unallocated region of memory. Retry the transfer, requesting
718 errcode
= target_xfer_memory (memaddr
, buf
, 1, 0, NULL
);
723 if (bufptr
- buffer
+ tlen
> buffer_allocated
)
726 bytes
= bufptr
- buffer
;
727 buffer_allocated
*= 2;
728 buffer
= xrealloc (buffer
, buffer_allocated
);
729 bufptr
= buffer
+ bytes
;
732 for (i
= 0; i
< tlen
; i
++)
734 *bufptr
++ = buf
[i
+ offset
];
735 if (buf
[i
+ offset
] == '\000')
737 nbytes_read
+= i
+ 1;
754 /* Read LEN bytes of target memory at address MEMADDR, placing the results in
755 GDB's memory at MYADDR. Returns either 0 for success or an errno value
758 If an error occurs, no guarantee is made about the contents of the data at
759 MYADDR. In particular, the caller should not depend upon partial reads
760 filling the buffer with good data. There is no way for the caller to know
761 how much good data might have been transfered anyway. Callers that can
762 deal with partial reads should call target_read_memory_partial. */
765 target_read_memory (memaddr
, myaddr
, len
)
770 return target_xfer_memory (memaddr
, myaddr
, len
, 0, NULL
);
774 target_read_memory_section (memaddr
, myaddr
, len
, bfd_section
)
778 asection
*bfd_section
;
780 return target_xfer_memory (memaddr
, myaddr
, len
, 0, bfd_section
);
783 /* Read LEN bytes of target memory at address MEMADDR, placing the results
784 in GDB's memory at MYADDR. Returns a count of the bytes actually read,
785 and optionally an errno value in the location pointed to by ERRNOPTR
786 if ERRNOPTR is non-null. */
789 target_read_memory_partial (memaddr
, myaddr
, len
, errnoptr
)
795 int nread
; /* Number of bytes actually read. */
796 int errcode
; /* Error from last read. */
798 /* First try a complete read. */
799 errcode
= target_xfer_memory (memaddr
, myaddr
, len
, 0, NULL
);
807 /* Loop, reading one byte at a time until we get as much as we can. */
808 for (errcode
= 0, nread
= 0; len
> 0 && errcode
== 0; nread
++, len
--)
810 errcode
= target_xfer_memory (memaddr
++, myaddr
++, 1, 0, NULL
);
812 /* If an error, the last read was unsuccessful, so adjust count. */
818 if (errnoptr
!= NULL
)
826 target_write_memory (memaddr
, myaddr
, len
)
831 return target_xfer_memory (memaddr
, myaddr
, len
, 1, NULL
);
834 /* This variable is used to pass section information down to targets. This
835 *should* be done by adding an argument to the target_xfer_memory function
836 of all the targets, but I didn't feel like changing 50+ files. */
838 asection
*target_memory_bfd_section
= NULL
;
840 /* Move memory to or from the targets. Iterate until all of it has
841 been moved, if necessary. The top target gets priority; anything
842 it doesn't want, is offered to the next one down, etc. Note the
843 business with curlen: if an early target says "no, but I have a
844 boundary overlapping this xfer" then we shorten what we offer to
845 the subsequent targets so the early guy will get a chance at the
846 tail before the subsequent ones do.
848 Result is 0 or errno value. */
851 target_xfer_memory (memaddr
, myaddr
, len
, write
, bfd_section
)
856 asection
*bfd_section
;
860 struct target_ops
*t
;
861 struct target_stack_item
*item
;
863 /* Zero length requests are ok and require no work. */
867 target_memory_bfd_section
= bfd_section
;
869 /* to_xfer_memory is not guaranteed to set errno, even when it returns
873 /* The quick case is that the top target does it all. */
874 res
= current_target
.to_xfer_memory
875 (memaddr
, myaddr
, len
, write
, ¤t_target
);
881 /* If res <= 0 then we call it again in the loop. Ah well. */
885 curlen
= len
; /* Want to do it all */
886 for (item
= target_stack
; item
; item
= item
->next
)
888 t
= item
->target_ops
;
889 if (!t
->to_has_memory
)
892 res
= t
->to_xfer_memory (memaddr
, myaddr
, curlen
, write
, t
);
894 break; /* Handled all or part of xfer */
895 if (t
->to_has_all_memory
)
901 /* If this address is for nonexistent memory,
902 read zeros if reading, or do nothing if writing. Return error. */
904 memset (myaddr
, 0, len
);
915 return 0; /* We managed to cover it all somehow. */
921 target_info (args
, from_tty
)
925 struct target_ops
*t
;
926 struct target_stack_item
*item
;
929 if (symfile_objfile
!= NULL
)
930 printf_unfiltered ("Symbols from \"%s\".\n", symfile_objfile
->name
);
932 #ifdef FILES_INFO_HOOK
933 if (FILES_INFO_HOOK ())
937 for (item
= target_stack
; item
; item
= item
->next
)
939 t
= item
->target_ops
;
941 if (!t
->to_has_memory
)
944 if ((int) (t
->to_stratum
) <= (int) dummy_stratum
)
947 printf_unfiltered ("\tWhile running this, GDB does not access memory from...\n");
948 printf_unfiltered ("%s:\n", t
->to_longname
);
949 (t
->to_files_info
) (t
);
950 has_all_mem
= t
->to_has_all_memory
;
954 /* This is to be called by the open routine before it does
958 target_preopen (from_tty
)
963 if (target_has_execution
)
965 if (query ("A program is being debugged already. Kill it? "))
968 error ("Program not killed.");
971 /* Calling target_kill may remove the target from the stack. But if
972 it doesn't (which seems like a win for UDI), remove it now. */
974 if (target_has_execution
)
978 /* Detach a target after doing deferred register stores. */
981 target_detach (args
, from_tty
)
985 /* Handle any optimized stores to the inferior. */
986 #ifdef DO_DEFERRED_STORES
989 (current_target
.to_detach
) (args
, from_tty
);
993 target_link (modname
, t_reloc
)
997 if (STREQ (current_target
.to_shortname
, "rombug"))
999 (current_target
.to_lookup_symbol
) (modname
, t_reloc
);
1001 error ("Unable to link to %s and get relocation in rombug", modname
);
1004 *t_reloc
= (CORE_ADDR
) - 1;
1007 /* Look through the list of possible targets for a target that can
1008 execute a run or attach command without any other data. This is
1009 used to locate the default process stratum.
1011 Result is always valid (error() is called for errors). */
1013 static struct target_ops
*
1014 find_default_run_target (do_mesg
)
1017 struct target_ops
**t
;
1018 struct target_ops
*runable
= NULL
;
1023 for (t
= target_structs
; t
< target_structs
+ target_struct_size
;
1026 if ((*t
)->to_can_run
&& target_can_run (*t
))
1034 error ("Don't know how to %s. Try \"help target\".", do_mesg
);
1040 find_default_attach (args
, from_tty
)
1044 struct target_ops
*t
;
1046 t
= find_default_run_target ("attach");
1047 (t
->to_attach
) (args
, from_tty
);
1052 find_default_require_attach (args
, from_tty
)
1056 struct target_ops
*t
;
1058 t
= find_default_run_target ("require_attach");
1059 (t
->to_require_attach
) (args
, from_tty
);
1064 find_default_require_detach (pid
, args
, from_tty
)
1069 struct target_ops
*t
;
1071 t
= find_default_run_target ("require_detach");
1072 (t
->to_require_detach
) (pid
, args
, from_tty
);
1077 find_default_create_inferior (exec_file
, allargs
, env
)
1082 struct target_ops
*t
;
1084 t
= find_default_run_target ("run");
1085 (t
->to_create_inferior
) (exec_file
, allargs
, env
);
1090 find_default_clone_and_follow_inferior (child_pid
, followed_child
)
1092 int *followed_child
;
1094 struct target_ops
*t
;
1096 t
= find_default_run_target ("run");
1097 (t
->to_clone_and_follow_inferior
) (child_pid
, followed_child
);
1113 /* Find a single runnable target in the stack and return it. If for
1114 some reason there is more than one, return NULL. */
1119 struct target_ops
**t
;
1120 struct target_ops
*runable
= NULL
;
1125 for (t
= target_structs
; t
< target_structs
+ target_struct_size
; ++t
)
1127 if ((*t
)->to_can_run
&& target_can_run (*t
))
1134 return (count
== 1 ? runable
: NULL
);
1140 struct target_ops
**t
;
1141 struct target_ops
*runable
= NULL
;
1146 for (t
= target_structs
; t
< target_structs
+ target_struct_size
;
1149 if ((*t
)->to_stratum
== core_stratum
)
1156 return (count
== 1 ? runable
: NULL
);
1159 /* The inferior process has died. Long live the inferior! */
1162 generic_mourn_inferior ()
1164 extern int show_breakpoint_hit_counts
;
1168 breakpoint_init_inferior (inf_exited
);
1169 registers_changed ();
1171 #ifdef CLEAR_DEFERRED_STORES
1172 /* Delete any pending stores to the inferior... */
1173 CLEAR_DEFERRED_STORES
;
1176 reopen_exec_file ();
1177 reinit_frame_cache ();
1179 /* It is confusing to the user for ignore counts to stick around
1180 from previous runs of the inferior. So clear them. */
1181 /* However, it is more confusing for the ignore counts to disappear when
1182 using hit counts. So don't clear them if we're counting hits. */
1183 if (!show_breakpoint_hit_counts
)
1184 breakpoint_clear_ignore_counts ();
1187 /* This table must match in order and size the signals in enum target_signal
1196 {"SIGHUP", "Hangup"},
1197 {"SIGINT", "Interrupt"},
1198 {"SIGQUIT", "Quit"},
1199 {"SIGILL", "Illegal instruction"},
1200 {"SIGTRAP", "Trace/breakpoint trap"},
1201 {"SIGABRT", "Aborted"},
1202 {"SIGEMT", "Emulation trap"},
1203 {"SIGFPE", "Arithmetic exception"},
1204 {"SIGKILL", "Killed"},
1205 {"SIGBUS", "Bus error"},
1206 {"SIGSEGV", "Segmentation fault"},
1207 {"SIGSYS", "Bad system call"},
1208 {"SIGPIPE", "Broken pipe"},
1209 {"SIGALRM", "Alarm clock"},
1210 {"SIGTERM", "Terminated"},
1211 {"SIGURG", "Urgent I/O condition"},
1212 {"SIGSTOP", "Stopped (signal)"},
1213 {"SIGTSTP", "Stopped (user)"},
1214 {"SIGCONT", "Continued"},
1215 {"SIGCHLD", "Child status changed"},
1216 {"SIGTTIN", "Stopped (tty input)"},
1217 {"SIGTTOU", "Stopped (tty output)"},
1218 {"SIGIO", "I/O possible"},
1219 {"SIGXCPU", "CPU time limit exceeded"},
1220 {"SIGXFSZ", "File size limit exceeded"},
1221 {"SIGVTALRM", "Virtual timer expired"},
1222 {"SIGPROF", "Profiling timer expired"},
1223 {"SIGWINCH", "Window size changed"},
1224 {"SIGLOST", "Resource lost"},
1225 {"SIGUSR1", "User defined signal 1"},
1226 {"SIGUSR2", "User defined signal 2"},
1227 {"SIGPWR", "Power fail/restart"},
1228 {"SIGPOLL", "Pollable event occurred"},
1229 {"SIGWIND", "SIGWIND"},
1230 {"SIGPHONE", "SIGPHONE"},
1231 {"SIGWAITING", "Process's LWPs are blocked"},
1232 {"SIGLWP", "Signal LWP"},
1233 {"SIGDANGER", "Swap space dangerously low"},
1234 {"SIGGRANT", "Monitor mode granted"},
1235 {"SIGRETRACT", "Need to relinquish monitor mode"},
1236 {"SIGMSG", "Monitor mode data available"},
1237 {"SIGSOUND", "Sound completed"},
1238 {"SIGSAK", "Secure attention"},
1239 {"SIGPRIO", "SIGPRIO"},
1240 {"SIG33", "Real-time event 33"},
1241 {"SIG34", "Real-time event 34"},
1242 {"SIG35", "Real-time event 35"},
1243 {"SIG36", "Real-time event 36"},
1244 {"SIG37", "Real-time event 37"},
1245 {"SIG38", "Real-time event 38"},
1246 {"SIG39", "Real-time event 39"},
1247 {"SIG40", "Real-time event 40"},
1248 {"SIG41", "Real-time event 41"},
1249 {"SIG42", "Real-time event 42"},
1250 {"SIG43", "Real-time event 43"},
1251 {"SIG44", "Real-time event 44"},
1252 {"SIG45", "Real-time event 45"},
1253 {"SIG46", "Real-time event 46"},
1254 {"SIG47", "Real-time event 47"},
1255 {"SIG48", "Real-time event 48"},
1256 {"SIG49", "Real-time event 49"},
1257 {"SIG50", "Real-time event 50"},
1258 {"SIG51", "Real-time event 51"},
1259 {"SIG52", "Real-time event 52"},
1260 {"SIG53", "Real-time event 53"},
1261 {"SIG54", "Real-time event 54"},
1262 {"SIG55", "Real-time event 55"},
1263 {"SIG56", "Real-time event 56"},
1264 {"SIG57", "Real-time event 57"},
1265 {"SIG58", "Real-time event 58"},
1266 {"SIG59", "Real-time event 59"},
1267 {"SIG60", "Real-time event 60"},
1268 {"SIG61", "Real-time event 61"},
1269 {"SIG62", "Real-time event 62"},
1270 {"SIG63", "Real-time event 63"},
1271 {"SIGCANCEL", "LWP internal signal"},
1273 #if defined(MACH) || defined(__MACH__)
1274 /* Mach exceptions */
1275 {"EXC_BAD_ACCESS", "Could not access memory"},
1276 {"EXC_BAD_INSTRUCTION", "Illegal instruction/operand"},
1277 {"EXC_ARITHMETIC", "Arithmetic exception"},
1278 {"EXC_EMULATION", "Emulation instruction"},
1279 {"EXC_SOFTWARE", "Software generated exception"},
1280 {"EXC_BREAKPOINT", "Breakpoint"},
1282 {"SIGINFO", "Information request"},
1284 {NULL
, "Unknown signal"},
1285 {NULL
, "Internal error: printing TARGET_SIGNAL_DEFAULT"},
1287 /* Last entry, used to check whether the table is the right size. */
1288 {NULL
, "TARGET_SIGNAL_MAGIC"}
1294 /* Return the string for a signal. */
1296 target_signal_to_string (sig
)
1297 enum target_signal sig
;
1299 if ((sig
>= TARGET_SIGNAL_FIRST
) && (sig
<= TARGET_SIGNAL_LAST
))
1300 return signals
[sig
].string
;
1302 return signals
[TARGET_SIGNAL_UNKNOWN
].string
;
1305 /* Return the name for a signal. */
1307 target_signal_to_name (sig
)
1308 enum target_signal sig
;
1310 if (sig
== TARGET_SIGNAL_UNKNOWN
)
1311 /* I think the code which prints this will always print it along with
1312 the string, so no need to be verbose. */
1314 return signals
[sig
].name
;
1317 /* Given a name, return its signal. */
1319 target_signal_from_name (name
)
1322 enum target_signal sig
;
1324 /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
1325 for TARGET_SIGNAL_SIGCHLD. SIGIOT, on the other hand, is more
1326 questionable; seems like by now people should call it SIGABRT
1329 /* This ugly cast brought to you by the native VAX compiler. */
1330 for (sig
= TARGET_SIGNAL_HUP
;
1331 signals
[sig
].name
!= NULL
;
1332 sig
= (enum target_signal
) ((int) sig
+ 1))
1333 if (STREQ (name
, signals
[sig
].name
))
1335 return TARGET_SIGNAL_UNKNOWN
;
1338 /* The following functions are to help certain targets deal
1339 with the signal/waitstatus stuff. They could just as well be in
1340 a file called native-utils.c or unixwaitstatus-utils.c or whatever. */
1342 /* Convert host signal to our signals. */
1344 target_signal_from_host (hostsig
)
1347 /* A switch statement would make sense but would require special kludges
1348 to deal with the cases where more than one signal has the same number. */
1351 return TARGET_SIGNAL_0
;
1353 #if defined (SIGHUP)
1354 if (hostsig
== SIGHUP
)
1355 return TARGET_SIGNAL_HUP
;
1357 #if defined (SIGINT)
1358 if (hostsig
== SIGINT
)
1359 return TARGET_SIGNAL_INT
;
1361 #if defined (SIGQUIT)
1362 if (hostsig
== SIGQUIT
)
1363 return TARGET_SIGNAL_QUIT
;
1365 #if defined (SIGILL)
1366 if (hostsig
== SIGILL
)
1367 return TARGET_SIGNAL_ILL
;
1369 #if defined (SIGTRAP)
1370 if (hostsig
== SIGTRAP
)
1371 return TARGET_SIGNAL_TRAP
;
1373 #if defined (SIGABRT)
1374 if (hostsig
== SIGABRT
)
1375 return TARGET_SIGNAL_ABRT
;
1377 #if defined (SIGEMT)
1378 if (hostsig
== SIGEMT
)
1379 return TARGET_SIGNAL_EMT
;
1381 #if defined (SIGFPE)
1382 if (hostsig
== SIGFPE
)
1383 return TARGET_SIGNAL_FPE
;
1385 #if defined (SIGKILL)
1386 if (hostsig
== SIGKILL
)
1387 return TARGET_SIGNAL_KILL
;
1389 #if defined (SIGBUS)
1390 if (hostsig
== SIGBUS
)
1391 return TARGET_SIGNAL_BUS
;
1393 #if defined (SIGSEGV)
1394 if (hostsig
== SIGSEGV
)
1395 return TARGET_SIGNAL_SEGV
;
1397 #if defined (SIGSYS)
1398 if (hostsig
== SIGSYS
)
1399 return TARGET_SIGNAL_SYS
;
1401 #if defined (SIGPIPE)
1402 if (hostsig
== SIGPIPE
)
1403 return TARGET_SIGNAL_PIPE
;
1405 #if defined (SIGALRM)
1406 if (hostsig
== SIGALRM
)
1407 return TARGET_SIGNAL_ALRM
;
1409 #if defined (SIGTERM)
1410 if (hostsig
== SIGTERM
)
1411 return TARGET_SIGNAL_TERM
;
1413 #if defined (SIGUSR1)
1414 if (hostsig
== SIGUSR1
)
1415 return TARGET_SIGNAL_USR1
;
1417 #if defined (SIGUSR2)
1418 if (hostsig
== SIGUSR2
)
1419 return TARGET_SIGNAL_USR2
;
1421 #if defined (SIGCLD)
1422 if (hostsig
== SIGCLD
)
1423 return TARGET_SIGNAL_CHLD
;
1425 #if defined (SIGCHLD)
1426 if (hostsig
== SIGCHLD
)
1427 return TARGET_SIGNAL_CHLD
;
1429 #if defined (SIGPWR)
1430 if (hostsig
== SIGPWR
)
1431 return TARGET_SIGNAL_PWR
;
1433 #if defined (SIGWINCH)
1434 if (hostsig
== SIGWINCH
)
1435 return TARGET_SIGNAL_WINCH
;
1437 #if defined (SIGURG)
1438 if (hostsig
== SIGURG
)
1439 return TARGET_SIGNAL_URG
;
1442 if (hostsig
== SIGIO
)
1443 return TARGET_SIGNAL_IO
;
1445 #if defined (SIGPOLL)
1446 if (hostsig
== SIGPOLL
)
1447 return TARGET_SIGNAL_POLL
;
1449 #if defined (SIGSTOP)
1450 if (hostsig
== SIGSTOP
)
1451 return TARGET_SIGNAL_STOP
;
1453 #if defined (SIGTSTP)
1454 if (hostsig
== SIGTSTP
)
1455 return TARGET_SIGNAL_TSTP
;
1457 #if defined (SIGCONT)
1458 if (hostsig
== SIGCONT
)
1459 return TARGET_SIGNAL_CONT
;
1461 #if defined (SIGTTIN)
1462 if (hostsig
== SIGTTIN
)
1463 return TARGET_SIGNAL_TTIN
;
1465 #if defined (SIGTTOU)
1466 if (hostsig
== SIGTTOU
)
1467 return TARGET_SIGNAL_TTOU
;
1469 #if defined (SIGVTALRM)
1470 if (hostsig
== SIGVTALRM
)
1471 return TARGET_SIGNAL_VTALRM
;
1473 #if defined (SIGPROF)
1474 if (hostsig
== SIGPROF
)
1475 return TARGET_SIGNAL_PROF
;
1477 #if defined (SIGXCPU)
1478 if (hostsig
== SIGXCPU
)
1479 return TARGET_SIGNAL_XCPU
;
1481 #if defined (SIGXFSZ)
1482 if (hostsig
== SIGXFSZ
)
1483 return TARGET_SIGNAL_XFSZ
;
1485 #if defined (SIGWIND)
1486 if (hostsig
== SIGWIND
)
1487 return TARGET_SIGNAL_WIND
;
1489 #if defined (SIGPHONE)
1490 if (hostsig
== SIGPHONE
)
1491 return TARGET_SIGNAL_PHONE
;
1493 #if defined (SIGLOST)
1494 if (hostsig
== SIGLOST
)
1495 return TARGET_SIGNAL_LOST
;
1497 #if defined (SIGWAITING)
1498 if (hostsig
== SIGWAITING
)
1499 return TARGET_SIGNAL_WAITING
;
1501 #if defined (SIGCANCEL)
1502 if (hostsig
== SIGCANCEL
)
1503 return TARGET_SIGNAL_CANCEL
;
1505 #if defined (SIGLWP)
1506 if (hostsig
== SIGLWP
)
1507 return TARGET_SIGNAL_LWP
;
1509 #if defined (SIGDANGER)
1510 if (hostsig
== SIGDANGER
)
1511 return TARGET_SIGNAL_DANGER
;
1513 #if defined (SIGGRANT)
1514 if (hostsig
== SIGGRANT
)
1515 return TARGET_SIGNAL_GRANT
;
1517 #if defined (SIGRETRACT)
1518 if (hostsig
== SIGRETRACT
)
1519 return TARGET_SIGNAL_RETRACT
;
1521 #if defined (SIGMSG)
1522 if (hostsig
== SIGMSG
)
1523 return TARGET_SIGNAL_MSG
;
1525 #if defined (SIGSOUND)
1526 if (hostsig
== SIGSOUND
)
1527 return TARGET_SIGNAL_SOUND
;
1529 #if defined (SIGSAK)
1530 if (hostsig
== SIGSAK
)
1531 return TARGET_SIGNAL_SAK
;
1533 #if defined (SIGPRIO)
1534 if (hostsig
== SIGPRIO
)
1535 return TARGET_SIGNAL_PRIO
;
1538 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1539 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1540 if (hostsig
== _NSIG
+ EXC_BAD_ACCESS
)
1541 return TARGET_EXC_BAD_ACCESS
;
1543 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
1544 if (hostsig
== _NSIG
+ EXC_BAD_INSTRUCTION
)
1545 return TARGET_EXC_BAD_INSTRUCTION
;
1547 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
1548 if (hostsig
== _NSIG
+ EXC_ARITHMETIC
)
1549 return TARGET_EXC_ARITHMETIC
;
1551 #if defined (EXC_EMULATION) && defined (_NSIG)
1552 if (hostsig
== _NSIG
+ EXC_EMULATION
)
1553 return TARGET_EXC_EMULATION
;
1555 #if defined (EXC_SOFTWARE) && defined (_NSIG)
1556 if (hostsig
== _NSIG
+ EXC_SOFTWARE
)
1557 return TARGET_EXC_SOFTWARE
;
1559 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
1560 if (hostsig
== _NSIG
+ EXC_BREAKPOINT
)
1561 return TARGET_EXC_BREAKPOINT
;
1564 #if defined (SIGINFO)
1565 if (hostsig
== SIGINFO
)
1566 return TARGET_SIGNAL_INFO
;
1569 #if defined (REALTIME_LO)
1570 if (hostsig
>= REALTIME_LO
&& hostsig
< REALTIME_HI
)
1571 return (enum target_signal
)
1572 (hostsig
- 33 + (int) TARGET_SIGNAL_REALTIME_33
);
1574 return TARGET_SIGNAL_UNKNOWN
;
1578 target_signal_to_host (oursig
)
1579 enum target_signal oursig
;
1583 case TARGET_SIGNAL_0
:
1586 #if defined (SIGHUP)
1587 case TARGET_SIGNAL_HUP
:
1590 #if defined (SIGINT)
1591 case TARGET_SIGNAL_INT
:
1594 #if defined (SIGQUIT)
1595 case TARGET_SIGNAL_QUIT
:
1598 #if defined (SIGILL)
1599 case TARGET_SIGNAL_ILL
:
1602 #if defined (SIGTRAP)
1603 case TARGET_SIGNAL_TRAP
:
1606 #if defined (SIGABRT)
1607 case TARGET_SIGNAL_ABRT
:
1610 #if defined (SIGEMT)
1611 case TARGET_SIGNAL_EMT
:
1614 #if defined (SIGFPE)
1615 case TARGET_SIGNAL_FPE
:
1618 #if defined (SIGKILL)
1619 case TARGET_SIGNAL_KILL
:
1622 #if defined (SIGBUS)
1623 case TARGET_SIGNAL_BUS
:
1626 #if defined (SIGSEGV)
1627 case TARGET_SIGNAL_SEGV
:
1630 #if defined (SIGSYS)
1631 case TARGET_SIGNAL_SYS
:
1634 #if defined (SIGPIPE)
1635 case TARGET_SIGNAL_PIPE
:
1638 #if defined (SIGALRM)
1639 case TARGET_SIGNAL_ALRM
:
1642 #if defined (SIGTERM)
1643 case TARGET_SIGNAL_TERM
:
1646 #if defined (SIGUSR1)
1647 case TARGET_SIGNAL_USR1
:
1650 #if defined (SIGUSR2)
1651 case TARGET_SIGNAL_USR2
:
1654 #if defined (SIGCHLD) || defined (SIGCLD)
1655 case TARGET_SIGNAL_CHLD
:
1656 #if defined (SIGCHLD)
1661 #endif /* SIGCLD or SIGCHLD */
1662 #if defined (SIGPWR)
1663 case TARGET_SIGNAL_PWR
:
1666 #if defined (SIGWINCH)
1667 case TARGET_SIGNAL_WINCH
:
1670 #if defined (SIGURG)
1671 case TARGET_SIGNAL_URG
:
1675 case TARGET_SIGNAL_IO
:
1678 #if defined (SIGPOLL)
1679 case TARGET_SIGNAL_POLL
:
1682 #if defined (SIGSTOP)
1683 case TARGET_SIGNAL_STOP
:
1686 #if defined (SIGTSTP)
1687 case TARGET_SIGNAL_TSTP
:
1690 #if defined (SIGCONT)
1691 case TARGET_SIGNAL_CONT
:
1694 #if defined (SIGTTIN)
1695 case TARGET_SIGNAL_TTIN
:
1698 #if defined (SIGTTOU)
1699 case TARGET_SIGNAL_TTOU
:
1702 #if defined (SIGVTALRM)
1703 case TARGET_SIGNAL_VTALRM
:
1706 #if defined (SIGPROF)
1707 case TARGET_SIGNAL_PROF
:
1710 #if defined (SIGXCPU)
1711 case TARGET_SIGNAL_XCPU
:
1714 #if defined (SIGXFSZ)
1715 case TARGET_SIGNAL_XFSZ
:
1718 #if defined (SIGWIND)
1719 case TARGET_SIGNAL_WIND
:
1722 #if defined (SIGPHONE)
1723 case TARGET_SIGNAL_PHONE
:
1726 #if defined (SIGLOST)
1727 case TARGET_SIGNAL_LOST
:
1730 #if defined (SIGWAITING)
1731 case TARGET_SIGNAL_WAITING
:
1734 #if defined (SIGCANCEL)
1735 case TARGET_SIGNAL_CANCEL
:
1738 #if defined (SIGLWP)
1739 case TARGET_SIGNAL_LWP
:
1742 #if defined (SIGDANGER)
1743 case TARGET_SIGNAL_DANGER
:
1746 #if defined (SIGGRANT)
1747 case TARGET_SIGNAL_GRANT
:
1750 #if defined (SIGRETRACT)
1751 case TARGET_SIGNAL_RETRACT
:
1754 #if defined (SIGMSG)
1755 case TARGET_SIGNAL_MSG
:
1758 #if defined (SIGSOUND)
1759 case TARGET_SIGNAL_SOUND
:
1762 #if defined (SIGSAK)
1763 case TARGET_SIGNAL_SAK
:
1766 #if defined (SIGPRIO)
1767 case TARGET_SIGNAL_PRIO
:
1771 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1772 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1773 case TARGET_EXC_BAD_ACCESS
:
1774 return _NSIG
+ EXC_BAD_ACCESS
;
1776 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
1777 case TARGET_EXC_BAD_INSTRUCTION
:
1778 return _NSIG
+ EXC_BAD_INSTRUCTION
;
1780 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
1781 case TARGET_EXC_ARITHMETIC
:
1782 return _NSIG
+ EXC_ARITHMETIC
;
1784 #if defined (EXC_EMULATION) && defined (_NSIG)
1785 case TARGET_EXC_EMULATION
:
1786 return _NSIG
+ EXC_EMULATION
;
1788 #if defined (EXC_SOFTWARE) && defined (_NSIG)
1789 case TARGET_EXC_SOFTWARE
:
1790 return _NSIG
+ EXC_SOFTWARE
;
1792 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
1793 case TARGET_EXC_BREAKPOINT
:
1794 return _NSIG
+ EXC_BREAKPOINT
;
1797 #if defined (SIGINFO)
1798 case TARGET_SIGNAL_INFO
:
1803 #if defined (REALTIME_LO)
1804 if (oursig
>= TARGET_SIGNAL_REALTIME_33
1805 && oursig
<= TARGET_SIGNAL_REALTIME_63
)
1808 (int) oursig
- (int) TARGET_SIGNAL_REALTIME_33
+ REALTIME_LO
;
1809 if (retsig
< REALTIME_HI
)
1813 /* The user might be trying to do "signal SIGSAK" where this system
1814 doesn't have SIGSAK. */
1815 warning ("Signal %s does not exist on this system.\n",
1816 target_signal_to_name (oursig
));
1821 /* Helper function for child_wait and the Lynx derivatives of child_wait.
1822 HOSTSTATUS is the waitstatus from wait() or the equivalent; store our
1823 translation of that in OURSTATUS. */
1825 store_waitstatus (ourstatus
, hoststatus
)
1826 struct target_waitstatus
*ourstatus
;
1829 #ifdef CHILD_SPECIAL_WAITSTATUS
1830 /* CHILD_SPECIAL_WAITSTATUS should return nonzero and set *OURSTATUS
1831 if it wants to deal with hoststatus. */
1832 if (CHILD_SPECIAL_WAITSTATUS (ourstatus
, hoststatus
))
1836 if (WIFEXITED (hoststatus
))
1838 ourstatus
->kind
= TARGET_WAITKIND_EXITED
;
1839 ourstatus
->value
.integer
= WEXITSTATUS (hoststatus
);
1841 else if (!WIFSTOPPED (hoststatus
))
1843 ourstatus
->kind
= TARGET_WAITKIND_SIGNALLED
;
1844 ourstatus
->value
.sig
= target_signal_from_host (WTERMSIG (hoststatus
));
1848 ourstatus
->kind
= TARGET_WAITKIND_STOPPED
;
1849 ourstatus
->value
.sig
= target_signal_from_host (WSTOPSIG (hoststatus
));
1853 /* In some circumstances we allow a command to specify a numeric
1854 signal. The idea is to keep these circumstances limited so that
1855 users (and scripts) develop portable habits. For comparison,
1856 POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a
1857 numeric signal at all is obscelescent. We are slightly more
1858 lenient and allow 1-15 which should match host signal numbers on
1859 most systems. Use of symbolic signal names is strongly encouraged. */
1862 target_signal_from_command (num
)
1865 if (num
>= 1 && num
<= 15)
1866 return (enum target_signal
) num
;
1867 error ("Only signals 1-15 are valid as numeric signals.\n\
1868 Use \"info signals\" for a list of symbolic signals.");
1871 /* Returns zero to leave the inferior alone, one to interrupt it. */
1872 int (*target_activity_function
) PARAMS ((void));
1873 int target_activity_fd
;
1875 /* Convert a normal process ID to a string. Returns the string in a static
1879 normal_pid_to_str (pid
)
1882 static char buf
[30];
1884 if (STREQ (current_target
.to_shortname
, "remote"))
1885 sprintf (buf
, "thread %d\0", pid
);
1887 sprintf (buf
, "process %d\0", pid
);
1892 /* Some targets (such as ttrace-based HPUX) don't allow us to request
1893 notification of inferior events such as fork and vork immediately
1894 after the inferior is created. (This because of how gdb gets an
1895 inferior created via invoking a shell to do it. In such a scenario,
1896 if the shell init file has commands in it, the shell will fork and
1897 exec for each of those commands, and we will see each such fork
1900 This function is used by all targets that allow us to request
1901 notification of forks, etc at inferior creation time; e.g., in
1902 target_acknowledge_forked_child.
1905 normal_target_post_startup_inferior (pid
)
1908 /* This space intentionally left blank. */
1911 /* Set up the handful of non-empty slots needed by the dummy target
1915 init_dummy_target ()
1917 dummy_target
.to_shortname
= "None";
1918 dummy_target
.to_longname
= "None";
1919 dummy_target
.to_doc
= "";
1920 dummy_target
.to_attach
= find_default_attach
;
1921 dummy_target
.to_require_attach
= find_default_require_attach
;
1922 dummy_target
.to_require_detach
= find_default_require_detach
;
1923 dummy_target
.to_create_inferior
= find_default_create_inferior
;
1924 dummy_target
.to_clone_and_follow_inferior
= find_default_clone_and_follow_inferior
;
1925 dummy_target
.to_stratum
= dummy_stratum
;
1926 dummy_target
.to_magic
= OPS_MAGIC
;
1930 static struct target_ops debug_target
;
1933 debug_to_open (args
, from_tty
)
1937 debug_target
.to_open (args
, from_tty
);
1939 fprintf_unfiltered (gdb_stderr
, "target_open (%s, %d)\n", args
, from_tty
);
1943 debug_to_close (quitting
)
1946 debug_target
.to_close (quitting
);
1948 fprintf_unfiltered (gdb_stderr
, "target_close (%d)\n", quitting
);
1952 debug_to_attach (args
, from_tty
)
1956 debug_target
.to_attach (args
, from_tty
);
1958 fprintf_unfiltered (gdb_stderr
, "target_attach (%s, %d)\n", args
, from_tty
);
1963 debug_to_post_attach (pid
)
1966 debug_target
.to_post_attach (pid
);
1968 fprintf_unfiltered (gdb_stderr
, "target_post_attach (%d)\n", pid
);
1972 debug_to_require_attach (args
, from_tty
)
1976 debug_target
.to_require_attach (args
, from_tty
);
1978 fprintf_unfiltered (gdb_stderr
,
1979 "target_require_attach (%s, %d)\n", args
, from_tty
);
1983 debug_to_detach (args
, from_tty
)
1987 debug_target
.to_detach (args
, from_tty
);
1989 fprintf_unfiltered (gdb_stderr
, "target_detach (%s, %d)\n", args
, from_tty
);
1993 debug_to_require_detach (pid
, args
, from_tty
)
1998 debug_target
.to_require_detach (pid
, args
, from_tty
);
2000 fprintf_unfiltered (gdb_stderr
,
2001 "target_require_detach (%d, %s, %d)\n", pid
, args
, from_tty
);
2005 debug_to_resume (pid
, step
, siggnal
)
2008 enum target_signal siggnal
;
2010 debug_target
.to_resume (pid
, step
, siggnal
);
2012 fprintf_unfiltered (gdb_stderr
, "target_resume (%d, %s, %s)\n", pid
,
2013 step
? "step" : "continue",
2014 target_signal_to_name (siggnal
));
2018 debug_to_wait (pid
, status
)
2020 struct target_waitstatus
*status
;
2024 retval
= debug_target
.to_wait (pid
, status
);
2026 fprintf_unfiltered (gdb_stderr
,
2027 "target_wait (%d, status) = %d, ", pid
, retval
);
2028 fprintf_unfiltered (gdb_stderr
, "status->kind = ");
2029 switch (status
->kind
)
2031 case TARGET_WAITKIND_EXITED
:
2032 fprintf_unfiltered (gdb_stderr
, "exited, status = %d\n",
2033 status
->value
.integer
);
2035 case TARGET_WAITKIND_STOPPED
:
2036 fprintf_unfiltered (gdb_stderr
, "stopped, signal = %s\n",
2037 target_signal_to_name (status
->value
.sig
));
2039 case TARGET_WAITKIND_SIGNALLED
:
2040 fprintf_unfiltered (gdb_stderr
, "signalled, signal = %s\n",
2041 target_signal_to_name (status
->value
.sig
));
2043 case TARGET_WAITKIND_LOADED
:
2044 fprintf_unfiltered (gdb_stderr
, "loaded\n");
2046 case TARGET_WAITKIND_FORKED
:
2047 fprintf_unfiltered (gdb_stderr
, "forked\n");
2049 case TARGET_WAITKIND_VFORKED
:
2050 fprintf_unfiltered (gdb_stderr
, "vforked\n");
2052 case TARGET_WAITKIND_EXECD
:
2053 fprintf_unfiltered (gdb_stderr
, "execd\n");
2055 case TARGET_WAITKIND_SPURIOUS
:
2056 fprintf_unfiltered (gdb_stderr
, "spurious\n");
2059 fprintf_unfiltered (gdb_stderr
, "unknown???\n");
2067 debug_to_post_wait (pid
, status
)
2071 debug_target
.to_post_wait (pid
, status
);
2073 fprintf_unfiltered (gdb_stderr
, "target_post_wait (%d, %d)\n",
2078 debug_to_fetch_registers (regno
)
2081 debug_target
.to_fetch_registers (regno
);
2083 fprintf_unfiltered (gdb_stderr
, "target_fetch_registers (%s)",
2084 regno
!= -1 ? REGISTER_NAME (regno
) : "-1");
2086 fprintf_unfiltered (gdb_stderr
, " = 0x%x %d",
2087 (unsigned long) read_register (regno
),
2088 read_register (regno
));
2089 fprintf_unfiltered (gdb_stderr
, "\n");
2093 debug_to_store_registers (regno
)
2096 debug_target
.to_store_registers (regno
);
2098 if (regno
>= 0 && regno
< NUM_REGS
)
2099 fprintf_unfiltered (gdb_stderr
, "target_store_registers (%s) = 0x%x %d\n",
2100 REGISTER_NAME (regno
),
2101 (unsigned long) read_register (regno
),
2102 (unsigned long) read_register (regno
));
2104 fprintf_unfiltered (gdb_stderr
, "target_store_registers (%d)\n", regno
);
2108 debug_to_prepare_to_store ()
2110 debug_target
.to_prepare_to_store ();
2112 fprintf_unfiltered (gdb_stderr
, "target_prepare_to_store ()\n");
2116 debug_to_xfer_memory (memaddr
, myaddr
, len
, write
, target
)
2121 struct target_ops
*target
;
2125 retval
= debug_target
.to_xfer_memory (memaddr
, myaddr
, len
, write
, target
);
2127 fprintf_unfiltered (gdb_stderr
,
2128 "target_xfer_memory (0x%x, xxx, %d, %s, xxx) = %d",
2129 (unsigned int) memaddr
, /* possable truncate long long */
2130 len
, write
? "write" : "read", retval
);
2138 fputs_unfiltered (", bytes =", gdb_stderr
);
2139 for (i
= 0; i
< retval
; i
++)
2141 if ((((long) &(myaddr
[i
])) & 0xf) == 0)
2142 fprintf_unfiltered (gdb_stderr
, "\n");
2143 fprintf_unfiltered (gdb_stderr
, " %02x", myaddr
[i
] & 0xff);
2147 fputc_unfiltered ('\n', gdb_stderr
);
2153 debug_to_files_info (target
)
2154 struct target_ops
*target
;
2156 debug_target
.to_files_info (target
);
2158 fprintf_unfiltered (gdb_stderr
, "target_files_info (xxx)\n");
2162 debug_to_insert_breakpoint (addr
, save
)
2168 retval
= debug_target
.to_insert_breakpoint (addr
, save
);
2170 fprintf_unfiltered (gdb_stderr
,
2171 "target_insert_breakpoint (0x%x, xxx) = %d\n",
2172 (unsigned long) addr
, retval
);
2177 debug_to_remove_breakpoint (addr
, save
)
2183 retval
= debug_target
.to_remove_breakpoint (addr
, save
);
2185 fprintf_unfiltered (gdb_stderr
,
2186 "target_remove_breakpoint (0x%x, xxx) = %d\n",
2187 (unsigned long) addr
, retval
);
2192 debug_to_terminal_init ()
2194 debug_target
.to_terminal_init ();
2196 fprintf_unfiltered (gdb_stderr
, "target_terminal_init ()\n");
2200 debug_to_terminal_inferior ()
2202 debug_target
.to_terminal_inferior ();
2204 fprintf_unfiltered (gdb_stderr
, "target_terminal_inferior ()\n");
2208 debug_to_terminal_ours_for_output ()
2210 debug_target
.to_terminal_ours_for_output ();
2212 fprintf_unfiltered (gdb_stderr
, "target_terminal_ours_for_output ()\n");
2216 debug_to_terminal_ours ()
2218 debug_target
.to_terminal_ours ();
2220 fprintf_unfiltered (gdb_stderr
, "target_terminal_ours ()\n");
2224 debug_to_terminal_info (arg
, from_tty
)
2228 debug_target
.to_terminal_info (arg
, from_tty
);
2230 fprintf_unfiltered (gdb_stderr
, "target_terminal_info (%s, %d)\n", arg
,
2237 debug_target
.to_kill ();
2239 fprintf_unfiltered (gdb_stderr
, "target_kill ()\n");
2243 debug_to_load (args
, from_tty
)
2247 debug_target
.to_load (args
, from_tty
);
2249 fprintf_unfiltered (gdb_stderr
, "target_load (%s, %d)\n", args
, from_tty
);
2253 debug_to_lookup_symbol (name
, addrp
)
2259 retval
= debug_target
.to_lookup_symbol (name
, addrp
);
2261 fprintf_unfiltered (gdb_stderr
, "target_lookup_symbol (%s, xxx)\n", name
);
2267 debug_to_create_inferior (exec_file
, args
, env
)
2272 debug_target
.to_create_inferior (exec_file
, args
, env
);
2274 fprintf_unfiltered (gdb_stderr
, "target_create_inferior (%s, %s, xxx)\n",
2279 debug_to_post_startup_inferior (pid
)
2282 debug_target
.to_post_startup_inferior (pid
);
2284 fprintf_unfiltered (gdb_stderr
, "target_post_startup_inferior (%d)\n",
2289 debug_to_acknowledge_created_inferior (pid
)
2292 debug_target
.to_acknowledge_created_inferior (pid
);
2294 fprintf_unfiltered (gdb_stderr
, "target_acknowledge_created_inferior (%d)\n",
2299 debug_to_clone_and_follow_inferior (child_pid
, followed_child
)
2301 int *followed_child
;
2303 debug_target
.to_clone_and_follow_inferior (child_pid
, followed_child
);
2305 fprintf_unfiltered (gdb_stderr
,
2306 "target_clone_and_follow_inferior (%d, %d)\n",
2307 child_pid
, *followed_child
);
2311 debug_to_post_follow_inferior_by_clone ()
2313 debug_target
.to_post_follow_inferior_by_clone ();
2315 fprintf_unfiltered (gdb_stderr
, "target_post_follow_inferior_by_clone ()\n");
2319 debug_to_insert_fork_catchpoint (pid
)
2324 retval
= debug_target
.to_insert_fork_catchpoint (pid
);
2326 fprintf_unfiltered (gdb_stderr
, "target_insert_fork_catchpoint (%d) = %d\n",
2333 debug_to_remove_fork_catchpoint (pid
)
2338 retval
= debug_target
.to_remove_fork_catchpoint (pid
);
2340 fprintf_unfiltered (gdb_stderr
, "target_remove_fork_catchpoint (%d) = %d\n",
2347 debug_to_insert_vfork_catchpoint (pid
)
2352 retval
= debug_target
.to_insert_vfork_catchpoint (pid
);
2354 fprintf_unfiltered (gdb_stderr
, "target_insert_vfork_catchpoint (%d)= %d\n",
2361 debug_to_remove_vfork_catchpoint (pid
)
2366 retval
= debug_target
.to_remove_vfork_catchpoint (pid
);
2368 fprintf_unfiltered (gdb_stderr
, "target_remove_vfork_catchpoint (%d) = %d\n",
2375 debug_to_has_forked (pid
, child_pid
)
2381 has_forked
= debug_target
.to_has_forked (pid
, child_pid
);
2383 fprintf_unfiltered (gdb_stderr
, "target_has_forked (%d, %d) = %d\n",
2384 pid
, *child_pid
, has_forked
);
2390 debug_to_has_vforked (pid
, child_pid
)
2396 has_vforked
= debug_target
.to_has_vforked (pid
, child_pid
);
2398 fprintf_unfiltered (gdb_stderr
, "target_has_vforked (%d, %d) = %d\n",
2399 pid
, *child_pid
, has_vforked
);
2405 debug_to_can_follow_vfork_prior_to_exec ()
2407 int can_immediately_follow_vfork
;
2409 can_immediately_follow_vfork
= debug_target
.to_can_follow_vfork_prior_to_exec ();
2411 fprintf_unfiltered (gdb_stderr
, "target_can_follow_vfork_prior_to_exec () = %d\n",
2412 can_immediately_follow_vfork
);
2414 return can_immediately_follow_vfork
;
2418 debug_to_post_follow_vfork (parent_pid
, followed_parent
, child_pid
, followed_child
)
2420 int followed_parent
;
2424 debug_target
.to_post_follow_vfork (parent_pid
, followed_parent
, child_pid
, followed_child
);
2426 fprintf_unfiltered (gdb_stderr
,
2427 "target_post_follow_vfork (%d, %d, %d, %d)\n",
2428 parent_pid
, followed_parent
, child_pid
, followed_child
);
2432 debug_to_insert_exec_catchpoint (pid
)
2437 retval
= debug_target
.to_insert_exec_catchpoint (pid
);
2439 fprintf_unfiltered (gdb_stderr
, "target_insert_exec_catchpoint (%d) = %d\n",
2446 debug_to_remove_exec_catchpoint (pid
)
2451 retval
= debug_target
.to_remove_exec_catchpoint (pid
);
2453 fprintf_unfiltered (gdb_stderr
, "target_remove_exec_catchpoint (%d) = %d\n",
2460 debug_to_has_execd (pid
, execd_pathname
)
2462 char **execd_pathname
;
2466 has_execd
= debug_target
.to_has_execd (pid
, execd_pathname
);
2468 fprintf_unfiltered (gdb_stderr
, "target_has_execd (%d, %s) = %d\n",
2469 pid
, (*execd_pathname
? *execd_pathname
: "<NULL>"),
2476 debug_to_reported_exec_events_per_exec_call ()
2478 int reported_exec_events
;
2480 reported_exec_events
= debug_target
.to_reported_exec_events_per_exec_call ();
2482 fprintf_unfiltered (gdb_stderr
,
2483 "target_reported_exec_events_per_exec_call () = %d\n",
2484 reported_exec_events
);
2486 return reported_exec_events
;
2490 debug_to_has_syscall_event (pid
, kind
, syscall_id
)
2492 enum target_waitkind
*kind
;
2495 int has_syscall_event
;
2496 char *kind_spelling
= "??";
2498 has_syscall_event
= debug_target
.to_has_syscall_event (pid
, kind
, syscall_id
);
2499 if (has_syscall_event
)
2503 case TARGET_WAITKIND_SYSCALL_ENTRY
:
2504 kind_spelling
= "SYSCALL_ENTRY";
2506 case TARGET_WAITKIND_SYSCALL_RETURN
:
2507 kind_spelling
= "SYSCALL_RETURN";
2514 fprintf_unfiltered (gdb_stderr
,
2515 "target_has_syscall_event (%d, %s, %d) = %d\n",
2516 pid
, kind_spelling
, *syscall_id
, has_syscall_event
);
2518 return has_syscall_event
;
2522 debug_to_has_exited (pid
, wait_status
, exit_status
)
2529 has_exited
= debug_target
.to_has_exited (pid
, wait_status
, exit_status
);
2531 fprintf_unfiltered (gdb_stderr
, "target_has_exited (%d, %d, %d) = %d\n",
2532 pid
, wait_status
, *exit_status
, has_exited
);
2538 debug_to_mourn_inferior ()
2540 debug_target
.to_mourn_inferior ();
2542 fprintf_unfiltered (gdb_stderr
, "target_mourn_inferior ()\n");
2550 retval
= debug_target
.to_can_run ();
2552 fprintf_unfiltered (gdb_stderr
, "target_can_run () = %d\n", retval
);
2558 debug_to_notice_signals (pid
)
2561 debug_target
.to_notice_signals (pid
);
2563 fprintf_unfiltered (gdb_stderr
, "target_notice_signals (%d)\n", pid
);
2567 debug_to_thread_alive (pid
)
2572 retval
= debug_target
.to_thread_alive (pid
);
2574 fprintf_unfiltered (gdb_stderr
, "target_thread_alive (%d) = %d\n",
2583 debug_target
.to_stop ();
2585 fprintf_unfiltered (gdb_stderr
, "target_stop ()\n");
2589 debug_to_query (type
, req
, resp
, siz
)
2597 retval
= debug_target
.to_query (type
, req
, resp
, siz
);
2599 fprintf_unfiltered (gdb_stderr
, "target_query (%c, %s, %s, %d) = %d\n", type
, req
, resp
, *siz
, retval
);
2604 static struct symtab_and_line
*
2605 debug_to_enable_exception_callback (kind
, enable
)
2606 enum exception_event_kind kind
;
2609 struct symtab_and_line
*result
;
2610 result
= debug_target
.to_enable_exception_callback (kind
, enable
);
2611 fprintf_unfiltered (gdb_stderr
,
2612 "target get_exception_callback_sal (%d, %d)\n",
2617 static struct exception_event_record
*
2618 debug_to_get_current_exception_event ()
2620 struct exception_event_record
*result
;
2621 result
= debug_target
.to_get_current_exception_event ();
2622 fprintf_unfiltered (gdb_stderr
, "target get_current_exception_event ()\n");
2627 debug_to_pid_to_exec_file (pid
)
2632 exec_file
= debug_target
.to_pid_to_exec_file (pid
);
2634 fprintf_unfiltered (gdb_stderr
, "target_pid_to_exec_file (%d) = %s\n",
2641 debug_to_core_file_to_sym_file (core
)
2646 sym_file
= debug_target
.to_core_file_to_sym_file (core
);
2648 fprintf_unfiltered (gdb_stderr
, "target_core_file_to_sym_file (%s) = %s\n",
2655 setup_target_debug ()
2657 memcpy (&debug_target
, ¤t_target
, sizeof debug_target
);
2659 current_target
.to_open
= debug_to_open
;
2660 current_target
.to_close
= debug_to_close
;
2661 current_target
.to_attach
= debug_to_attach
;
2662 current_target
.to_post_attach
= debug_to_post_attach
;
2663 current_target
.to_require_attach
= debug_to_require_attach
;
2664 current_target
.to_detach
= debug_to_detach
;
2665 current_target
.to_require_detach
= debug_to_require_detach
;
2666 current_target
.to_resume
= debug_to_resume
;
2667 current_target
.to_wait
= debug_to_wait
;
2668 current_target
.to_post_wait
= debug_to_post_wait
;
2669 current_target
.to_fetch_registers
= debug_to_fetch_registers
;
2670 current_target
.to_store_registers
= debug_to_store_registers
;
2671 current_target
.to_prepare_to_store
= debug_to_prepare_to_store
;
2672 current_target
.to_xfer_memory
= debug_to_xfer_memory
;
2673 current_target
.to_files_info
= debug_to_files_info
;
2674 current_target
.to_insert_breakpoint
= debug_to_insert_breakpoint
;
2675 current_target
.to_remove_breakpoint
= debug_to_remove_breakpoint
;
2676 current_target
.to_terminal_init
= debug_to_terminal_init
;
2677 current_target
.to_terminal_inferior
= debug_to_terminal_inferior
;
2678 current_target
.to_terminal_ours_for_output
= debug_to_terminal_ours_for_output
;
2679 current_target
.to_terminal_ours
= debug_to_terminal_ours
;
2680 current_target
.to_terminal_info
= debug_to_terminal_info
;
2681 current_target
.to_kill
= debug_to_kill
;
2682 current_target
.to_load
= debug_to_load
;
2683 current_target
.to_lookup_symbol
= debug_to_lookup_symbol
;
2684 current_target
.to_create_inferior
= debug_to_create_inferior
;
2685 current_target
.to_post_startup_inferior
= debug_to_post_startup_inferior
;
2686 current_target
.to_acknowledge_created_inferior
= debug_to_acknowledge_created_inferior
;
2687 current_target
.to_clone_and_follow_inferior
= debug_to_clone_and_follow_inferior
;
2688 current_target
.to_post_follow_inferior_by_clone
= debug_to_post_follow_inferior_by_clone
;
2689 current_target
.to_insert_fork_catchpoint
= debug_to_insert_fork_catchpoint
;
2690 current_target
.to_remove_fork_catchpoint
= debug_to_remove_fork_catchpoint
;
2691 current_target
.to_insert_vfork_catchpoint
= debug_to_insert_vfork_catchpoint
;
2692 current_target
.to_remove_vfork_catchpoint
= debug_to_remove_vfork_catchpoint
;
2693 current_target
.to_has_forked
= debug_to_has_forked
;
2694 current_target
.to_has_vforked
= debug_to_has_vforked
;
2695 current_target
.to_can_follow_vfork_prior_to_exec
= debug_to_can_follow_vfork_prior_to_exec
;
2696 current_target
.to_post_follow_vfork
= debug_to_post_follow_vfork
;
2697 current_target
.to_insert_exec_catchpoint
= debug_to_insert_exec_catchpoint
;
2698 current_target
.to_remove_exec_catchpoint
= debug_to_remove_exec_catchpoint
;
2699 current_target
.to_has_execd
= debug_to_has_execd
;
2700 current_target
.to_reported_exec_events_per_exec_call
= debug_to_reported_exec_events_per_exec_call
;
2701 current_target
.to_has_syscall_event
= debug_to_has_syscall_event
;
2702 current_target
.to_has_exited
= debug_to_has_exited
;
2703 current_target
.to_mourn_inferior
= debug_to_mourn_inferior
;
2704 current_target
.to_can_run
= debug_to_can_run
;
2705 current_target
.to_notice_signals
= debug_to_notice_signals
;
2706 current_target
.to_thread_alive
= debug_to_thread_alive
;
2707 current_target
.to_stop
= debug_to_stop
;
2708 current_target
.to_query
= debug_to_query
;
2709 current_target
.to_enable_exception_callback
= debug_to_enable_exception_callback
;
2710 current_target
.to_get_current_exception_event
= debug_to_get_current_exception_event
;
2711 current_target
.to_pid_to_exec_file
= debug_to_pid_to_exec_file
;
2712 current_target
.to_core_file_to_sym_file
= debug_to_core_file_to_sym_file
;
2717 static char targ_desc
[] =
2718 "Names of targets and files being debugged.\n\
2719 Shows the entire stack of targets currently in use (including the exec-file,\n\
2720 core-file, and process, if any), as well as the symbol file name.";
2723 initialize_targets ()
2725 init_dummy_target ();
2726 push_target (&dummy_target
);
2728 add_info ("target", target_info
, targ_desc
);
2729 add_info ("files", target_info
, targ_desc
);
2732 add_set_cmd ("targetdebug", class_maintenance
, var_zinteger
,
2733 (char *) &targetdebug
,
2734 "Set target debugging.\n\
2735 When non-zero, target debugging is enabled.", &setlist
),
2738 if (!STREQ (signals
[TARGET_SIGNAL_LAST
].string
, "TARGET_SIGNAL_MAGIC"))