This commit was generated by cvs2svn to track changes on a CVS vendor
[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 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, Boston, MA 02111-1307, USA. */
20
21 #if !defined (INFERIOR_H)
22 #define INFERIOR_H 1
23
24 /* For bpstat. */
25 #include "breakpoint.h"
26
27 /* For enum target_signal. */
28 #include "target.h"
29
30 /* Structure in which to save the status of the inferior. Save
31 through "save_inferior_status", restore through
32 "restore_inferior_status".
33 This pair of routines should be called around any transfer of
34 control to the inferior which you don't want showing up in your
35 control variables. */
36
37 struct inferior_status {
38 enum target_signal stop_signal;
39 CORE_ADDR stop_pc;
40 bpstat stop_bpstat;
41 int stop_step;
42 int stop_stack_dummy;
43 int stopped_by_random_signal;
44 int trap_expected;
45 CORE_ADDR step_range_start;
46 CORE_ADDR step_range_end;
47 CORE_ADDR step_frame_address;
48 int step_over_calls;
49 CORE_ADDR step_resume_break_address;
50 int stop_after_trap;
51 int stop_soon_quietly;
52 CORE_ADDR selected_frame_address;
53 int selected_level;
54 char stop_registers[REGISTER_BYTES];
55
56 /* These are here because if call_function_by_hand has written some
57 registers and then decides to call error(), we better not have changed
58 any registers. */
59 char registers[REGISTER_BYTES];
60
61 int breakpoint_proceeded;
62 int restore_stack_info;
63 int proceed_to_finish;
64 };
65
66 /* This macro gives the number of registers actually in use by the
67 inferior. This may be less than the total number of registers,
68 perhaps depending on the actual CPU in use or program being run. */
69
70 #ifndef ARCH_NUM_REGS
71 #define ARCH_NUM_REGS NUM_REGS
72 #endif
73
74 extern void save_inferior_status PARAMS ((struct inferior_status *, int));
75
76 extern void restore_inferior_status PARAMS ((struct inferior_status *));
77
78 extern void set_sigint_trap PARAMS ((void));
79
80 extern void clear_sigint_trap PARAMS ((void));
81
82 extern void set_sigio_trap PARAMS ((void));
83
84 extern void clear_sigio_trap PARAMS ((void));
85
86 /* File name for default use for standard in/out in the inferior. */
87
88 extern char *inferior_io_terminal;
89
90 /* Pid of our debugged inferior, or 0 if no inferior now. */
91
92 extern int inferior_pid;
93
94 /* Inferior environment. */
95
96 extern struct environ *inferior_environ;
97
98 /* Character array containing an image of the inferior programs' registers. */
99
100 extern char registers[];
101
102 /* Array of validity bits (one per register). Nonzero at position XXX_REGNUM
103 means that `registers' contains a valid copy of inferior register XXX. */
104
105 extern char register_valid[NUM_REGS];
106
107 extern void clear_proceed_status PARAMS ((void));
108
109 extern void proceed PARAMS ((CORE_ADDR, enum target_signal, int));
110
111 extern void kill_inferior PARAMS ((void));
112
113 extern void generic_mourn_inferior PARAMS ((void));
114
115 extern void terminal_ours PARAMS ((void));
116
117 extern int run_stack_dummy PARAMS ((CORE_ADDR, char [REGISTER_BYTES]));
118
119 extern CORE_ADDR read_pc PARAMS ((void));
120
121 extern CORE_ADDR read_pc_pid PARAMS ((int));
122
123 extern void write_pc PARAMS ((CORE_ADDR));
124
125 extern CORE_ADDR read_sp PARAMS ((void));
126
127 extern void write_sp PARAMS ((CORE_ADDR));
128
129 extern CORE_ADDR read_fp PARAMS ((void));
130
131 extern void write_fp PARAMS ((CORE_ADDR));
132
133 extern void wait_for_inferior PARAMS ((void));
134
135 extern void init_wait_for_inferior PARAMS ((void));
136
137 extern void close_exec_file PARAMS ((void));
138
139 extern void reopen_exec_file PARAMS ((void));
140
141 /* The `resume' routine should only be called in special circumstances.
142 Normally, use `proceed', which handles a lot of bookkeeping. */
143
144 extern void resume PARAMS ((int, enum target_signal));
145
146 /* From misc files */
147
148 extern void store_inferior_registers PARAMS ((int));
149
150 extern void fetch_inferior_registers PARAMS ((int));
151
152 extern void solib_create_inferior_hook PARAMS ((void));
153
154 extern void child_terminal_info PARAMS ((char *, int));
155
156 extern void term_info PARAMS ((char *, int));
157
158 extern void terminal_ours_for_output PARAMS ((void));
159
160 extern void terminal_inferior PARAMS ((void));
161
162 extern void terminal_init_inferior PARAMS ((void));
163
164 #ifdef PROCESS_GROUP_TYPE
165 extern void terminal_init_inferior_with_pgrp PARAMS ((PROCESS_GROUP_TYPE pgrp));
166 #endif
167
168 /* From infptrace.c */
169
170 extern int attach PARAMS ((int));
171
172 void detach PARAMS ((int));
173
174 extern void child_resume PARAMS ((int, int, enum target_signal));
175
176 #ifndef PTRACE_ARG3_TYPE
177 #define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */
178 #endif
179
180 extern int call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int));
181
182 /* From procfs.c */
183
184 extern int proc_iterate_over_mappings PARAMS ((int (*) (int, CORE_ADDR)));
185
186 /* From fork-child.c */
187
188 extern void fork_inferior PARAMS ((char *, char *, char **,
189 void (*) (void),
190 int (*) (int), char *));
191
192 extern void startup_inferior PARAMS ((int));
193
194 /* From inflow.c */
195
196 extern void new_tty_prefork PARAMS ((char *));
197
198 extern int gdb_has_a_terminal PARAMS ((void));
199
200 /* From infrun.c */
201
202 extern void start_remote PARAMS ((void));
203
204 extern void normal_stop PARAMS ((void));
205
206 extern int signal_stop_state PARAMS ((int));
207
208 extern int signal_print_state PARAMS ((int));
209
210 extern int signal_pass_state PARAMS ((int));
211
212 /* From infcmd.c */
213
214 extern void tty_command PARAMS ((char *, int));
215
216 extern void attach_command PARAMS ((char *, int));
217
218 /* Last signal that the inferior received (why it stopped). */
219
220 extern enum target_signal stop_signal;
221
222 /* Address at which inferior stopped. */
223
224 extern CORE_ADDR stop_pc;
225
226 /* Chain containing status of breakpoint(s) that we have stopped at. */
227
228 extern bpstat stop_bpstat;
229
230 /* Flag indicating that a command has proceeded the inferior past the
231 current breakpoint. */
232
233 extern int breakpoint_proceeded;
234
235 /* Nonzero if stopped due to a step command. */
236
237 extern int stop_step;
238
239 /* Nonzero if stopped due to completion of a stack dummy routine. */
240
241 extern int stop_stack_dummy;
242
243 /* Nonzero if program stopped due to a random (unexpected) signal in
244 inferior process. */
245
246 extern int stopped_by_random_signal;
247
248 /* Range to single step within.
249 If this is nonzero, respond to a single-step signal
250 by continuing to step if the pc is in this range.
251
252 If step_range_start and step_range_end are both 1, it means to step for
253 a single instruction (FIXME: it might clean up wait_for_inferior in a
254 minor way if this were changed to the address of the instruction and
255 that address plus one. But maybe not.). */
256
257 extern CORE_ADDR step_range_start; /* Inclusive */
258 extern CORE_ADDR step_range_end; /* Exclusive */
259
260 /* Stack frame address as of when stepping command was issued.
261 This is how we know when we step into a subroutine call,
262 and how to set the frame for the breakpoint used to step out. */
263
264 extern CORE_ADDR step_frame_address;
265
266 /* Our notion of the current stack pointer. */
267
268 extern CORE_ADDR step_sp;
269
270 /* 1 means step over all subroutine calls.
271 -1 means step over calls to undebuggable functions. */
272
273 extern int step_over_calls;
274
275 /* If stepping, nonzero means step count is > 1
276 so don't print frame next time inferior stops
277 if it stops due to stepping. */
278
279 extern int step_multi;
280
281 /* Nonzero means expecting a trap and caller will handle it themselves.
282 It is used after attach, due to attaching to a process;
283 when running in the shell before the child program has been exec'd;
284 and when running some kinds of remote stuff (FIXME?). */
285
286 extern int stop_soon_quietly;
287
288 /* Nonzero if proceed is being used for a "finish" command or a similar
289 situation when stop_registers should be saved. */
290
291 extern int proceed_to_finish;
292
293 /* Save register contents here when about to pop a stack dummy frame,
294 if-and-only-if proceed_to_finish is set.
295 Thus this contains the return value from the called function (assuming
296 values are returned in a register). */
297
298 extern char stop_registers[REGISTER_BYTES];
299
300 /* Nonzero if the child process in inferior_pid was attached rather
301 than forked. */
302
303 extern int attach_flag;
304 \f
305 /* Sigtramp is a routine that the kernel calls (which then calls the
306 signal handler). On most machines it is a library routine that
307 is linked into the executable.
308
309 This macro, given a program counter value and the name of the
310 function in which that PC resides (which can be null if the
311 name is not known), returns nonzero if the PC and name show
312 that we are in sigtramp.
313
314 On most machines just see if the name is sigtramp (and if we have
315 no name, assume we are not in sigtramp). */
316 #if !defined (IN_SIGTRAMP)
317 # if defined (SIGTRAMP_START)
318 # define IN_SIGTRAMP(pc, name) \
319 ((pc) >= SIGTRAMP_START \
320 && (pc) < SIGTRAMP_END \
321 )
322 # else
323 # define IN_SIGTRAMP(pc, name) \
324 (name && STREQ ("_sigtramp", name))
325 # endif
326 #endif
327 \f
328 /* Possible values for CALL_DUMMY_LOCATION. */
329 #define ON_STACK 1
330 #define BEFORE_TEXT_END 2
331 #define AFTER_TEXT_END 3
332 #define AT_ENTRY_POINT 4
333
334 #if !defined (CALL_DUMMY_LOCATION)
335 #define CALL_DUMMY_LOCATION ON_STACK
336 #endif /* No CALL_DUMMY_LOCATION. */
337
338 /* Are we in a call dummy? The code below which allows DECR_PC_AFTER_BREAK
339 below is for infrun.c, which may give the macro a pc without that
340 subtracted out. */
341 #if !defined (PC_IN_CALL_DUMMY)
342 #if CALL_DUMMY_LOCATION == BEFORE_TEXT_END
343 extern CORE_ADDR text_end;
344 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
345 ((pc) >= text_end - CALL_DUMMY_LENGTH \
346 && (pc) <= text_end + DECR_PC_AFTER_BREAK)
347 #endif /* Before text_end. */
348
349 #if CALL_DUMMY_LOCATION == AFTER_TEXT_END
350 extern CORE_ADDR text_end;
351 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
352 ((pc) >= text_end \
353 && (pc) <= text_end + CALL_DUMMY_LENGTH + DECR_PC_AFTER_BREAK)
354 #endif /* After text_end. */
355
356 #if CALL_DUMMY_LOCATION == ON_STACK
357 /* Is the PC in a call dummy? SP and FRAME_ADDRESS are the bottom and
358 top of the stack frame which we are checking, where "bottom" and
359 "top" refer to some section of memory which contains the code for
360 the call dummy. Calls to this macro assume that the contents of
361 SP_REGNUM and FP_REGNUM (or the saved values thereof), respectively,
362 are the things to pass.
363
364 This won't work on the 29k, where SP_REGNUM and FP_REGNUM don't
365 have that meaning, but the 29k doesn't use ON_STACK. This could be
366 fixed by generalizing this scheme, perhaps by passing in a frame
367 and adding a few fields, at least on machines which need them for
368 PC_IN_CALL_DUMMY.
369
370 Something simpler, like checking for the stack segment, doesn't work,
371 since various programs (threads implementations, gcc nested function
372 stubs, etc) may either allocate stack frames in another segment, or
373 allocate other kinds of code on the stack. */
374
375 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
376 ((sp) INNER_THAN (pc) && (frame_address != 0) && (pc) INNER_THAN (frame_address))
377 #endif /* On stack. */
378
379 #if CALL_DUMMY_LOCATION == AT_ENTRY_POINT
380 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
381 ((pc) >= CALL_DUMMY_ADDRESS () \
382 && (pc) <= (CALL_DUMMY_ADDRESS () + DECR_PC_AFTER_BREAK))
383 #endif /* At entry point. */
384 #endif /* No PC_IN_CALL_DUMMY. */
385
386 #endif /* !defined (INFERIOR_H) */
This page took 0.038154 seconds and 5 git commands to generate.