sim: nrun: add --env-{set,unset,clear} command line options

Provide explicit control over the program's environment with the
basic set/unset/clear options.  These are a bit clunky to use,
but they're functional.

The env set operation is split out into a separate function as it'll
be used in the next commit.

With these in place, we can adjust the custom cris testsuite to use
the now standard options and not its one-off hack.
This commit is contained in:
Mike Frysinger
2021-11-16 02:54:44 -05:00
parent 85588c9ab9
commit 35818ade96
5 changed files with 107 additions and 10 deletions

View File

@@ -62,6 +62,7 @@ main (int argc, char **argv)
{
const char *name;
char **prog_argv = NULL;
char **prog_envp = NULL;
struct bfd *prog_bfd;
enum sim_stop reason;
int sigrc = 0;
@@ -99,6 +100,7 @@ main (int argc, char **argv)
/* Was there a program to run? */
prog_argv = STATE_PROG_ARGV (sd);
prog_envp = STATE_PROG_ENVP (sd) ? : environ;
prog_bfd = STATE_PROG_BFD (sd);
if (prog_argv == NULL || *prog_argv == NULL)
usage ();
@@ -131,7 +133,7 @@ main (int argc, char **argv)
exit (1);
/* Prepare the program for execution. */
sim_create_inferior (sd, prog_bfd, prog_argv, environ);
sim_create_inferior (sd, prog_bfd, prog_argv, prog_envp);
/* To accommodate relative file paths, chdir to sysroot now. We
mustn't do this until BFD has opened the program, else we wouldn't