}
}
-/* See gdbsupport/common-inferior.h. */
-
-const char *
-get_exec_file ()
-{
- if (current_program_space->exec_filename () != nullptr)
- return current_program_space->exec_filename ();
-
- error (_("No executable file specified.\n\
-Use the \"file\" or \"exec-file\" command."));
-}
-\f
-
std::string
memory_error_message (enum target_xfer_status err,
struct gdbarch *gdbarch, CORE_ADDR memaddr)
const std::string &allargs,
char **env, int from_tty)
{
+ if (exec_file == nullptr)
+ no_executable_specified_error ();
+
std::optional<scoped_restore_tmpl<bool>> restore_startup_with_shell;
darwin_nat_target *the_target = this;
gdb::observers::executable_changed.notify (current_program_space, reload_p);
}
+/* See exec.h. */
+
+void
+no_executable_specified_error ()
+{
+ error (_("No executable file specified.\n\
+Use the \"file\" or \"exec-file\" command."));
+}
+
/* Process the first arg in ARGS as the new exec file.
Note that we have to explicitly ignore additional args, since we can
extern void try_open_exec_file (const char *exec_file_host,
struct inferior *inf,
symfile_add_flags add_flags);
+
+/* Report a "No executable file specified" error. */
+
+extern void no_executable_specified_error ();
+
#endif
char **env,
int from_tty)
{
+ if (exec_file == nullptr)
+ no_executable_specified_error ();
+
struct inf *inf = cur_inf ();
inferior *inferior = current_inferior ();
int pid;
int result;
const char *args = allargs.c_str ();
- /* If no exec file handed to us, get it from the exec-file command -- with
- a good, common error message if none is specified. */
- if (exec_file == 0)
- exec_file = get_exec_file ();
+ if (exec_file == nullptr)
+ no_executable_specified_error ();
resume_signal = -1;
resume_is_step = 0;
const std::string &allargs,
char **env, int from_tty)
{
+ if (exec_file == nullptr)
+ no_executable_specified_error ();
+
inferior *inf = current_inferior ();
/* Do not change either targets above or the same target if already present.
/* See nat/fork-inferior.h. */
pid_t
-fork_inferior (const char *exec_file_arg, const std::string &allargs,
- char **env, traceme_ftype traceme_fun,
- init_trace_ftype init_trace_fun, pre_trace_ftype pre_trace_fun,
- const char *shell_file_arg, exec_ftype exec_fun)
+fork_inferior (const char *exec_file, const std::string &allargs, char **env,
+ traceme_ftype traceme_fun, init_trace_ftype init_trace_fun,
+ pre_trace_ftype pre_trace_fun, const char *shell_file_arg,
+ exec_ftype exec_fun)
{
pid_t pid;
/* Set debug_fork then attach to the child while it sleeps, to debug. */
int debug_fork = 0;
const char *shell_file;
- const char *exec_file;
char **save_our_env;
int i;
int save_errno;
- /* If no exec file handed to us, get it from the exec-file command
- -- with a good, common error message if none is specified. */
- if (exec_file_arg == NULL)
- exec_file = get_exec_file ();
- else
- exec_file = exec_file_arg;
+ gdb_assert (exec_file != nullptr);
/* 'startup_with_shell' is declared in inferior.h and bound to the
"set startup-with-shell" option. If 0, we'll just do a
const std::string &allargs,
char **env, int from_tty)
{
+ if (exec_file == nullptr)
+ no_executable_specified_error ();
+
struct inheritance inherit;
pid_t pid;
int flags, errn;
argv = xmalloc ((allargs.size () / (unsigned) 2 + 2) *
sizeof (*argv));
- argv[0] = const_cast<char *> (get_exec_file ());
+ argv[0] = exec_file;
args = xstrdup (allargs.c_str ());
- breakup_args (args, (exec_file != NULL) ? &argv[1] : &argv[0]);
+ breakup_args (args, &argv[1]);
argv = nto_parse_redirection (argv, &in, &out, &err);
const std::string &allargs,
char **env, int from_tty)
{
+ if (exec_file == nullptr)
+ no_executable_specified_error ();
+
const char *shell_file = get_shell ();
char *tryname;
int pid;
{
const char *parg, *prev;
- arg = get_exec_file ();
+ arg = current_program_space->exec_filename ();
+ if (arg == nullptr)
+ no_executable_specified_error ();
/* We may need to quote this string so buildargv can pull it
apart. */
return !wrapper_argv.empty () ? wrapper_argv.c_str () : NULL;
}
-/* See gdbsupport/common-inferior.h. */
-
-const char *
-get_exec_file ()
-{
- if (program_path.get () == NULL)
- error (_("No executable file specified."));
-
- return program_path.get ();
-}
-
/* See server.h. */
gdb_environ *
otherwise. */
extern const char *get_exec_wrapper ();
-/* Return the name of the executable file as a string.
-
- Error out if no executable is specified. */
-extern const char *get_exec_file ();
-
/* Return the inferior's current working directory.
If it is not set, the string is empty. */