* serial.h (SERIAL_SET_TTY_STATE): Comment return value.
[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/*
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 */
38struct 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
68extern void
69save_inferior_status PARAMS ((struct inferior_status *, int));
70
71extern void
72restore_inferior_status PARAMS ((struct inferior_status *));
73
74extern void set_sigint_trap PARAMS ((void));
75extern void clear_sigint_trap PARAMS ((void));
76
77/* File name for default use for standard in/out in the inferior. */
78
79extern char *inferior_io_terminal;
80
81/* Pid of our debugged inferior, or 0 if no inferior now. */
82
83extern int inferior_pid;
84
85/* Character array containing an image of the inferior programs' registers. */
86
87extern 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
92extern char register_valid[NUM_REGS];
93
94extern void
95clear_proceed_status PARAMS ((void));
96
97extern void
98proceed PARAMS ((CORE_ADDR, int, int));
99
100extern void
101kill_inferior PARAMS ((void));
102
103extern void
104generic_mourn_inferior PARAMS ((void));
105
106extern void
107terminal_ours PARAMS ((void));
108
109extern int run_stack_dummy PARAMS ((CORE_ADDR, char [REGISTER_BYTES]));
110
111extern CORE_ADDR
112read_pc PARAMS ((void));
113
114extern void
115write_pc PARAMS ((CORE_ADDR));
116
117extern CORE_ADDR
118read_sp PARAMS ((void));
119
120extern void
121write_sp PARAMS ((CORE_ADDR));
122
123extern CORE_ADDR
124read_fp PARAMS ((void));
125
126extern void
127write_fp PARAMS ((CORE_ADDR));
128
129extern void
130wait_for_inferior PARAMS ((void));
131
132extern void
133init_wait_for_inferior PARAMS ((void));
134
135extern void
136close_exec_file PARAMS ((void));
137
138extern void
139reopen_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. */
143extern void
144resume PARAMS ((int, int));
145
146/* From misc files */
147
148extern void
149store_inferior_registers PARAMS ((int));
150
151extern void
152fetch_inferior_registers PARAMS ((int));
153
154extern void
155solib_create_inferior_hook PARAMS ((void));
156
157extern void
158child_terminal_info PARAMS ((char *, int));
159
160extern void
161term_info PARAMS ((char *, int));
162
163extern void
164terminal_ours_for_output PARAMS ((void));
165
166extern void
167terminal_inferior PARAMS ((void));
168
169extern void
170terminal_init_inferior PARAMS ((void));
171
172/* From infptrace.c */
173
174extern int
175attach PARAMS ((int));
176
177void
178detach PARAMS ((int));
179
180extern void
181child_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
187extern int
188call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int));
189
190/* From procfs.c */
191
192extern int
193proc_iterate_over_mappings PARAMS ((int (*) (int, CORE_ADDR)));
194
195/* From fork-child.c */
196
197extern void
198fork_inferior PARAMS ((char *, char *, char **,
199 void (*) (void),
200 void (*) (int)));
201
202/* From inflow.c */
203
204extern void
205new_tty_prefork PARAMS ((char *));
206
207extern int gdb_has_a_terminal PARAMS ((void));
208
209/* From infrun.c */
210
211extern void
212start_remote PARAMS ((void));
213
214extern void
215normal_stop PARAMS ((void));
216
217extern int
218signal_stop_state PARAMS ((int));
219
220extern int
221signal_print_state PARAMS ((int));
222
223extern int
224signal_pass_state PARAMS ((int));
225
226/* From infcmd.c */
227
228extern void
229tty_command PARAMS ((char *, int));
230
231extern void
232attach_command PARAMS ((char *, int));
233
234/* Last signal that the inferior received (why it stopped). */
235
236extern int stop_signal;
237
238/* Address at which inferior stopped. */
239
240extern CORE_ADDR stop_pc;
241
242/* Stack frame when program stopped. */
243
244extern FRAME_ADDR stop_frame_address;
245
246/* Chain containing status of breakpoint(s) that we have stopped at. */
247
248extern bpstat stop_bpstat;
249
250/* Flag indicating that a command has proceeded the inferior past the
251 current breakpoint. */
252
253extern int breakpoint_proceeded;
254
255/* Nonzero if stopped due to a step command. */
256
257extern int stop_step;
258
259/* Nonzero if stopped due to completion of a stack dummy routine. */
260
261extern int stop_stack_dummy;
262
263/* Nonzero if program stopped due to a random (unexpected) signal in
264 inferior process. */
265
266extern 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
277extern CORE_ADDR step_range_start; /* Inclusive */
278extern 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
284extern FRAME_ADDR step_frame_address;
285
286/* 1 means step over all subroutine calls.
287 -1 means step over calls to undebuggable functions. */
288
289extern 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
295extern 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
302extern 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
307extern 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
314extern char stop_registers[REGISTER_BYTES];
315
316/* Nonzero if the child process in inferior_pid was attached rather
317 than forked. */
318
319extern 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
359extern 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
366extern 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
396extern CORE_ADDR
397entry_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.023457 seconds and 4 git commands to generate.