Remove non-address bits for longjmp resume breakpoint
[deliverable/binutils-gdb.git] / gdb / inferior.h
CommitLineData
c906108c
SS
1/* Variables that describe the inferior process running under GDB:
2 Where it is, why it stopped, and how to step it.
1bac305b 3
ecd75fc8 4 Copyright (C) 1986-2014 Free Software Foundation, Inc.
c906108c 5
c5aa993b 6 This file is part of GDB.
c906108c 7
c5aa993b
JM
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
a9762ec7 10 the Free Software Foundation; either version 3 of the License, or
c5aa993b 11 (at your option) any later version.
c906108c 12
c5aa993b
JM
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
c906108c 17
c5aa993b 18 You should have received a copy of the GNU General Public License
a9762ec7 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
20
21#if !defined (INFERIOR_H)
22#define INFERIOR_H 1
23
da3331ec
AC
24struct target_waitstatus;
25struct frame_info;
26struct ui_file;
27struct type;
67a2b77e 28struct gdbarch;
72cec141 29struct regcache;
b77209e0 30struct ui_out;
7e1789f5 31struct terminal_info;
6ecd4729 32struct target_desc_info;
67a2b77e 33
c906108c
SS
34/* For bpstat. */
35#include "breakpoint.h"
36
2ea28649 37/* For enum gdb_signal. */
c906108c
SS
38#include "target.h"
39
aa0cd9c1
AC
40/* For struct frame_id. */
41#include "frame.h"
42
6c95b8df 43#include "progspace.h"
8e260fc0 44#include "registry.h"
6c95b8df 45
16c381f0
JK
46struct infcall_suspend_state;
47struct infcall_control_state;
7a292a7a 48
16c381f0
JK
49extern struct infcall_suspend_state *save_infcall_suspend_state (void);
50extern struct infcall_control_state *save_infcall_control_state (void);
c906108c 51
16c381f0
JK
52extern void restore_infcall_suspend_state (struct infcall_suspend_state *);
53extern void restore_infcall_control_state (struct infcall_control_state *);
b89667eb 54
16c381f0
JK
55extern struct cleanup *make_cleanup_restore_infcall_suspend_state
56 (struct infcall_suspend_state *);
57extern struct cleanup *make_cleanup_restore_infcall_control_state
58 (struct infcall_control_state *);
b89667eb 59
16c381f0
JK
60extern void discard_infcall_suspend_state (struct infcall_suspend_state *);
61extern void discard_infcall_control_state (struct infcall_control_state *);
7a292a7a 62
16c381f0
JK
63extern struct regcache *
64 get_infcall_suspend_state_regcache (struct infcall_suspend_state *);
b89667eb 65
ce696e05
KB
66/* Save value of inferior_ptid so that it may be restored by
67 a later call to do_cleanups(). Returns the struct cleanup
68 pointer needed for later doing the cleanup. */
69extern struct cleanup * save_inferior_ptid (void);
70
a14ed312 71extern void set_sigint_trap (void);
c906108c 72
a14ed312 73extern void clear_sigint_trap (void);
c906108c 74
3cb3b8df 75/* Set/get file name for default use for standard in/out in the inferior. */
c906108c 76
3cb3b8df
BR
77extern void set_inferior_io_terminal (const char *terminal_name);
78extern const char *get_inferior_io_terminal (void);
c906108c 79
39f77062 80/* Collected pid, tid, etc. of the debugged inferior. When there's
dfd4cc63 81 no inferior, ptid_get_pid (inferior_ptid) will be 0. */
c906108c 82
39f77062 83extern ptid_t inferior_ptid;
c906108c 84
a14ed312 85extern void generic_mourn_inferior (void);
c906108c 86
9898f801
UW
87extern CORE_ADDR unsigned_pointer_to_address (struct gdbarch *gdbarch,
88 struct type *type,
b60c417a 89 const gdb_byte *buf);
9898f801
UW
90extern void unsigned_address_to_pointer (struct gdbarch *gdbarch,
91 struct type *type, gdb_byte *buf,
ac2e2ef7 92 CORE_ADDR addr);
9898f801
UW
93extern CORE_ADDR signed_pointer_to_address (struct gdbarch *gdbarch,
94 struct type *type,
b60c417a 95 const gdb_byte *buf);
9898f801
UW
96extern void address_to_signed_pointer (struct gdbarch *gdbarch,
97 struct type *type, gdb_byte *buf,
ac2e2ef7 98 CORE_ADDR addr);
4478b372 99
a14ed312 100extern void reopen_exec_file (void);
c906108c 101
c906108c
SS
102/* From misc files */
103
0ab7a791
AC
104extern void default_print_registers_info (struct gdbarch *gdbarch,
105 struct ui_file *file,
106 struct frame_info *frame,
107 int regnum, int all);
666e11c5 108
0a4f40a2 109extern void child_terminal_info (struct target_ops *self, const char *, int);
c906108c 110
a14ed312 111extern void term_info (char *, int);
c906108c 112
d6b64346
PA
113extern void child_terminal_ours (struct target_ops *self);
114
115extern void child_terminal_ours_for_output (struct target_ops *self);
c906108c 116
d6b64346 117extern void child_terminal_inferior (struct target_ops *self);
c906108c 118
d6b64346 119extern void child_terminal_init (struct target_ops *self);
c906108c 120
d6b64346 121extern void child_terminal_init_with_pgrp (int pgrp);
c906108c 122
c906108c
SS
123/* From fork-child.c */
124
136d6dae
VP
125extern int fork_inferior (char *, char *, char **,
126 void (*)(void),
e69860f1
TG
127 void (*)(int), void (*)(void), char *,
128 void (*)(const char *,
129 char * const *, char * const *));
c906108c
SS
130
131
a14ed312 132extern void startup_inferior (int);
c906108c 133
bd57a748 134extern char *construct_inferior_arguments (int, char **);
552c04a7 135
c906108c
SS
136/* From infcmd.c */
137
281b533b
DJ
138extern void post_create_inferior (struct target_ops *, int);
139
a14ed312 140extern void attach_command (char *, int);
c906108c 141
a250df2e 142extern char *get_inferior_args (void);
07091751 143
3f81c18a 144extern void set_inferior_args (char *);
07091751 145
552c04a7
TT
146extern void set_inferior_args_vector (int, char **);
147
36dc181b
EZ
148extern void registers_info (char *, int);
149
77ebaa5a
VP
150extern void continue_1 (int all_threads);
151
77ebaa5a
VP
152extern void interrupt_target_1 (int all_threads);
153
186c406b
TT
154extern void delete_longjmp_breakpoint_cleanup (void *arg);
155
6418d433
VP
156extern void detach_command (char *, int);
157
1941c569
PA
158extern void notice_new_inferior (ptid_t, int, int);
159
6a3a010b 160extern struct value *get_return_value (struct value *function,
cc72b2a2
KP
161 struct type *value_type);
162
329ea579
PA
163/* Prepare for execution command. TARGET is the target that will run
164 the command. BACKGROUND determines whether this is a foreground
165 (synchronous) or background (asynchronous) command. */
166
167extern void prepare_execution_command (struct target_ops *target,
168 int background);
169
98882a26
PA
170/* Whether to start up the debuggee under a shell.
171
172 If startup-with-shell is set, GDB's "run" will attempt to start up
173 the debuggee under a shell.
174
175 This is in order for argument-expansion to occur. E.g.,
176
177 (gdb) run *
178
179 The "*" gets expanded by the shell into a list of files.
180
181 While this is a nice feature, it may be handy to bypass the shell
182 in some cases. To disable this feature, do "set startup-with-shell
183 false".
184
185 The catch-exec traps expected during start-up will be one more if
186 the target is started up with a shell. */
187extern int startup_with_shell;
188
c906108c
SS
189/* Address at which inferior stopped. */
190
191extern CORE_ADDR stop_pc;
192
c906108c
SS
193/* Nonzero if stopped due to completion of a stack dummy routine. */
194
aa7d318d 195extern enum stop_stack_kind stop_stack_dummy;
c906108c
SS
196
197/* Nonzero if program stopped due to a random (unexpected) signal in
198 inferior process. */
199
200extern int stopped_by_random_signal;
201
a49f981f
MS
202/* STEP_OVER_ALL means step over all subroutine calls.
203 STEP_OVER_UNDEBUGGABLE means step over calls to undebuggable functions.
204 STEP_OVER_NONE means don't step over any subroutine calls. */
c906108c 205
5fbbeb29
CF
206enum step_over_calls_kind
207 {
208 STEP_OVER_NONE,
209 STEP_OVER_ALL,
a4acd088
CF
210 STEP_OVER_UNDEBUGGABLE
211 };
212
b0f4b84b
DJ
213/* Anything but NO_STOP_QUIETLY means we expect a trap and the caller
214 will handle it themselves. STOP_QUIETLY is used when running in
215 the shell before the child program has been exec'd and when running
216 through shared library loading. STOP_QUIETLY_REMOTE is used when
217 setting up a remote connection; it is like STOP_QUIETLY_NO_SIGSTOP
218 except that there is no need to hide a signal. */
c54cfec8 219
7c0bc051
DE
220/* STOP_QUIETLY_NO_SIGSTOP is used to handle a tricky situation with attach.
221 When doing an attach, the kernel stops the debuggee with a SIGSTOP.
222 On newer GNU/Linux kernels (>= 2.5.61) the handling of SIGSTOP for
223 a ptraced process has changed. Earlier versions of the kernel
224 would ignore these SIGSTOPs, while now SIGSTOP is treated like any
225 other signal, i.e. it is not muffled.
226
c54cfec8
EZ
227 If the gdb user does a 'continue' after the 'attach', gdb passes
228 the global variable stop_signal (which stores the signal from the
229 attach, SIGSTOP) to the ptrace(PTRACE_CONT,...) call. This is
230 problematic, because the kernel doesn't ignore such SIGSTOP
1777feb0 231 now. I.e. it is reported back to gdb, which in turn presents it
c54cfec8 232 back to the user.
7c0bc051 233
c54cfec8
EZ
234 To avoid the problem, we use STOP_QUIETLY_NO_SIGSTOP, which allows
235 gdb to clear the value of stop_signal after the attach, so that it
236 is not passed back down to the kernel. */
237
238enum stop_kind
239 {
240 NO_STOP_QUIETLY = 0,
241 STOP_QUIETLY,
b0f4b84b 242 STOP_QUIETLY_REMOTE,
c54cfec8
EZ
243 STOP_QUIETLY_NO_SIGSTOP
244 };
c906108c 245
c906108c 246\f
faaf634c 247/* Possible values for gdbarch_call_dummy_location. */
c906108c 248#define ON_STACK 1
c906108c
SS
249#define AT_ENTRY_POINT 4
250
98882a26
PA
251/* Number of traps that happen between exec'ing the shell to run an
252 inferior and when we finally get to the inferior code, not counting
253 the exec for the shell. This is 1 on most implementations.
254 Overridden in nm.h files. */
c906108c 255#if !defined(START_INFERIOR_TRAPS_EXPECTED)
98882a26 256#define START_INFERIOR_TRAPS_EXPECTED 1
c906108c 257#endif
b77209e0
PA
258
259struct private_inferior;
260
16c381f0
JK
261/* Inferior process specific part of `struct infcall_control_state'.
262
263 Inferior thread counterpart is `struct thread_control_state'. */
264
265struct inferior_control_state
266{
267 /* See the definition of stop_kind above. */
268 enum stop_kind stop_soon;
269};
270
271/* Inferior process specific part of `struct infcall_suspend_state'.
272
273 Inferior thread counterpart is `struct thread_suspend_state'. */
274
dd80ea3c 275#if 0 /* Currently unused and empty structures are not valid C. */
16c381f0
JK
276struct inferior_suspend_state
277{
278};
dd80ea3c 279#endif
16c381f0 280
b77209e0
PA
281/* GDB represents the state of each program execution with an object
282 called an inferior. An inferior typically corresponds to a process
283 but is more general and applies also to targets that do not have a
284 notion of processes. Each run of an executable creates a new
285 inferior, as does each attachment to an existing process.
286 Inferiors have unique internal identifiers that are different from
287 target process ids. Each inferior may in turn have multiple
288 threads running in it. */
289
290struct inferior
291{
292 /* Pointer to next inferior in singly-linked list of inferiors. */
293 struct inferior *next;
294
295 /* Convenient handle (GDB inferior id). Unique across all
296 inferiors. */
297 int num;
298
299 /* Actual target inferior id, usually, a process id. This matches
300 the ptid_t.pid member of threads of this inferior. */
301 int pid;
e714e1bf
UW
302 /* True if the PID was actually faked by GDB. */
303 int fake_pid_p;
b77209e0 304
16c381f0
JK
305 /* State of GDB control of inferior process execution.
306 See `struct inferior_control_state'. */
307 struct inferior_control_state control;
308
309 /* State of inferior process to restore after GDB is done with an inferior
310 call. See `struct inferior_suspend_state'. */
dd80ea3c 311#if 0 /* Currently unused and empty structures are not valid C. */
16c381f0 312 struct inferior_suspend_state suspend;
dd80ea3c 313#endif
16c381f0 314
6c95b8df
PA
315 /* True if this was an auto-created inferior, e.g. created from
316 following a fork; false, if this inferior was manually added by
317 the user, and we should not attempt to prune it
318 automatically. */
319 int removable;
320
321 /* The address space bound to this inferior. */
322 struct address_space *aspace;
323
324 /* The program space bound to this inferior. */
325 struct program_space *pspace;
326
3f81c18a
VP
327 /* The arguments string to use when running. */
328 char *args;
329
330 /* The size of elements in argv. */
331 int argc;
332
333 /* The vector version of arguments. If ARGC is nonzero,
334 then we must compute ARGS from this (via the target).
335 This is always coming from main's argv and therefore
336 should never be freed. */
337 char **argv;
338
339 /* The name of terminal device to use for I/O. */
340 char *terminal;
341
342 /* Environment to use for running inferior,
343 in format described in environ.h. */
344 struct gdb_environ *environment;
345
181e7f93
PA
346 /* Nonzero if this child process was attached rather than
347 forked. */
348 int attach_flag;
349
6c95b8df
PA
350 /* If this inferior is a vfork child, then this is the pointer to
351 its vfork parent, if GDB is still attached to it. */
352 struct inferior *vfork_parent;
353
354 /* If this process is a vfork parent, this is the pointer to the
355 child. Since a vfork parent is left frozen by the kernel until
356 the child execs or exits, a process can only have one vfork child
357 at a given time. */
358 struct inferior *vfork_child;
359
360 /* True if this inferior should be detached when it's vfork sibling
361 exits or execs. */
362 int pending_detach;
363
364 /* True if this inferior is a vfork parent waiting for a vfork child
365 not under our control to be done with the shared memory region,
366 either by exiting or execing. */
367 int waiting_for_vfork_done;
368
24291992
PA
369 /* True if we're in the process of detaching from this inferior. */
370 int detaching;
371
e0ba6746
PA
372 /* What is left to do for an execution command after any thread of
373 this inferior stops. For continuations associated with a
374 specific thread, see `struct thread_info'. */
375 struct continuation *continuations;
376
b77209e0
PA
377 /* Private data used by the target vector implementation. */
378 struct private_inferior *private;
a96d9b2e 379
8cf64490
TT
380 /* HAS_EXIT_CODE is true if the inferior exited with an exit code.
381 In this case, the EXIT_CODE field is also valid. */
382 int has_exit_code;
383 LONGEST exit_code;
384
7dcd53a0
TT
385 /* Default flags to pass to the symbol reading functions. These are
386 used whenever a new objfile is created. The valid values come
387 from enum symfile_add_flags. */
388 int symfile_flags;
389
6ecd4729
PA
390 /* Info about an inferior's target description (if it's fetched; the
391 user supplied description's filename, if any; etc.). */
392 struct target_desc_info *tdesc_info;
393
394 /* The architecture associated with the inferior through the
395 connection to the target.
396
397 The architecture vector provides some information that is really
398 a property of the inferior, accessed through a particular target:
399 ptrace operations; the layout of certain RSP packets; the
400 solib_ops vector; etc. To differentiate architecture accesses to
401 per-inferior/target properties from
402 per-thread/per-frame/per-objfile properties, accesses to
403 per-inferior/target properties should be made through
404 this gdbarch. */
405 struct gdbarch *gdbarch;
406
6c95b8df 407 /* Per inferior data-pointers required by other GDB modules. */
8e260fc0 408 REGISTRY_FIELDS;
b77209e0
PA
409};
410
6c95b8df
PA
411/* Keep a registry of per-inferior data-pointers required by other GDB
412 modules. */
413
8e260fc0 414DECLARE_REGISTRY (inferior);
6c95b8df 415
b77209e0
PA
416/* Create an empty inferior list, or empty the existing one. */
417extern void init_inferior_list (void);
418
419/* Add an inferior to the inferior list, print a message that a new
420 inferior is found, and return the pointer to the new inferior.
421 Caller may use this pointer to initialize the private inferior
422 data. */
423extern struct inferior *add_inferior (int pid);
424
425/* Same as add_inferior, but don't print new inferior notifications to
426 the CLI. */
427extern struct inferior *add_inferior_silent (int pid);
428
429/* Delete an existing inferior list entry, due to inferior exit. */
430extern void delete_inferior (int pid);
431
a79b8f6e
VP
432extern void delete_inferior_1 (struct inferior *todel, int silent);
433
b77209e0
PA
434/* Same as delete_inferior, but don't print new inferior notifications
435 to the CLI. */
436extern void delete_inferior_silent (int pid);
437
438/* Delete an existing inferior list entry, due to inferior detaching. */
439extern void detach_inferior (int pid);
440
6c95b8df
PA
441extern void exit_inferior (int pid);
442
443extern void exit_inferior_silent (int pid);
444
445extern void exit_inferior_num_silent (int num);
446
447extern void inferior_appeared (struct inferior *inf, int pid);
448
82f73884
PA
449/* Get rid of all inferiors. */
450extern void discard_all_inferiors (void);
451
b77209e0
PA
452/* Translate the integer inferior id (GDB's homegrown id, not the system's)
453 into a "pid" (which may be overloaded with extra inferior information). */
454extern int gdb_inferior_id_to_pid (int);
455
456/* Translate a target 'pid' into the integer inferior id (GDB's
457 homegrown id, not the system's). */
458extern int pid_to_gdb_inferior_id (int pid);
459
460/* Boolean test for an already-known pid. */
461extern int in_inferior_list (int pid);
462
463/* Boolean test for an already-known inferior id (GDB's homegrown id,
464 not the system's). */
2c0b251b 465extern int valid_gdb_inferior_id (int num);
b77209e0 466
6c95b8df 467/* Search function to lookup an inferior by target 'pid'. */
b77209e0
PA
468extern struct inferior *find_inferior_pid (int pid);
469
6c95b8df
PA
470/* Search function to lookup an inferior by GDB 'num'. */
471extern struct inferior *find_inferior_id (int num);
472
32990ada
PA
473/* Find an inferior bound to PSPACE, giving preference to the current
474 inferior. */
6c95b8df
PA
475extern struct inferior *
476 find_inferior_for_program_space (struct program_space *pspace);
477
b77209e0
PA
478/* Inferior iterator function.
479
480 Calls a callback function once for each inferior, so long as the
481 callback function returns false. If the callback function returns
482 true, the iteration will end and the current inferior will be
483 returned. This can be useful for implementing a search for a
484 inferior with arbitrary attributes, or for applying some operation
485 to every inferior.
486
487 It is safe to delete the iterated inferior from the callback. */
488extern struct inferior *iterate_over_inferiors (int (*) (struct inferior *,
489 void *),
490 void *);
491
b77209e0
PA
492/* Returns true if the inferior list is not empty. */
493extern int have_inferiors (void);
494
c35b1492
PA
495/* Returns true if there are any live inferiors in the inferior list
496 (not cores, not executables, real live processes). */
497extern int have_live_inferiors (void);
498
b77209e0
PA
499/* Return a pointer to the current inferior. It is an error to call
500 this if there is no current inferior. */
501extern struct inferior *current_inferior (void);
502
6c95b8df
PA
503extern void set_current_inferior (struct inferior *);
504
505extern struct cleanup *save_current_inferior (void);
506
c65b3e0d
PA
507/* Traverse all inferiors. */
508
509#define ALL_INFERIORS(I) \
510 for ((I) = inferior_list; (I); (I) = (I)->next)
511
6c95b8df
PA
512extern struct inferior *inferior_list;
513
514/* Prune away automatically added inferiors that aren't required
515 anymore. */
516extern void prune_inferiors (void);
517
518extern int number_of_inferiors (void);
519
a79b8f6e
VP
520extern struct inferior *add_inferior_with_spaces (void);
521
c906108c 522#endif /* !defined (INFERIOR_H) */
This page took 1.147884 seconds and 4 git commands to generate.