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