/* New version of run front end support for simulators.
- Copyright (C) 1997-2021 Free Software Foundation, Inc.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
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
#include <stdlib.h>
/* For strsignal. */
#include <string.h>
-
-#include "sim-main.h"
-#include "sim/callback.h"
+/* For chdir. */
+#include <unistd.h>
#include "bfd.h"
#include "environ.h"
+#include "sim-main.h"
+#include "sim-signal.h"
+#include "sim/callback.h"
+
#ifndef HAVE_STRSIGNAL
/* While libiberty provides a fallback, it doesn't provide a prototype. */
extern const char *strsignal (int);
#endif
-#ifdef HAVE_UNISTD_H
-/* For chdir. */
-#include <unistd.h>
-#endif
-
static void usage (void);
extern host_callback default_callback;
{
const char *name;
char **prog_argv = NULL;
+ char **prog_envp = NULL;
struct bfd *prog_bfd;
enum sim_stop reason;
int sigrc = 0;
/* 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 ();
- name = *prog_argv;
+ name = STATE_PROG_FILE (sd);
/* For simulators that don't open prog during sim_open() */
if (prog_bfd == NULL)
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
static void
usage (void)
{
- fprintf (stderr, "Usage: %s [options] program [program args]\n", myname);
+ fprintf (stderr, "Usage: %s [options] [VAR=VAL|--] program [program args]\n",
+ myname);
fprintf (stderr, "Run `%s --help' for full list of options.\n", myname);
exit (1);
}