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