sim: remove use of PTR
[binutils-gdb.git] / sim / m32r / sim-if.c
index b2f7b4636e0de8130dab35d851fae2038da1b4d8..878a0d5f576412578c6feabf83601f50b3579d9b 100644 (file)
@@ -1,5 +1,5 @@
 /* Main simulator entry points specific to the M32R.
-   Copyright (C) 1996-2021 Free Software Foundation, Inc.
+   Copyright (C) 1996-2022 Free Software Foundation, Inc.
    Contributed by Cygnus Support.
 
    This file is part of GDB, the GNU debugger.
 /* This must come before any other includes.  */
 #include "defs.h"
 
+#include <string.h>
+#include <stdlib.h>
+
+#include "sim/callback.h"
 #include "sim-main.h"
 #include "sim-options.h"
 #include "libiberty.h"
 #include "bfd.h"
 
-#include <string.h>
-#include <stdlib.h>
-
 #include "dv-m32r_uart.h"
 
 #define M32R_DEFAULT_MEM_SIZE 0x2000000 /* 32M */
@@ -145,9 +146,10 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
 \f
 SIM_RC
 sim_create_inferior (SIM_DESC sd, struct bfd *abfd, char * const *argv,
-                    char * const *envp)
+                    char * const *env)
 {
   SIM_CPU *current_cpu = STATE_CPU (sd, 0);
+  host_callback *cb = STATE_CALLBACK (sd);
   SIM_ADDR addr;
 
   if (abfd != NULL)
@@ -174,6 +176,15 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd, char * const *argv,
       STATE_PROG_ARGV (sd) = dupargv (argv);
     }
 
+  if (STATE_PROG_ENVP (sd) != env)
+    {
+      freeargv (STATE_PROG_ENVP (sd));
+      STATE_PROG_ENVP (sd) = dupargv (env);
+    }
+
+  cb->argv = STATE_PROG_ARGV (sd);
+  cb->envp = STATE_PROG_ENVP (sd);
+
   return SIM_RC_OK;
 }