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, Boston, MA 02111-1307, USA. */
24 #include "gdb_string.h"
38 target_info
PARAMS ((char *, int));
41 cleanup_target
PARAMS ((struct target_ops
*));
44 maybe_kill_then_create_inferior
PARAMS ((char *, char *, char **));
47 default_clone_and_follow_inferior
PARAMS ((int, int *));
50 maybe_kill_then_attach
PARAMS ((char *, int));
53 kill_or_be_killed
PARAMS ((int));
56 default_terminal_info
PARAMS ((char *, int));
59 nosymbol
PARAMS ((char *, CORE_ADDR
*));
62 tcomplain
PARAMS ((void));
65 nomemory
PARAMS ((CORE_ADDR
, char *, int, int, struct target_ops
*));
68 return_zero
PARAMS ((void));
71 return_one
PARAMS ((void));
74 target_ignore
PARAMS ((void));
77 target_command
PARAMS ((char *, int));
79 static struct target_ops
*
80 find_default_run_target
PARAMS ((char *));
83 update_current_target
PARAMS ((void));
85 static void nosupport_runtime
PARAMS ((void));
87 static void normal_target_post_startup_inferior
PARAMS ((int pid
));
89 /* Transfer LEN bytes between target address MEMADDR and GDB address MYADDR.
90 Returns 0 for success, errno code for failure (which includes partial
91 transfers--if you want a more useful response to partial transfers, try
92 target_read_memory_partial). */
95 target_xfer_memory
PARAMS ((CORE_ADDR memaddr
, char *myaddr
, int len
,
96 int write
, asection
*bfd_section
));
98 static void init_dummy_target
PARAMS ((void));
101 debug_to_open
PARAMS ((char *, int));
104 debug_to_close
PARAMS ((int));
107 debug_to_attach
PARAMS ((char *, int));
110 debug_to_detach
PARAMS ((char *, int));
113 debug_to_resume
PARAMS ((int, int, enum target_signal
));
116 debug_to_wait
PARAMS ((int, struct target_waitstatus
*));
119 debug_to_fetch_registers
PARAMS ((int));
122 debug_to_store_registers
PARAMS ((int));
125 debug_to_prepare_to_store
PARAMS ((void));
128 debug_to_xfer_memory
PARAMS ((CORE_ADDR
, char *, int, int, struct target_ops
*));
131 debug_to_files_info
PARAMS ((struct target_ops
*));
134 debug_to_insert_breakpoint
PARAMS ((CORE_ADDR
, char *));
137 debug_to_remove_breakpoint
PARAMS ((CORE_ADDR
, char *));
140 debug_to_terminal_init
PARAMS ((void));
143 debug_to_terminal_inferior
PARAMS ((void));
146 debug_to_terminal_ours_for_output
PARAMS ((void));
149 debug_to_terminal_ours
PARAMS ((void));
152 debug_to_terminal_info
PARAMS ((char *, int));
155 debug_to_kill
PARAMS ((void));
158 debug_to_load
PARAMS ((char *, int));
161 debug_to_lookup_symbol
PARAMS ((char *, CORE_ADDR
*));
164 debug_to_create_inferior
PARAMS ((char *, char *, char **));
167 debug_to_mourn_inferior
PARAMS ((void));
170 debug_to_can_run
PARAMS ((void));
173 debug_to_notice_signals
PARAMS ((int));
176 debug_to_thread_alive
PARAMS ((int));
179 debug_to_stop
PARAMS ((void));
181 static int debug_to_query
PARAMS ((int/*char*/, char *, char *, int *));
183 /* Pointer to array of target architecture structures; the size of the
184 array; the current index into the array; the allocated size of the
186 struct target_ops
**target_structs
;
187 unsigned target_struct_size
;
188 unsigned target_struct_index
;
189 unsigned target_struct_allocsize
;
190 #define DEFAULT_ALLOCSIZE 10
192 /* The initial current target, so that there is always a semi-valid
195 static struct target_ops dummy_target
;
197 /* Top of target stack. */
199 struct target_stack_item
*target_stack
;
201 /* The target structure we are currently using to talk to a process
202 or file or whatever "inferior" we have. */
204 struct target_ops current_target
;
206 /* Command list for target. */
208 static struct cmd_list_element
*targetlist
= NULL
;
210 /* Nonzero if we are debugging an attached outside process
211 rather than an inferior. */
215 /* Non-zero if we want to see trace of target level stuff. */
217 static int targetdebug
= 0;
219 static void setup_target_debug
PARAMS ((void));
221 /* The user just typed 'target' without the name of a target. */
225 target_command (arg
, from_tty
)
229 fputs_filtered ("Argument required (target name). Try `help target'\n",
233 /* Add a possible target architecture to the list. */
237 struct target_ops
*t
;
241 target_struct_allocsize
= DEFAULT_ALLOCSIZE
;
242 target_structs
= (struct target_ops
**) xmalloc
243 (target_struct_allocsize
* sizeof (*target_structs
));
245 if (target_struct_size
>= target_struct_allocsize
)
247 target_struct_allocsize
*= 2;
248 target_structs
= (struct target_ops
**)
249 xrealloc ((char *) target_structs
,
250 target_struct_allocsize
* sizeof (*target_structs
));
252 target_structs
[target_struct_size
++] = t
;
253 /* cleanup_target (t);*/
255 if (targetlist
== NULL
)
256 add_prefix_cmd ("target", class_run
, target_command
,
257 "Connect to a target machine or process.\n\
258 The first argument is the type or protocol of the target machine.\n\
259 Remaining arguments are interpreted by the target protocol. For more\n\
260 information on the arguments for a particular protocol, type\n\
261 `help target ' followed by the protocol name.",
262 &targetlist
, "target ", 0, &cmdlist
);
263 add_cmd (t
->to_shortname
, no_class
, t
->to_open
, t
->to_doc
, &targetlist
);
275 nomemory (memaddr
, myaddr
, len
, write
, t
)
280 struct target_ops
*t
;
282 errno
= EIO
; /* Can't read/write this location */
283 return 0; /* No bytes handled */
289 error ("You can't do that when your target is `%s'",
290 current_target
.to_shortname
);
296 error ("You can't do that without a process to debug.");
301 nosymbol (name
, addrp
)
305 return 1; /* Symbol does not exist in target env */
315 error ("No run-time support for this");
321 default_terminal_info (args
, from_tty
)
325 printf_unfiltered("No saved terminal information.\n");
328 /* This is the default target_create_inferior and target_attach function.
329 If the current target is executing, it asks whether to kill it off.
330 If this function returns without calling error(), it has killed off
331 the target, and the operation should be attempted. */
334 kill_or_be_killed (from_tty
)
337 if (target_has_execution
)
339 printf_unfiltered ("You are already running a program:\n");
340 target_files_info ();
341 if (query ("Kill it? ")) {
343 if (target_has_execution
)
344 error ("Killing the program did not help.");
347 error ("Program not killed.");
354 maybe_kill_then_attach (args
, from_tty
)
358 kill_or_be_killed (from_tty
);
359 target_attach (args
, from_tty
);
363 maybe_kill_then_create_inferior (exec
, args
, env
)
368 kill_or_be_killed (0);
369 target_create_inferior (exec
, args
, env
);
373 default_clone_and_follow_inferior (child_pid
, followed_child
)
377 target_clone_and_follow_inferior (child_pid
, followed_child
);
380 /* Clean up a target struct so it no longer has any zero pointers in it.
381 We default entries, at least to stubs that print error messages. */
385 struct target_ops
*t
;
388 #define de_fault(field, value) \
389 if (!t->field) t->field = value
391 /* FIELD DEFAULT VALUE */
393 de_fault (to_open
, (void (*) PARAMS((char *, int))) tcomplain
);
394 de_fault (to_close
, (void (*) PARAMS((int))) target_ignore
);
395 de_fault (to_attach
, maybe_kill_then_attach
);
396 de_fault (to_post_attach
, (void (*) PARAMS ((int))) target_ignore
);
397 de_fault (to_require_attach
, maybe_kill_then_attach
);
398 de_fault (to_detach
, (void (*) PARAMS((char *, int))) target_ignore
);
399 de_fault (to_require_detach
, (void (*) PARAMS((int, char *, int))) target_ignore
);
400 de_fault (to_resume
, (void (*) PARAMS((int, int, enum target_signal
))) noprocess
);
401 de_fault (to_wait
, (int (*) PARAMS((int, struct target_waitstatus
*))) noprocess
);
402 de_fault (to_post_wait
, (void (*) PARAMS ((int, int))) target_ignore
);
403 de_fault (to_fetch_registers
, (void (*) PARAMS((int))) target_ignore
);
404 de_fault (to_store_registers
, (void (*) PARAMS((int))) noprocess
);
405 de_fault (to_prepare_to_store
, (void (*) PARAMS((void))) noprocess
);
406 de_fault (to_xfer_memory
, (int (*) PARAMS((CORE_ADDR
, char *, int, int, struct target_ops
*))) nomemory
);
407 de_fault (to_files_info
, (void (*) PARAMS((struct target_ops
*))) target_ignore
);
408 de_fault (to_insert_breakpoint
, memory_insert_breakpoint
);
409 de_fault (to_remove_breakpoint
, memory_remove_breakpoint
);
410 de_fault (to_terminal_init
, (void (*) PARAMS((void))) target_ignore
);
411 de_fault (to_terminal_inferior
, (void (*) PARAMS ((void))) target_ignore
);
412 de_fault (to_terminal_ours_for_output
,(void (*) PARAMS ((void))) target_ignore
);
413 de_fault (to_terminal_ours
, (void (*) PARAMS ((void))) target_ignore
);
414 de_fault (to_terminal_info
, default_terminal_info
);
415 de_fault (to_kill
, (void (*) PARAMS((void))) noprocess
);
416 de_fault (to_load
, (void (*) PARAMS((char *, int))) tcomplain
);
417 de_fault (to_lookup_symbol
, (int (*) PARAMS ((char *, CORE_ADDR
*))) nosymbol
);
418 de_fault (to_create_inferior
, maybe_kill_then_create_inferior
);
419 de_fault (to_post_startup_inferior
, (void (*) PARAMS ((int))) target_ignore
);
420 de_fault (to_acknowledge_created_inferior
, (void (*) PARAMS((int))) target_ignore
);
421 de_fault (to_clone_and_follow_inferior
, default_clone_and_follow_inferior
);
422 de_fault (to_post_follow_inferior_by_clone
, (void (*) PARAMS ((void))) target_ignore
);
423 de_fault (to_insert_fork_catchpoint
, (int (*) PARAMS ((int))) tcomplain
);
424 de_fault (to_remove_fork_catchpoint
, (int (*) PARAMS ((int))) tcomplain
);
425 de_fault (to_insert_vfork_catchpoint
, (int (*) PARAMS ((int))) tcomplain
);
426 de_fault (to_remove_vfork_catchpoint
, (int (*) PARAMS ((int))) tcomplain
);
427 de_fault (to_has_forked
, (int (*) PARAMS ((int, int *))) return_zero
);
428 de_fault (to_has_vforked
, (int (*) PARAMS ((int, int *))) return_zero
);
429 de_fault (to_can_follow_vfork_prior_to_exec
, (int (*) PARAMS ((void ))) return_zero
);
430 de_fault (to_post_follow_vfork
, (void (*) PARAMS ((int, int, int, int))) target_ignore
);
431 de_fault (to_insert_exec_catchpoint
, (int (*) PARAMS ((int))) tcomplain
);
432 de_fault (to_remove_exec_catchpoint
, (int (*) PARAMS ((int))) tcomplain
);
433 de_fault (to_has_execd
, (int (*) PARAMS ((int, char **))) return_zero
);
434 de_fault (to_reported_exec_events_per_exec_call
, (int (*) PARAMS ((void))) return_one
);
435 de_fault (to_has_syscall_event
, (int (*) PARAMS ((int, enum target_waitkind
*, int *))) return_zero
);
436 de_fault (to_has_exited
, (int (*) PARAMS ((int, int, int *))) return_zero
);
437 de_fault (to_mourn_inferior
, (void (*) PARAMS ((void))) noprocess
);
438 de_fault (to_can_run
, return_zero
);
439 de_fault (to_notice_signals
, (void (*) PARAMS((int))) target_ignore
);
440 de_fault (to_thread_alive
, (int (*) PARAMS((int))) target_ignore
);
441 de_fault (to_stop
, (void (*) PARAMS((void))) target_ignore
);
442 de_fault (to_query
, (int (*) PARAMS((int/*char*/, char*, char *, int *))) target_ignore
);
443 de_fault (to_enable_exception_callback
, (struct symtab_and_line
* (*) PARAMS((enum exception_event_kind
, int))) nosupport_runtime
);
444 de_fault (to_get_current_exception_event
, (struct exception_event_record
* (*) PARAMS((void))) nosupport_runtime
);
446 de_fault (to_pid_to_exec_file
, (char* (*) PARAMS((int))) return_zero
);
447 de_fault (to_core_file_to_sym_file
, (char* (*) PARAMS ((char *))) return_zero
);
451 /* Go through the target stack from top to bottom, copying over zero entries in
452 current_target. In effect, we are doing class inheritance through the
453 pushed target vectors. */
456 update_current_target ()
458 struct target_stack_item
*item
;
459 struct target_ops
*t
;
461 /* First, reset current_target */
462 memset (¤t_target
, 0, sizeof current_target
);
464 for (item
= target_stack
; item
; item
= item
->next
)
466 t
= item
->target_ops
;
468 #define INHERIT(FIELD, TARGET) \
469 if (!current_target.FIELD) \
470 current_target.FIELD = TARGET->FIELD
472 INHERIT (to_shortname
, t
);
473 INHERIT (to_longname
, t
);
475 INHERIT (to_open
, t
);
476 INHERIT (to_close
, t
);
477 INHERIT (to_attach
, t
);
478 INHERIT (to_post_attach
, t
);
479 INHERIT (to_require_attach
, t
);
480 INHERIT (to_detach
, t
);
481 INHERIT (to_require_detach
, t
);
482 INHERIT (to_resume
, t
);
483 INHERIT (to_wait
, t
);
484 INHERIT (to_post_wait
, t
);
485 INHERIT (to_fetch_registers
, t
);
486 INHERIT (to_store_registers
, t
);
487 INHERIT (to_prepare_to_store
, t
);
488 INHERIT (to_xfer_memory
, t
);
489 INHERIT (to_files_info
, t
);
490 INHERIT (to_insert_breakpoint
, t
);
491 INHERIT (to_remove_breakpoint
, t
);
492 INHERIT (to_terminal_init
, t
);
493 INHERIT (to_terminal_inferior
, t
);
494 INHERIT (to_terminal_ours_for_output
, t
);
495 INHERIT (to_terminal_ours
, t
);
496 INHERIT (to_terminal_info
, t
);
497 INHERIT (to_kill
, t
);
498 INHERIT (to_load
, t
);
499 INHERIT (to_lookup_symbol
, t
);
500 INHERIT (to_create_inferior
, t
);
501 INHERIT (to_post_startup_inferior
, t
);
502 INHERIT (to_acknowledge_created_inferior
, t
);
503 INHERIT (to_clone_and_follow_inferior
, t
);
504 INHERIT (to_post_follow_inferior_by_clone
, t
);
505 INHERIT (to_insert_fork_catchpoint
, t
);
506 INHERIT (to_remove_fork_catchpoint
, t
);
507 INHERIT (to_insert_vfork_catchpoint
, t
);
508 INHERIT (to_remove_vfork_catchpoint
, t
);
509 INHERIT (to_has_forked
, t
);
510 INHERIT (to_has_vforked
, t
);
511 INHERIT (to_can_follow_vfork_prior_to_exec
, t
);
512 INHERIT (to_post_follow_vfork
, t
);
513 INHERIT (to_insert_exec_catchpoint
, t
);
514 INHERIT (to_remove_exec_catchpoint
, t
);
515 INHERIT (to_has_execd
, t
);
516 INHERIT (to_reported_exec_events_per_exec_call
, t
);
517 INHERIT (to_has_syscall_event
, t
);
518 INHERIT (to_has_exited
, t
);
519 INHERIT (to_mourn_inferior
, t
);
520 INHERIT (to_can_run
, t
);
521 INHERIT (to_notice_signals
, t
);
522 INHERIT (to_thread_alive
, t
);
523 INHERIT (to_find_new_threads
, t
);
524 INHERIT (to_stop
, t
);
525 INHERIT (to_query
, t
);
526 INHERIT (to_enable_exception_callback
, t
);
527 INHERIT (to_get_current_exception_event
, t
);
528 INHERIT (to_pid_to_exec_file
, t
);
529 INHERIT (to_core_file_to_sym_file
, t
);
530 INHERIT (to_stratum
, t
);
531 INHERIT (DONT_USE
, t
);
532 INHERIT (to_has_all_memory
, t
);
533 INHERIT (to_has_memory
, t
);
534 INHERIT (to_has_stack
, t
);
535 INHERIT (to_has_registers
, t
);
536 INHERIT (to_has_execution
, t
);
537 INHERIT (to_has_thread_control
, t
);
538 INHERIT (to_has_async_exec
, t
);
539 INHERIT (to_sections
, t
);
540 INHERIT (to_sections_end
, t
);
541 INHERIT (to_magic
, t
);
547 /* Push a new target type into the stack of the existing target accessors,
548 possibly superseding some of the existing accessors.
550 Result is zero if the pushed target ended up on top of the stack,
551 nonzero if at least one target is on top of it.
553 Rather than allow an empty stack, we always have the dummy target at
554 the bottom stratum, so we can call the function vectors without
559 struct target_ops
*t
;
561 struct target_stack_item
*cur
, *prev
, *tmp
;
563 /* Check magic number. If wrong, it probably means someone changed
564 the struct definition, but not all the places that initialize one. */
565 if (t
->to_magic
!= OPS_MAGIC
)
567 fprintf_unfiltered(gdb_stderr
,
568 "Magic number of %s target struct wrong\n",
573 /* Find the proper stratum to install this target in. */
575 for (prev
= NULL
, cur
= target_stack
; cur
; prev
= cur
, cur
= cur
->next
)
577 if ((int)(t
->to_stratum
) >= (int)(cur
->target_ops
->to_stratum
))
581 /* If there's already targets at this stratum, remove them. */
584 while (t
->to_stratum
== cur
->target_ops
->to_stratum
)
586 /* There's already something on this stratum. Close it off. */
587 if (cur
->target_ops
->to_close
)
588 (cur
->target_ops
->to_close
) (0);
590 prev
->next
= cur
->next
; /* Unchain old target_ops */
592 target_stack
= cur
->next
; /* Unchain first on list */
598 /* We have removed all targets in our stratum, now add the new one. */
600 tmp
= (struct target_stack_item
*)
601 xmalloc (sizeof (struct target_stack_item
));
610 update_current_target ();
612 cleanup_target (¤t_target
); /* Fill in the gaps */
615 setup_target_debug ();
620 /* Remove a target_ops vector from the stack, wherever it may be.
621 Return how many times it was removed (0 or 1). */
625 struct target_ops
*t
;
627 struct target_stack_item
*cur
, *prev
;
630 t
->to_close (0); /* Let it clean up */
632 /* Look for the specified target. Note that we assume that a target
633 can only occur once in the target stack. */
635 for (cur
= target_stack
, prev
= NULL
; cur
; prev
= cur
, cur
= cur
->next
)
636 if (cur
->target_ops
== t
)
640 return 0; /* Didn't find target_ops, quit now */
642 /* Unchain the target */
645 target_stack
= cur
->next
;
647 prev
->next
= cur
->next
;
649 free (cur
); /* Release the target_stack_item */
651 update_current_target ();
652 cleanup_target (¤t_target
);
660 (current_target
.to_close
)(0); /* Let it clean up */
661 if (unpush_target (target_stack
->target_ops
) == 1)
664 fprintf_unfiltered(gdb_stderr
,
665 "pop_target couldn't find target %s\n",
666 current_target
.to_shortname
);
671 #define MIN(A, B) (((A) <= (B)) ? (A) : (B))
673 /* target_read_string -- read a null terminated string, up to LEN bytes,
674 from MEMADDR in target. Set *ERRNOP to the errno code, or 0 if successful.
675 Set *STRING to a pointer to malloc'd memory containing the data; the caller
676 is responsible for freeing it. Return the number of bytes successfully
680 target_read_string (memaddr
, string
, len
, errnop
)
686 int tlen
, origlen
, offset
, i
;
690 int buffer_allocated
;
692 unsigned int nbytes_read
= 0;
694 /* Small for testing. */
695 buffer_allocated
= 4;
696 buffer
= xmalloc (buffer_allocated
);
703 tlen
= MIN (len
, 4 - (memaddr
& 3));
704 offset
= memaddr
& 3;
706 errcode
= target_xfer_memory (memaddr
& ~3, buf
, 4, 0, NULL
);
709 /* The transfer request might have crossed the boundary to an
710 unallocated region of memory. Retry the transfer, requesting
714 errcode
= target_xfer_memory (memaddr
, buf
, 1, 0, NULL
);
719 if (bufptr
- buffer
+ tlen
> buffer_allocated
)
722 bytes
= bufptr
- buffer
;
723 buffer_allocated
*= 2;
724 buffer
= xrealloc (buffer
, buffer_allocated
);
725 bufptr
= buffer
+ bytes
;
728 for (i
= 0; i
< tlen
; i
++)
730 *bufptr
++ = buf
[i
+ offset
];
731 if (buf
[i
+ offset
] == '\000')
733 nbytes_read
+= i
+ 1;
750 /* Read LEN bytes of target memory at address MEMADDR, placing the results in
751 GDB's memory at MYADDR. Returns either 0 for success or an errno value
754 If an error occurs, no guarantee is made about the contents of the data at
755 MYADDR. In particular, the caller should not depend upon partial reads
756 filling the buffer with good data. There is no way for the caller to know
757 how much good data might have been transfered anyway. Callers that can
758 deal with partial reads should call target_read_memory_partial. */
761 target_read_memory (memaddr
, myaddr
, len
)
766 return target_xfer_memory (memaddr
, myaddr
, len
, 0, NULL
);
770 target_read_memory_section (memaddr
, myaddr
, len
, bfd_section
)
774 asection
*bfd_section
;
776 return target_xfer_memory (memaddr
, myaddr
, len
, 0, bfd_section
);
779 /* Read LEN bytes of target memory at address MEMADDR, placing the results
780 in GDB's memory at MYADDR. Returns a count of the bytes actually read,
781 and optionally an errno value in the location pointed to by ERRNOPTR
782 if ERRNOPTR is non-null. */
785 target_read_memory_partial (memaddr
, myaddr
, len
, errnoptr
)
791 int nread
; /* Number of bytes actually read. */
792 int errcode
; /* Error from last read. */
794 /* First try a complete read. */
795 errcode
= target_xfer_memory (memaddr
, myaddr
, len
, 0, NULL
);
803 /* Loop, reading one byte at a time until we get as much as we can. */
804 for (errcode
= 0, nread
= 0; len
> 0 && errcode
== 0; nread
++, len
--)
806 errcode
= target_xfer_memory (memaddr
++, myaddr
++, 1, 0, NULL
);
808 /* If an error, the last read was unsuccessful, so adjust count. */
814 if (errnoptr
!= NULL
)
822 target_write_memory (memaddr
, myaddr
, len
)
827 return target_xfer_memory (memaddr
, myaddr
, len
, 1, NULL
);
830 /* This variable is used to pass section information down to targets. This
831 *should* be done by adding an argument to the target_xfer_memory function
832 of all the targets, but I didn't feel like changing 50+ files. */
834 asection
*target_memory_bfd_section
= NULL
;
836 /* Move memory to or from the targets. Iterate until all of it has
837 been moved, if necessary. The top target gets priority; anything
838 it doesn't want, is offered to the next one down, etc. Note the
839 business with curlen: if an early target says "no, but I have a
840 boundary overlapping this xfer" then we shorten what we offer to
841 the subsequent targets so the early guy will get a chance at the
842 tail before the subsequent ones do.
844 Result is 0 or errno value. */
847 target_xfer_memory (memaddr
, myaddr
, len
, write
, bfd_section
)
852 asection
*bfd_section
;
856 struct target_ops
*t
;
857 struct target_stack_item
*item
;
859 /* Zero length requests are ok and require no work. */
863 target_memory_bfd_section
= bfd_section
;
865 /* to_xfer_memory is not guaranteed to set errno, even when it returns
869 /* The quick case is that the top target does it all. */
870 res
= current_target
.to_xfer_memory
871 (memaddr
, myaddr
, len
, write
, ¤t_target
);
877 /* If res <= 0 then we call it again in the loop. Ah well. */
881 curlen
= len
; /* Want to do it all */
882 for (item
= target_stack
; item
; item
= item
->next
)
884 t
= item
->target_ops
;
885 if (!t
->to_has_memory
)
888 res
= t
->to_xfer_memory (memaddr
, myaddr
, curlen
, write
, t
);
890 break; /* Handled all or part of xfer */
891 if (t
->to_has_all_memory
)
897 /* If this address is for nonexistent memory,
898 read zeros if reading, or do nothing if writing. Return error. */
900 memset (myaddr
, 0, len
);
911 return 0; /* We managed to cover it all somehow. */
917 target_info (args
, from_tty
)
921 struct target_ops
*t
;
922 struct target_stack_item
*item
;
925 if (symfile_objfile
!= NULL
)
926 printf_unfiltered ("Symbols from \"%s\".\n", symfile_objfile
->name
);
928 #ifdef FILES_INFO_HOOK
929 if (FILES_INFO_HOOK ())
933 for (item
= target_stack
; item
; item
= item
->next
)
935 t
= item
->target_ops
;
937 if (!t
->to_has_memory
)
940 if ((int)(t
->to_stratum
) <= (int)dummy_stratum
)
943 printf_unfiltered("\tWhile running this, GDB does not access memory from...\n");
944 printf_unfiltered("%s:\n", t
->to_longname
);
945 (t
->to_files_info
)(t
);
946 has_all_mem
= t
->to_has_all_memory
;
950 /* This is to be called by the open routine before it does
954 target_preopen (from_tty
)
959 if (target_has_execution
)
961 if (query ("A program is being debugged already. Kill it? "))
964 error ("Program not killed.");
967 /* Calling target_kill may remove the target from the stack. But if
968 it doesn't (which seems like a win for UDI), remove it now. */
970 if (target_has_execution
)
974 /* Detach a target after doing deferred register stores. */
977 target_detach (args
, from_tty
)
981 /* Handle any optimized stores to the inferior. */
982 #ifdef DO_DEFERRED_STORES
985 (current_target
.to_detach
) (args
, from_tty
);
989 target_link (modname
, t_reloc
)
993 if (STREQ(current_target
.to_shortname
, "rombug"))
995 (current_target
.to_lookup_symbol
) (modname
, t_reloc
);
997 error("Unable to link to %s and get relocation in rombug", modname
);
1000 *t_reloc
= (CORE_ADDR
)-1;
1003 /* Look through the list of possible targets for a target that can
1004 execute a run or attach command without any other data. This is
1005 used to locate the default process stratum.
1007 Result is always valid (error() is called for errors). */
1009 static struct target_ops
*
1010 find_default_run_target (do_mesg
)
1013 struct target_ops
**t
;
1014 struct target_ops
*runable
= NULL
;
1019 for (t
= target_structs
; t
< target_structs
+ target_struct_size
;
1022 if ((*t
)->to_can_run
&& target_can_run(*t
))
1030 error ("Don't know how to %s. Try \"help target\".", do_mesg
);
1036 find_default_attach (args
, from_tty
)
1040 struct target_ops
*t
;
1042 t
= find_default_run_target("attach");
1043 (t
->to_attach
) (args
, from_tty
);
1048 find_default_require_attach (args
, from_tty
)
1052 struct target_ops
*t
;
1054 t
= find_default_run_target("require_attach");
1055 (t
->to_require_attach
) (args
, from_tty
);
1060 find_default_require_detach (pid
, args
, from_tty
)
1065 struct target_ops
*t
;
1067 t
= find_default_run_target("require_detach");
1068 (t
->to_require_detach
) (pid
, args
, from_tty
);
1073 find_default_create_inferior (exec_file
, allargs
, env
)
1078 struct target_ops
*t
;
1080 t
= find_default_run_target("run");
1081 (t
->to_create_inferior
) (exec_file
, allargs
, env
);
1086 find_default_clone_and_follow_inferior (child_pid
, followed_child
)
1088 int *followed_child
;
1090 struct target_ops
*t
;
1092 t
= find_default_run_target("run");
1093 (t
->to_clone_and_follow_inferior
) (child_pid
, followed_child
);
1109 /* Find a single runnable target in the stack and return it. If for
1110 some reason there is more than one, return NULL. */
1115 struct target_ops
**t
;
1116 struct target_ops
*runable
= NULL
;
1121 for (t
= target_structs
; t
< target_structs
+ target_struct_size
; ++t
)
1123 if ((*t
)->to_can_run
&& target_can_run(*t
))
1130 return (count
== 1 ? runable
: NULL
);
1136 struct target_ops
**t
;
1137 struct target_ops
*runable
= NULL
;
1142 for (t
= target_structs
; t
< target_structs
+ target_struct_size
;
1145 if ((*t
)->to_stratum
== core_stratum
)
1152 return(count
== 1 ? runable
: NULL
);
1155 /* The inferior process has died. Long live the inferior! */
1158 generic_mourn_inferior ()
1160 extern int show_breakpoint_hit_counts
;
1164 breakpoint_init_inferior (inf_exited
);
1165 registers_changed ();
1167 #ifdef CLEAR_DEFERRED_STORES
1168 /* Delete any pending stores to the inferior... */
1169 CLEAR_DEFERRED_STORES
;
1172 reopen_exec_file ();
1173 reinit_frame_cache ();
1175 /* It is confusing to the user for ignore counts to stick around
1176 from previous runs of the inferior. So clear them. */
1177 /* However, it is more confusing for the ignore counts to disappear when
1178 using hit counts. So don't clear them if we're counting hits. */
1179 if (!show_breakpoint_hit_counts
)
1180 breakpoint_clear_ignore_counts ();
1183 /* This table must match in order and size the signals in enum target_signal
1191 {"SIGHUP", "Hangup"},
1192 {"SIGINT", "Interrupt"},
1193 {"SIGQUIT", "Quit"},
1194 {"SIGILL", "Illegal instruction"},
1195 {"SIGTRAP", "Trace/breakpoint trap"},
1196 {"SIGABRT", "Aborted"},
1197 {"SIGEMT", "Emulation trap"},
1198 {"SIGFPE", "Arithmetic exception"},
1199 {"SIGKILL", "Killed"},
1200 {"SIGBUS", "Bus error"},
1201 {"SIGSEGV", "Segmentation fault"},
1202 {"SIGSYS", "Bad system call"},
1203 {"SIGPIPE", "Broken pipe"},
1204 {"SIGALRM", "Alarm clock"},
1205 {"SIGTERM", "Terminated"},
1206 {"SIGURG", "Urgent I/O condition"},
1207 {"SIGSTOP", "Stopped (signal)"},
1208 {"SIGTSTP", "Stopped (user)"},
1209 {"SIGCONT", "Continued"},
1210 {"SIGCHLD", "Child status changed"},
1211 {"SIGTTIN", "Stopped (tty input)"},
1212 {"SIGTTOU", "Stopped (tty output)"},
1213 {"SIGIO", "I/O possible"},
1214 {"SIGXCPU", "CPU time limit exceeded"},
1215 {"SIGXFSZ", "File size limit exceeded"},
1216 {"SIGVTALRM", "Virtual timer expired"},
1217 {"SIGPROF", "Profiling timer expired"},
1218 {"SIGWINCH", "Window size changed"},
1219 {"SIGLOST", "Resource lost"},
1220 {"SIGUSR1", "User defined signal 1"},
1221 {"SIGUSR2", "User defined signal 2"},
1222 {"SIGPWR", "Power fail/restart"},
1223 {"SIGPOLL", "Pollable event occurred"},
1224 {"SIGWIND", "SIGWIND"},
1225 {"SIGPHONE", "SIGPHONE"},
1226 {"SIGWAITING", "Process's LWPs are blocked"},
1227 {"SIGLWP", "Signal LWP"},
1228 {"SIGDANGER", "Swap space dangerously low"},
1229 {"SIGGRANT", "Monitor mode granted"},
1230 {"SIGRETRACT", "Need to relinquish monitor mode"},
1231 {"SIGMSG", "Monitor mode data available"},
1232 {"SIGSOUND", "Sound completed"},
1233 {"SIGSAK", "Secure attention"},
1234 {"SIGPRIO", "SIGPRIO"},
1235 {"SIG33", "Real-time event 33"},
1236 {"SIG34", "Real-time event 34"},
1237 {"SIG35", "Real-time event 35"},
1238 {"SIG36", "Real-time event 36"},
1239 {"SIG37", "Real-time event 37"},
1240 {"SIG38", "Real-time event 38"},
1241 {"SIG39", "Real-time event 39"},
1242 {"SIG40", "Real-time event 40"},
1243 {"SIG41", "Real-time event 41"},
1244 {"SIG42", "Real-time event 42"},
1245 {"SIG43", "Real-time event 43"},
1246 {"SIG44", "Real-time event 44"},
1247 {"SIG45", "Real-time event 45"},
1248 {"SIG46", "Real-time event 46"},
1249 {"SIG47", "Real-time event 47"},
1250 {"SIG48", "Real-time event 48"},
1251 {"SIG49", "Real-time event 49"},
1252 {"SIG50", "Real-time event 50"},
1253 {"SIG51", "Real-time event 51"},
1254 {"SIG52", "Real-time event 52"},
1255 {"SIG53", "Real-time event 53"},
1256 {"SIG54", "Real-time event 54"},
1257 {"SIG55", "Real-time event 55"},
1258 {"SIG56", "Real-time event 56"},
1259 {"SIG57", "Real-time event 57"},
1260 {"SIG58", "Real-time event 58"},
1261 {"SIG59", "Real-time event 59"},
1262 {"SIG60", "Real-time event 60"},
1263 {"SIG61", "Real-time event 61"},
1264 {"SIG62", "Real-time event 62"},
1265 {"SIG63", "Real-time event 63"},
1266 {"SIGCANCEL", "LWP internal signal"},
1268 #if defined(MACH) || defined(__MACH__)
1269 /* Mach exceptions */
1270 {"EXC_BAD_ACCESS", "Could not access memory"},
1271 {"EXC_BAD_INSTRUCTION", "Illegal instruction/operand"},
1272 {"EXC_ARITHMETIC", "Arithmetic exception"},
1273 {"EXC_EMULATION", "Emulation instruction"},
1274 {"EXC_SOFTWARE", "Software generated exception"},
1275 {"EXC_BREAKPOINT", "Breakpoint"},
1277 {"SIGINFO", "Information request"},
1279 {NULL
, "Unknown signal"},
1280 {NULL
, "Internal error: printing TARGET_SIGNAL_DEFAULT"},
1282 /* Last entry, used to check whether the table is the right size. */
1283 {NULL
, "TARGET_SIGNAL_MAGIC"}
1286 /* Return the string for a signal. */
1288 target_signal_to_string (sig
)
1289 enum target_signal sig
;
1291 if ((sig
>= TARGET_SIGNAL_FIRST
) && (sig
<= TARGET_SIGNAL_LAST
))
1292 return signals
[sig
].string
;
1294 return signals
[TARGET_SIGNAL_UNKNOWN
].string
;
1297 /* Return the name for a signal. */
1299 target_signal_to_name (sig
)
1300 enum target_signal sig
;
1302 if (sig
== TARGET_SIGNAL_UNKNOWN
)
1303 /* I think the code which prints this will always print it along with
1304 the string, so no need to be verbose. */
1306 return signals
[sig
].name
;
1309 /* Given a name, return its signal. */
1311 target_signal_from_name (name
)
1314 enum target_signal sig
;
1316 /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
1317 for TARGET_SIGNAL_SIGCHLD. SIGIOT, on the other hand, is more
1318 questionable; seems like by now people should call it SIGABRT
1321 /* This ugly cast brought to you by the native VAX compiler. */
1322 for (sig
= TARGET_SIGNAL_HUP
;
1323 signals
[sig
].name
!= NULL
;
1324 sig
= (enum target_signal
)((int)sig
+ 1))
1325 if (STREQ (name
, signals
[sig
].name
))
1327 return TARGET_SIGNAL_UNKNOWN
;
1330 /* The following functions are to help certain targets deal
1331 with the signal/waitstatus stuff. They could just as well be in
1332 a file called native-utils.c or unixwaitstatus-utils.c or whatever. */
1334 /* Convert host signal to our signals. */
1336 target_signal_from_host (hostsig
)
1339 /* A switch statement would make sense but would require special kludges
1340 to deal with the cases where more than one signal has the same number. */
1342 if (hostsig
== 0) return TARGET_SIGNAL_0
;
1344 #if defined (SIGHUP)
1345 if (hostsig
== SIGHUP
) return TARGET_SIGNAL_HUP
;
1347 #if defined (SIGINT)
1348 if (hostsig
== SIGINT
) return TARGET_SIGNAL_INT
;
1350 #if defined (SIGQUIT)
1351 if (hostsig
== SIGQUIT
) return TARGET_SIGNAL_QUIT
;
1353 #if defined (SIGILL)
1354 if (hostsig
== SIGILL
) return TARGET_SIGNAL_ILL
;
1356 #if defined (SIGTRAP)
1357 if (hostsig
== SIGTRAP
) return TARGET_SIGNAL_TRAP
;
1359 #if defined (SIGABRT)
1360 if (hostsig
== SIGABRT
) return TARGET_SIGNAL_ABRT
;
1362 #if defined (SIGEMT)
1363 if (hostsig
== SIGEMT
) return TARGET_SIGNAL_EMT
;
1365 #if defined (SIGFPE)
1366 if (hostsig
== SIGFPE
) return TARGET_SIGNAL_FPE
;
1368 #if defined (SIGKILL)
1369 if (hostsig
== SIGKILL
) return TARGET_SIGNAL_KILL
;
1371 #if defined (SIGBUS)
1372 if (hostsig
== SIGBUS
) return TARGET_SIGNAL_BUS
;
1374 #if defined (SIGSEGV)
1375 if (hostsig
== SIGSEGV
) return TARGET_SIGNAL_SEGV
;
1377 #if defined (SIGSYS)
1378 if (hostsig
== SIGSYS
) return TARGET_SIGNAL_SYS
;
1380 #if defined (SIGPIPE)
1381 if (hostsig
== SIGPIPE
) return TARGET_SIGNAL_PIPE
;
1383 #if defined (SIGALRM)
1384 if (hostsig
== SIGALRM
) return TARGET_SIGNAL_ALRM
;
1386 #if defined (SIGTERM)
1387 if (hostsig
== SIGTERM
) return TARGET_SIGNAL_TERM
;
1389 #if defined (SIGUSR1)
1390 if (hostsig
== SIGUSR1
) return TARGET_SIGNAL_USR1
;
1392 #if defined (SIGUSR2)
1393 if (hostsig
== SIGUSR2
) return TARGET_SIGNAL_USR2
;
1395 #if defined (SIGCLD)
1396 if (hostsig
== SIGCLD
) return TARGET_SIGNAL_CHLD
;
1398 #if defined (SIGCHLD)
1399 if (hostsig
== SIGCHLD
) return TARGET_SIGNAL_CHLD
;
1401 #if defined (SIGPWR)
1402 if (hostsig
== SIGPWR
) return TARGET_SIGNAL_PWR
;
1404 #if defined (SIGWINCH)
1405 if (hostsig
== SIGWINCH
) return TARGET_SIGNAL_WINCH
;
1407 #if defined (SIGURG)
1408 if (hostsig
== SIGURG
) return TARGET_SIGNAL_URG
;
1411 if (hostsig
== SIGIO
) return TARGET_SIGNAL_IO
;
1413 #if defined (SIGPOLL)
1414 if (hostsig
== SIGPOLL
) return TARGET_SIGNAL_POLL
;
1416 #if defined (SIGSTOP)
1417 if (hostsig
== SIGSTOP
) return TARGET_SIGNAL_STOP
;
1419 #if defined (SIGTSTP)
1420 if (hostsig
== SIGTSTP
) return TARGET_SIGNAL_TSTP
;
1422 #if defined (SIGCONT)
1423 if (hostsig
== SIGCONT
) return TARGET_SIGNAL_CONT
;
1425 #if defined (SIGTTIN)
1426 if (hostsig
== SIGTTIN
) return TARGET_SIGNAL_TTIN
;
1428 #if defined (SIGTTOU)
1429 if (hostsig
== SIGTTOU
) return TARGET_SIGNAL_TTOU
;
1431 #if defined (SIGVTALRM)
1432 if (hostsig
== SIGVTALRM
) return TARGET_SIGNAL_VTALRM
;
1434 #if defined (SIGPROF)
1435 if (hostsig
== SIGPROF
) return TARGET_SIGNAL_PROF
;
1437 #if defined (SIGXCPU)
1438 if (hostsig
== SIGXCPU
) return TARGET_SIGNAL_XCPU
;
1440 #if defined (SIGXFSZ)
1441 if (hostsig
== SIGXFSZ
) return TARGET_SIGNAL_XFSZ
;
1443 #if defined (SIGWIND)
1444 if (hostsig
== SIGWIND
) return TARGET_SIGNAL_WIND
;
1446 #if defined (SIGPHONE)
1447 if (hostsig
== SIGPHONE
) return TARGET_SIGNAL_PHONE
;
1449 #if defined (SIGLOST)
1450 if (hostsig
== SIGLOST
) return TARGET_SIGNAL_LOST
;
1452 #if defined (SIGWAITING)
1453 if (hostsig
== SIGWAITING
) return TARGET_SIGNAL_WAITING
;
1455 #if defined (SIGCANCEL)
1456 if (hostsig
== SIGCANCEL
) return TARGET_SIGNAL_CANCEL
;
1458 #if defined (SIGLWP)
1459 if (hostsig
== SIGLWP
) return TARGET_SIGNAL_LWP
;
1461 #if defined (SIGDANGER)
1462 if (hostsig
== SIGDANGER
) return TARGET_SIGNAL_DANGER
;
1464 #if defined (SIGGRANT)
1465 if (hostsig
== SIGGRANT
) return TARGET_SIGNAL_GRANT
;
1467 #if defined (SIGRETRACT)
1468 if (hostsig
== SIGRETRACT
) return TARGET_SIGNAL_RETRACT
;
1470 #if defined (SIGMSG)
1471 if (hostsig
== SIGMSG
) return TARGET_SIGNAL_MSG
;
1473 #if defined (SIGSOUND)
1474 if (hostsig
== SIGSOUND
) return TARGET_SIGNAL_SOUND
;
1476 #if defined (SIGSAK)
1477 if (hostsig
== SIGSAK
) return TARGET_SIGNAL_SAK
;
1479 #if defined (SIGPRIO)
1480 if (hostsig
== SIGPRIO
) return TARGET_SIGNAL_PRIO
;
1483 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1484 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1485 if (hostsig
== _NSIG
+ EXC_BAD_ACCESS
) return TARGET_EXC_BAD_ACCESS
;
1487 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
1488 if (hostsig
== _NSIG
+ EXC_BAD_INSTRUCTION
) return TARGET_EXC_BAD_INSTRUCTION
;
1490 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
1491 if (hostsig
== _NSIG
+ EXC_ARITHMETIC
) return TARGET_EXC_ARITHMETIC
;
1493 #if defined (EXC_EMULATION) && defined (_NSIG)
1494 if (hostsig
== _NSIG
+ EXC_EMULATION
) return TARGET_EXC_EMULATION
;
1496 #if defined (EXC_SOFTWARE) && defined (_NSIG)
1497 if (hostsig
== _NSIG
+ EXC_SOFTWARE
) return TARGET_EXC_SOFTWARE
;
1499 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
1500 if (hostsig
== _NSIG
+ EXC_BREAKPOINT
) return TARGET_EXC_BREAKPOINT
;
1503 #if defined (SIGINFO)
1504 if (hostsig
== SIGINFO
) return TARGET_SIGNAL_INFO
;
1507 #if defined (REALTIME_LO)
1508 if (hostsig
>= REALTIME_LO
&& hostsig
< REALTIME_HI
)
1509 return (enum target_signal
)
1510 (hostsig
- 33 + (int) TARGET_SIGNAL_REALTIME_33
);
1512 return TARGET_SIGNAL_UNKNOWN
;
1516 target_signal_to_host (oursig
)
1517 enum target_signal oursig
;
1521 case TARGET_SIGNAL_0
: return 0;
1523 #if defined (SIGHUP)
1524 case TARGET_SIGNAL_HUP
: return SIGHUP
;
1526 #if defined (SIGINT)
1527 case TARGET_SIGNAL_INT
: return SIGINT
;
1529 #if defined (SIGQUIT)
1530 case TARGET_SIGNAL_QUIT
: return SIGQUIT
;
1532 #if defined (SIGILL)
1533 case TARGET_SIGNAL_ILL
: return SIGILL
;
1535 #if defined (SIGTRAP)
1536 case TARGET_SIGNAL_TRAP
: return SIGTRAP
;
1538 #if defined (SIGABRT)
1539 case TARGET_SIGNAL_ABRT
: return SIGABRT
;
1541 #if defined (SIGEMT)
1542 case TARGET_SIGNAL_EMT
: return SIGEMT
;
1544 #if defined (SIGFPE)
1545 case TARGET_SIGNAL_FPE
: return SIGFPE
;
1547 #if defined (SIGKILL)
1548 case TARGET_SIGNAL_KILL
: return SIGKILL
;
1550 #if defined (SIGBUS)
1551 case TARGET_SIGNAL_BUS
: return SIGBUS
;
1553 #if defined (SIGSEGV)
1554 case TARGET_SIGNAL_SEGV
: return SIGSEGV
;
1556 #if defined (SIGSYS)
1557 case TARGET_SIGNAL_SYS
: return SIGSYS
;
1559 #if defined (SIGPIPE)
1560 case TARGET_SIGNAL_PIPE
: return SIGPIPE
;
1562 #if defined (SIGALRM)
1563 case TARGET_SIGNAL_ALRM
: return SIGALRM
;
1565 #if defined (SIGTERM)
1566 case TARGET_SIGNAL_TERM
: return SIGTERM
;
1568 #if defined (SIGUSR1)
1569 case TARGET_SIGNAL_USR1
: return SIGUSR1
;
1571 #if defined (SIGUSR2)
1572 case TARGET_SIGNAL_USR2
: return SIGUSR2
;
1574 #if defined (SIGCHLD) || defined (SIGCLD)
1575 case TARGET_SIGNAL_CHLD
:
1576 #if defined (SIGCHLD)
1581 #endif /* SIGCLD or SIGCHLD */
1582 #if defined (SIGPWR)
1583 case TARGET_SIGNAL_PWR
: return SIGPWR
;
1585 #if defined (SIGWINCH)
1586 case TARGET_SIGNAL_WINCH
: return SIGWINCH
;
1588 #if defined (SIGURG)
1589 case TARGET_SIGNAL_URG
: return SIGURG
;
1592 case TARGET_SIGNAL_IO
: return SIGIO
;
1594 #if defined (SIGPOLL)
1595 case TARGET_SIGNAL_POLL
: return SIGPOLL
;
1597 #if defined (SIGSTOP)
1598 case TARGET_SIGNAL_STOP
: return SIGSTOP
;
1600 #if defined (SIGTSTP)
1601 case TARGET_SIGNAL_TSTP
: return SIGTSTP
;
1603 #if defined (SIGCONT)
1604 case TARGET_SIGNAL_CONT
: return SIGCONT
;
1606 #if defined (SIGTTIN)
1607 case TARGET_SIGNAL_TTIN
: return SIGTTIN
;
1609 #if defined (SIGTTOU)
1610 case TARGET_SIGNAL_TTOU
: return SIGTTOU
;
1612 #if defined (SIGVTALRM)
1613 case TARGET_SIGNAL_VTALRM
: return SIGVTALRM
;
1615 #if defined (SIGPROF)
1616 case TARGET_SIGNAL_PROF
: return SIGPROF
;
1618 #if defined (SIGXCPU)
1619 case TARGET_SIGNAL_XCPU
: return SIGXCPU
;
1621 #if defined (SIGXFSZ)
1622 case TARGET_SIGNAL_XFSZ
: return SIGXFSZ
;
1624 #if defined (SIGWIND)
1625 case TARGET_SIGNAL_WIND
: return SIGWIND
;
1627 #if defined (SIGPHONE)
1628 case TARGET_SIGNAL_PHONE
: return SIGPHONE
;
1630 #if defined (SIGLOST)
1631 case TARGET_SIGNAL_LOST
: return SIGLOST
;
1633 #if defined (SIGWAITING)
1634 case TARGET_SIGNAL_WAITING
: return SIGWAITING
;
1636 #if defined (SIGCANCEL)
1637 case TARGET_SIGNAL_CANCEL
: return SIGCANCEL
;
1639 #if defined (SIGLWP)
1640 case TARGET_SIGNAL_LWP
: return SIGLWP
;
1642 #if defined (SIGDANGER)
1643 case TARGET_SIGNAL_DANGER
: return SIGDANGER
;
1645 #if defined (SIGGRANT)
1646 case TARGET_SIGNAL_GRANT
: return SIGGRANT
;
1648 #if defined (SIGRETRACT)
1649 case TARGET_SIGNAL_RETRACT
: return SIGRETRACT
;
1651 #if defined (SIGMSG)
1652 case TARGET_SIGNAL_MSG
: return SIGMSG
;
1654 #if defined (SIGSOUND)
1655 case TARGET_SIGNAL_SOUND
: return SIGSOUND
;
1657 #if defined (SIGSAK)
1658 case TARGET_SIGNAL_SAK
: return SIGSAK
;
1660 #if defined (SIGPRIO)
1661 case TARGET_SIGNAL_PRIO
: return SIGPRIO
;
1664 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1665 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1666 case TARGET_EXC_BAD_ACCESS
: return _NSIG
+ EXC_BAD_ACCESS
;
1668 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
1669 case TARGET_EXC_BAD_INSTRUCTION
: return _NSIG
+ EXC_BAD_INSTRUCTION
;
1671 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
1672 case TARGET_EXC_ARITHMETIC
: return _NSIG
+ EXC_ARITHMETIC
;
1674 #if defined (EXC_EMULATION) && defined (_NSIG)
1675 case TARGET_EXC_EMULATION
: return _NSIG
+ EXC_EMULATION
;
1677 #if defined (EXC_SOFTWARE) && defined (_NSIG)
1678 case TARGET_EXC_SOFTWARE
: return _NSIG
+ EXC_SOFTWARE
;
1680 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
1681 case TARGET_EXC_BREAKPOINT
: return _NSIG
+ EXC_BREAKPOINT
;
1684 #if defined (SIGINFO)
1685 case TARGET_SIGNAL_INFO
: return SIGINFO
;
1689 #if defined (REALTIME_LO)
1690 if (oursig
>= TARGET_SIGNAL_REALTIME_33
1691 && oursig
<= TARGET_SIGNAL_REALTIME_63
)
1694 (int)oursig
- (int)TARGET_SIGNAL_REALTIME_33
+ REALTIME_LO
;
1695 if (retsig
< REALTIME_HI
)
1699 /* The user might be trying to do "signal SIGSAK" where this system
1700 doesn't have SIGSAK. */
1701 warning ("Signal %s does not exist on this system.\n",
1702 target_signal_to_name (oursig
));
1707 /* Helper function for child_wait and the Lynx derivatives of child_wait.
1708 HOSTSTATUS is the waitstatus from wait() or the equivalent; store our
1709 translation of that in OURSTATUS. */
1711 store_waitstatus (ourstatus
, hoststatus
)
1712 struct target_waitstatus
*ourstatus
;
1715 #ifdef CHILD_SPECIAL_WAITSTATUS
1716 /* CHILD_SPECIAL_WAITSTATUS should return nonzero and set *OURSTATUS
1717 if it wants to deal with hoststatus. */
1718 if (CHILD_SPECIAL_WAITSTATUS (ourstatus
, hoststatus
))
1722 if (WIFEXITED (hoststatus
))
1724 ourstatus
->kind
= TARGET_WAITKIND_EXITED
;
1725 ourstatus
->value
.integer
= WEXITSTATUS (hoststatus
);
1727 else if (!WIFSTOPPED (hoststatus
))
1729 ourstatus
->kind
= TARGET_WAITKIND_SIGNALLED
;
1730 ourstatus
->value
.sig
= target_signal_from_host (WTERMSIG (hoststatus
));
1734 ourstatus
->kind
= TARGET_WAITKIND_STOPPED
;
1735 ourstatus
->value
.sig
= target_signal_from_host (WSTOPSIG (hoststatus
));
1739 /* In some circumstances we allow a command to specify a numeric
1740 signal. The idea is to keep these circumstances limited so that
1741 users (and scripts) develop portable habits. For comparison,
1742 POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a
1743 numeric signal at all is obscelescent. We are slightly more
1744 lenient and allow 1-15 which should match host signal numbers on
1745 most systems. Use of symbolic signal names is strongly encouraged. */
1748 target_signal_from_command (num
)
1751 if (num
>= 1 && num
<= 15)
1752 return (enum target_signal
)num
;
1753 error ("Only signals 1-15 are valid as numeric signals.\n\
1754 Use \"info signals\" for a list of symbolic signals.");
1757 /* Returns zero to leave the inferior alone, one to interrupt it. */
1758 int (*target_activity_function
) PARAMS ((void));
1759 int target_activity_fd
;
1761 /* Convert a normal process ID to a string. Returns the string in a static
1765 normal_pid_to_str (pid
)
1768 static char buf
[30];
1770 if (STREQ (current_target
.to_shortname
, "remote"))
1771 sprintf (buf
, "thread %d\0", pid
);
1773 sprintf (buf
, "process %d\0", pid
);
1778 /* Some targets (such as ttrace-based HPUX) don't allow us to request
1779 notification of inferior events such as fork and vork immediately
1780 after the inferior is created. (This because of how gdb gets an
1781 inferior created via invoking a shell to do it. In such a scenario,
1782 if the shell init file has commands in it, the shell will fork and
1783 exec for each of those commands, and we will see each such fork
1786 This function is used by all targets that allow us to request
1787 notification of forks, etc at inferior creation time; e.g., in
1788 target_acknowledge_forked_child.
1791 normal_target_post_startup_inferior (pid
)
1794 /* This space intentionally left blank. */
1797 /* Set up the handful of non-empty slots needed by the dummy target
1801 init_dummy_target ()
1803 dummy_target
.to_shortname
= "None";
1804 dummy_target
.to_longname
= "None";
1805 dummy_target
.to_doc
= "";
1806 dummy_target
.to_attach
= find_default_attach
;
1807 dummy_target
.to_require_attach
= find_default_require_attach
;
1808 dummy_target
.to_require_detach
= find_default_require_detach
;
1809 dummy_target
.to_create_inferior
= find_default_create_inferior
;
1810 dummy_target
.to_clone_and_follow_inferior
= find_default_clone_and_follow_inferior
;
1811 dummy_target
.to_stratum
= dummy_stratum
;
1812 dummy_target
.to_magic
= OPS_MAGIC
;
1816 static struct target_ops debug_target
;
1819 debug_to_open (args
, from_tty
)
1823 debug_target
.to_open (args
, from_tty
);
1825 fprintf_unfiltered (gdb_stderr
, "target_open (%s, %d)\n", args
, from_tty
);
1829 debug_to_close (quitting
)
1832 debug_target
.to_close (quitting
);
1834 fprintf_unfiltered (gdb_stderr
, "target_close (%d)\n", quitting
);
1838 debug_to_attach (args
, from_tty
)
1842 debug_target
.to_attach (args
, from_tty
);
1844 fprintf_unfiltered (gdb_stderr
, "target_attach (%s, %d)\n", args
, from_tty
);
1849 debug_to_post_attach (pid
)
1852 debug_target
.to_post_attach (pid
);
1854 fprintf_unfiltered (gdb_stderr
, "target_post_attach (%d)\n", pid
);
1858 debug_to_require_attach (args
, from_tty
)
1862 debug_target
.to_require_attach (args
, from_tty
);
1864 fprintf_unfiltered (gdb_stderr
,
1865 "target_require_attach (%s, %d)\n", args
, from_tty
);
1869 debug_to_detach (args
, from_tty
)
1873 debug_target
.to_detach (args
, from_tty
);
1875 fprintf_unfiltered (gdb_stderr
, "target_detach (%s, %d)\n", args
, from_tty
);
1879 debug_to_require_detach (pid
, args
, from_tty
)
1884 debug_target
.to_require_detach (pid
, args
, from_tty
);
1886 fprintf_unfiltered (gdb_stderr
,
1887 "target_require_detach (%d, %s, %d)\n", pid
, args
, from_tty
);
1891 debug_to_resume (pid
, step
, siggnal
)
1894 enum target_signal siggnal
;
1896 debug_target
.to_resume (pid
, step
, siggnal
);
1898 fprintf_unfiltered (gdb_stderr
, "target_resume (%d, %s, %s)\n", pid
,
1899 step
? "step" : "continue",
1900 target_signal_to_name (siggnal
));
1904 debug_to_wait (pid
, status
)
1906 struct target_waitstatus
*status
;
1910 retval
= debug_target
.to_wait (pid
, status
);
1912 fprintf_unfiltered (gdb_stderr
,
1913 "target_wait (%d, status) = %d, ", pid
, retval
);
1914 fprintf_unfiltered (gdb_stderr
, "status->kind = ");
1915 switch (status
->kind
)
1917 case TARGET_WAITKIND_EXITED
:
1918 fprintf_unfiltered (gdb_stderr
, "exited, status = %d\n",
1919 status
->value
.integer
);
1921 case TARGET_WAITKIND_STOPPED
:
1922 fprintf_unfiltered (gdb_stderr
, "stopped, signal = %s\n",
1923 target_signal_to_name (status
->value
.sig
));
1925 case TARGET_WAITKIND_SIGNALLED
:
1926 fprintf_unfiltered (gdb_stderr
, "signalled, signal = %s\n",
1927 target_signal_to_name (status
->value
.sig
));
1929 case TARGET_WAITKIND_LOADED
:
1930 fprintf_unfiltered (gdb_stderr
, "loaded\n");
1932 case TARGET_WAITKIND_FORKED
:
1933 fprintf_unfiltered (gdb_stderr
, "forked\n");
1935 case TARGET_WAITKIND_VFORKED
:
1936 fprintf_unfiltered (gdb_stderr
, "vforked\n");
1938 case TARGET_WAITKIND_EXECD
:
1939 fprintf_unfiltered (gdb_stderr
, "execd\n");
1941 case TARGET_WAITKIND_SPURIOUS
:
1942 fprintf_unfiltered (gdb_stderr
, "spurious\n");
1945 fprintf_unfiltered (gdb_stderr
, "unknown???\n");
1953 debug_to_post_wait (pid
, status
)
1957 debug_target
.to_post_wait (pid
, status
);
1959 fprintf_unfiltered (gdb_stderr
, "target_post_wait (%d, %d)\n",
1964 debug_to_fetch_registers (regno
)
1967 debug_target
.to_fetch_registers (regno
);
1969 fprintf_unfiltered (gdb_stderr
, "target_fetch_registers (%s)",
1970 regno
!= -1 ? REGISTER_NAME (regno
) : "-1");
1972 fprintf_unfiltered (gdb_stderr
, " = 0x%x %d",
1973 (unsigned long) read_register (regno
),
1974 read_register (regno
));
1975 fprintf_unfiltered (gdb_stderr
, "\n");
1979 debug_to_store_registers (regno
)
1982 debug_target
.to_store_registers (regno
);
1984 if (regno
>= 0 && regno
< NUM_REGS
)
1985 fprintf_unfiltered (gdb_stderr
, "target_store_registers (%s) = 0x%x %d\n",
1986 REGISTER_NAME (regno
),
1987 (unsigned long) read_register (regno
),
1988 (unsigned long) read_register (regno
));
1990 fprintf_unfiltered (gdb_stderr
, "target_store_registers (%d)\n", regno
);
1994 debug_to_prepare_to_store ()
1996 debug_target
.to_prepare_to_store ();
1998 fprintf_unfiltered (gdb_stderr
, "target_prepare_to_store ()\n");
2002 debug_to_xfer_memory (memaddr
, myaddr
, len
, write
, target
)
2007 struct target_ops
*target
;
2011 retval
= debug_target
.to_xfer_memory (memaddr
, myaddr
, len
, write
, target
);
2013 fprintf_unfiltered (gdb_stderr
,
2014 "target_xfer_memory (0x%x, xxx, %d, %s, xxx) = %d",
2015 (unsigned int) memaddr
, /* possable truncate long long */
2016 len
, write
? "write" : "read", retval
);
2024 fputs_unfiltered (", bytes =", gdb_stderr
);
2025 for (i
= 0; i
< retval
; i
++)
2027 if ((((long) &(myaddr
[i
])) & 0xf) == 0)
2028 fprintf_unfiltered (gdb_stderr
, "\n");
2029 fprintf_unfiltered (gdb_stderr
, " %02x", myaddr
[i
] & 0xff);
2033 fputc_unfiltered ('\n', gdb_stderr
);
2039 debug_to_files_info (target
)
2040 struct target_ops
*target
;
2042 debug_target
.to_files_info (target
);
2044 fprintf_unfiltered (gdb_stderr
, "target_files_info (xxx)\n");
2048 debug_to_insert_breakpoint (addr
, save
)
2054 retval
= debug_target
.to_insert_breakpoint (addr
, save
);
2056 fprintf_unfiltered (gdb_stderr
,
2057 "target_insert_breakpoint (0x%x, xxx) = %d\n",
2058 (unsigned long) addr
, retval
);
2063 debug_to_remove_breakpoint (addr
, save
)
2069 retval
= debug_target
.to_remove_breakpoint (addr
, save
);
2071 fprintf_unfiltered (gdb_stderr
,
2072 "target_remove_breakpoint (0x%x, xxx) = %d\n",
2073 (unsigned long)addr
, retval
);
2078 debug_to_terminal_init ()
2080 debug_target
.to_terminal_init ();
2082 fprintf_unfiltered (gdb_stderr
, "target_terminal_init ()\n");
2086 debug_to_terminal_inferior ()
2088 debug_target
.to_terminal_inferior ();
2090 fprintf_unfiltered (gdb_stderr
, "target_terminal_inferior ()\n");
2094 debug_to_terminal_ours_for_output ()
2096 debug_target
.to_terminal_ours_for_output ();
2098 fprintf_unfiltered (gdb_stderr
, "target_terminal_ours_for_output ()\n");
2102 debug_to_terminal_ours ()
2104 debug_target
.to_terminal_ours ();
2106 fprintf_unfiltered (gdb_stderr
, "target_terminal_ours ()\n");
2110 debug_to_terminal_info (arg
, from_tty
)
2114 debug_target
.to_terminal_info (arg
, from_tty
);
2116 fprintf_unfiltered (gdb_stderr
, "target_terminal_info (%s, %d)\n", arg
,
2123 debug_target
.to_kill ();
2125 fprintf_unfiltered (gdb_stderr
, "target_kill ()\n");
2129 debug_to_load (args
, from_tty
)
2133 debug_target
.to_load (args
, from_tty
);
2135 fprintf_unfiltered (gdb_stderr
, "target_load (%s, %d)\n", args
, from_tty
);
2139 debug_to_lookup_symbol (name
, addrp
)
2145 retval
= debug_target
.to_lookup_symbol (name
, addrp
);
2147 fprintf_unfiltered (gdb_stderr
, "target_lookup_symbol (%s, xxx)\n", name
);
2153 debug_to_create_inferior (exec_file
, args
, env
)
2158 debug_target
.to_create_inferior (exec_file
, args
, env
);
2160 fprintf_unfiltered (gdb_stderr
, "target_create_inferior (%s, %s, xxx)\n",
2165 debug_to_post_startup_inferior (pid
)
2168 debug_target
.to_post_startup_inferior (pid
);
2170 fprintf_unfiltered (gdb_stderr
, "target_post_startup_inferior (%d)\n",
2175 debug_to_acknowledge_created_inferior (pid
)
2178 debug_target
.to_acknowledge_created_inferior (pid
);
2180 fprintf_unfiltered (gdb_stderr
, "target_acknowledge_created_inferior (%d)\n",
2185 debug_to_clone_and_follow_inferior (child_pid
, followed_child
)
2187 int *followed_child
;
2189 debug_target
.to_clone_and_follow_inferior (child_pid
, followed_child
);
2191 fprintf_unfiltered (gdb_stderr
,
2192 "target_clone_and_follow_inferior (%d, %d)\n",
2193 child_pid
, *followed_child
);
2197 debug_to_post_follow_inferior_by_clone ()
2199 debug_target
.to_post_follow_inferior_by_clone ();
2201 fprintf_unfiltered (gdb_stderr
, "target_post_follow_inferior_by_clone ()\n");
2205 debug_to_insert_fork_catchpoint (pid
)
2210 retval
= debug_target
.to_insert_fork_catchpoint (pid
);
2212 fprintf_unfiltered (gdb_stderr
, "target_insert_fork_catchpoint (%d) = %d\n",
2219 debug_to_remove_fork_catchpoint (pid
)
2224 retval
= debug_target
.to_remove_fork_catchpoint (pid
);
2226 fprintf_unfiltered (gdb_stderr
, "target_remove_fork_catchpoint (%d) = %d\n",
2233 debug_to_insert_vfork_catchpoint (pid
)
2238 retval
= debug_target
.to_insert_vfork_catchpoint (pid
);
2240 fprintf_unfiltered (gdb_stderr
, "target_insert_vfork_catchpoint (%d)= %d\n",
2247 debug_to_remove_vfork_catchpoint (pid
)
2252 retval
= debug_target
.to_remove_vfork_catchpoint (pid
);
2254 fprintf_unfiltered (gdb_stderr
, "target_remove_vfork_catchpoint (%d) = %d\n",
2261 debug_to_has_forked (pid
, child_pid
)
2267 has_forked
= debug_target
.to_has_forked (pid
, child_pid
);
2269 fprintf_unfiltered (gdb_stderr
, "target_has_forked (%d, %d) = %d\n",
2270 pid
, *child_pid
, has_forked
);
2276 debug_to_has_vforked (pid
, child_pid
)
2282 has_vforked
= debug_target
.to_has_vforked (pid
, child_pid
);
2284 fprintf_unfiltered (gdb_stderr
, "target_has_vforked (%d, %d) = %d\n",
2285 pid
, *child_pid
, has_vforked
);
2291 debug_to_can_follow_vfork_prior_to_exec ()
2293 int can_immediately_follow_vfork
;
2295 can_immediately_follow_vfork
= debug_target
.to_can_follow_vfork_prior_to_exec ();
2297 fprintf_unfiltered (gdb_stderr
, "target_can_follow_vfork_prior_to_exec () = %d\n",
2298 can_immediately_follow_vfork
);
2300 return can_immediately_follow_vfork
;
2304 debug_to_post_follow_vfork (parent_pid
, followed_parent
, child_pid
, followed_child
)
2306 int followed_parent
;
2310 debug_target
.to_post_follow_vfork (parent_pid
, followed_parent
, child_pid
, followed_child
);
2312 fprintf_unfiltered (gdb_stderr
,
2313 "target_post_follow_vfork (%d, %d, %d, %d)\n",
2314 parent_pid
, followed_parent
, child_pid
, followed_child
);
2318 debug_to_insert_exec_catchpoint (pid
)
2323 retval
= debug_target
.to_insert_exec_catchpoint (pid
);
2325 fprintf_unfiltered (gdb_stderr
, "target_insert_exec_catchpoint (%d) = %d\n",
2332 debug_to_remove_exec_catchpoint (pid
)
2337 retval
= debug_target
.to_remove_exec_catchpoint (pid
);
2339 fprintf_unfiltered (gdb_stderr
, "target_remove_exec_catchpoint (%d) = %d\n",
2346 debug_to_has_execd (pid
, execd_pathname
)
2348 char ** execd_pathname
;
2352 has_execd
= debug_target
.to_has_execd (pid
, execd_pathname
);
2354 fprintf_unfiltered (gdb_stderr
, "target_has_execd (%d, %s) = %d\n",
2355 pid
, (*execd_pathname
? *execd_pathname
: "<NULL>"),
2362 debug_to_reported_exec_events_per_exec_call ()
2364 int reported_exec_events
;
2366 reported_exec_events
= debug_target
.to_reported_exec_events_per_exec_call ();
2368 fprintf_unfiltered (gdb_stderr
,
2369 "target_reported_exec_events_per_exec_call () = %d\n",
2370 reported_exec_events
);
2372 return reported_exec_events
;
2376 debug_to_has_syscall_event (pid
, kind
, syscall_id
)
2378 enum target_waitkind
* kind
;
2381 int has_syscall_event
;
2382 char * kind_spelling
= "??";
2384 has_syscall_event
= debug_target
.to_has_syscall_event (pid
, kind
, syscall_id
);
2385 if (has_syscall_event
)
2389 case TARGET_WAITKIND_SYSCALL_ENTRY
:
2390 kind_spelling
= "SYSCALL_ENTRY";
2392 case TARGET_WAITKIND_SYSCALL_RETURN
:
2393 kind_spelling
= "SYSCALL_RETURN";
2400 fprintf_unfiltered (gdb_stderr
,
2401 "target_has_syscall_event (%d, %s, %d) = %d\n",
2402 pid
, kind_spelling
, *syscall_id
, has_syscall_event
);
2404 return has_syscall_event
;
2408 debug_to_has_exited (pid
, wait_status
, exit_status
)
2415 has_exited
= debug_target
.to_has_exited (pid
, wait_status
, exit_status
);
2417 fprintf_unfiltered (gdb_stderr
, "target_has_exited (%d, %d, %d) = %d\n",
2418 pid
, wait_status
, *exit_status
, has_exited
);
2424 debug_to_mourn_inferior ()
2426 debug_target
.to_mourn_inferior ();
2428 fprintf_unfiltered (gdb_stderr
, "target_mourn_inferior ()\n");
2436 retval
= debug_target
.to_can_run ();
2438 fprintf_unfiltered (gdb_stderr
, "target_can_run () = %d\n", retval
);
2444 debug_to_notice_signals (pid
)
2447 debug_target
.to_notice_signals (pid
);
2449 fprintf_unfiltered (gdb_stderr
, "target_notice_signals (%d)\n", pid
);
2453 debug_to_thread_alive (pid
)
2458 retval
= debug_target
.to_thread_alive (pid
);
2460 fprintf_unfiltered (gdb_stderr
, "target_thread_alive (%d) = %d\n",
2469 debug_target
.to_stop ();
2471 fprintf_unfiltered (gdb_stderr
, "target_stop ()\n");
2475 debug_to_query (type
, req
, resp
, siz
)
2483 retval
= debug_target
.to_query (type
, req
, resp
, siz
);
2485 fprintf_unfiltered (gdb_stderr
, "target_query (%c, %s, %s, %d) = %d\n", type
, req
, resp
, *siz
, retval
);
2490 static struct symtab_and_line
*
2491 debug_to_enable_exception_callback (kind
, enable
)
2492 enum exception_event_kind kind
;
2495 struct symtab_and_line
*result
;
2496 result
= debug_target
.to_enable_exception_callback (kind
, enable
);
2497 fprintf_unfiltered (gdb_stderr
,
2498 "target get_exception_callback_sal (%d, %d)\n",
2503 static struct exception_event_record
*
2504 debug_to_get_current_exception_event ()
2506 struct exception_event_record
*result
;
2507 result
= debug_target
.to_get_current_exception_event();
2508 fprintf_unfiltered (gdb_stderr
, "target get_current_exception_event ()\n");
2513 debug_to_pid_to_exec_file (pid
)
2518 exec_file
= debug_target
.to_pid_to_exec_file (pid
);
2520 fprintf_unfiltered (gdb_stderr
, "target_pid_to_exec_file (%d) = %s\n",
2527 debug_to_core_file_to_sym_file (core
)
2532 sym_file
= debug_target
.to_core_file_to_sym_file (core
);
2534 fprintf_unfiltered (gdb_stderr
, "target_core_file_to_sym_file (%s) = %s\n",
2541 setup_target_debug ()
2543 memcpy (&debug_target
, ¤t_target
, sizeof debug_target
);
2545 current_target
.to_open
= debug_to_open
;
2546 current_target
.to_close
= debug_to_close
;
2547 current_target
.to_attach
= debug_to_attach
;
2548 current_target
.to_post_attach
= debug_to_post_attach
;
2549 current_target
.to_require_attach
= debug_to_require_attach
;
2550 current_target
.to_detach
= debug_to_detach
;
2551 current_target
.to_require_detach
= debug_to_require_detach
;
2552 current_target
.to_resume
= debug_to_resume
;
2553 current_target
.to_wait
= debug_to_wait
;
2554 current_target
.to_post_wait
= debug_to_post_wait
;
2555 current_target
.to_fetch_registers
= debug_to_fetch_registers
;
2556 current_target
.to_store_registers
= debug_to_store_registers
;
2557 current_target
.to_prepare_to_store
= debug_to_prepare_to_store
;
2558 current_target
.to_xfer_memory
= debug_to_xfer_memory
;
2559 current_target
.to_files_info
= debug_to_files_info
;
2560 current_target
.to_insert_breakpoint
= debug_to_insert_breakpoint
;
2561 current_target
.to_remove_breakpoint
= debug_to_remove_breakpoint
;
2562 current_target
.to_terminal_init
= debug_to_terminal_init
;
2563 current_target
.to_terminal_inferior
= debug_to_terminal_inferior
;
2564 current_target
.to_terminal_ours_for_output
= debug_to_terminal_ours_for_output
;
2565 current_target
.to_terminal_ours
= debug_to_terminal_ours
;
2566 current_target
.to_terminal_info
= debug_to_terminal_info
;
2567 current_target
.to_kill
= debug_to_kill
;
2568 current_target
.to_load
= debug_to_load
;
2569 current_target
.to_lookup_symbol
= debug_to_lookup_symbol
;
2570 current_target
.to_create_inferior
= debug_to_create_inferior
;
2571 current_target
.to_post_startup_inferior
= debug_to_post_startup_inferior
;
2572 current_target
.to_acknowledge_created_inferior
= debug_to_acknowledge_created_inferior
;
2573 current_target
.to_clone_and_follow_inferior
= debug_to_clone_and_follow_inferior
;
2574 current_target
.to_post_follow_inferior_by_clone
= debug_to_post_follow_inferior_by_clone
;
2575 current_target
.to_insert_fork_catchpoint
= debug_to_insert_fork_catchpoint
;
2576 current_target
.to_remove_fork_catchpoint
= debug_to_remove_fork_catchpoint
;
2577 current_target
.to_insert_vfork_catchpoint
= debug_to_insert_vfork_catchpoint
;
2578 current_target
.to_remove_vfork_catchpoint
= debug_to_remove_vfork_catchpoint
;
2579 current_target
.to_has_forked
= debug_to_has_forked
;
2580 current_target
.to_has_vforked
= debug_to_has_vforked
;
2581 current_target
.to_can_follow_vfork_prior_to_exec
= debug_to_can_follow_vfork_prior_to_exec
;
2582 current_target
.to_post_follow_vfork
= debug_to_post_follow_vfork
;
2583 current_target
.to_insert_exec_catchpoint
= debug_to_insert_exec_catchpoint
;
2584 current_target
.to_remove_exec_catchpoint
= debug_to_remove_exec_catchpoint
;
2585 current_target
.to_has_execd
= debug_to_has_execd
;
2586 current_target
.to_reported_exec_events_per_exec_call
= debug_to_reported_exec_events_per_exec_call
;
2587 current_target
.to_has_syscall_event
= debug_to_has_syscall_event
;
2588 current_target
.to_has_exited
= debug_to_has_exited
;
2589 current_target
.to_mourn_inferior
= debug_to_mourn_inferior
;
2590 current_target
.to_can_run
= debug_to_can_run
;
2591 current_target
.to_notice_signals
= debug_to_notice_signals
;
2592 current_target
.to_thread_alive
= debug_to_thread_alive
;
2593 current_target
.to_stop
= debug_to_stop
;
2594 current_target
.to_query
= debug_to_query
;
2595 current_target
.to_enable_exception_callback
= debug_to_enable_exception_callback
;
2596 current_target
.to_get_current_exception_event
= debug_to_get_current_exception_event
;
2597 current_target
.to_pid_to_exec_file
= debug_to_pid_to_exec_file
;
2598 current_target
.to_core_file_to_sym_file
= debug_to_core_file_to_sym_file
;
2603 static char targ_desc
[] =
2604 "Names of targets and files being debugged.\n\
2605 Shows the entire stack of targets currently in use (including the exec-file,\n\
2606 core-file, and process, if any), as well as the symbol file name.";
2609 initialize_targets ()
2611 init_dummy_target ();
2612 push_target (&dummy_target
);
2614 add_info ("target", target_info
, targ_desc
);
2615 add_info ("files", target_info
, targ_desc
);
2618 add_set_cmd ("targetdebug", class_maintenance
, var_zinteger
,
2619 (char *)&targetdebug
,
2620 "Set target debugging.\n\
2621 When non-zero, target debugging is enabled.", &setlist
),
2624 if (!STREQ (signals
[TARGET_SIGNAL_LAST
].string
, "TARGET_SIGNAL_MAGIC"))