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 | ||
57 | /* Whether to start up the debuggee under a shell. | |
58 | ||
59 | If startup-with-shell is set, GDB's "run" will attempt to start up | |
60 | the debuggee under a shell. This also happens when using GDBserver | |
61 | under extended remote mode. | |
62 | ||
63 | This is in order for argument-expansion to occur. E.g., | |
64 | ||
65 | (gdb) run * | |
66 | ||
67 | The "*" gets expanded by the shell into a list of files. | |
68 | ||
69 | While this is a nice feature, it may be handy to bypass the shell | |
70 | in some cases. To disable this feature, do "set startup-with-shell | |
71 | false". | |
72 | ||
73 | The catch-exec traps expected during start-up will be one more if | |
74 | the target is started up with a shell. */ | |
491144b5 | 75 | extern bool startup_with_shell; |
2090129c SDJ |
76 | |
77 | /* Perform any necessary tasks before a fork/vfork takes place. ARGS | |
78 | is a string containing all the arguments received by the inferior. | |
79 | This function is mainly used by fork_inferior. */ | |
80 | extern void prefork_hook (const char *args); | |
81 | ||
82 | /* Perform any necessary tasks after a fork/vfork takes place. This | |
83 | function is mainly used by fork_inferior. */ | |
84 | extern void postfork_hook (pid_t pid); | |
85 | ||
86 | /* Perform any necessary tasks *on the child* after a fork/vfork takes | |
87 | place. This function is mainly used by fork_inferior. */ | |
88 | extern void postfork_child_hook (); | |
89 | ||
90 | /* Flush both stdout and stderr. This function needs to be | |
91 | implemented differently on GDB and GDBserver. */ | |
92 | extern void gdb_flush_out_err (); | |
93 | ||
94 | /* Report an error that happened when starting to trace the inferior | |
95 | (i.e., when the "traceme_fun" callback is called on fork_inferior) | |
96 | and bail out. This function does not return. */ | |
97 | extern void trace_start_error (const char *fmt, ...) | |
1d4fbac9 | 98 | ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2); |
2090129c SDJ |
99 | |
100 | /* Like "trace_start_error", but the error message is constructed by | |
50fa3001 SDJ |
101 | combining STRING with the system error message for errno. This |
102 | function does not return. */ | |
103 | extern void trace_start_error_with_name (const char *string) | |
2090129c SDJ |
104 | ATTRIBUTE_NORETURN; |
105 | ||
1a5c2598 | 106 | #endif /* NAT_FORK_INFERIOR_H */ |