* target.c (target_signal_from_host, do_target_signal_to_host):
[deliverable/binutils-gdb.git] / gdb / target.c
1 /* Select target systems and architectures at runtime for GDB.
2 Copyright 1990, 1992-1995, 1998-2000 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
4
5 This file is part of GDB.
6
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.
11
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.
16
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. */
21
22 #include "defs.h"
23 #include <errno.h>
24 #include <ctype.h>
25 #include "gdb_string.h"
26 #include "target.h"
27 #include "gdbcmd.h"
28 #include "symtab.h"
29 #include "inferior.h"
30 #include "bfd.h"
31 #include "symfile.h"
32 #include "objfiles.h"
33 #include "gdb_wait.h"
34 #include <signal.h>
35
36 extern int errno;
37
38 static void target_info (char *, int);
39
40 static void cleanup_target (struct target_ops *);
41
42 static void maybe_kill_then_create_inferior (char *, char *, char **);
43
44 static void default_clone_and_follow_inferior (int, int *);
45
46 static void maybe_kill_then_attach (char *, int);
47
48 static void kill_or_be_killed (int);
49
50 static void default_terminal_info (char *, int);
51
52 static int nosymbol (char *, CORE_ADDR *);
53
54 static void tcomplain (void);
55
56 static int nomemory (CORE_ADDR, char *, int, int, struct target_ops *);
57
58 static int return_zero (void);
59
60 static int return_one (void);
61
62 void target_ignore (void);
63
64 static void target_command (char *, int);
65
66 static struct target_ops *find_default_run_target (char *);
67
68 static void update_current_target (void);
69
70 static void nosupport_runtime (void);
71
72 static void normal_target_post_startup_inferior (int pid);
73
74 /* Transfer LEN bytes between target address MEMADDR and GDB address
75 MYADDR. Returns 0 for success, errno code for failure (which
76 includes partial transfers -- if you want a more useful response to
77 partial transfers, try either target_read_memory_partial or
78 target_write_memory_partial). */
79
80 static int
81 target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write);
82
83 static void init_dummy_target (void);
84
85 static void debug_to_open (char *, int);
86
87 static void debug_to_close (int);
88
89 static void debug_to_attach (char *, int);
90
91 static void debug_to_detach (char *, int);
92
93 static void debug_to_resume (int, int, enum target_signal);
94
95 static int debug_to_wait (int, struct target_waitstatus *);
96
97 static void debug_to_fetch_registers (int);
98
99 static void debug_to_store_registers (int);
100
101 static void debug_to_prepare_to_store (void);
102
103 static int
104 debug_to_xfer_memory (CORE_ADDR, char *, int, int, struct target_ops *);
105
106 static void debug_to_files_info (struct target_ops *);
107
108 static int debug_to_insert_breakpoint (CORE_ADDR, char *);
109
110 static int debug_to_remove_breakpoint (CORE_ADDR, char *);
111
112 static void debug_to_terminal_init (void);
113
114 static void debug_to_terminal_inferior (void);
115
116 static void debug_to_terminal_ours_for_output (void);
117
118 static void debug_to_terminal_ours (void);
119
120 static void debug_to_terminal_info (char *, int);
121
122 static void debug_to_kill (void);
123
124 static void debug_to_load (char *, int);
125
126 static int debug_to_lookup_symbol (char *, CORE_ADDR *);
127
128 static void debug_to_create_inferior (char *, char *, char **);
129
130 static void debug_to_mourn_inferior (void);
131
132 static int debug_to_can_run (void);
133
134 static void debug_to_notice_signals (int);
135
136 static int debug_to_thread_alive (int);
137
138 static void debug_to_stop (void);
139
140 static int debug_to_query (int /*char */ , char *, char *, int *);
141
142 /* Pointer to array of target architecture structures; the size of the
143 array; the current index into the array; the allocated size of the
144 array. */
145 struct target_ops **target_structs;
146 unsigned target_struct_size;
147 unsigned target_struct_index;
148 unsigned target_struct_allocsize;
149 #define DEFAULT_ALLOCSIZE 10
150
151 /* The initial current target, so that there is always a semi-valid
152 current target. */
153
154 static struct target_ops dummy_target;
155
156 /* Top of target stack. */
157
158 struct target_stack_item *target_stack;
159
160 /* The target structure we are currently using to talk to a process
161 or file or whatever "inferior" we have. */
162
163 struct target_ops current_target;
164
165 /* Command list for target. */
166
167 static struct cmd_list_element *targetlist = NULL;
168
169 /* Nonzero if we are debugging an attached outside process
170 rather than an inferior. */
171
172 int attach_flag;
173
174 /* Non-zero if we want to see trace of target level stuff. */
175
176 static int targetdebug = 0;
177
178 static void setup_target_debug (void);
179
180 /* The user just typed 'target' without the name of a target. */
181
182 /* ARGSUSED */
183 static void
184 target_command (char *arg, int from_tty)
185 {
186 fputs_filtered ("Argument required (target name). Try `help target'\n",
187 gdb_stdout);
188 }
189
190 /* Add a possible target architecture to the list. */
191
192 void
193 add_target (struct target_ops *t)
194 {
195 if (!target_structs)
196 {
197 target_struct_allocsize = DEFAULT_ALLOCSIZE;
198 target_structs = (struct target_ops **) xmalloc
199 (target_struct_allocsize * sizeof (*target_structs));
200 }
201 if (target_struct_size >= target_struct_allocsize)
202 {
203 target_struct_allocsize *= 2;
204 target_structs = (struct target_ops **)
205 xrealloc ((char *) target_structs,
206 target_struct_allocsize * sizeof (*target_structs));
207 }
208 target_structs[target_struct_size++] = t;
209 /* cleanup_target (t); */
210
211 if (targetlist == NULL)
212 add_prefix_cmd ("target", class_run, target_command,
213 "Connect to a target machine or process.\n\
214 The first argument is the type or protocol of the target machine.\n\
215 Remaining arguments are interpreted by the target protocol. For more\n\
216 information on the arguments for a particular protocol, type\n\
217 `help target ' followed by the protocol name.",
218 &targetlist, "target ", 0, &cmdlist);
219 add_cmd (t->to_shortname, no_class, t->to_open, t->to_doc, &targetlist);
220 }
221
222 /* Stub functions */
223
224 void
225 target_ignore (void)
226 {
227 }
228
229 void
230 target_load (char *arg, int from_tty)
231 {
232 (*current_target.to_load) (arg, from_tty);
233 }
234
235 /* ARGSUSED */
236 static int
237 nomemory (CORE_ADDR memaddr, char *myaddr, int len, int write,
238 struct target_ops *t)
239 {
240 errno = EIO; /* Can't read/write this location */
241 return 0; /* No bytes handled */
242 }
243
244 static void
245 tcomplain (void)
246 {
247 error ("You can't do that when your target is `%s'",
248 current_target.to_shortname);
249 }
250
251 void
252 noprocess (void)
253 {
254 error ("You can't do that without a process to debug.");
255 }
256
257 /* ARGSUSED */
258 static int
259 nosymbol (char *name, CORE_ADDR *addrp)
260 {
261 return 1; /* Symbol does not exist in target env */
262 }
263
264 /* ARGSUSED */
265 static void
266 nosupport_runtime (void)
267 {
268 if (!inferior_pid)
269 noprocess ();
270 else
271 error ("No run-time support for this");
272 }
273
274
275 /* ARGSUSED */
276 static void
277 default_terminal_info (char *args, int from_tty)
278 {
279 printf_unfiltered ("No saved terminal information.\n");
280 }
281
282 /* This is the default target_create_inferior and target_attach function.
283 If the current target is executing, it asks whether to kill it off.
284 If this function returns without calling error(), it has killed off
285 the target, and the operation should be attempted. */
286
287 static void
288 kill_or_be_killed (int from_tty)
289 {
290 if (target_has_execution)
291 {
292 printf_unfiltered ("You are already running a program:\n");
293 target_files_info ();
294 if (query ("Kill it? "))
295 {
296 target_kill ();
297 if (target_has_execution)
298 error ("Killing the program did not help.");
299 return;
300 }
301 else
302 {
303 error ("Program not killed.");
304 }
305 }
306 tcomplain ();
307 }
308
309 static void
310 maybe_kill_then_attach (char *args, int from_tty)
311 {
312 kill_or_be_killed (from_tty);
313 target_attach (args, from_tty);
314 }
315
316 static void
317 maybe_kill_then_create_inferior (char *exec, char *args, char **env)
318 {
319 kill_or_be_killed (0);
320 target_create_inferior (exec, args, env);
321 }
322
323 static void
324 default_clone_and_follow_inferior (int child_pid, int *followed_child)
325 {
326 target_clone_and_follow_inferior (child_pid, followed_child);
327 }
328
329 /* Clean up a target struct so it no longer has any zero pointers in it.
330 We default entries, at least to stubs that print error messages. */
331
332 static void
333 cleanup_target (struct target_ops *t)
334 {
335
336 #define de_fault(field, value) \
337 if (!t->field) \
338 t->field = value
339
340 de_fault (to_open,
341 (void (*) (char *, int))
342 tcomplain);
343 de_fault (to_close,
344 (void (*) (int))
345 target_ignore);
346 de_fault (to_attach,
347 maybe_kill_then_attach);
348 de_fault (to_post_attach,
349 (void (*) (int))
350 target_ignore);
351 de_fault (to_require_attach,
352 maybe_kill_then_attach);
353 de_fault (to_detach,
354 (void (*) (char *, int))
355 target_ignore);
356 de_fault (to_require_detach,
357 (void (*) (int, char *, int))
358 target_ignore);
359 de_fault (to_resume,
360 (void (*) (int, int, enum target_signal))
361 noprocess);
362 de_fault (to_wait,
363 (int (*) (int, struct target_waitstatus *))
364 noprocess);
365 de_fault (to_post_wait,
366 (void (*) (int, int))
367 target_ignore);
368 de_fault (to_fetch_registers,
369 (void (*) (int))
370 target_ignore);
371 de_fault (to_store_registers,
372 (void (*) (int))
373 noprocess);
374 de_fault (to_prepare_to_store,
375 (void (*) (void))
376 noprocess);
377 de_fault (to_xfer_memory,
378 (int (*) (CORE_ADDR, char *, int, int, struct target_ops *))
379 nomemory);
380 de_fault (to_files_info,
381 (void (*) (struct target_ops *))
382 target_ignore);
383 de_fault (to_insert_breakpoint,
384 memory_insert_breakpoint);
385 de_fault (to_remove_breakpoint,
386 memory_remove_breakpoint);
387 de_fault (to_terminal_init,
388 (void (*) (void))
389 target_ignore);
390 de_fault (to_terminal_inferior,
391 (void (*) (void))
392 target_ignore);
393 de_fault (to_terminal_ours_for_output,
394 (void (*) (void))
395 target_ignore);
396 de_fault (to_terminal_ours,
397 (void (*) (void))
398 target_ignore);
399 de_fault (to_terminal_info,
400 default_terminal_info);
401 de_fault (to_kill,
402 (void (*) (void))
403 noprocess);
404 de_fault (to_load,
405 (void (*) (char *, int))
406 tcomplain);
407 de_fault (to_lookup_symbol,
408 (int (*) (char *, CORE_ADDR *))
409 nosymbol);
410 de_fault (to_create_inferior,
411 maybe_kill_then_create_inferior);
412 de_fault (to_post_startup_inferior,
413 (void (*) (int))
414 target_ignore);
415 de_fault (to_acknowledge_created_inferior,
416 (void (*) (int))
417 target_ignore);
418 de_fault (to_clone_and_follow_inferior,
419 default_clone_and_follow_inferior);
420 de_fault (to_post_follow_inferior_by_clone,
421 (void (*) (void))
422 target_ignore);
423 de_fault (to_insert_fork_catchpoint,
424 (int (*) (int))
425 tcomplain);
426 de_fault (to_remove_fork_catchpoint,
427 (int (*) (int))
428 tcomplain);
429 de_fault (to_insert_vfork_catchpoint,
430 (int (*) (int))
431 tcomplain);
432 de_fault (to_remove_vfork_catchpoint,
433 (int (*) (int))
434 tcomplain);
435 de_fault (to_has_forked,
436 (int (*) (int, int *))
437 return_zero);
438 de_fault (to_has_vforked,
439 (int (*) (int, int *))
440 return_zero);
441 de_fault (to_can_follow_vfork_prior_to_exec,
442 (int (*) (void))
443 return_zero);
444 de_fault (to_post_follow_vfork,
445 (void (*) (int, int, int, int))
446 target_ignore);
447 de_fault (to_insert_exec_catchpoint,
448 (int (*) (int))
449 tcomplain);
450 de_fault (to_remove_exec_catchpoint,
451 (int (*) (int))
452 tcomplain);
453 de_fault (to_has_execd,
454 (int (*) (int, char **))
455 return_zero);
456 de_fault (to_reported_exec_events_per_exec_call,
457 (int (*) (void))
458 return_one);
459 de_fault (to_has_syscall_event,
460 (int (*) (int, enum target_waitkind *, int *))
461 return_zero);
462 de_fault (to_has_exited,
463 (int (*) (int, int, int *))
464 return_zero);
465 de_fault (to_mourn_inferior,
466 (void (*) (void))
467 noprocess);
468 de_fault (to_can_run,
469 return_zero);
470 de_fault (to_notice_signals,
471 (void (*) (int))
472 target_ignore);
473 de_fault (to_thread_alive,
474 (int (*) (int))
475 return_zero);
476 de_fault (to_find_new_threads,
477 (void (*) (void))
478 target_ignore);
479 de_fault (to_extra_thread_info,
480 (char *(*) (struct thread_info *))
481 return_zero);
482 de_fault (to_stop,
483 (void (*) (void))
484 target_ignore);
485 de_fault (to_query,
486 (int (*) (int, char *, char *, int *))
487 return_zero);
488 de_fault (to_rcmd,
489 (void (*) (char *, struct ui_file *))
490 tcomplain);
491 de_fault (to_enable_exception_callback,
492 (struct symtab_and_line * (*) (enum exception_event_kind, int))
493 nosupport_runtime);
494 de_fault (to_get_current_exception_event,
495 (struct exception_event_record * (*) (void))
496 nosupport_runtime);
497 de_fault (to_pid_to_exec_file,
498 (char *(*) (int))
499 return_zero);
500 de_fault (to_core_file_to_sym_file,
501 (char *(*) (char *))
502 return_zero);
503 de_fault (to_can_async_p,
504 (int (*) (void))
505 return_zero);
506 de_fault (to_is_async_p,
507 (int (*) (void))
508 return_zero);
509 de_fault (to_async,
510 (void (*) (void (*) (enum inferior_event_type, void*), void*))
511 tcomplain);
512 #undef de_fault
513 }
514
515 /* Go through the target stack from top to bottom, copying over zero entries in
516 current_target. In effect, we are doing class inheritance through the
517 pushed target vectors. */
518
519 static void
520 update_current_target (void)
521 {
522 struct target_stack_item *item;
523 struct target_ops *t;
524
525 /* First, reset current_target */
526 memset (&current_target, 0, sizeof current_target);
527
528 for (item = target_stack; item; item = item->next)
529 {
530 t = item->target_ops;
531
532 #define INHERIT(FIELD, TARGET) \
533 if (!current_target.FIELD) \
534 current_target.FIELD = TARGET->FIELD
535
536 INHERIT (to_shortname, t);
537 INHERIT (to_longname, t);
538 INHERIT (to_doc, t);
539 INHERIT (to_open, t);
540 INHERIT (to_close, t);
541 INHERIT (to_attach, t);
542 INHERIT (to_post_attach, t);
543 INHERIT (to_require_attach, t);
544 INHERIT (to_detach, t);
545 INHERIT (to_require_detach, t);
546 INHERIT (to_resume, t);
547 INHERIT (to_wait, t);
548 INHERIT (to_post_wait, t);
549 INHERIT (to_fetch_registers, t);
550 INHERIT (to_store_registers, t);
551 INHERIT (to_prepare_to_store, t);
552 INHERIT (to_xfer_memory, t);
553 INHERIT (to_files_info, t);
554 INHERIT (to_insert_breakpoint, t);
555 INHERIT (to_remove_breakpoint, t);
556 INHERIT (to_terminal_init, t);
557 INHERIT (to_terminal_inferior, t);
558 INHERIT (to_terminal_ours_for_output, t);
559 INHERIT (to_terminal_ours, t);
560 INHERIT (to_terminal_info, t);
561 INHERIT (to_kill, t);
562 INHERIT (to_load, t);
563 INHERIT (to_lookup_symbol, t);
564 INHERIT (to_create_inferior, t);
565 INHERIT (to_post_startup_inferior, t);
566 INHERIT (to_acknowledge_created_inferior, t);
567 INHERIT (to_clone_and_follow_inferior, t);
568 INHERIT (to_post_follow_inferior_by_clone, t);
569 INHERIT (to_insert_fork_catchpoint, t);
570 INHERIT (to_remove_fork_catchpoint, t);
571 INHERIT (to_insert_vfork_catchpoint, t);
572 INHERIT (to_remove_vfork_catchpoint, t);
573 INHERIT (to_has_forked, t);
574 INHERIT (to_has_vforked, t);
575 INHERIT (to_can_follow_vfork_prior_to_exec, t);
576 INHERIT (to_post_follow_vfork, t);
577 INHERIT (to_insert_exec_catchpoint, t);
578 INHERIT (to_remove_exec_catchpoint, t);
579 INHERIT (to_has_execd, t);
580 INHERIT (to_reported_exec_events_per_exec_call, t);
581 INHERIT (to_has_syscall_event, t);
582 INHERIT (to_has_exited, t);
583 INHERIT (to_mourn_inferior, t);
584 INHERIT (to_can_run, t);
585 INHERIT (to_notice_signals, t);
586 INHERIT (to_thread_alive, t);
587 INHERIT (to_find_new_threads, t);
588 INHERIT (to_pid_to_str, t);
589 INHERIT (to_extra_thread_info, t);
590 INHERIT (to_stop, t);
591 INHERIT (to_query, t);
592 INHERIT (to_rcmd, t);
593 INHERIT (to_enable_exception_callback, t);
594 INHERIT (to_get_current_exception_event, t);
595 INHERIT (to_pid_to_exec_file, t);
596 INHERIT (to_core_file_to_sym_file, t);
597 INHERIT (to_stratum, t);
598 INHERIT (DONT_USE, t);
599 INHERIT (to_has_all_memory, t);
600 INHERIT (to_has_memory, t);
601 INHERIT (to_has_stack, t);
602 INHERIT (to_has_registers, t);
603 INHERIT (to_has_execution, t);
604 INHERIT (to_has_thread_control, t);
605 INHERIT (to_sections, t);
606 INHERIT (to_sections_end, t);
607 INHERIT (to_can_async_p, t);
608 INHERIT (to_is_async_p, t);
609 INHERIT (to_async, t);
610 INHERIT (to_async_mask_value, t);
611 INHERIT (to_magic, t);
612
613 #undef INHERIT
614 }
615 }
616
617 /* Push a new target type into the stack of the existing target accessors,
618 possibly superseding some of the existing accessors.
619
620 Result is zero if the pushed target ended up on top of the stack,
621 nonzero if at least one target is on top of it.
622
623 Rather than allow an empty stack, we always have the dummy target at
624 the bottom stratum, so we can call the function vectors without
625 checking them. */
626
627 int
628 push_target (struct target_ops *t)
629 {
630 struct target_stack_item *cur, *prev, *tmp;
631
632 /* Check magic number. If wrong, it probably means someone changed
633 the struct definition, but not all the places that initialize one. */
634 if (t->to_magic != OPS_MAGIC)
635 {
636 fprintf_unfiltered (gdb_stderr,
637 "Magic number of %s target struct wrong\n",
638 t->to_shortname);
639 abort ();
640 }
641
642 /* Find the proper stratum to install this target in. */
643
644 for (prev = NULL, cur = target_stack; cur; prev = cur, cur = cur->next)
645 {
646 if ((int) (t->to_stratum) >= (int) (cur->target_ops->to_stratum))
647 break;
648 }
649
650 /* If there's already targets at this stratum, remove them. */
651
652 if (cur)
653 while (t->to_stratum == cur->target_ops->to_stratum)
654 {
655 /* There's already something on this stratum. Close it off. */
656 if (cur->target_ops->to_close)
657 (cur->target_ops->to_close) (0);
658 if (prev)
659 prev->next = cur->next; /* Unchain old target_ops */
660 else
661 target_stack = cur->next; /* Unchain first on list */
662 tmp = cur->next;
663 free (cur);
664 cur = tmp;
665 }
666
667 /* We have removed all targets in our stratum, now add the new one. */
668
669 tmp = (struct target_stack_item *)
670 xmalloc (sizeof (struct target_stack_item));
671 tmp->next = cur;
672 tmp->target_ops = t;
673
674 if (prev)
675 prev->next = tmp;
676 else
677 target_stack = tmp;
678
679 update_current_target ();
680
681 cleanup_target (&current_target); /* Fill in the gaps */
682
683 if (targetdebug)
684 setup_target_debug ();
685
686 return prev != 0;
687 }
688
689 /* Remove a target_ops vector from the stack, wherever it may be.
690 Return how many times it was removed (0 or 1). */
691
692 int
693 unpush_target (struct target_ops *t)
694 {
695 struct target_stack_item *cur, *prev;
696
697 if (t->to_close)
698 t->to_close (0); /* Let it clean up */
699
700 /* Look for the specified target. Note that we assume that a target
701 can only occur once in the target stack. */
702
703 for (cur = target_stack, prev = NULL; cur; prev = cur, cur = cur->next)
704 if (cur->target_ops == t)
705 break;
706
707 if (!cur)
708 return 0; /* Didn't find target_ops, quit now */
709
710 /* Unchain the target */
711
712 if (!prev)
713 target_stack = cur->next;
714 else
715 prev->next = cur->next;
716
717 free (cur); /* Release the target_stack_item */
718
719 update_current_target ();
720 cleanup_target (&current_target);
721
722 return 1;
723 }
724
725 void
726 pop_target (void)
727 {
728 (current_target.to_close) (0); /* Let it clean up */
729 if (unpush_target (target_stack->target_ops) == 1)
730 return;
731
732 fprintf_unfiltered (gdb_stderr,
733 "pop_target couldn't find target %s\n",
734 current_target.to_shortname);
735 abort ();
736 }
737
738 #undef MIN
739 #define MIN(A, B) (((A) <= (B)) ? (A) : (B))
740
741 /* target_read_string -- read a null terminated string, up to LEN bytes,
742 from MEMADDR in target. Set *ERRNOP to the errno code, or 0 if successful.
743 Set *STRING to a pointer to malloc'd memory containing the data; the caller
744 is responsible for freeing it. Return the number of bytes successfully
745 read. */
746
747 int
748 target_read_string (CORE_ADDR memaddr, char **string, int len, int *errnop)
749 {
750 int tlen, origlen, offset, i;
751 char buf[4];
752 int errcode = 0;
753 char *buffer;
754 int buffer_allocated;
755 char *bufptr;
756 unsigned int nbytes_read = 0;
757
758 /* Small for testing. */
759 buffer_allocated = 4;
760 buffer = xmalloc (buffer_allocated);
761 bufptr = buffer;
762
763 origlen = len;
764
765 while (len > 0)
766 {
767 tlen = MIN (len, 4 - (memaddr & 3));
768 offset = memaddr & 3;
769
770 errcode = target_xfer_memory (memaddr & ~3, buf, 4, 0);
771 if (errcode != 0)
772 {
773 /* The transfer request might have crossed the boundary to an
774 unallocated region of memory. Retry the transfer, requesting
775 a single byte. */
776 tlen = 1;
777 offset = 0;
778 errcode = target_xfer_memory (memaddr, buf, 1, 0);
779 if (errcode != 0)
780 goto done;
781 }
782
783 if (bufptr - buffer + tlen > buffer_allocated)
784 {
785 unsigned int bytes;
786 bytes = bufptr - buffer;
787 buffer_allocated *= 2;
788 buffer = xrealloc (buffer, buffer_allocated);
789 bufptr = buffer + bytes;
790 }
791
792 for (i = 0; i < tlen; i++)
793 {
794 *bufptr++ = buf[i + offset];
795 if (buf[i + offset] == '\000')
796 {
797 nbytes_read += i + 1;
798 goto done;
799 }
800 }
801
802 memaddr += tlen;
803 len -= tlen;
804 nbytes_read += tlen;
805 }
806 done:
807 if (errnop != NULL)
808 *errnop = errcode;
809 if (string != NULL)
810 *string = buffer;
811 return nbytes_read;
812 }
813
814 /* Read LEN bytes of target memory at address MEMADDR, placing the results in
815 GDB's memory at MYADDR. Returns either 0 for success or an errno value
816 if any error occurs.
817
818 If an error occurs, no guarantee is made about the contents of the data at
819 MYADDR. In particular, the caller should not depend upon partial reads
820 filling the buffer with good data. There is no way for the caller to know
821 how much good data might have been transfered anyway. Callers that can
822 deal with partial reads should call target_read_memory_partial. */
823
824 int
825 target_read_memory (CORE_ADDR memaddr, char *myaddr, int len)
826 {
827 return target_xfer_memory (memaddr, myaddr, len, 0);
828 }
829
830 int
831 target_write_memory (CORE_ADDR memaddr, char *myaddr, int len)
832 {
833 return target_xfer_memory (memaddr, myaddr, len, 1);
834 }
835
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.
843
844 Result is 0 or errno value. */
845
846 static int
847 target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
848 {
849 int curlen;
850 int res;
851 struct target_ops *t;
852 struct target_stack_item *item;
853
854 /* Zero length requests are ok and require no work. */
855 if (len == 0)
856 return 0;
857
858 /* to_xfer_memory is not guaranteed to set errno, even when it returns
859 0. */
860 errno = 0;
861
862 /* The quick case is that the top target does it all. */
863 res = current_target.to_xfer_memory
864 (memaddr, myaddr, len, write, &current_target);
865 if (res == len)
866 return 0;
867
868 if (res > 0)
869 goto bump;
870 /* If res <= 0 then we call it again in the loop. Ah well. */
871
872 for (; len > 0;)
873 {
874 curlen = len; /* Want to do it all */
875 for (item = target_stack; item; item = item->next)
876 {
877 t = item->target_ops;
878 if (!t->to_has_memory)
879 continue;
880
881 res = t->to_xfer_memory (memaddr, myaddr, curlen, write, t);
882 if (res > 0)
883 break; /* Handled all or part of xfer */
884 if (t->to_has_all_memory)
885 break;
886 }
887
888 if (res <= 0)
889 {
890 /* If this address is for nonexistent memory,
891 read zeros if reading, or do nothing if writing. Return error. */
892 if (!write)
893 memset (myaddr, 0, len);
894 if (errno == 0)
895 return EIO;
896 else
897 return errno;
898 }
899 bump:
900 memaddr += res;
901 myaddr += res;
902 len -= res;
903 }
904 return 0; /* We managed to cover it all somehow. */
905 }
906
907
908 /* Perform a partial memory transfer. */
909
910 static int
911 target_xfer_memory_partial (CORE_ADDR memaddr, char *buf, int len,
912 int write_p, int *err)
913 {
914 int res;
915 int err_res;
916 int len_res;
917 struct target_ops *t;
918 struct target_stack_item *item;
919
920 /* Zero length requests are ok and require no work. */
921 if (len == 0)
922 {
923 *err = 0;
924 return 0;
925 }
926
927 /* The quick case is that the top target does it all. */
928 res = current_target.to_xfer_memory (memaddr, buf, len, write_p, &current_target);
929 if (res > 0)
930 {
931 *err = 0;
932 return res;
933 }
934
935 /* xfer memory doesn't always reliably set errno. */
936 errno = 0;
937
938 /* Try all levels of the target stack to see one can handle it. */
939 for (item = target_stack; item; item = item->next)
940 {
941 t = item->target_ops;
942 if (!t->to_has_memory)
943 continue;
944 res = t->to_xfer_memory (memaddr, buf, len, write_p, t);
945 if (res > 0)
946 {
947 /* Handled all or part of xfer */
948 *err = 0;
949 return res;
950 }
951 if (t->to_has_all_memory)
952 break;
953 }
954
955 /* Total failure. Return error. */
956 if (errno != 0)
957 {
958 *err = errno;
959 return -1;
960 }
961 *err = EIO;
962 return -1;
963 }
964
965 int
966 target_read_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err)
967 {
968 return target_xfer_memory_partial (memaddr, buf, len, 0, err);
969 }
970
971 int
972 target_write_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err)
973 {
974 return target_xfer_memory_partial (memaddr, buf, len, 1, err);
975 }
976
977 /* ARGSUSED */
978 static void
979 target_info (char *args, int from_tty)
980 {
981 struct target_ops *t;
982 struct target_stack_item *item;
983 int has_all_mem = 0;
984
985 if (symfile_objfile != NULL)
986 printf_unfiltered ("Symbols from \"%s\".\n", symfile_objfile->name);
987
988 #ifdef FILES_INFO_HOOK
989 if (FILES_INFO_HOOK ())
990 return;
991 #endif
992
993 for (item = target_stack; item; item = item->next)
994 {
995 t = item->target_ops;
996
997 if (!t->to_has_memory)
998 continue;
999
1000 if ((int) (t->to_stratum) <= (int) dummy_stratum)
1001 continue;
1002 if (has_all_mem)
1003 printf_unfiltered ("\tWhile running this, GDB does not access memory from...\n");
1004 printf_unfiltered ("%s:\n", t->to_longname);
1005 (t->to_files_info) (t);
1006 has_all_mem = t->to_has_all_memory;
1007 }
1008 }
1009
1010 /* This is to be called by the open routine before it does
1011 anything. */
1012
1013 void
1014 target_preopen (int from_tty)
1015 {
1016 dont_repeat ();
1017
1018 if (target_has_execution)
1019 {
1020 if (!from_tty
1021 || query ("A program is being debugged already. Kill it? "))
1022 target_kill ();
1023 else
1024 error ("Program not killed.");
1025 }
1026
1027 /* Calling target_kill may remove the target from the stack. But if
1028 it doesn't (which seems like a win for UDI), remove it now. */
1029
1030 if (target_has_execution)
1031 pop_target ();
1032 }
1033
1034 /* Detach a target after doing deferred register stores. */
1035
1036 void
1037 target_detach (char *args, int from_tty)
1038 {
1039 /* Handle any optimized stores to the inferior. */
1040 #ifdef DO_DEFERRED_STORES
1041 DO_DEFERRED_STORES;
1042 #endif
1043 (current_target.to_detach) (args, from_tty);
1044 }
1045
1046 void
1047 target_link (char *modname, CORE_ADDR *t_reloc)
1048 {
1049 if (STREQ (current_target.to_shortname, "rombug"))
1050 {
1051 (current_target.to_lookup_symbol) (modname, t_reloc);
1052 if (*t_reloc == 0)
1053 error ("Unable to link to %s and get relocation in rombug", modname);
1054 }
1055 else
1056 *t_reloc = (CORE_ADDR) -1;
1057 }
1058
1059 int
1060 target_async_mask (int mask)
1061 {
1062 int saved_async_masked_status = target_async_mask_value;
1063 target_async_mask_value = mask;
1064 return saved_async_masked_status;
1065 }
1066
1067 /* Look through the list of possible targets for a target that can
1068 execute a run or attach command without any other data. This is
1069 used to locate the default process stratum.
1070
1071 Result is always valid (error() is called for errors). */
1072
1073 static struct target_ops *
1074 find_default_run_target (char *do_mesg)
1075 {
1076 struct target_ops **t;
1077 struct target_ops *runable = NULL;
1078 int count;
1079
1080 count = 0;
1081
1082 for (t = target_structs; t < target_structs + target_struct_size;
1083 ++t)
1084 {
1085 if ((*t)->to_can_run && target_can_run (*t))
1086 {
1087 runable = *t;
1088 ++count;
1089 }
1090 }
1091
1092 if (count != 1)
1093 error ("Don't know how to %s. Try \"help target\".", do_mesg);
1094
1095 return runable;
1096 }
1097
1098 void
1099 find_default_attach (char *args, int from_tty)
1100 {
1101 struct target_ops *t;
1102
1103 t = find_default_run_target ("attach");
1104 (t->to_attach) (args, from_tty);
1105 return;
1106 }
1107
1108 void
1109 find_default_require_attach (char *args, int from_tty)
1110 {
1111 struct target_ops *t;
1112
1113 t = find_default_run_target ("require_attach");
1114 (t->to_require_attach) (args, from_tty);
1115 return;
1116 }
1117
1118 void
1119 find_default_require_detach (int pid, char *args, int from_tty)
1120 {
1121 struct target_ops *t;
1122
1123 t = find_default_run_target ("require_detach");
1124 (t->to_require_detach) (pid, args, from_tty);
1125 return;
1126 }
1127
1128 void
1129 find_default_create_inferior (char *exec_file, char *allargs, char **env)
1130 {
1131 struct target_ops *t;
1132
1133 t = find_default_run_target ("run");
1134 (t->to_create_inferior) (exec_file, allargs, env);
1135 return;
1136 }
1137
1138 void
1139 find_default_clone_and_follow_inferior (int child_pid, int *followed_child)
1140 {
1141 struct target_ops *t;
1142
1143 t = find_default_run_target ("run");
1144 (t->to_clone_and_follow_inferior) (child_pid, followed_child);
1145 return;
1146 }
1147
1148 static int
1149 return_zero (void)
1150 {
1151 return 0;
1152 }
1153
1154 static int
1155 return_one (void)
1156 {
1157 return 1;
1158 }
1159
1160 /*
1161 * Resize the to_sections pointer. Also make sure that anyone that
1162 * was holding on to an old value of it gets updated.
1163 * Returns the old size.
1164 */
1165
1166 int
1167 target_resize_to_sections (struct target_ops *target, int num_added)
1168 {
1169 struct target_ops **t;
1170 struct section_table *old_value;
1171 int old_count;
1172
1173 old_value = target->to_sections;
1174
1175 if (target->to_sections)
1176 {
1177 old_count = target->to_sections_end - target->to_sections;
1178 target->to_sections = (struct section_table *)
1179 xrealloc ((char *) target->to_sections,
1180 (sizeof (struct section_table)) * (num_added + old_count));
1181 }
1182 else
1183 {
1184 old_count = 0;
1185 target->to_sections = (struct section_table *)
1186 xmalloc ((sizeof (struct section_table)) * num_added);
1187 }
1188 target->to_sections_end = target->to_sections + (num_added + old_count);
1189
1190 /* Check to see if anyone else was pointing to this structure.
1191 If old_value was null, then no one was. */
1192
1193 if (old_value)
1194 {
1195 for (t = target_structs; t < target_structs + target_struct_size;
1196 ++t)
1197 {
1198 if ((*t)->to_sections == old_value)
1199 {
1200 (*t)->to_sections = target->to_sections;
1201 (*t)->to_sections_end = target->to_sections_end;
1202 }
1203 }
1204 }
1205
1206 return old_count;
1207
1208 }
1209
1210 /* Remove all target sections taken from ABFD.
1211
1212 Scan the current target stack for targets whose section tables
1213 refer to sections from BFD, and remove those sections. We use this
1214 when we notice that the inferior has unloaded a shared object, for
1215 example. */
1216 void
1217 remove_target_sections (bfd *abfd)
1218 {
1219 struct target_ops **t;
1220
1221 for (t = target_structs; t < target_structs + target_struct_size; t++)
1222 {
1223 struct section_table *src, *dest;
1224
1225 dest = (*t)->to_sections;
1226 for (src = (*t)->to_sections; src < (*t)->to_sections_end; src++)
1227 if (src->bfd != abfd)
1228 {
1229 /* Keep this section. */
1230 if (dest < src) *dest = *src;
1231 dest++;
1232 }
1233
1234 /* If we've dropped any sections, resize the section table. */
1235 if (dest < src)
1236 target_resize_to_sections (*t, dest - src);
1237 }
1238 }
1239
1240
1241
1242
1243 /* Find a single runnable target in the stack and return it. If for
1244 some reason there is more than one, return NULL. */
1245
1246 struct target_ops *
1247 find_run_target (void)
1248 {
1249 struct target_ops **t;
1250 struct target_ops *runable = NULL;
1251 int count;
1252
1253 count = 0;
1254
1255 for (t = target_structs; t < target_structs + target_struct_size; ++t)
1256 {
1257 if ((*t)->to_can_run && target_can_run (*t))
1258 {
1259 runable = *t;
1260 ++count;
1261 }
1262 }
1263
1264 return (count == 1 ? runable : NULL);
1265 }
1266
1267 /* Find a single core_stratum target in the list of targets and return it.
1268 If for some reason there is more than one, return NULL. */
1269
1270 struct target_ops *
1271 find_core_target (void)
1272 {
1273 struct target_ops **t;
1274 struct target_ops *runable = NULL;
1275 int count;
1276
1277 count = 0;
1278
1279 for (t = target_structs; t < target_structs + target_struct_size;
1280 ++t)
1281 {
1282 if ((*t)->to_stratum == core_stratum)
1283 {
1284 runable = *t;
1285 ++count;
1286 }
1287 }
1288
1289 return (count == 1 ? runable : NULL);
1290 }
1291
1292 /*
1293 * Find the next target down the stack from the specified target.
1294 */
1295
1296 struct target_ops *
1297 find_target_beneath (struct target_ops *t)
1298 {
1299 struct target_stack_item *cur;
1300
1301 for (cur = target_stack; cur; cur = cur->next)
1302 if (cur->target_ops == t)
1303 break;
1304
1305 if (cur == NULL || cur->next == NULL)
1306 return NULL;
1307 else
1308 return cur->next->target_ops;
1309 }
1310
1311 \f
1312 /* The inferior process has died. Long live the inferior! */
1313
1314 void
1315 generic_mourn_inferior (void)
1316 {
1317 extern int show_breakpoint_hit_counts;
1318
1319 inferior_pid = 0;
1320 attach_flag = 0;
1321 breakpoint_init_inferior (inf_exited);
1322 registers_changed ();
1323
1324 #ifdef CLEAR_DEFERRED_STORES
1325 /* Delete any pending stores to the inferior... */
1326 CLEAR_DEFERRED_STORES;
1327 #endif
1328
1329 reopen_exec_file ();
1330 reinit_frame_cache ();
1331
1332 /* It is confusing to the user for ignore counts to stick around
1333 from previous runs of the inferior. So clear them. */
1334 /* However, it is more confusing for the ignore counts to disappear when
1335 using hit counts. So don't clear them if we're counting hits. */
1336 if (!show_breakpoint_hit_counts)
1337 breakpoint_clear_ignore_counts ();
1338 }
1339 \f
1340 /* This table must match in order and size the signals in enum target_signal
1341 in target.h. */
1342 /* *INDENT-OFF* */
1343 static struct {
1344 char *name;
1345 char *string;
1346 } signals [] =
1347 {
1348 {"0", "Signal 0"},
1349 {"SIGHUP", "Hangup"},
1350 {"SIGINT", "Interrupt"},
1351 {"SIGQUIT", "Quit"},
1352 {"SIGILL", "Illegal instruction"},
1353 {"SIGTRAP", "Trace/breakpoint trap"},
1354 {"SIGABRT", "Aborted"},
1355 {"SIGEMT", "Emulation trap"},
1356 {"SIGFPE", "Arithmetic exception"},
1357 {"SIGKILL", "Killed"},
1358 {"SIGBUS", "Bus error"},
1359 {"SIGSEGV", "Segmentation fault"},
1360 {"SIGSYS", "Bad system call"},
1361 {"SIGPIPE", "Broken pipe"},
1362 {"SIGALRM", "Alarm clock"},
1363 {"SIGTERM", "Terminated"},
1364 {"SIGURG", "Urgent I/O condition"},
1365 {"SIGSTOP", "Stopped (signal)"},
1366 {"SIGTSTP", "Stopped (user)"},
1367 {"SIGCONT", "Continued"},
1368 {"SIGCHLD", "Child status changed"},
1369 {"SIGTTIN", "Stopped (tty input)"},
1370 {"SIGTTOU", "Stopped (tty output)"},
1371 {"SIGIO", "I/O possible"},
1372 {"SIGXCPU", "CPU time limit exceeded"},
1373 {"SIGXFSZ", "File size limit exceeded"},
1374 {"SIGVTALRM", "Virtual timer expired"},
1375 {"SIGPROF", "Profiling timer expired"},
1376 {"SIGWINCH", "Window size changed"},
1377 {"SIGLOST", "Resource lost"},
1378 {"SIGUSR1", "User defined signal 1"},
1379 {"SIGUSR2", "User defined signal 2"},
1380 {"SIGPWR", "Power fail/restart"},
1381 {"SIGPOLL", "Pollable event occurred"},
1382 {"SIGWIND", "SIGWIND"},
1383 {"SIGPHONE", "SIGPHONE"},
1384 {"SIGWAITING", "Process's LWPs are blocked"},
1385 {"SIGLWP", "Signal LWP"},
1386 {"SIGDANGER", "Swap space dangerously low"},
1387 {"SIGGRANT", "Monitor mode granted"},
1388 {"SIGRETRACT", "Need to relinquish monitor mode"},
1389 {"SIGMSG", "Monitor mode data available"},
1390 {"SIGSOUND", "Sound completed"},
1391 {"SIGSAK", "Secure attention"},
1392 {"SIGPRIO", "SIGPRIO"},
1393 {"SIG33", "Real-time event 33"},
1394 {"SIG34", "Real-time event 34"},
1395 {"SIG35", "Real-time event 35"},
1396 {"SIG36", "Real-time event 36"},
1397 {"SIG37", "Real-time event 37"},
1398 {"SIG38", "Real-time event 38"},
1399 {"SIG39", "Real-time event 39"},
1400 {"SIG40", "Real-time event 40"},
1401 {"SIG41", "Real-time event 41"},
1402 {"SIG42", "Real-time event 42"},
1403 {"SIG43", "Real-time event 43"},
1404 {"SIG44", "Real-time event 44"},
1405 {"SIG45", "Real-time event 45"},
1406 {"SIG46", "Real-time event 46"},
1407 {"SIG47", "Real-time event 47"},
1408 {"SIG48", "Real-time event 48"},
1409 {"SIG49", "Real-time event 49"},
1410 {"SIG50", "Real-time event 50"},
1411 {"SIG51", "Real-time event 51"},
1412 {"SIG52", "Real-time event 52"},
1413 {"SIG53", "Real-time event 53"},
1414 {"SIG54", "Real-time event 54"},
1415 {"SIG55", "Real-time event 55"},
1416 {"SIG56", "Real-time event 56"},
1417 {"SIG57", "Real-time event 57"},
1418 {"SIG58", "Real-time event 58"},
1419 {"SIG59", "Real-time event 59"},
1420 {"SIG60", "Real-time event 60"},
1421 {"SIG61", "Real-time event 61"},
1422 {"SIG62", "Real-time event 62"},
1423 {"SIG63", "Real-time event 63"},
1424 {"SIGCANCEL", "LWP internal signal"},
1425 {"SIG32", "Real-time event 32"},
1426
1427 #if defined(MACH) || defined(__MACH__)
1428 /* Mach exceptions */
1429 {"EXC_BAD_ACCESS", "Could not access memory"},
1430 {"EXC_BAD_INSTRUCTION", "Illegal instruction/operand"},
1431 {"EXC_ARITHMETIC", "Arithmetic exception"},
1432 {"EXC_EMULATION", "Emulation instruction"},
1433 {"EXC_SOFTWARE", "Software generated exception"},
1434 {"EXC_BREAKPOINT", "Breakpoint"},
1435 #endif
1436 {"SIGINFO", "Information request"},
1437
1438 {NULL, "Unknown signal"},
1439 {NULL, "Internal error: printing TARGET_SIGNAL_DEFAULT"},
1440
1441 /* Last entry, used to check whether the table is the right size. */
1442 {NULL, "TARGET_SIGNAL_MAGIC"}
1443 };
1444 /* *INDENT-ON* */
1445
1446
1447
1448 /* Return the string for a signal. */
1449 char *
1450 target_signal_to_string (enum target_signal sig)
1451 {
1452 if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST))
1453 return signals[sig].string;
1454 else
1455 return signals[TARGET_SIGNAL_UNKNOWN].string;
1456 }
1457
1458 /* Return the name for a signal. */
1459 char *
1460 target_signal_to_name (enum target_signal sig)
1461 {
1462 if (sig == TARGET_SIGNAL_UNKNOWN)
1463 /* I think the code which prints this will always print it along with
1464 the string, so no need to be verbose. */
1465 return "?";
1466 return signals[sig].name;
1467 }
1468
1469 /* Given a name, return its signal. */
1470 enum target_signal
1471 target_signal_from_name (char *name)
1472 {
1473 enum target_signal sig;
1474
1475 /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
1476 for TARGET_SIGNAL_SIGCHLD. SIGIOT, on the other hand, is more
1477 questionable; seems like by now people should call it SIGABRT
1478 instead. */
1479
1480 /* This ugly cast brought to you by the native VAX compiler. */
1481 for (sig = TARGET_SIGNAL_HUP;
1482 signals[sig].name != NULL;
1483 sig = (enum target_signal) ((int) sig + 1))
1484 if (STREQ (name, signals[sig].name))
1485 return sig;
1486 return TARGET_SIGNAL_UNKNOWN;
1487 }
1488 \f
1489 /* The following functions are to help certain targets deal
1490 with the signal/waitstatus stuff. They could just as well be in
1491 a file called native-utils.c or unixwaitstatus-utils.c or whatever. */
1492
1493 /* Convert host signal to our signals. */
1494 enum target_signal
1495 target_signal_from_host (int hostsig)
1496 {
1497 /* A switch statement would make sense but would require special kludges
1498 to deal with the cases where more than one signal has the same number. */
1499
1500 if (hostsig == 0)
1501 return TARGET_SIGNAL_0;
1502
1503 #if defined (SIGHUP)
1504 if (hostsig == SIGHUP)
1505 return TARGET_SIGNAL_HUP;
1506 #endif
1507 #if defined (SIGINT)
1508 if (hostsig == SIGINT)
1509 return TARGET_SIGNAL_INT;
1510 #endif
1511 #if defined (SIGQUIT)
1512 if (hostsig == SIGQUIT)
1513 return TARGET_SIGNAL_QUIT;
1514 #endif
1515 #if defined (SIGILL)
1516 if (hostsig == SIGILL)
1517 return TARGET_SIGNAL_ILL;
1518 #endif
1519 #if defined (SIGTRAP)
1520 if (hostsig == SIGTRAP)
1521 return TARGET_SIGNAL_TRAP;
1522 #endif
1523 #if defined (SIGABRT)
1524 if (hostsig == SIGABRT)
1525 return TARGET_SIGNAL_ABRT;
1526 #endif
1527 #if defined (SIGEMT)
1528 if (hostsig == SIGEMT)
1529 return TARGET_SIGNAL_EMT;
1530 #endif
1531 #if defined (SIGFPE)
1532 if (hostsig == SIGFPE)
1533 return TARGET_SIGNAL_FPE;
1534 #endif
1535 #if defined (SIGKILL)
1536 if (hostsig == SIGKILL)
1537 return TARGET_SIGNAL_KILL;
1538 #endif
1539 #if defined (SIGBUS)
1540 if (hostsig == SIGBUS)
1541 return TARGET_SIGNAL_BUS;
1542 #endif
1543 #if defined (SIGSEGV)
1544 if (hostsig == SIGSEGV)
1545 return TARGET_SIGNAL_SEGV;
1546 #endif
1547 #if defined (SIGSYS)
1548 if (hostsig == SIGSYS)
1549 return TARGET_SIGNAL_SYS;
1550 #endif
1551 #if defined (SIGPIPE)
1552 if (hostsig == SIGPIPE)
1553 return TARGET_SIGNAL_PIPE;
1554 #endif
1555 #if defined (SIGALRM)
1556 if (hostsig == SIGALRM)
1557 return TARGET_SIGNAL_ALRM;
1558 #endif
1559 #if defined (SIGTERM)
1560 if (hostsig == SIGTERM)
1561 return TARGET_SIGNAL_TERM;
1562 #endif
1563 #if defined (SIGUSR1)
1564 if (hostsig == SIGUSR1)
1565 return TARGET_SIGNAL_USR1;
1566 #endif
1567 #if defined (SIGUSR2)
1568 if (hostsig == SIGUSR2)
1569 return TARGET_SIGNAL_USR2;
1570 #endif
1571 #if defined (SIGCLD)
1572 if (hostsig == SIGCLD)
1573 return TARGET_SIGNAL_CHLD;
1574 #endif
1575 #if defined (SIGCHLD)
1576 if (hostsig == SIGCHLD)
1577 return TARGET_SIGNAL_CHLD;
1578 #endif
1579 #if defined (SIGPWR)
1580 if (hostsig == SIGPWR)
1581 return TARGET_SIGNAL_PWR;
1582 #endif
1583 #if defined (SIGWINCH)
1584 if (hostsig == SIGWINCH)
1585 return TARGET_SIGNAL_WINCH;
1586 #endif
1587 #if defined (SIGURG)
1588 if (hostsig == SIGURG)
1589 return TARGET_SIGNAL_URG;
1590 #endif
1591 #if defined (SIGIO)
1592 if (hostsig == SIGIO)
1593 return TARGET_SIGNAL_IO;
1594 #endif
1595 #if defined (SIGPOLL)
1596 if (hostsig == SIGPOLL)
1597 return TARGET_SIGNAL_POLL;
1598 #endif
1599 #if defined (SIGSTOP)
1600 if (hostsig == SIGSTOP)
1601 return TARGET_SIGNAL_STOP;
1602 #endif
1603 #if defined (SIGTSTP)
1604 if (hostsig == SIGTSTP)
1605 return TARGET_SIGNAL_TSTP;
1606 #endif
1607 #if defined (SIGCONT)
1608 if (hostsig == SIGCONT)
1609 return TARGET_SIGNAL_CONT;
1610 #endif
1611 #if defined (SIGTTIN)
1612 if (hostsig == SIGTTIN)
1613 return TARGET_SIGNAL_TTIN;
1614 #endif
1615 #if defined (SIGTTOU)
1616 if (hostsig == SIGTTOU)
1617 return TARGET_SIGNAL_TTOU;
1618 #endif
1619 #if defined (SIGVTALRM)
1620 if (hostsig == SIGVTALRM)
1621 return TARGET_SIGNAL_VTALRM;
1622 #endif
1623 #if defined (SIGPROF)
1624 if (hostsig == SIGPROF)
1625 return TARGET_SIGNAL_PROF;
1626 #endif
1627 #if defined (SIGXCPU)
1628 if (hostsig == SIGXCPU)
1629 return TARGET_SIGNAL_XCPU;
1630 #endif
1631 #if defined (SIGXFSZ)
1632 if (hostsig == SIGXFSZ)
1633 return TARGET_SIGNAL_XFSZ;
1634 #endif
1635 #if defined (SIGWIND)
1636 if (hostsig == SIGWIND)
1637 return TARGET_SIGNAL_WIND;
1638 #endif
1639 #if defined (SIGPHONE)
1640 if (hostsig == SIGPHONE)
1641 return TARGET_SIGNAL_PHONE;
1642 #endif
1643 #if defined (SIGLOST)
1644 if (hostsig == SIGLOST)
1645 return TARGET_SIGNAL_LOST;
1646 #endif
1647 #if defined (SIGWAITING)
1648 if (hostsig == SIGWAITING)
1649 return TARGET_SIGNAL_WAITING;
1650 #endif
1651 #if defined (SIGCANCEL)
1652 if (hostsig == SIGCANCEL)
1653 return TARGET_SIGNAL_CANCEL;
1654 #endif
1655 #if defined (SIGLWP)
1656 if (hostsig == SIGLWP)
1657 return TARGET_SIGNAL_LWP;
1658 #endif
1659 #if defined (SIGDANGER)
1660 if (hostsig == SIGDANGER)
1661 return TARGET_SIGNAL_DANGER;
1662 #endif
1663 #if defined (SIGGRANT)
1664 if (hostsig == SIGGRANT)
1665 return TARGET_SIGNAL_GRANT;
1666 #endif
1667 #if defined (SIGRETRACT)
1668 if (hostsig == SIGRETRACT)
1669 return TARGET_SIGNAL_RETRACT;
1670 #endif
1671 #if defined (SIGMSG)
1672 if (hostsig == SIGMSG)
1673 return TARGET_SIGNAL_MSG;
1674 #endif
1675 #if defined (SIGSOUND)
1676 if (hostsig == SIGSOUND)
1677 return TARGET_SIGNAL_SOUND;
1678 #endif
1679 #if defined (SIGSAK)
1680 if (hostsig == SIGSAK)
1681 return TARGET_SIGNAL_SAK;
1682 #endif
1683 #if defined (SIGPRIO)
1684 if (hostsig == SIGPRIO)
1685 return TARGET_SIGNAL_PRIO;
1686 #endif
1687
1688 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1689 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1690 if (hostsig == _NSIG + EXC_BAD_ACCESS)
1691 return TARGET_EXC_BAD_ACCESS;
1692 #endif
1693 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
1694 if (hostsig == _NSIG + EXC_BAD_INSTRUCTION)
1695 return TARGET_EXC_BAD_INSTRUCTION;
1696 #endif
1697 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
1698 if (hostsig == _NSIG + EXC_ARITHMETIC)
1699 return TARGET_EXC_ARITHMETIC;
1700 #endif
1701 #if defined (EXC_EMULATION) && defined (_NSIG)
1702 if (hostsig == _NSIG + EXC_EMULATION)
1703 return TARGET_EXC_EMULATION;
1704 #endif
1705 #if defined (EXC_SOFTWARE) && defined (_NSIG)
1706 if (hostsig == _NSIG + EXC_SOFTWARE)
1707 return TARGET_EXC_SOFTWARE;
1708 #endif
1709 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
1710 if (hostsig == _NSIG + EXC_BREAKPOINT)
1711 return TARGET_EXC_BREAKPOINT;
1712 #endif
1713
1714 #if defined (SIGINFO)
1715 if (hostsig == SIGINFO)
1716 return TARGET_SIGNAL_INFO;
1717 #endif
1718
1719 #if defined (REALTIME_LO)
1720 if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI)
1721 {
1722 /* This block of TARGET_SIGNAL_REALTIME value is in order. */
1723 if (33 <= hostsig && hostsig <= 63)
1724 return (enum target_signal)
1725 (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
1726 else if (hostsig == 32)
1727 return TARGET_SIGNAL_REALTIME_32;
1728 else
1729 error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
1730 }
1731 #endif
1732
1733 #if defined (SIGRTMIN)
1734 if (hostsig >= SIGRTMIN && hostsig <= SIGRTMAX)
1735 {
1736 /* This block of TARGET_SIGNAL_REALTIME value is in order. */
1737 if (33 <= hostsig && hostsig <= 63)
1738 return (enum target_signal)
1739 (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
1740 else
1741 error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
1742 }
1743 #endif
1744 return TARGET_SIGNAL_UNKNOWN;
1745 }
1746
1747 /* Convert a OURSIG (an enum target_signal) to the form used by the
1748 target operating system (refered to as the ``host'') or zero if the
1749 equivalent host signal is not available. Set/clear OURSIG_OK
1750 accordingly. */
1751
1752 static int
1753 do_target_signal_to_host (enum target_signal oursig,
1754 int *oursig_ok)
1755 {
1756 *oursig_ok = 1;
1757 switch (oursig)
1758 {
1759 case TARGET_SIGNAL_0:
1760 return 0;
1761
1762 #if defined (SIGHUP)
1763 case TARGET_SIGNAL_HUP:
1764 return SIGHUP;
1765 #endif
1766 #if defined (SIGINT)
1767 case TARGET_SIGNAL_INT:
1768 return SIGINT;
1769 #endif
1770 #if defined (SIGQUIT)
1771 case TARGET_SIGNAL_QUIT:
1772 return SIGQUIT;
1773 #endif
1774 #if defined (SIGILL)
1775 case TARGET_SIGNAL_ILL:
1776 return SIGILL;
1777 #endif
1778 #if defined (SIGTRAP)
1779 case TARGET_SIGNAL_TRAP:
1780 return SIGTRAP;
1781 #endif
1782 #if defined (SIGABRT)
1783 case TARGET_SIGNAL_ABRT:
1784 return SIGABRT;
1785 #endif
1786 #if defined (SIGEMT)
1787 case TARGET_SIGNAL_EMT:
1788 return SIGEMT;
1789 #endif
1790 #if defined (SIGFPE)
1791 case TARGET_SIGNAL_FPE:
1792 return SIGFPE;
1793 #endif
1794 #if defined (SIGKILL)
1795 case TARGET_SIGNAL_KILL:
1796 return SIGKILL;
1797 #endif
1798 #if defined (SIGBUS)
1799 case TARGET_SIGNAL_BUS:
1800 return SIGBUS;
1801 #endif
1802 #if defined (SIGSEGV)
1803 case TARGET_SIGNAL_SEGV:
1804 return SIGSEGV;
1805 #endif
1806 #if defined (SIGSYS)
1807 case TARGET_SIGNAL_SYS:
1808 return SIGSYS;
1809 #endif
1810 #if defined (SIGPIPE)
1811 case TARGET_SIGNAL_PIPE:
1812 return SIGPIPE;
1813 #endif
1814 #if defined (SIGALRM)
1815 case TARGET_SIGNAL_ALRM:
1816 return SIGALRM;
1817 #endif
1818 #if defined (SIGTERM)
1819 case TARGET_SIGNAL_TERM:
1820 return SIGTERM;
1821 #endif
1822 #if defined (SIGUSR1)
1823 case TARGET_SIGNAL_USR1:
1824 return SIGUSR1;
1825 #endif
1826 #if defined (SIGUSR2)
1827 case TARGET_SIGNAL_USR2:
1828 return SIGUSR2;
1829 #endif
1830 #if defined (SIGCHLD) || defined (SIGCLD)
1831 case TARGET_SIGNAL_CHLD:
1832 #if defined (SIGCHLD)
1833 return SIGCHLD;
1834 #else
1835 return SIGCLD;
1836 #endif
1837 #endif /* SIGCLD or SIGCHLD */
1838 #if defined (SIGPWR)
1839 case TARGET_SIGNAL_PWR:
1840 return SIGPWR;
1841 #endif
1842 #if defined (SIGWINCH)
1843 case TARGET_SIGNAL_WINCH:
1844 return SIGWINCH;
1845 #endif
1846 #if defined (SIGURG)
1847 case TARGET_SIGNAL_URG:
1848 return SIGURG;
1849 #endif
1850 #if defined (SIGIO)
1851 case TARGET_SIGNAL_IO:
1852 return SIGIO;
1853 #endif
1854 #if defined (SIGPOLL)
1855 case TARGET_SIGNAL_POLL:
1856 return SIGPOLL;
1857 #endif
1858 #if defined (SIGSTOP)
1859 case TARGET_SIGNAL_STOP:
1860 return SIGSTOP;
1861 #endif
1862 #if defined (SIGTSTP)
1863 case TARGET_SIGNAL_TSTP:
1864 return SIGTSTP;
1865 #endif
1866 #if defined (SIGCONT)
1867 case TARGET_SIGNAL_CONT:
1868 return SIGCONT;
1869 #endif
1870 #if defined (SIGTTIN)
1871 case TARGET_SIGNAL_TTIN:
1872 return SIGTTIN;
1873 #endif
1874 #if defined (SIGTTOU)
1875 case TARGET_SIGNAL_TTOU:
1876 return SIGTTOU;
1877 #endif
1878 #if defined (SIGVTALRM)
1879 case TARGET_SIGNAL_VTALRM:
1880 return SIGVTALRM;
1881 #endif
1882 #if defined (SIGPROF)
1883 case TARGET_SIGNAL_PROF:
1884 return SIGPROF;
1885 #endif
1886 #if defined (SIGXCPU)
1887 case TARGET_SIGNAL_XCPU:
1888 return SIGXCPU;
1889 #endif
1890 #if defined (SIGXFSZ)
1891 case TARGET_SIGNAL_XFSZ:
1892 return SIGXFSZ;
1893 #endif
1894 #if defined (SIGWIND)
1895 case TARGET_SIGNAL_WIND:
1896 return SIGWIND;
1897 #endif
1898 #if defined (SIGPHONE)
1899 case TARGET_SIGNAL_PHONE:
1900 return SIGPHONE;
1901 #endif
1902 #if defined (SIGLOST)
1903 case TARGET_SIGNAL_LOST:
1904 return SIGLOST;
1905 #endif
1906 #if defined (SIGWAITING)
1907 case TARGET_SIGNAL_WAITING:
1908 return SIGWAITING;
1909 #endif
1910 #if defined (SIGCANCEL)
1911 case TARGET_SIGNAL_CANCEL:
1912 return SIGCANCEL;
1913 #endif
1914 #if defined (SIGLWP)
1915 case TARGET_SIGNAL_LWP:
1916 return SIGLWP;
1917 #endif
1918 #if defined (SIGDANGER)
1919 case TARGET_SIGNAL_DANGER:
1920 return SIGDANGER;
1921 #endif
1922 #if defined (SIGGRANT)
1923 case TARGET_SIGNAL_GRANT:
1924 return SIGGRANT;
1925 #endif
1926 #if defined (SIGRETRACT)
1927 case TARGET_SIGNAL_RETRACT:
1928 return SIGRETRACT;
1929 #endif
1930 #if defined (SIGMSG)
1931 case TARGET_SIGNAL_MSG:
1932 return SIGMSG;
1933 #endif
1934 #if defined (SIGSOUND)
1935 case TARGET_SIGNAL_SOUND:
1936 return SIGSOUND;
1937 #endif
1938 #if defined (SIGSAK)
1939 case TARGET_SIGNAL_SAK:
1940 return SIGSAK;
1941 #endif
1942 #if defined (SIGPRIO)
1943 case TARGET_SIGNAL_PRIO:
1944 return SIGPRIO;
1945 #endif
1946
1947 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
1948 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
1949 case TARGET_EXC_BAD_ACCESS:
1950 return _NSIG + EXC_BAD_ACCESS;
1951 #endif
1952 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
1953 case TARGET_EXC_BAD_INSTRUCTION:
1954 return _NSIG + EXC_BAD_INSTRUCTION;
1955 #endif
1956 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
1957 case TARGET_EXC_ARITHMETIC:
1958 return _NSIG + EXC_ARITHMETIC;
1959 #endif
1960 #if defined (EXC_EMULATION) && defined (_NSIG)
1961 case TARGET_EXC_EMULATION:
1962 return _NSIG + EXC_EMULATION;
1963 #endif
1964 #if defined (EXC_SOFTWARE) && defined (_NSIG)
1965 case TARGET_EXC_SOFTWARE:
1966 return _NSIG + EXC_SOFTWARE;
1967 #endif
1968 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
1969 case TARGET_EXC_BREAKPOINT:
1970 return _NSIG + EXC_BREAKPOINT;
1971 #endif
1972
1973 #if defined (SIGINFO)
1974 case TARGET_SIGNAL_INFO:
1975 return SIGINFO;
1976 #endif
1977
1978 default:
1979 #if defined (REALTIME_LO)
1980 if (oursig >= TARGET_SIGNAL_REALTIME_33
1981 && oursig <= TARGET_SIGNAL_REALTIME_63)
1982 {
1983 /* This block of signals is continuous, and
1984 TARGET_SIGNAL_REALTIME_33 is 33 by definition. */
1985 int retsig =
1986 (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
1987 if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
1988 return retsig;
1989 }
1990 #if (REALTIME_LO < 33)
1991 else if (oursig == TARGET_SIGNAL_REALTIME_32)
1992 {
1993 /* TARGET_SIGNAL_REALTIME_32 isn't contiguous with
1994 TARGET_SIGNAL_REALTIME_33. It is 32 by definition. */
1995 return 32;
1996 }
1997 #endif
1998 #endif
1999
2000 #if defined (SIGRTMIN)
2001 if (oursig >= TARGET_SIGNAL_REALTIME_33
2002 && oursig <= TARGET_SIGNAL_REALTIME_63)
2003 {
2004 /* This block of signals is continuous, and
2005 TARGET_SIGNAL_REALTIME_33 is 33 by definition. */
2006 int retsig =
2007 (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
2008 if (retsig >= SIGRTMIN && retsig <= SIGRTMAX)
2009 return retsig;
2010 }
2011 #endif
2012 *oursig_ok = 0;
2013 return 0;
2014 }
2015 }
2016
2017 int
2018 target_signal_to_host_p (enum target_signal oursig)
2019 {
2020 int oursig_ok;
2021 do_target_signal_to_host (oursig, &oursig_ok);
2022 return oursig_ok;
2023 }
2024
2025 int
2026 target_signal_to_host (enum target_signal oursig)
2027 {
2028 int oursig_ok;
2029 int targ_signo = do_target_signal_to_host (oursig, &oursig_ok);
2030 if (!oursig_ok)
2031 {
2032 /* The user might be trying to do "signal SIGSAK" where this system
2033 doesn't have SIGSAK. */
2034 warning ("Signal %s does not exist on this system.\n",
2035 target_signal_to_name (oursig));
2036 return 0;
2037 }
2038 else
2039 return targ_signo;
2040 }
2041
2042 /* Helper function for child_wait and the Lynx derivatives of child_wait.
2043 HOSTSTATUS is the waitstatus from wait() or the equivalent; store our
2044 translation of that in OURSTATUS. */
2045 void
2046 store_waitstatus (struct target_waitstatus *ourstatus, int hoststatus)
2047 {
2048 #ifdef CHILD_SPECIAL_WAITSTATUS
2049 /* CHILD_SPECIAL_WAITSTATUS should return nonzero and set *OURSTATUS
2050 if it wants to deal with hoststatus. */
2051 if (CHILD_SPECIAL_WAITSTATUS (ourstatus, hoststatus))
2052 return;
2053 #endif
2054
2055 if (WIFEXITED (hoststatus))
2056 {
2057 ourstatus->kind = TARGET_WAITKIND_EXITED;
2058 ourstatus->value.integer = WEXITSTATUS (hoststatus);
2059 }
2060 else if (!WIFSTOPPED (hoststatus))
2061 {
2062 ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
2063 ourstatus->value.sig = target_signal_from_host (WTERMSIG (hoststatus));
2064 }
2065 else
2066 {
2067 ourstatus->kind = TARGET_WAITKIND_STOPPED;
2068 ourstatus->value.sig = target_signal_from_host (WSTOPSIG (hoststatus));
2069 }
2070 }
2071 \f
2072 /* In some circumstances we allow a command to specify a numeric
2073 signal. The idea is to keep these circumstances limited so that
2074 users (and scripts) develop portable habits. For comparison,
2075 POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a
2076 numeric signal at all is obscelescent. We are slightly more
2077 lenient and allow 1-15 which should match host signal numbers on
2078 most systems. Use of symbolic signal names is strongly encouraged. */
2079
2080 enum target_signal
2081 target_signal_from_command (int num)
2082 {
2083 if (num >= 1 && num <= 15)
2084 return (enum target_signal) num;
2085 error ("Only signals 1-15 are valid as numeric signals.\n\
2086 Use \"info signals\" for a list of symbolic signals.");
2087 }
2088 \f
2089 /* Returns zero to leave the inferior alone, one to interrupt it. */
2090 int (*target_activity_function) (void);
2091 int target_activity_fd;
2092 \f
2093 /* Convert a normal process ID to a string. Returns the string in a static
2094 buffer. */
2095
2096 char *
2097 normal_pid_to_str (int pid)
2098 {
2099 static char buf[30];
2100
2101 if (STREQ (current_target.to_shortname, "remote"))
2102 sprintf (buf, "thread %d", pid);
2103 else
2104 sprintf (buf, "process %d", pid);
2105
2106 return buf;
2107 }
2108
2109 /* Some targets (such as ttrace-based HPUX) don't allow us to request
2110 notification of inferior events such as fork and vork immediately
2111 after the inferior is created. (This because of how gdb gets an
2112 inferior created via invoking a shell to do it. In such a scenario,
2113 if the shell init file has commands in it, the shell will fork and
2114 exec for each of those commands, and we will see each such fork
2115 event. Very bad.)
2116
2117 This function is used by all targets that allow us to request
2118 notification of forks, etc at inferior creation time; e.g., in
2119 target_acknowledge_forked_child.
2120 */
2121 static void
2122 normal_target_post_startup_inferior (int pid)
2123 {
2124 /* This space intentionally left blank. */
2125 }
2126
2127 /* Set up the handful of non-empty slots needed by the dummy target
2128 vector. */
2129
2130 static void
2131 init_dummy_target (void)
2132 {
2133 dummy_target.to_shortname = "None";
2134 dummy_target.to_longname = "None";
2135 dummy_target.to_doc = "";
2136 dummy_target.to_attach = find_default_attach;
2137 dummy_target.to_require_attach = find_default_require_attach;
2138 dummy_target.to_require_detach = find_default_require_detach;
2139 dummy_target.to_create_inferior = find_default_create_inferior;
2140 dummy_target.to_clone_and_follow_inferior = find_default_clone_and_follow_inferior;
2141 dummy_target.to_pid_to_str = normal_pid_to_str;
2142 dummy_target.to_stratum = dummy_stratum;
2143 dummy_target.to_magic = OPS_MAGIC;
2144 }
2145 \f
2146
2147 static struct target_ops debug_target;
2148
2149 static void
2150 debug_to_open (char *args, int from_tty)
2151 {
2152 debug_target.to_open (args, from_tty);
2153
2154 fprintf_unfiltered (gdb_stdlog, "target_open (%s, %d)\n", args, from_tty);
2155 }
2156
2157 static void
2158 debug_to_close (int quitting)
2159 {
2160 debug_target.to_close (quitting);
2161
2162 fprintf_unfiltered (gdb_stdlog, "target_close (%d)\n", quitting);
2163 }
2164
2165 static void
2166 debug_to_attach (char *args, int from_tty)
2167 {
2168 debug_target.to_attach (args, from_tty);
2169
2170 fprintf_unfiltered (gdb_stdlog, "target_attach (%s, %d)\n", args, from_tty);
2171 }
2172
2173
2174 static void
2175 debug_to_post_attach (int pid)
2176 {
2177 debug_target.to_post_attach (pid);
2178
2179 fprintf_unfiltered (gdb_stdlog, "target_post_attach (%d)\n", pid);
2180 }
2181
2182 static void
2183 debug_to_require_attach (char *args, int from_tty)
2184 {
2185 debug_target.to_require_attach (args, from_tty);
2186
2187 fprintf_unfiltered (gdb_stdlog,
2188 "target_require_attach (%s, %d)\n", args, from_tty);
2189 }
2190
2191 static void
2192 debug_to_detach (char *args, int from_tty)
2193 {
2194 debug_target.to_detach (args, from_tty);
2195
2196 fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n", args, from_tty);
2197 }
2198
2199 static void
2200 debug_to_require_detach (int pid, char *args, int from_tty)
2201 {
2202 debug_target.to_require_detach (pid, args, from_tty);
2203
2204 fprintf_unfiltered (gdb_stdlog,
2205 "target_require_detach (%d, %s, %d)\n", pid, args, from_tty);
2206 }
2207
2208 static void
2209 debug_to_resume (int pid, int step, enum target_signal siggnal)
2210 {
2211 debug_target.to_resume (pid, step, siggnal);
2212
2213 fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n", pid,
2214 step ? "step" : "continue",
2215 target_signal_to_name (siggnal));
2216 }
2217
2218 static int
2219 debug_to_wait (int pid, struct target_waitstatus *status)
2220 {
2221 int retval;
2222
2223 retval = debug_target.to_wait (pid, status);
2224
2225 fprintf_unfiltered (gdb_stdlog,
2226 "target_wait (%d, status) = %d, ", pid, retval);
2227 fprintf_unfiltered (gdb_stdlog, "status->kind = ");
2228 switch (status->kind)
2229 {
2230 case TARGET_WAITKIND_EXITED:
2231 fprintf_unfiltered (gdb_stdlog, "exited, status = %d\n",
2232 status->value.integer);
2233 break;
2234 case TARGET_WAITKIND_STOPPED:
2235 fprintf_unfiltered (gdb_stdlog, "stopped, signal = %s\n",
2236 target_signal_to_name (status->value.sig));
2237 break;
2238 case TARGET_WAITKIND_SIGNALLED:
2239 fprintf_unfiltered (gdb_stdlog, "signalled, signal = %s\n",
2240 target_signal_to_name (status->value.sig));
2241 break;
2242 case TARGET_WAITKIND_LOADED:
2243 fprintf_unfiltered (gdb_stdlog, "loaded\n");
2244 break;
2245 case TARGET_WAITKIND_FORKED:
2246 fprintf_unfiltered (gdb_stdlog, "forked\n");
2247 break;
2248 case TARGET_WAITKIND_VFORKED:
2249 fprintf_unfiltered (gdb_stdlog, "vforked\n");
2250 break;
2251 case TARGET_WAITKIND_EXECD:
2252 fprintf_unfiltered (gdb_stdlog, "execd\n");
2253 break;
2254 case TARGET_WAITKIND_SPURIOUS:
2255 fprintf_unfiltered (gdb_stdlog, "spurious\n");
2256 break;
2257 default:
2258 fprintf_unfiltered (gdb_stdlog, "unknown???\n");
2259 break;
2260 }
2261
2262 return retval;
2263 }
2264
2265 static void
2266 debug_to_post_wait (int pid, int status)
2267 {
2268 debug_target.to_post_wait (pid, status);
2269
2270 fprintf_unfiltered (gdb_stdlog, "target_post_wait (%d, %d)\n",
2271 pid, status);
2272 }
2273
2274 static void
2275 debug_to_fetch_registers (int regno)
2276 {
2277 debug_target.to_fetch_registers (regno);
2278
2279 fprintf_unfiltered (gdb_stdlog, "target_fetch_registers (%s)",
2280 regno != -1 ? REGISTER_NAME (regno) : "-1");
2281 if (regno != -1)
2282 fprintf_unfiltered (gdb_stdlog, " = 0x%lx %ld",
2283 (unsigned long) read_register (regno),
2284 (unsigned long) read_register (regno));
2285 fprintf_unfiltered (gdb_stdlog, "\n");
2286 }
2287
2288 static void
2289 debug_to_store_registers (int regno)
2290 {
2291 debug_target.to_store_registers (regno);
2292
2293 if (regno >= 0 && regno < NUM_REGS)
2294 fprintf_unfiltered (gdb_stdlog, "target_store_registers (%s) = 0x%lx %ld\n",
2295 REGISTER_NAME (regno),
2296 (unsigned long) read_register (regno),
2297 (unsigned long) read_register (regno));
2298 else
2299 fprintf_unfiltered (gdb_stdlog, "target_store_registers (%d)\n", regno);
2300 }
2301
2302 static void
2303 debug_to_prepare_to_store (void)
2304 {
2305 debug_target.to_prepare_to_store ();
2306
2307 fprintf_unfiltered (gdb_stdlog, "target_prepare_to_store ()\n");
2308 }
2309
2310 static int
2311 debug_to_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
2312 struct target_ops *target)
2313 {
2314 int retval;
2315
2316 retval = debug_target.to_xfer_memory (memaddr, myaddr, len, write, target);
2317
2318 fprintf_unfiltered (gdb_stdlog,
2319 "target_xfer_memory (0x%x, xxx, %d, %s, xxx) = %d",
2320 (unsigned int) memaddr, /* possable truncate long long */
2321 len, write ? "write" : "read", retval);
2322
2323
2324
2325 if (retval > 0)
2326 {
2327 int i;
2328
2329 fputs_unfiltered (", bytes =", gdb_stdlog);
2330 for (i = 0; i < retval; i++)
2331 {
2332 if ((((long) &(myaddr[i])) & 0xf) == 0)
2333 fprintf_unfiltered (gdb_stdlog, "\n");
2334 fprintf_unfiltered (gdb_stdlog, " %02x", myaddr[i] & 0xff);
2335 }
2336 }
2337
2338 fputc_unfiltered ('\n', gdb_stdlog);
2339
2340 return retval;
2341 }
2342
2343 static void
2344 debug_to_files_info (struct target_ops *target)
2345 {
2346 debug_target.to_files_info (target);
2347
2348 fprintf_unfiltered (gdb_stdlog, "target_files_info (xxx)\n");
2349 }
2350
2351 static int
2352 debug_to_insert_breakpoint (CORE_ADDR addr, char *save)
2353 {
2354 int retval;
2355
2356 retval = debug_target.to_insert_breakpoint (addr, save);
2357
2358 fprintf_unfiltered (gdb_stdlog,
2359 "target_insert_breakpoint (0x%lx, xxx) = %ld\n",
2360 (unsigned long) addr,
2361 (unsigned long) retval);
2362 return retval;
2363 }
2364
2365 static int
2366 debug_to_remove_breakpoint (CORE_ADDR addr, char *save)
2367 {
2368 int retval;
2369
2370 retval = debug_target.to_remove_breakpoint (addr, save);
2371
2372 fprintf_unfiltered (gdb_stdlog,
2373 "target_remove_breakpoint (0x%lx, xxx) = %ld\n",
2374 (unsigned long) addr,
2375 (unsigned long) retval);
2376 return retval;
2377 }
2378
2379 static void
2380 debug_to_terminal_init (void)
2381 {
2382 debug_target.to_terminal_init ();
2383
2384 fprintf_unfiltered (gdb_stdlog, "target_terminal_init ()\n");
2385 }
2386
2387 static void
2388 debug_to_terminal_inferior (void)
2389 {
2390 debug_target.to_terminal_inferior ();
2391
2392 fprintf_unfiltered (gdb_stdlog, "target_terminal_inferior ()\n");
2393 }
2394
2395 static void
2396 debug_to_terminal_ours_for_output (void)
2397 {
2398 debug_target.to_terminal_ours_for_output ();
2399
2400 fprintf_unfiltered (gdb_stdlog, "target_terminal_ours_for_output ()\n");
2401 }
2402
2403 static void
2404 debug_to_terminal_ours (void)
2405 {
2406 debug_target.to_terminal_ours ();
2407
2408 fprintf_unfiltered (gdb_stdlog, "target_terminal_ours ()\n");
2409 }
2410
2411 static void
2412 debug_to_terminal_info (char *arg, int from_tty)
2413 {
2414 debug_target.to_terminal_info (arg, from_tty);
2415
2416 fprintf_unfiltered (gdb_stdlog, "target_terminal_info (%s, %d)\n", arg,
2417 from_tty);
2418 }
2419
2420 static void
2421 debug_to_kill (void)
2422 {
2423 debug_target.to_kill ();
2424
2425 fprintf_unfiltered (gdb_stdlog, "target_kill ()\n");
2426 }
2427
2428 static void
2429 debug_to_load (char *args, int from_tty)
2430 {
2431 debug_target.to_load (args, from_tty);
2432
2433 fprintf_unfiltered (gdb_stdlog, "target_load (%s, %d)\n", args, from_tty);
2434 }
2435
2436 static int
2437 debug_to_lookup_symbol (char *name, CORE_ADDR *addrp)
2438 {
2439 int retval;
2440
2441 retval = debug_target.to_lookup_symbol (name, addrp);
2442
2443 fprintf_unfiltered (gdb_stdlog, "target_lookup_symbol (%s, xxx)\n", name);
2444
2445 return retval;
2446 }
2447
2448 static void
2449 debug_to_create_inferior (char *exec_file, char *args, char **env)
2450 {
2451 debug_target.to_create_inferior (exec_file, args, env);
2452
2453 fprintf_unfiltered (gdb_stdlog, "target_create_inferior (%s, %s, xxx)\n",
2454 exec_file, args);
2455 }
2456
2457 static void
2458 debug_to_post_startup_inferior (int pid)
2459 {
2460 debug_target.to_post_startup_inferior (pid);
2461
2462 fprintf_unfiltered (gdb_stdlog, "target_post_startup_inferior (%d)\n",
2463 pid);
2464 }
2465
2466 static void
2467 debug_to_acknowledge_created_inferior (int pid)
2468 {
2469 debug_target.to_acknowledge_created_inferior (pid);
2470
2471 fprintf_unfiltered (gdb_stdlog, "target_acknowledge_created_inferior (%d)\n",
2472 pid);
2473 }
2474
2475 static void
2476 debug_to_clone_and_follow_inferior (int child_pid, int *followed_child)
2477 {
2478 debug_target.to_clone_and_follow_inferior (child_pid, followed_child);
2479
2480 fprintf_unfiltered (gdb_stdlog,
2481 "target_clone_and_follow_inferior (%d, %d)\n",
2482 child_pid, *followed_child);
2483 }
2484
2485 static void
2486 debug_to_post_follow_inferior_by_clone (void)
2487 {
2488 debug_target.to_post_follow_inferior_by_clone ();
2489
2490 fprintf_unfiltered (gdb_stdlog, "target_post_follow_inferior_by_clone ()\n");
2491 }
2492
2493 static int
2494 debug_to_insert_fork_catchpoint (int pid)
2495 {
2496 int retval;
2497
2498 retval = debug_target.to_insert_fork_catchpoint (pid);
2499
2500 fprintf_unfiltered (gdb_stdlog, "target_insert_fork_catchpoint (%d) = %d\n",
2501 pid, retval);
2502
2503 return retval;
2504 }
2505
2506 static int
2507 debug_to_remove_fork_catchpoint (int pid)
2508 {
2509 int retval;
2510
2511 retval = debug_target.to_remove_fork_catchpoint (pid);
2512
2513 fprintf_unfiltered (gdb_stdlog, "target_remove_fork_catchpoint (%d) = %d\n",
2514 pid, retval);
2515
2516 return retval;
2517 }
2518
2519 static int
2520 debug_to_insert_vfork_catchpoint (int pid)
2521 {
2522 int retval;
2523
2524 retval = debug_target.to_insert_vfork_catchpoint (pid);
2525
2526 fprintf_unfiltered (gdb_stdlog, "target_insert_vfork_catchpoint (%d)= %d\n",
2527 pid, retval);
2528
2529 return retval;
2530 }
2531
2532 static int
2533 debug_to_remove_vfork_catchpoint (int pid)
2534 {
2535 int retval;
2536
2537 retval = debug_target.to_remove_vfork_catchpoint (pid);
2538
2539 fprintf_unfiltered (gdb_stdlog, "target_remove_vfork_catchpoint (%d) = %d\n",
2540 pid, retval);
2541
2542 return retval;
2543 }
2544
2545 static int
2546 debug_to_has_forked (int pid, int *child_pid)
2547 {
2548 int has_forked;
2549
2550 has_forked = debug_target.to_has_forked (pid, child_pid);
2551
2552 fprintf_unfiltered (gdb_stdlog, "target_has_forked (%d, %d) = %d\n",
2553 pid, *child_pid, has_forked);
2554
2555 return has_forked;
2556 }
2557
2558 static int
2559 debug_to_has_vforked (int pid, int *child_pid)
2560 {
2561 int has_vforked;
2562
2563 has_vforked = debug_target.to_has_vforked (pid, child_pid);
2564
2565 fprintf_unfiltered (gdb_stdlog, "target_has_vforked (%d, %d) = %d\n",
2566 pid, *child_pid, has_vforked);
2567
2568 return has_vforked;
2569 }
2570
2571 static int
2572 debug_to_can_follow_vfork_prior_to_exec (void)
2573 {
2574 int can_immediately_follow_vfork;
2575
2576 can_immediately_follow_vfork = debug_target.to_can_follow_vfork_prior_to_exec ();
2577
2578 fprintf_unfiltered (gdb_stdlog, "target_can_follow_vfork_prior_to_exec () = %d\n",
2579 can_immediately_follow_vfork);
2580
2581 return can_immediately_follow_vfork;
2582 }
2583
2584 static void
2585 debug_to_post_follow_vfork (int parent_pid, int followed_parent, int child_pid,
2586 int followed_child)
2587 {
2588 debug_target.to_post_follow_vfork (parent_pid, followed_parent, child_pid, followed_child);
2589
2590 fprintf_unfiltered (gdb_stdlog,
2591 "target_post_follow_vfork (%d, %d, %d, %d)\n",
2592 parent_pid, followed_parent, child_pid, followed_child);
2593 }
2594
2595 static int
2596 debug_to_insert_exec_catchpoint (int pid)
2597 {
2598 int retval;
2599
2600 retval = debug_target.to_insert_exec_catchpoint (pid);
2601
2602 fprintf_unfiltered (gdb_stdlog, "target_insert_exec_catchpoint (%d) = %d\n",
2603 pid, retval);
2604
2605 return retval;
2606 }
2607
2608 static int
2609 debug_to_remove_exec_catchpoint (int pid)
2610 {
2611 int retval;
2612
2613 retval = debug_target.to_remove_exec_catchpoint (pid);
2614
2615 fprintf_unfiltered (gdb_stdlog, "target_remove_exec_catchpoint (%d) = %d\n",
2616 pid, retval);
2617
2618 return retval;
2619 }
2620
2621 static int
2622 debug_to_has_execd (int pid, char **execd_pathname)
2623 {
2624 int has_execd;
2625
2626 has_execd = debug_target.to_has_execd (pid, execd_pathname);
2627
2628 fprintf_unfiltered (gdb_stdlog, "target_has_execd (%d, %s) = %d\n",
2629 pid, (*execd_pathname ? *execd_pathname : "<NULL>"),
2630 has_execd);
2631
2632 return has_execd;
2633 }
2634
2635 static int
2636 debug_to_reported_exec_events_per_exec_call (void)
2637 {
2638 int reported_exec_events;
2639
2640 reported_exec_events = debug_target.to_reported_exec_events_per_exec_call ();
2641
2642 fprintf_unfiltered (gdb_stdlog,
2643 "target_reported_exec_events_per_exec_call () = %d\n",
2644 reported_exec_events);
2645
2646 return reported_exec_events;
2647 }
2648
2649 static int
2650 debug_to_has_syscall_event (int pid, enum target_waitkind *kind,
2651 int *syscall_id)
2652 {
2653 int has_syscall_event;
2654 char *kind_spelling = "??";
2655
2656 has_syscall_event = debug_target.to_has_syscall_event (pid, kind, syscall_id);
2657 if (has_syscall_event)
2658 {
2659 switch (*kind)
2660 {
2661 case TARGET_WAITKIND_SYSCALL_ENTRY:
2662 kind_spelling = "SYSCALL_ENTRY";
2663 break;
2664 case TARGET_WAITKIND_SYSCALL_RETURN:
2665 kind_spelling = "SYSCALL_RETURN";
2666 break;
2667 default:
2668 break;
2669 }
2670 }
2671
2672 fprintf_unfiltered (gdb_stdlog,
2673 "target_has_syscall_event (%d, %s, %d) = %d\n",
2674 pid, kind_spelling, *syscall_id, has_syscall_event);
2675
2676 return has_syscall_event;
2677 }
2678
2679 static int
2680 debug_to_has_exited (int pid, int wait_status, int *exit_status)
2681 {
2682 int has_exited;
2683
2684 has_exited = debug_target.to_has_exited (pid, wait_status, exit_status);
2685
2686 fprintf_unfiltered (gdb_stdlog, "target_has_exited (%d, %d, %d) = %d\n",
2687 pid, wait_status, *exit_status, has_exited);
2688
2689 return has_exited;
2690 }
2691
2692 static void
2693 debug_to_mourn_inferior (void)
2694 {
2695 debug_target.to_mourn_inferior ();
2696
2697 fprintf_unfiltered (gdb_stdlog, "target_mourn_inferior ()\n");
2698 }
2699
2700 static int
2701 debug_to_can_run (void)
2702 {
2703 int retval;
2704
2705 retval = debug_target.to_can_run ();
2706
2707 fprintf_unfiltered (gdb_stdlog, "target_can_run () = %d\n", retval);
2708
2709 return retval;
2710 }
2711
2712 static void
2713 debug_to_notice_signals (int pid)
2714 {
2715 debug_target.to_notice_signals (pid);
2716
2717 fprintf_unfiltered (gdb_stdlog, "target_notice_signals (%d)\n", pid);
2718 }
2719
2720 static int
2721 debug_to_thread_alive (int pid)
2722 {
2723 int retval;
2724
2725 retval = debug_target.to_thread_alive (pid);
2726
2727 fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n",
2728 pid, retval);
2729
2730 return retval;
2731 }
2732
2733 static void
2734 debug_to_find_new_threads (void)
2735 {
2736 debug_target.to_find_new_threads ();
2737
2738 fputs_unfiltered ("target_find_new_threads ()\n", gdb_stdlog);
2739 }
2740
2741 static void
2742 debug_to_stop (void)
2743 {
2744 debug_target.to_stop ();
2745
2746 fprintf_unfiltered (gdb_stdlog, "target_stop ()\n");
2747 }
2748
2749 static int
2750 debug_to_query (int type, char *req, char *resp, int *siz)
2751 {
2752 int retval;
2753
2754 retval = debug_target.to_query (type, req, resp, siz);
2755
2756 fprintf_unfiltered (gdb_stdlog, "target_query (%c, %s, %s, %d) = %d\n", type, req, resp, *siz, retval);
2757
2758 return retval;
2759 }
2760
2761 static void
2762 debug_to_rcmd (char *command,
2763 struct ui_file *outbuf)
2764 {
2765 debug_target.to_rcmd (command, outbuf);
2766 fprintf_unfiltered (gdb_stdlog, "target_rcmd (%s, ...)\n", command);
2767 }
2768
2769 static struct symtab_and_line *
2770 debug_to_enable_exception_callback (enum exception_event_kind kind, int enable)
2771 {
2772 struct symtab_and_line *result;
2773 result = debug_target.to_enable_exception_callback (kind, enable);
2774 fprintf_unfiltered (gdb_stdlog,
2775 "target get_exception_callback_sal (%d, %d)\n",
2776 kind, enable);
2777 return result;
2778 }
2779
2780 static struct exception_event_record *
2781 debug_to_get_current_exception_event (void)
2782 {
2783 struct exception_event_record *result;
2784 result = debug_target.to_get_current_exception_event ();
2785 fprintf_unfiltered (gdb_stdlog, "target get_current_exception_event ()\n");
2786 return result;
2787 }
2788
2789 static char *
2790 debug_to_pid_to_exec_file (int pid)
2791 {
2792 char *exec_file;
2793
2794 exec_file = debug_target.to_pid_to_exec_file (pid);
2795
2796 fprintf_unfiltered (gdb_stdlog, "target_pid_to_exec_file (%d) = %s\n",
2797 pid, exec_file);
2798
2799 return exec_file;
2800 }
2801
2802 static char *
2803 debug_to_core_file_to_sym_file (char *core)
2804 {
2805 char *sym_file;
2806
2807 sym_file = debug_target.to_core_file_to_sym_file (core);
2808
2809 fprintf_unfiltered (gdb_stdlog, "target_core_file_to_sym_file (%s) = %s\n",
2810 core, sym_file);
2811
2812 return sym_file;
2813 }
2814
2815 static void
2816 setup_target_debug (void)
2817 {
2818 memcpy (&debug_target, &current_target, sizeof debug_target);
2819
2820 current_target.to_open = debug_to_open;
2821 current_target.to_close = debug_to_close;
2822 current_target.to_attach = debug_to_attach;
2823 current_target.to_post_attach = debug_to_post_attach;
2824 current_target.to_require_attach = debug_to_require_attach;
2825 current_target.to_detach = debug_to_detach;
2826 current_target.to_require_detach = debug_to_require_detach;
2827 current_target.to_resume = debug_to_resume;
2828 current_target.to_wait = debug_to_wait;
2829 current_target.to_post_wait = debug_to_post_wait;
2830 current_target.to_fetch_registers = debug_to_fetch_registers;
2831 current_target.to_store_registers = debug_to_store_registers;
2832 current_target.to_prepare_to_store = debug_to_prepare_to_store;
2833 current_target.to_xfer_memory = debug_to_xfer_memory;
2834 current_target.to_files_info = debug_to_files_info;
2835 current_target.to_insert_breakpoint = debug_to_insert_breakpoint;
2836 current_target.to_remove_breakpoint = debug_to_remove_breakpoint;
2837 current_target.to_terminal_init = debug_to_terminal_init;
2838 current_target.to_terminal_inferior = debug_to_terminal_inferior;
2839 current_target.to_terminal_ours_for_output = debug_to_terminal_ours_for_output;
2840 current_target.to_terminal_ours = debug_to_terminal_ours;
2841 current_target.to_terminal_info = debug_to_terminal_info;
2842 current_target.to_kill = debug_to_kill;
2843 current_target.to_load = debug_to_load;
2844 current_target.to_lookup_symbol = debug_to_lookup_symbol;
2845 current_target.to_create_inferior = debug_to_create_inferior;
2846 current_target.to_post_startup_inferior = debug_to_post_startup_inferior;
2847 current_target.to_acknowledge_created_inferior = debug_to_acknowledge_created_inferior;
2848 current_target.to_clone_and_follow_inferior = debug_to_clone_and_follow_inferior;
2849 current_target.to_post_follow_inferior_by_clone = debug_to_post_follow_inferior_by_clone;
2850 current_target.to_insert_fork_catchpoint = debug_to_insert_fork_catchpoint;
2851 current_target.to_remove_fork_catchpoint = debug_to_remove_fork_catchpoint;
2852 current_target.to_insert_vfork_catchpoint = debug_to_insert_vfork_catchpoint;
2853 current_target.to_remove_vfork_catchpoint = debug_to_remove_vfork_catchpoint;
2854 current_target.to_has_forked = debug_to_has_forked;
2855 current_target.to_has_vforked = debug_to_has_vforked;
2856 current_target.to_can_follow_vfork_prior_to_exec = debug_to_can_follow_vfork_prior_to_exec;
2857 current_target.to_post_follow_vfork = debug_to_post_follow_vfork;
2858 current_target.to_insert_exec_catchpoint = debug_to_insert_exec_catchpoint;
2859 current_target.to_remove_exec_catchpoint = debug_to_remove_exec_catchpoint;
2860 current_target.to_has_execd = debug_to_has_execd;
2861 current_target.to_reported_exec_events_per_exec_call = debug_to_reported_exec_events_per_exec_call;
2862 current_target.to_has_syscall_event = debug_to_has_syscall_event;
2863 current_target.to_has_exited = debug_to_has_exited;
2864 current_target.to_mourn_inferior = debug_to_mourn_inferior;
2865 current_target.to_can_run = debug_to_can_run;
2866 current_target.to_notice_signals = debug_to_notice_signals;
2867 current_target.to_thread_alive = debug_to_thread_alive;
2868 current_target.to_find_new_threads = debug_to_find_new_threads;
2869 current_target.to_stop = debug_to_stop;
2870 current_target.to_query = debug_to_query;
2871 current_target.to_rcmd = debug_to_rcmd;
2872 current_target.to_enable_exception_callback = debug_to_enable_exception_callback;
2873 current_target.to_get_current_exception_event = debug_to_get_current_exception_event;
2874 current_target.to_pid_to_exec_file = debug_to_pid_to_exec_file;
2875 current_target.to_core_file_to_sym_file = debug_to_core_file_to_sym_file;
2876
2877 }
2878 \f
2879
2880 static char targ_desc[] =
2881 "Names of targets and files being debugged.\n\
2882 Shows the entire stack of targets currently in use (including the exec-file,\n\
2883 core-file, and process, if any), as well as the symbol file name.";
2884
2885 static void
2886 do_monitor_command (char *cmd,
2887 int from_tty)
2888 {
2889 if ((current_target.to_rcmd
2890 == (void (*) (char *, struct ui_file *)) tcomplain)
2891 || (current_target.to_rcmd == debug_to_rcmd
2892 && (debug_target.to_rcmd
2893 == (void (*) (char *, struct ui_file *)) tcomplain)))
2894 {
2895 error ("\"monitor\" command not supported by this target.\n");
2896 }
2897 target_rcmd (cmd, gdb_stdtarg);
2898 }
2899
2900 void
2901 initialize_targets (void)
2902 {
2903 init_dummy_target ();
2904 push_target (&dummy_target);
2905
2906 add_info ("target", target_info, targ_desc);
2907 add_info ("files", target_info, targ_desc);
2908
2909 add_show_from_set (
2910 add_set_cmd ("target", class_maintenance, var_zinteger,
2911 (char *) &targetdebug,
2912 "Set target debugging.\n\
2913 When non-zero, target debugging is enabled.", &setdebuglist),
2914 &showdebuglist);
2915
2916
2917 add_com ("monitor", class_obscure, do_monitor_command,
2918 "Send a command to the remote monitor (remote targets only).");
2919
2920 if (!STREQ (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC"))
2921 abort ();
2922 }
This page took 0.088439 seconds and 5 git commands to generate.