summaryrefslogtreecommitdiff
path: root/gdb/nat/fork-inferior.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/nat/fork-inferior.h')
-rw-r--r--gdb/nat/fork-inferior.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/gdb/nat/fork-inferior.h b/gdb/nat/fork-inferior.h
new file mode 100644
index 00000000000..10e383299c6
--- /dev/null
+++ b/gdb/nat/fork-inferior.h
@@ -0,0 +1,106 @@
+/* Functions and data responsible for forking the inferior process.
+
+ Copyright (C) 1986-2017 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef FORK_INFERIOR_H
+#define FORK_INFERIOR_H
+
+#include <string>
+
+/* Number of traps that happen between exec'ing the shell to run an
+ inferior and when we finally get to the inferior code, not counting
+ the exec for the shell. This is 1 on all supported
+ implementations. */
+#define START_INFERIOR_TRAPS_EXPECTED 1
+
+/* Start an inferior Unix child process and sets inferior_ptid to its
+ pid. EXEC_FILE is the file to run. ALLARGS is a string containing
+ the arguments to the program. ENV is the environment vector to
+ pass. SHELL_FILE is the shell file, or NULL if we should pick
+ one. EXEC_FUN is the exec(2) function to use, or NULL for the default
+ one. */
+
+/* This function is NOT reentrant. Some of the variables have been
+ made static to ensure that they survive the vfork call. */
+extern pid_t fork_inferior (const char *exec_file_arg,
+ const std::string &allargs,
+ char **env, void (*traceme_fun) (),
+ void (*init_trace_fun) (int),
+ void (*pre_trace_fun) (),
+ const char *shell_file_arg,
+ void (*exec_fun) (const char *file,
+ char * const *argv,
+ char * const *env));
+
+/* Accept NTRAPS traps from the inferior.
+
+ Return the ptid of the inferior being started. */
+extern ptid_t startup_inferior (pid_t pid, int ntraps,
+ struct target_waitstatus *mystatus,
+ ptid_t *myptid);
+
+/* Whether to start up the debuggee under a shell.
+
+ If startup-with-shell is set, GDB's "run" will attempt to start up
+ the debuggee under a shell. This also happens when using GDBserver
+ under extended remote mode.
+
+ This is in order for argument-expansion to occur. E.g.,
+
+ (gdb) run *
+
+ The "*" gets expanded by the shell into a list of files.
+
+ While this is a nice feature, it may be handy to bypass the shell
+ in some cases. To disable this feature, do "set startup-with-shell
+ false".
+
+ The catch-exec traps expected during start-up will be one more if
+ the target is started up with a shell. */
+extern int startup_with_shell;
+
+/* Perform any necessary tasks before a fork/vfork takes place. ARGS
+ is a string containing all the arguments received by the inferior.
+ This function is mainly used by fork_inferior. */
+extern void prefork_hook (const char *args);
+
+/* Perform any necessary tasks after a fork/vfork takes place. This
+ function is mainly used by fork_inferior. */
+extern void postfork_hook (pid_t pid);
+
+/* Perform any necessary tasks *on the child* after a fork/vfork takes
+ place. This function is mainly used by fork_inferior. */
+extern void postfork_child_hook ();
+
+/* Flush both stdout and stderr. This function needs to be
+ implemented differently on GDB and GDBserver. */
+extern void gdb_flush_out_err ();
+
+/* Report an error that happened when starting to trace the inferior
+ (i.e., when the "traceme_fun" callback is called on fork_inferior)
+ and bail out. This function does not return. */
+extern void trace_start_error (const char *fmt, ...)
+ ATTRIBUTE_NORETURN;
+
+/* Like "trace_start_error", but the error message is constructed by
+ combining STRING with the system error message for errno. This
+ function does not return. */
+extern void trace_start_error_with_name (const char *string)
+ ATTRIBUTE_NORETURN;
+
+#endif /* ! FORK_INFERIOR_H */