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