fname = lbasename (exe);
psargs = std::string (exe);
- const char *infargs = get_inferior_args ();
+ const char *infargs = current_inferior ()->args ();
if (infargs != nullptr)
psargs += " " + std::string (infargs);
const char *fname = lbasename (get_exec_file (0));
std::string psargs = fname;
- const char *infargs = get_inferior_args ();
+ const char *infargs = current_inferior ()->args ();
if (infargs != NULL)
psargs = psargs + " " + infargs;
"is \"%s\".\n"), inferior_tty);
}
-const char *
-get_inferior_args (void)
-{
- if (current_inferior ()->args == nullptr)
- return "";
-
- return current_inferior ()->args.get ();
-}
-
-/* Set the arguments for the current inferior. Ownership of
- NEWARGS is not transferred. */
-
-void
-set_inferior_args (const char *newargs)
-{
- if (newargs != nullptr)
- current_inferior ()->args = make_unique_xstrdup (newargs);
- else
- current_inferior ()->args.reset ();
-}
-
void
set_inferior_args_vector (int argc, char **argv)
{
gdb::array_view<char * const> args (argv, argc);
std::string n = construct_inferior_arguments (args);
- set_inferior_args (n.c_str ());
+ current_inferior ()->set_args (n.c_str ());
}
/* Notice when `set args' is run. */
{
/* CLI has assigned the user-provided value to inferior_args_scratch.
Now route it to current inferior. */
- set_inferior_args (inferior_args_scratch);
+ current_inferior ()->set_args (inferior_args_scratch);
}
/* Notice when `show args' is run. */
{
/* Note that we ignore the passed-in value in favor of computing it
directly. */
- deprecated_show_value_hack (file, from_tty, c, get_inferior_args ());
+ deprecated_show_value_hack (file, from_tty, c,
+ current_inferior ()->args ());
}
/* Set the inferior current working directory. If CWD is NULL, unset
/* If there were other args, beside '&', process them. */
if (args != NULL)
- set_inferior_args (args);
+ current_inferior ()->set_args (args);
if (from_tty)
{
if (exec_file)
uiout->field_string ("execfile", exec_file);
uiout->spaces (1);
- uiout->field_string ("infargs", get_inferior_args ());
+ uiout->field_string ("infargs", current_inferior ()->args ());
uiout->text ("\n");
uiout->flush ();
}
run_target->create_inferior (exec_file,
- std::string (get_inferior_args ()),
+ current_inferior ()->args (),
current_inferior ()->environment.envp (),
from_tty);
/* to_create_inferior should push the target, so after this point we
extern void attach_command (const char *, int);
-extern const char *get_inferior_args (void);
-
-extern void set_inferior_args (const char *);
-
extern void set_inferior_args_vector (int, char **);
extern void registers_info (const char *, int);
void set_tty (const char *terminal_name);
const char *tty ();
+ /* Set the argument string to use when running this inferior.
+
+ Either nullptr or an empty string can be used to represent "no
+ arguments". */
+ void set_args (const char *args)
+ {
+ if (args != nullptr && args[0] != '\0')
+ m_args = make_unique_xstrdup (args);
+ else
+ m_args.reset ();
+ };
+
+ /* Get the argument string to use when running this inferior.
+
+ The return value is always non-nullptr. No arguments is represented by
+ an empty string. */
+ const char *args () const
+ {
+ if (m_args == nullptr)
+ return "";
+
+ return m_args.get ();
+ }
+
/* Convenient handle (GDB inferior id). Unique across all
inferiors. */
int num = 0;
/* The program space bound to this inferior. */
struct program_space *pspace = NULL;
- /* The arguments string to use when running. */
- gdb::unique_xmalloc_ptr<char> args;
-
/* The current working directory that will be used when starting
this inferior. */
gdb::unique_xmalloc_ptr<char> cwd;
/* The list of continuations. */
std::list<std::function<void ()>> m_continuations;
+
+ /* The arguments string to use when running.
+
+ This is nullptr when there are not args. */
+ gdb::unique_xmalloc_ptr<char> m_args;
};
/* Keep a registry of per-inferior data-pointers required by other GDB
char filename[100];
/* The basename of the executable. */
const char *basename;
- const char *infargs;
/* Temporary buffer. */
char *tmpstr;
/* The valid states of a process, according to the Linux kernel. */
strncpy (p->pr_fname, basename, sizeof (p->pr_fname) - 1);
p->pr_fname[sizeof (p->pr_fname) - 1] = '\0';
- infargs = get_inferior_args ();
+ const char *infargs = current_inferior ()->args ();
/* The arguments of the program. */
std::string psargs = fname.get ();
strncpy (psargs, get_exec_file (0), sizeof (psargs));
psargs[sizeof (psargs) - 1] = 0;
- inf_args = get_inferior_args ();
+ inf_args = current_inferior ()->args ();
if (inf_args && *inf_args
&& (strlen (inf_args)
< ((int) sizeof (psargs) - (int) strlen (psargs))))