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