Multi-target support
[deliverable/binutils-gdb.git] / gdb / nat / fork-inferior.h
1 /* Functions and data responsible for forking the inferior process.
2
3 Copyright (C) 1986-2020 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #ifndef NAT_FORK_INFERIOR_H
21 #define NAT_FORK_INFERIOR_H
22
23 #include <string>
24
25 struct process_stratum_target;
26
27 /* Number of traps that happen between exec'ing the shell to run an
28 inferior and when we finally get to the inferior code, not counting
29 the exec for the shell. This is 1 on all supported
30 implementations. */
31 #define START_INFERIOR_TRAPS_EXPECTED 1
32
33 /* Start an inferior Unix child process and sets inferior_ptid to its
34 pid. EXEC_FILE is the file to run. ALLARGS is a string containing
35 the arguments to the program. ENV is the environment vector to
36 pass. SHELL_FILE is the shell file, or NULL if we should pick
37 one. EXEC_FUN is the exec(2) function to use, or NULL for the default
38 one. */
39
40 /* This function is NOT reentrant. Some of the variables have been
41 made static to ensure that they survive the vfork call. */
42 extern pid_t fork_inferior (const char *exec_file_arg,
43 const std::string &allargs,
44 char **env, void (*traceme_fun) (),
45 void (*init_trace_fun) (int),
46 void (*pre_trace_fun) (),
47 const char *shell_file_arg,
48 void (*exec_fun) (const char *file,
49 char * const *argv,
50 char * const *env));
51
52 /* Accept NTRAPS traps from the inferior.
53
54 Return the ptid of the inferior being started. */
55 extern ptid_t startup_inferior (process_stratum_target *proc_target,
56 pid_t pid, int ntraps,
57 struct target_waitstatus *mystatus,
58 ptid_t *myptid);
59
60 /* Perform any necessary tasks before a fork/vfork takes place. ARGS
61 is a string containing all the arguments received by the inferior.
62 This function is mainly used by fork_inferior. */
63 extern void prefork_hook (const char *args);
64
65 /* Perform any necessary tasks after a fork/vfork takes place. This
66 function is mainly used by fork_inferior. */
67 extern void postfork_hook (pid_t pid);
68
69 /* Perform any necessary tasks *on the child* after a fork/vfork takes
70 place. This function is mainly used by fork_inferior. */
71 extern void postfork_child_hook ();
72
73 /* Flush both stdout and stderr. This function needs to be
74 implemented differently on GDB and GDBserver. */
75 extern void gdb_flush_out_err ();
76
77 /* Report an error that happened when starting to trace the inferior
78 (i.e., when the "traceme_fun" callback is called on fork_inferior)
79 and bail out. This function does not return. */
80 extern void trace_start_error (const char *fmt, ...)
81 ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
82
83 /* Like "trace_start_error", but the error message is constructed by
84 combining STRING with the system error message for errno. This
85 function does not return. */
86 extern void trace_start_error_with_name (const char *string)
87 ATTRIBUTE_NORETURN;
88
89 #endif /* NAT_FORK_INFERIOR_H */
This page took 0.030437 seconds and 4 git commands to generate.