Commit | Line | Data |
---|---|---|
2090129c SDJ |
1 | /* Functions and data responsible for forking the inferior process. |
2 | ||
42a4f53d | 3 | Copyright (C) 1986-2019 Free Software Foundation, Inc. |
2090129c SDJ |
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 | ||
1a5c2598 TT |
20 | #ifndef NAT_FORK_INFERIOR_H |
21 | #define NAT_FORK_INFERIOR_H | |
2090129c SDJ |
22 | |
23 | #include <string> | |
24 | ||
25 | /* Number of traps that happen between exec'ing the shell to run an | |
26 | inferior and when we finally get to the inferior code, not counting | |
27 | the exec for the shell. This is 1 on all supported | |
28 | implementations. */ | |
29 | #define START_INFERIOR_TRAPS_EXPECTED 1 | |
30 | ||
31 | /* Start an inferior Unix child process and sets inferior_ptid to its | |
32 | pid. EXEC_FILE is the file to run. ALLARGS is a string containing | |
33 | the arguments to the program. ENV is the environment vector to | |
34 | pass. SHELL_FILE is the shell file, or NULL if we should pick | |
35 | one. EXEC_FUN is the exec(2) function to use, or NULL for the default | |
36 | one. */ | |
37 | ||
38 | /* This function is NOT reentrant. Some of the variables have been | |
39 | made static to ensure that they survive the vfork call. */ | |
40 | extern pid_t fork_inferior (const char *exec_file_arg, | |
41 | const std::string &allargs, | |
42 | char **env, void (*traceme_fun) (), | |
43 | void (*init_trace_fun) (int), | |
44 | void (*pre_trace_fun) (), | |
45 | const char *shell_file_arg, | |
46 | void (*exec_fun) (const char *file, | |
47 | char * const *argv, | |
48 | char * const *env)); | |
49 | ||
50 | /* Accept NTRAPS traps from the inferior. | |
51 | ||
52 | Return the ptid of the inferior being started. */ | |
53 | extern ptid_t startup_inferior (pid_t pid, int ntraps, | |
54 | struct target_waitstatus *mystatus, | |
55 | ptid_t *myptid); | |
56 | ||
2090129c SDJ |
57 | /* Perform any necessary tasks before a fork/vfork takes place. ARGS |
58 | is a string containing all the arguments received by the inferior. | |
59 | This function is mainly used by fork_inferior. */ | |
60 | extern void prefork_hook (const char *args); | |
61 | ||
62 | /* Perform any necessary tasks after a fork/vfork takes place. This | |
63 | function is mainly used by fork_inferior. */ | |
64 | extern void postfork_hook (pid_t pid); | |
65 | ||
66 | /* Perform any necessary tasks *on the child* after a fork/vfork takes | |
67 | place. This function is mainly used by fork_inferior. */ | |
68 | extern void postfork_child_hook (); | |
69 | ||
70 | /* Flush both stdout and stderr. This function needs to be | |
71 | implemented differently on GDB and GDBserver. */ | |
72 | extern void gdb_flush_out_err (); | |
73 | ||
74 | /* Report an error that happened when starting to trace the inferior | |
75 | (i.e., when the "traceme_fun" callback is called on fork_inferior) | |
76 | and bail out. This function does not return. */ | |
77 | extern void trace_start_error (const char *fmt, ...) | |
1d4fbac9 | 78 | ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2); |
2090129c SDJ |
79 | |
80 | /* Like "trace_start_error", but the error message is constructed by | |
50fa3001 SDJ |
81 | combining STRING with the system error message for errno. This |
82 | function does not return. */ | |
83 | extern void trace_start_error_with_name (const char *string) | |
2090129c SDJ |
84 | ATTRIBUTE_NORETURN; |
85 | ||
1a5c2598 | 86 | #endif /* NAT_FORK_INFERIOR_H */ |