* gdbarch.sh: Add NUM_PSEUDO_REGS to the gdbarch structure.
[deliverable/binutils-gdb.git] / gdb / inferior.h
1 /* Variables that describe the inferior process running under GDB:
2 Where it is, why it stopped, and how to step it.
3 Copyright 1986, 1989, 1992, 1996, 1998 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 #if !defined (INFERIOR_H)
23 #define INFERIOR_H 1
24
25 /* For bpstat. */
26 #include "breakpoint.h"
27
28 /* For enum target_signal. */
29 #include "target.h"
30
31 /* Structure in which to save the status of the inferior. Create/Save
32 through "save_inferior_status", restore through
33 "restore_inferior_status".
34
35 This pair of routines should be called around any transfer of
36 control to the inferior which you don't want showing up in your
37 control variables. */
38
39 struct inferior_status;
40
41 extern struct inferior_status *save_inferior_status (int);
42
43 extern void restore_inferior_status (struct inferior_status *);
44
45 extern struct cleanup *make_cleanup_restore_inferior_status (struct inferior_status *);
46
47 extern void discard_inferior_status (struct inferior_status *);
48
49 extern void write_inferior_status_register (struct inferior_status
50 *inf_status, int regno,
51 LONGEST val);
52
53 /* This macro gives the number of registers actually in use by the
54 inferior. This may be less than the total number of registers,
55 perhaps depending on the actual CPU in use or program being run.
56 FIXME: This could be replaced by the new MULTI_ARCH capability. */
57
58 #ifndef ARCH_NUM_REGS
59 #define ARCH_NUM_REGS NUM_REGS
60 #endif
61
62 /* This function is called when the value of a pseudo-register needs
63 to be updated. Typically it will be defined on a per-architecture
64 basis. FIXME: move into gdbarch.[ch]. */
65 #ifndef ARCH_FETCH_PSEUDO_REGISTERS
66 #define ARCH_FETCH_PSEUDO_REGISTERS(REGNUM) /* no-op */
67 #endif
68
69 /* This function is called when the value of a pseudo-register needs
70 to be set or stored. Typically it will be defined on a per-architecture
71 basis. FIXME: move into gdbarch.[ch]. */
72 #ifndef ARCH_STORE_PSEUDO_REGISTERS
73 #define ARCH_STORE_PSEUDO_REGISTERS(REGNUM) /* no-op */
74 #endif
75
76 extern void set_sigint_trap (void);
77
78 extern void clear_sigint_trap (void);
79
80 extern void set_sigio_trap (void);
81
82 extern void clear_sigio_trap (void);
83
84 /* File name for default use for standard in/out in the inferior. */
85
86 extern char *inferior_io_terminal;
87
88 /* Pid of our debugged inferior, or 0 if no inferior now. */
89
90 extern int inferior_pid;
91
92 /* Is the inferior running right now, as a result of a 'run&',
93 'continue&' etc command? This is used in asycn gdb to determine
94 whether a command that the user enters while the target is running
95 is allowed or not. */
96 extern int target_executing;
97
98 /* Are we simulating synchronous execution? This is used in async gdb
99 to implement the 'run', 'continue' etc commands, which will not
100 redisplay the prompt until the execution is actually over. */
101 extern int sync_execution;
102
103 /* This is only valid when inferior_pid is non-zero.
104
105 If this is 0, then exec events should be noticed and responded to
106 by the debugger (i.e., be reported to the user).
107
108 If this is > 0, then that many subsequent exec events should be
109 ignored (i.e., not be reported to the user).
110 */
111 extern int inferior_ignoring_startup_exec_events;
112
113 /* This is only valid when inferior_ignoring_startup_exec_events is
114 zero.
115
116 Some targets (stupidly) report more than one exec event per actual
117 call to an event() system call. If only the last such exec event
118 need actually be noticed and responded to by the debugger (i.e.,
119 be reported to the user), then this is the number of "leading"
120 exec events which should be ignored.
121 */
122 extern int inferior_ignoring_leading_exec_events;
123
124 /* Inferior environment. */
125
126 extern struct environ *inferior_environ;
127
128 /* Character array containing an image of the inferior programs'
129 registers. */
130
131 extern char *registers;
132
133 /* Character array containing the current state of each register
134 (unavailable<0, valid=0, invalid>0). */
135
136 extern signed char *register_valid;
137
138 extern void clear_proceed_status (void);
139
140 extern void proceed (CORE_ADDR, enum target_signal, int);
141
142 extern void kill_inferior (void);
143
144 extern void generic_mourn_inferior (void);
145
146 extern void terminal_ours (void);
147
148 extern int run_stack_dummy (CORE_ADDR, char *);
149
150 extern CORE_ADDR read_pc (void);
151
152 extern CORE_ADDR read_pc_pid (int);
153
154 extern CORE_ADDR generic_target_read_pc (int);
155
156 extern void write_pc (CORE_ADDR);
157
158 extern void write_pc_pid (CORE_ADDR, int);
159
160 extern void generic_target_write_pc (CORE_ADDR, int);
161
162 extern CORE_ADDR read_sp (void);
163
164 extern CORE_ADDR generic_target_read_sp (void);
165
166 extern void write_sp (CORE_ADDR);
167
168 extern void generic_target_write_sp (CORE_ADDR);
169
170 extern CORE_ADDR read_fp (void);
171
172 extern CORE_ADDR generic_target_read_fp (void);
173
174 extern void write_fp (CORE_ADDR);
175
176 extern void generic_target_write_fp (CORE_ADDR);
177
178 extern CORE_ADDR unsigned_pointer_to_address (struct type *type, void *buf);
179
180 extern void unsigned_address_to_pointer (struct type *type, void *buf,
181 CORE_ADDR addr);
182 extern CORE_ADDR signed_pointer_to_address (struct type *type, void *buf);
183 extern void address_to_signed_pointer (struct type *type, void *buf,
184 CORE_ADDR addr);
185
186 extern void wait_for_inferior (void);
187
188 extern void fetch_inferior_event (void *);
189
190 extern void init_wait_for_inferior (void);
191
192 extern void close_exec_file (void);
193
194 extern void reopen_exec_file (void);
195
196 /* The `resume' routine should only be called in special circumstances.
197 Normally, use `proceed', which handles a lot of bookkeeping. */
198
199 extern void resume (int, enum target_signal);
200
201 /* From misc files */
202
203 extern void store_inferior_registers (int);
204
205 extern void fetch_inferior_registers (int);
206
207 extern void solib_create_inferior_hook (void);
208
209 extern void child_terminal_info (char *, int);
210
211 extern void term_info (char *, int);
212
213 extern void terminal_ours_for_output (void);
214
215 extern void terminal_inferior (void);
216
217 extern void terminal_init_inferior (void);
218
219 extern void terminal_init_inferior_with_pgrp (int pgrp);
220
221 /* From infptrace.c or infttrace.c */
222
223 extern int attach (int);
224
225 #if !defined(REQUIRE_ATTACH)
226 #define REQUIRE_ATTACH attach
227 #endif
228
229 #if !defined(REQUIRE_DETACH)
230 #define REQUIRE_DETACH(pid,siggnal) detach (siggnal)
231 #endif
232
233 extern void detach (int);
234
235 /* PTRACE method of waiting for inferior process. */
236 int ptrace_wait (int, int *);
237
238 extern void child_resume (int, int, enum target_signal);
239
240 #ifndef PTRACE_ARG3_TYPE
241 #define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */
242 #endif
243
244 extern int call_ptrace (int, int, PTRACE_ARG3_TYPE, int);
245
246 extern void pre_fork_inferior (void);
247
248 /* From procfs.c */
249
250 extern int proc_iterate_over_mappings (int (*)(int, CORE_ADDR));
251
252 extern int procfs_first_available (void);
253
254 /* From fork-child.c */
255
256 extern void fork_inferior (char *, char *, char **,
257 void (*)(void),
258 void (*)(int), void (*)(void), char *);
259
260
261 extern void clone_and_follow_inferior (int, int *);
262
263 extern void startup_inferior (int);
264
265 /* From inflow.c */
266
267 extern void new_tty_prefork (char *);
268
269 extern int gdb_has_a_terminal (void);
270
271 /* From infrun.c */
272
273 extern void start_remote (void);
274
275 extern void normal_stop (void);
276
277 extern int signal_stop_state (int);
278
279 extern int signal_print_state (int);
280
281 extern int signal_pass_state (int);
282
283 extern int signal_stop_update (int, int);
284
285 extern int signal_print_update (int, int);
286
287 extern int signal_pass_update (int, int);
288
289 /* From infcmd.c */
290
291 extern void tty_command (char *, int);
292
293 extern void attach_command (char *, int);
294
295 /* Last signal that the inferior received (why it stopped). */
296
297 extern enum target_signal stop_signal;
298
299 /* Address at which inferior stopped. */
300
301 extern CORE_ADDR stop_pc;
302
303 /* Chain containing status of breakpoint(s) that we have stopped at. */
304
305 extern bpstat stop_bpstat;
306
307 /* Flag indicating that a command has proceeded the inferior past the
308 current breakpoint. */
309
310 extern int breakpoint_proceeded;
311
312 /* Nonzero if stopped due to a step command. */
313
314 extern int stop_step;
315
316 /* Nonzero if stopped due to completion of a stack dummy routine. */
317
318 extern int stop_stack_dummy;
319
320 /* Nonzero if program stopped due to a random (unexpected) signal in
321 inferior process. */
322
323 extern int stopped_by_random_signal;
324
325 /* Range to single step within.
326 If this is nonzero, respond to a single-step signal
327 by continuing to step if the pc is in this range.
328
329 If step_range_start and step_range_end are both 1, it means to step for
330 a single instruction (FIXME: it might clean up wait_for_inferior in a
331 minor way if this were changed to the address of the instruction and
332 that address plus one. But maybe not.). */
333
334 extern CORE_ADDR step_range_start; /* Inclusive */
335 extern CORE_ADDR step_range_end; /* Exclusive */
336
337 /* Stack frame address as of when stepping command was issued.
338 This is how we know when we step into a subroutine call,
339 and how to set the frame for the breakpoint used to step out. */
340
341 extern CORE_ADDR step_frame_address;
342
343 /* Our notion of the current stack pointer. */
344
345 extern CORE_ADDR step_sp;
346
347 /* 1 means step over all subroutine calls.
348 -1 means step over calls to undebuggable functions. */
349
350 extern int step_over_calls;
351
352 /* If stepping, nonzero means step count is > 1
353 so don't print frame next time inferior stops
354 if it stops due to stepping. */
355
356 extern int step_multi;
357
358 /* Nonzero means expecting a trap and caller will handle it themselves.
359 It is used after attach, due to attaching to a process;
360 when running in the shell before the child program has been exec'd;
361 and when running some kinds of remote stuff (FIXME?). */
362
363 extern int stop_soon_quietly;
364
365 /* Nonzero if proceed is being used for a "finish" command or a similar
366 situation when stop_registers should be saved. */
367
368 extern int proceed_to_finish;
369
370 /* Save register contents here when about to pop a stack dummy frame,
371 if-and-only-if proceed_to_finish is set.
372 Thus this contains the return value from the called function (assuming
373 values are returned in a register). */
374
375 extern char *stop_registers;
376
377 /* Nonzero if the child process in inferior_pid was attached rather
378 than forked. */
379
380 extern int attach_flag;
381 \f
382 /* Sigtramp is a routine that the kernel calls (which then calls the
383 signal handler). On most machines it is a library routine that
384 is linked into the executable.
385
386 This macro, given a program counter value and the name of the
387 function in which that PC resides (which can be null if the
388 name is not known), returns nonzero if the PC and name show
389 that we are in sigtramp.
390
391 On most machines just see if the name is sigtramp (and if we have
392 no name, assume we are not in sigtramp). */
393 #if !defined (IN_SIGTRAMP)
394 #if defined (SIGTRAMP_START)
395 #define IN_SIGTRAMP(pc, name) \
396 ((pc) >= SIGTRAMP_START(pc) \
397 && (pc) < SIGTRAMP_END(pc) \
398 )
399 #else
400 #define IN_SIGTRAMP(pc, name) \
401 (name && STREQ ("_sigtramp", name))
402 #endif
403 #endif
404 \f
405 /* Possible values for CALL_DUMMY_LOCATION. */
406 #define ON_STACK 1
407 #define BEFORE_TEXT_END 2
408 #define AFTER_TEXT_END 3
409 #define AT_ENTRY_POINT 4
410
411 #if !defined (USE_GENERIC_DUMMY_FRAMES)
412 #define USE_GENERIC_DUMMY_FRAMES 0
413 #endif
414
415 #if !defined (CALL_DUMMY_LOCATION)
416 #define CALL_DUMMY_LOCATION ON_STACK
417 #endif /* No CALL_DUMMY_LOCATION. */
418
419 #if !defined (CALL_DUMMY_ADDRESS)
420 #define CALL_DUMMY_ADDRESS() (internal_error ("CALL_DUMMY_ADDRESS"), 0)
421 #endif
422 #if !defined (CALL_DUMMY_START_OFFSET)
423 #define CALL_DUMMY_START_OFFSET (internal_error ("CALL_DUMMY_START_OFFSET"), 0)
424 #endif
425 #if !defined (CALL_DUMMY_BREAKPOINT_OFFSET)
426 #define CALL_DUMMY_BREAKPOINT_OFFSET_P (0)
427 #define CALL_DUMMY_BREAKPOINT_OFFSET (internal_error ("CALL_DUMMY_BREAKPOINT_OFFSET"), 0)
428 #endif
429 #if !defined CALL_DUMMY_BREAKPOINT_OFFSET_P
430 #define CALL_DUMMY_BREAKPOINT_OFFSET_P (1)
431 #endif
432 #if !defined (CALL_DUMMY_LENGTH)
433 #define CALL_DUMMY_LENGTH (internal_error ("CALL_DUMMY_LENGTH"), 0)
434 #endif
435
436 #if defined (CALL_DUMMY_STACK_ADJUST)
437 #if !defined (CALL_DUMMY_STACK_ADJUST_P)
438 #define CALL_DUMMY_STACK_ADJUST_P (1)
439 #endif
440 #endif
441 #if !defined (CALL_DUMMY_STACK_ADJUST)
442 #define CALL_DUMMY_STACK_ADJUST (internal_error ("CALL_DUMMY_STACK_ADJUST"), 0)
443 #endif
444 #if !defined (CALL_DUMMY_STACK_ADJUST_P)
445 #define CALL_DUMMY_STACK_ADJUST_P (0)
446 #endif
447
448 /* FIXME: cagney/2000-04-17: gdbarch should manage this. The default
449 shouldn't be necessary. */
450
451 #if !defined (CALL_DUMMY_P)
452 #if defined (CALL_DUMMY)
453 #define CALL_DUMMY_P 1
454 #else
455 #define CALL_DUMMY_P 0
456 #endif
457 #endif
458
459 #if !defined PUSH_DUMMY_FRAME
460 #define PUSH_DUMMY_FRAME (internal_error ("PUSH_DUMMY_FRAME"), 0)
461 #endif
462
463 #if !defined FIX_CALL_DUMMY
464 #define FIX_CALL_DUMMY(a1,a2,a3,a4,a5,a6,a7) (internal_error ("FIX_CALL_DUMMY"), 0)
465 #endif
466
467 #if !defined STORE_STRUCT_RETURN
468 #define STORE_STRUCT_RETURN(a1,a2) (internal_error ("STORE_STRUCT_RETURN"), 0)
469 #endif
470
471
472 /* Are we in a call dummy? */
473
474 extern int pc_in_call_dummy_before_text_end (CORE_ADDR pc, CORE_ADDR sp,
475 CORE_ADDR frame_address);
476 #if !GDB_MULTI_ARCH
477 #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == BEFORE_TEXT_END
478 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_before_text_end (pc, sp, frame_address)
479 #endif /* Before text_end. */
480 #endif
481
482 extern int pc_in_call_dummy_after_text_end (CORE_ADDR pc, CORE_ADDR sp,
483 CORE_ADDR frame_address);
484 #if !GDB_MULTI_ARCH
485 #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == AFTER_TEXT_END
486 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_after_text_end (pc, sp, frame_address)
487 #endif
488 #endif
489
490 extern int pc_in_call_dummy_on_stack (CORE_ADDR pc, CORE_ADDR sp,
491 CORE_ADDR frame_address);
492 #if !GDB_MULTI_ARCH
493 #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == ON_STACK
494 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_on_stack (pc, sp, frame_address)
495 #endif
496 #endif
497
498 extern int pc_in_call_dummy_at_entry_point (CORE_ADDR pc, CORE_ADDR sp,
499 CORE_ADDR frame_address);
500 #if !GDB_MULTI_ARCH
501 #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == AT_ENTRY_POINT
502 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_at_entry_point (pc, sp, frame_address)
503 #endif
504 #endif
505
506 /* It's often not enough for our clients to know whether the PC is merely
507 somewhere within the call dummy. They may need to know whether the
508 call dummy has actually completed. (For example, wait_for_inferior
509 wants to know when it should truly stop because the call dummy has
510 completed. If we're single-stepping because of slow watchpoints,
511 then we may find ourselves stopped at the entry of the call dummy,
512 and want to continue stepping until we reach the end.)
513
514 Note that this macro is intended for targets (like HP-UX) which
515 require more than a single breakpoint in their call dummies, and
516 therefore cannot use the CALL_DUMMY_BREAKPOINT_OFFSET mechanism.
517
518 If a target does define CALL_DUMMY_BREAKPOINT_OFFSET, then this
519 default implementation of CALL_DUMMY_HAS_COMPLETED is sufficient.
520 Else, a target may wish to supply an implementation that works in
521 the presense of multiple breakpoints in its call dummy.
522 */
523 #if !defined(CALL_DUMMY_HAS_COMPLETED)
524 #define CALL_DUMMY_HAS_COMPLETED(pc, sp, frame_address) \
525 PC_IN_CALL_DUMMY((pc), (sp), (frame_address))
526 #endif
527
528 /* If STARTUP_WITH_SHELL is set, GDB's "run"
529 will attempts to start up the debugee under a shell.
530 This is in order for argument-expansion to occur. E.g.,
531 (gdb) run *
532 The "*" gets expanded by the shell into a list of files.
533 While this is a nice feature, it turns out to interact badly
534 with some of the catch-fork/catch-exec features we have added.
535 In particular, if the shell does any fork/exec's before
536 the exec of the target program, that can confuse GDB.
537 To disable this feature, set STARTUP_WITH_SHELL to 0.
538 To enable this feature, set STARTUP_WITH_SHELL to 1.
539 The catch-exec traps expected during start-up will
540 be 1 if target is not started up with a shell, 2 if it is.
541 - RT
542 If you disable this, you need to decrement
543 START_INFERIOR_TRAPS_EXPECTED in tm.h. */
544 #define STARTUP_WITH_SHELL 1
545 #if !defined(START_INFERIOR_TRAPS_EXPECTED)
546 #define START_INFERIOR_TRAPS_EXPECTED 2
547 #endif
548 #endif /* !defined (INFERIOR_H) */
This page took 0.039873 seconds and 5 git commands to generate.