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