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