Changes from the FSF for Hurd thread support.
[deliverable/binutils-gdb.git] / gdb / inferior.h
CommitLineData
bd5635a1
RP
1/* Variables that describe the inferior process running under GDB:
2 Where it is, why it stopped, and how to step it.
647e52ea 3 Copyright 1986, 1989, 1992, 1996 Free Software Foundation, Inc.
bd5635a1
RP
4
5This file is part of GDB.
6
bdbd5f50 7This program is free software; you can redistribute it and/or modify
bd5635a1 8it under the terms of the GNU General Public License as published by
bdbd5f50
JG
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
bd5635a1 11
bdbd5f50 12This program is distributed in the hope that it will be useful,
bd5635a1
RP
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
bdbd5f50 18along with this program; if not, write to the Free Software
647e52ea 19Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
bd5635a1 20
cc221e76
FF
21#if !defined (INFERIOR_H)
22#define INFERIOR_H 1
23
bd5635a1
RP
24/* For bpstat. */
25#include "breakpoint.h"
26
49b476bd
SS
27/* For enum target_signal. */
28#include "target.h"
29
647e52ea
SG
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
bd5635a1 37struct inferior_status {
49b476bd 38 enum target_signal stop_signal;
100f92e2 39 CORE_ADDR stop_pc;
bd5635a1
RP
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;
647e52ea 47 CORE_ADDR step_frame_address;
bd5635a1
RP
48 int step_over_calls;
49 CORE_ADDR step_resume_break_address;
50 int stop_after_trap;
51 int stop_soon_quietly;
647e52ea 52 CORE_ADDR selected_frame_address;
bd5635a1
RP
53 int selected_level;
54 char stop_registers[REGISTER_BYTES];
100f92e2
JK
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
bd5635a1
RP
61 int breakpoint_proceeded;
62 int restore_stack_info;
63 int proceed_to_finish;
64};
65
647e52ea
SG
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
74extern void save_inferior_status PARAMS ((struct inferior_status *, int));
cc221e76 75
647e52ea 76extern void restore_inferior_status PARAMS ((struct inferior_status *));
bd5635a1 77
100f92e2 78extern void set_sigint_trap PARAMS ((void));
647e52ea 79
100f92e2
JK
80extern void clear_sigint_trap PARAMS ((void));
81
49b476bd 82extern void set_sigio_trap PARAMS ((void));
647e52ea 83
49b476bd
SS
84extern void clear_sigio_trap PARAMS ((void));
85
bd5635a1
RP
86/* File name for default use for standard in/out in the inferior. */
87
88extern char *inferior_io_terminal;
89
90/* Pid of our debugged inferior, or 0 if no inferior now. */
91
92extern int inferior_pid;
93
647e52ea
SG
94/* Inferior environment. */
95
96extern struct environ *inferior_environ;
97
bd5635a1
RP
98/* Character array containing an image of the inferior programs' registers. */
99
100extern char registers[];
101
310cc570
RP
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
105extern char register_valid[NUM_REGS];
106
647e52ea 107extern void clear_proceed_status PARAMS ((void));
cc221e76 108
647e52ea 109extern void proceed PARAMS ((CORE_ADDR, enum target_signal, int));
cc221e76 110
647e52ea 111extern void kill_inferior PARAMS ((void));
cc221e76 112
647e52ea 113extern void generic_mourn_inferior PARAMS ((void));
cc221e76 114
647e52ea 115extern void terminal_ours PARAMS ((void));
cc221e76 116
100f92e2 117extern int run_stack_dummy PARAMS ((CORE_ADDR, char [REGISTER_BYTES]));
cc221e76 118
647e52ea 119extern CORE_ADDR read_pc PARAMS ((void));
cc221e76 120
647e52ea 121extern CORE_ADDR read_pc_pid PARAMS ((int));
49b476bd 122
647e52ea 123extern void write_pc PARAMS ((CORE_ADDR));
cc221e76 124
647e52ea 125extern CORE_ADDR read_sp PARAMS ((void));
23a8e291 126
647e52ea 127extern void write_sp PARAMS ((CORE_ADDR));
23a8e291 128
647e52ea 129extern CORE_ADDR read_fp PARAMS ((void));
23a8e291 130
647e52ea 131extern void write_fp PARAMS ((CORE_ADDR));
23a8e291 132
647e52ea 133extern void wait_for_inferior PARAMS ((void));
cc221e76 134
647e52ea 135extern void init_wait_for_inferior PARAMS ((void));
cc221e76 136
647e52ea 137extern void close_exec_file PARAMS ((void));
cc221e76 138
647e52ea 139extern void reopen_exec_file PARAMS ((void));
cc221e76 140
3aa6856a
JG
141/* The `resume' routine should only be called in special circumstances.
142 Normally, use `proceed', which handles a lot of bookkeeping. */
647e52ea
SG
143
144extern void resume PARAMS ((int, enum target_signal));
310cc570 145
cc221e76
FF
146/* From misc files */
147
647e52ea 148extern void store_inferior_registers PARAMS ((int));
cc221e76 149
647e52ea 150extern void fetch_inferior_registers PARAMS ((int));
cc221e76 151
647e52ea 152extern void solib_create_inferior_hook PARAMS ((void));
cc221e76 153
647e52ea 154extern void child_terminal_info PARAMS ((char *, int));
cc221e76 155
647e52ea 156extern void term_info PARAMS ((char *, int));
cc221e76 157
647e52ea 158extern void terminal_ours_for_output PARAMS ((void));
cc221e76 159
647e52ea 160extern void terminal_inferior PARAMS ((void));
cc221e76 161
647e52ea
SG
162extern void terminal_init_inferior PARAMS ((void));
163
164#ifdef PROCESS_GROUP_TYPE
165extern void terminal_init_inferior_with_pgrp PARAMS ((PROCESS_GROUP_TYPE pgrp));
166#endif
cc221e76 167
34517ebc 168/* From infptrace.c */
cc221e76 169
647e52ea 170extern int attach PARAMS ((int));
cc221e76 171
647e52ea 172void detach PARAMS ((int));
cc221e76 173
647e52ea 174extern void child_resume PARAMS ((int, int, enum target_signal));
cc221e76 175
310cc570
RP
176#ifndef PTRACE_ARG3_TYPE
177#define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */
178#endif
179
647e52ea 180extern int call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int));
310cc570 181
cc221e76
FF
182/* From procfs.c */
183
647e52ea 184extern int proc_iterate_over_mappings PARAMS ((int (*) (int, CORE_ADDR)));
cc221e76 185
34517ebc 186/* From fork-child.c */
bd5635a1 187
49b476bd
SS
188extern void fork_inferior PARAMS ((char *, char *, char **,
189 void (*) (void),
647e52ea 190 int (*) (int), char *));
49b476bd
SS
191
192extern void startup_inferior PARAMS ((int));
cc221e76
FF
193
194/* From inflow.c */
195
647e52ea 196extern void new_tty_prefork PARAMS ((char *));
cc221e76 197
23a8e291
JK
198extern int gdb_has_a_terminal PARAMS ((void));
199
cc221e76
FF
200/* From infrun.c */
201
647e52ea 202extern void start_remote PARAMS ((void));
cc221e76 203
647e52ea 204extern void normal_stop PARAMS ((void));
cc221e76 205
647e52ea 206extern int signal_stop_state PARAMS ((int));
cc221e76 207
647e52ea 208extern int signal_print_state PARAMS ((int));
cc221e76 209
647e52ea 210extern int signal_pass_state PARAMS ((int));
cc221e76
FF
211
212/* From infcmd.c */
213
647e52ea 214extern void tty_command PARAMS ((char *, int));
cc221e76 215
647e52ea 216extern void attach_command PARAMS ((char *, int));
cc221e76 217
bd5635a1
RP
218/* Last signal that the inferior received (why it stopped). */
219
49b476bd 220extern enum target_signal stop_signal;
bd5635a1
RP
221
222/* Address at which inferior stopped. */
223
224extern CORE_ADDR stop_pc;
225
bd5635a1
RP
226/* Chain containing status of breakpoint(s) that we have stopped at. */
227
228extern bpstat stop_bpstat;
229
230/* Flag indicating that a command has proceeded the inferior past the
231 current breakpoint. */
232
233extern int breakpoint_proceeded;
234
235/* Nonzero if stopped due to a step command. */
236
237extern int stop_step;
238
239/* Nonzero if stopped due to completion of a stack dummy routine. */
240
241extern int stop_stack_dummy;
242
243/* Nonzero if program stopped due to a random (unexpected) signal in
244 inferior process. */
245
246extern int stopped_by_random_signal;
247
248/* Range to single step within.
249 If this is nonzero, respond to a single-step signal
100f92e2
JK
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.). */
bd5635a1
RP
256
257extern CORE_ADDR step_range_start; /* Inclusive */
258extern 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
647e52ea
SG
264extern CORE_ADDR step_frame_address;
265
266/* Our notion of the current stack pointer. */
267
268extern CORE_ADDR step_sp;
bd5635a1
RP
269
270/* 1 means step over all subroutine calls.
271 -1 means step over calls to undebuggable functions. */
272
273extern 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
279extern int step_multi;
280
bdbd5f50
JG
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
cc221e76 286extern int stop_soon_quietly;
bdbd5f50 287
bd5635a1
RP
288/* Nonzero if proceed is being used for a "finish" command or a similar
289 situation when stop_registers should be saved. */
290
291extern 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
298extern char stop_registers[REGISTER_BYTES];
299
bd5635a1
RP
300/* Nonzero if the child process in inferior_pid was attached rather
301 than forked. */
302
cc221e76 303extern int attach_flag;
bd5635a1 304\f
23a8e291
JK
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
bd5635a1
RP
328/* Possible values for CALL_DUMMY_LOCATION. */
329#define ON_STACK 1
330#define BEFORE_TEXT_END 2
331#define AFTER_TEXT_END 3
100f92e2 332#define AT_ENTRY_POINT 4
bd5635a1
RP
333
334#if !defined (CALL_DUMMY_LOCATION)
bd5635a1 335#define CALL_DUMMY_LOCATION ON_STACK
bd5635a1
RP
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
cc221e76 343extern CORE_ADDR text_end;
bd5635a1
RP
344#define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
345 ((pc) >= text_end - CALL_DUMMY_LENGTH \
34517ebc 346 && (pc) <= text_end + DECR_PC_AFTER_BREAK)
100f92e2
JK
347#endif /* Before text_end. */
348
bd5635a1 349#if CALL_DUMMY_LOCATION == AFTER_TEXT_END
cc221e76 350extern CORE_ADDR text_end;
bd5635a1
RP
351#define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
352 ((pc) >= text_end \
34517ebc 353 && (pc) <= text_end + CALL_DUMMY_LENGTH + DECR_PC_AFTER_BREAK)
100f92e2 354#endif /* After text_end. */
f49cf589 355
100f92e2 356#if CALL_DUMMY_LOCATION == ON_STACK
23a8e291
JK
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. */
f49cf589 374
bd5635a1 375#define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
f49cf589 376 ((sp) INNER_THAN (pc) && (frame_address != 0) && (pc) INNER_THAN (frame_address))
bd5635a1 377#endif /* On stack. */
100f92e2
JK
378
379#if CALL_DUMMY_LOCATION == AT_ENTRY_POINT
100f92e2 380#define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
49b476bd
SS
381 ((pc) >= CALL_DUMMY_ADDRESS () \
382 && (pc) <= (CALL_DUMMY_ADDRESS () + DECR_PC_AFTER_BREAK))
100f92e2 383#endif /* At entry point. */
bd5635a1 384#endif /* No PC_IN_CALL_DUMMY. */
cc221e76
FF
385
386#endif /* !defined (INFERIOR_H) */
This page took 0.256237 seconds and 4 git commands to generate.