Fix mi-nonstop.exp with extended-remote
[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
32d0add0 4 Copyright (C) 1986-2015 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
cc86d1cb
YQ
109/* Default implementation of gdbarch_print_float_info. Print
110 the values of all floating point registers. */
111
112extern void default_print_float_info (struct gdbarch *gdbarch,
113 struct ui_file *file,
114 struct frame_info *frame,
115 const char *args);
116
0a4f40a2 117extern void child_terminal_info (struct target_ops *self, const char *, int);
c906108c 118
a14ed312 119extern void term_info (char *, int);
c906108c 120
d6b64346
PA
121extern void child_terminal_ours (struct target_ops *self);
122
123extern void child_terminal_ours_for_output (struct target_ops *self);
c906108c 124
d6b64346 125extern void child_terminal_inferior (struct target_ops *self);
c906108c 126
d6b64346 127extern void child_terminal_init (struct target_ops *self);
c906108c 128
d6b64346 129extern void child_terminal_init_with_pgrp (int pgrp);
c906108c 130
c906108c
SS
131/* From fork-child.c */
132
136d6dae
VP
133extern int fork_inferior (char *, char *, char **,
134 void (*)(void),
e69860f1
TG
135 void (*)(int), void (*)(void), char *,
136 void (*)(const char *,
137 char * const *, char * const *));
c906108c
SS
138
139
a14ed312 140extern void startup_inferior (int);
c906108c 141
bd57a748 142extern char *construct_inferior_arguments (int, char **);
552c04a7 143
c906108c
SS
144/* From infcmd.c */
145
281b533b
DJ
146extern void post_create_inferior (struct target_ops *, int);
147
a14ed312 148extern void attach_command (char *, int);
c906108c 149
a250df2e 150extern char *get_inferior_args (void);
07091751 151
3f81c18a 152extern void set_inferior_args (char *);
07091751 153
552c04a7
TT
154extern void set_inferior_args_vector (int, char **);
155
36dc181b
EZ
156extern void registers_info (char *, int);
157
77ebaa5a
VP
158extern void continue_1 (int all_threads);
159
77ebaa5a
VP
160extern void interrupt_target_1 (int all_threads);
161
186c406b
TT
162extern void delete_longjmp_breakpoint_cleanup (void *arg);
163
6418d433
VP
164extern void detach_command (char *, int);
165
1941c569
PA
166extern void notice_new_inferior (ptid_t, int, int);
167
0700e23e
PA
168extern struct value *get_return_value (struct value *function,
169 struct type *value_type);
cc72b2a2 170
329ea579
PA
171/* Prepare for execution command. TARGET is the target that will run
172 the command. BACKGROUND determines whether this is a foreground
173 (synchronous) or background (asynchronous) command. */
174
175extern void prepare_execution_command (struct target_ops *target,
176 int background);
177
98882a26
PA
178/* Whether to start up the debuggee under a shell.
179
180 If startup-with-shell is set, GDB's "run" will attempt to start up
181 the debuggee under a shell.
182
183 This is in order for argument-expansion to occur. E.g.,
184
185 (gdb) run *
186
187 The "*" gets expanded by the shell into a list of files.
188
189 While this is a nice feature, it may be handy to bypass the shell
190 in some cases. To disable this feature, do "set startup-with-shell
191 false".
192
193 The catch-exec traps expected during start-up will be one more if
194 the target is started up with a shell. */
195extern int startup_with_shell;
196
c906108c
SS
197/* Address at which inferior stopped. */
198
199extern CORE_ADDR stop_pc;
200
c906108c
SS
201/* Nonzero if stopped due to completion of a stack dummy routine. */
202
aa7d318d 203extern enum stop_stack_kind stop_stack_dummy;
c906108c
SS
204
205/* Nonzero if program stopped due to a random (unexpected) signal in
206 inferior process. */
207
208extern int stopped_by_random_signal;
209
a49f981f
MS
210/* STEP_OVER_ALL means step over all subroutine calls.
211 STEP_OVER_UNDEBUGGABLE means step over calls to undebuggable functions.
212 STEP_OVER_NONE means don't step over any subroutine calls. */
c906108c 213
5fbbeb29
CF
214enum step_over_calls_kind
215 {
216 STEP_OVER_NONE,
217 STEP_OVER_ALL,
a4acd088
CF
218 STEP_OVER_UNDEBUGGABLE
219 };
220
b0f4b84b
DJ
221/* Anything but NO_STOP_QUIETLY means we expect a trap and the caller
222 will handle it themselves. STOP_QUIETLY is used when running in
223 the shell before the child program has been exec'd and when running
224 through shared library loading. STOP_QUIETLY_REMOTE is used when
225 setting up a remote connection; it is like STOP_QUIETLY_NO_SIGSTOP
226 except that there is no need to hide a signal. */
c54cfec8 227
7c0bc051
DE
228/* STOP_QUIETLY_NO_SIGSTOP is used to handle a tricky situation with attach.
229 When doing an attach, the kernel stops the debuggee with a SIGSTOP.
230 On newer GNU/Linux kernels (>= 2.5.61) the handling of SIGSTOP for
231 a ptraced process has changed. Earlier versions of the kernel
232 would ignore these SIGSTOPs, while now SIGSTOP is treated like any
233 other signal, i.e. it is not muffled.
234
c54cfec8
EZ
235 If the gdb user does a 'continue' after the 'attach', gdb passes
236 the global variable stop_signal (which stores the signal from the
237 attach, SIGSTOP) to the ptrace(PTRACE_CONT,...) call. This is
238 problematic, because the kernel doesn't ignore such SIGSTOP
1777feb0 239 now. I.e. it is reported back to gdb, which in turn presents it
c54cfec8 240 back to the user.
7c0bc051 241
c54cfec8
EZ
242 To avoid the problem, we use STOP_QUIETLY_NO_SIGSTOP, which allows
243 gdb to clear the value of stop_signal after the attach, so that it
244 is not passed back down to the kernel. */
245
246enum stop_kind
247 {
248 NO_STOP_QUIETLY = 0,
249 STOP_QUIETLY,
b0f4b84b 250 STOP_QUIETLY_REMOTE,
c54cfec8
EZ
251 STOP_QUIETLY_NO_SIGSTOP
252 };
c906108c 253
c906108c 254\f
faaf634c 255/* Possible values for gdbarch_call_dummy_location. */
c906108c 256#define ON_STACK 1
c906108c
SS
257#define AT_ENTRY_POINT 4
258
98882a26
PA
259/* Number of traps that happen between exec'ing the shell to run an
260 inferior and when we finally get to the inferior code, not counting
32a8097b
PA
261 the exec for the shell. This is 1 on all supported
262 implementations. */
98882a26 263#define START_INFERIOR_TRAPS_EXPECTED 1
b77209e0
PA
264
265struct private_inferior;
266
16c381f0
JK
267/* Inferior process specific part of `struct infcall_control_state'.
268
269 Inferior thread counterpart is `struct thread_control_state'. */
270
271struct inferior_control_state
272{
273 /* See the definition of stop_kind above. */
274 enum stop_kind stop_soon;
275};
276
b77209e0
PA
277/* GDB represents the state of each program execution with an object
278 called an inferior. An inferior typically corresponds to a process
279 but is more general and applies also to targets that do not have a
280 notion of processes. Each run of an executable creates a new
281 inferior, as does each attachment to an existing process.
282 Inferiors have unique internal identifiers that are different from
283 target process ids. Each inferior may in turn have multiple
284 threads running in it. */
285
286struct inferior
287{
288 /* Pointer to next inferior in singly-linked list of inferiors. */
289 struct inferior *next;
290
291 /* Convenient handle (GDB inferior id). Unique across all
292 inferiors. */
293 int num;
294
295 /* Actual target inferior id, usually, a process id. This matches
296 the ptid_t.pid member of threads of this inferior. */
297 int pid;
e714e1bf
UW
298 /* True if the PID was actually faked by GDB. */
299 int fake_pid_p;
b77209e0 300
16c381f0
JK
301 /* State of GDB control of inferior process execution.
302 See `struct inferior_control_state'. */
303 struct inferior_control_state control;
304
6c95b8df
PA
305 /* True if this was an auto-created inferior, e.g. created from
306 following a fork; false, if this inferior was manually added by
307 the user, and we should not attempt to prune it
308 automatically. */
309 int removable;
310
311 /* The address space bound to this inferior. */
312 struct address_space *aspace;
313
314 /* The program space bound to this inferior. */
315 struct program_space *pspace;
316
3f81c18a
VP
317 /* The arguments string to use when running. */
318 char *args;
319
320 /* The size of elements in argv. */
321 int argc;
322
323 /* The vector version of arguments. If ARGC is nonzero,
324 then we must compute ARGS from this (via the target).
325 This is always coming from main's argv and therefore
326 should never be freed. */
327 char **argv;
328
329 /* The name of terminal device to use for I/O. */
330 char *terminal;
331
332 /* Environment to use for running inferior,
333 in format described in environ.h. */
334 struct gdb_environ *environment;
335
181e7f93
PA
336 /* Nonzero if this child process was attached rather than
337 forked. */
338 int attach_flag;
339
6c95b8df
PA
340 /* If this inferior is a vfork child, then this is the pointer to
341 its vfork parent, if GDB is still attached to it. */
342 struct inferior *vfork_parent;
343
344 /* If this process is a vfork parent, this is the pointer to the
345 child. Since a vfork parent is left frozen by the kernel until
346 the child execs or exits, a process can only have one vfork child
347 at a given time. */
348 struct inferior *vfork_child;
349
350 /* True if this inferior should be detached when it's vfork sibling
351 exits or execs. */
352 int pending_detach;
353
354 /* True if this inferior is a vfork parent waiting for a vfork child
355 not under our control to be done with the shared memory region,
356 either by exiting or execing. */
357 int waiting_for_vfork_done;
358
24291992
PA
359 /* True if we're in the process of detaching from this inferior. */
360 int detaching;
361
e0ba6746
PA
362 /* What is left to do for an execution command after any thread of
363 this inferior stops. For continuations associated with a
364 specific thread, see `struct thread_info'. */
365 struct continuation *continuations;
366
b77209e0 367 /* Private data used by the target vector implementation. */
fe978cb0 368 struct private_inferior *priv;
a96d9b2e 369
8cf64490
TT
370 /* HAS_EXIT_CODE is true if the inferior exited with an exit code.
371 In this case, the EXIT_CODE field is also valid. */
372 int has_exit_code;
373 LONGEST exit_code;
374
7dcd53a0
TT
375 /* Default flags to pass to the symbol reading functions. These are
376 used whenever a new objfile is created. The valid values come
377 from enum symfile_add_flags. */
378 int symfile_flags;
379
6ecd4729
PA
380 /* Info about an inferior's target description (if it's fetched; the
381 user supplied description's filename, if any; etc.). */
382 struct target_desc_info *tdesc_info;
383
384 /* The architecture associated with the inferior through the
385 connection to the target.
386
387 The architecture vector provides some information that is really
388 a property of the inferior, accessed through a particular target:
389 ptrace operations; the layout of certain RSP packets; the
390 solib_ops vector; etc. To differentiate architecture accesses to
391 per-inferior/target properties from
392 per-thread/per-frame/per-objfile properties, accesses to
393 per-inferior/target properties should be made through
394 this gdbarch. */
395 struct gdbarch *gdbarch;
396
6c95b8df 397 /* Per inferior data-pointers required by other GDB modules. */
8e260fc0 398 REGISTRY_FIELDS;
b77209e0
PA
399};
400
6c95b8df
PA
401/* Keep a registry of per-inferior data-pointers required by other GDB
402 modules. */
403
8e260fc0 404DECLARE_REGISTRY (inferior);
6c95b8df 405
b77209e0
PA
406/* Create an empty inferior list, or empty the existing one. */
407extern void init_inferior_list (void);
408
409/* Add an inferior to the inferior list, print a message that a new
410 inferior is found, and return the pointer to the new inferior.
411 Caller may use this pointer to initialize the private inferior
412 data. */
413extern struct inferior *add_inferior (int pid);
414
415/* Same as add_inferior, but don't print new inferior notifications to
416 the CLI. */
417extern struct inferior *add_inferior_silent (int pid);
418
7a41607e 419extern void delete_inferior (struct inferior *todel);
b77209e0
PA
420
421/* Delete an existing inferior list entry, due to inferior detaching. */
422extern void detach_inferior (int pid);
423
6c95b8df
PA
424extern void exit_inferior (int pid);
425
426extern void exit_inferior_silent (int pid);
427
428extern void exit_inferior_num_silent (int num);
429
430extern void inferior_appeared (struct inferior *inf, int pid);
431
82f73884
PA
432/* Get rid of all inferiors. */
433extern void discard_all_inferiors (void);
434
b77209e0
PA
435/* Translate the integer inferior id (GDB's homegrown id, not the system's)
436 into a "pid" (which may be overloaded with extra inferior information). */
437extern int gdb_inferior_id_to_pid (int);
438
439/* Translate a target 'pid' into the integer inferior id (GDB's
440 homegrown id, not the system's). */
441extern int pid_to_gdb_inferior_id (int pid);
442
443/* Boolean test for an already-known pid. */
444extern int in_inferior_list (int pid);
445
446/* Boolean test for an already-known inferior id (GDB's homegrown id,
447 not the system's). */
2c0b251b 448extern int valid_gdb_inferior_id (int num);
b77209e0 449
6c95b8df 450/* Search function to lookup an inferior by target 'pid'. */
b77209e0
PA
451extern struct inferior *find_inferior_pid (int pid);
452
c9657e70
SM
453/* Search function to lookup an inferior whose pid is equal to 'ptid.pid'. */
454extern struct inferior *find_inferior_ptid (ptid_t ptid);
455
6c95b8df
PA
456/* Search function to lookup an inferior by GDB 'num'. */
457extern struct inferior *find_inferior_id (int num);
458
32990ada
PA
459/* Find an inferior bound to PSPACE, giving preference to the current
460 inferior. */
6c95b8df
PA
461extern struct inferior *
462 find_inferior_for_program_space (struct program_space *pspace);
463
b77209e0
PA
464/* Inferior iterator function.
465
466 Calls a callback function once for each inferior, so long as the
467 callback function returns false. If the callback function returns
468 true, the iteration will end and the current inferior will be
469 returned. This can be useful for implementing a search for a
470 inferior with arbitrary attributes, or for applying some operation
471 to every inferior.
472
473 It is safe to delete the iterated inferior from the callback. */
474extern struct inferior *iterate_over_inferiors (int (*) (struct inferior *,
475 void *),
476 void *);
477
b77209e0
PA
478/* Returns true if the inferior list is not empty. */
479extern int have_inferiors (void);
480
c35b1492
PA
481/* Returns true if there are any live inferiors in the inferior list
482 (not cores, not executables, real live processes). */
483extern int have_live_inferiors (void);
484
b77209e0
PA
485/* Return a pointer to the current inferior. It is an error to call
486 this if there is no current inferior. */
487extern struct inferior *current_inferior (void);
488
6c95b8df
PA
489extern void set_current_inferior (struct inferior *);
490
491extern struct cleanup *save_current_inferior (void);
492
c65b3e0d
PA
493/* Traverse all inferiors. */
494
495#define ALL_INFERIORS(I) \
496 for ((I) = inferior_list; (I); (I) = (I)->next)
497
6c95b8df
PA
498extern struct inferior *inferior_list;
499
500/* Prune away automatically added inferiors that aren't required
501 anymore. */
502extern void prune_inferiors (void);
503
504extern int number_of_inferiors (void);
505
a79b8f6e
VP
506extern struct inferior *add_inferior_with_spaces (void);
507
c906108c 508#endif /* !defined (INFERIOR_H) */
This page took 1.319453 seconds and 4 git commands to generate.