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