Add --target=BFDTARGET and --architecture=MACHINE options.
authorAndrew Cagney <cagney@redhat.com>
Thu, 28 Aug 1997 09:44:42 +0000 (09:44 +0000)
committerAndrew Cagney <cagney@redhat.com>
Thu, 28 Aug 1997 09:44:42 +0000 (09:44 +0000)
sim/common/ChangeLog
sim/common/sim-base.h
sim/common/sim-options.c
sim/common/sim-utils.c

index 2c0b780548d24d74400e835b53588c81c5fe25eb..03efafe2fd983081fde1e6fc83074156abda5b67 100644 (file)
@@ -1,3 +1,19 @@
+Thu Aug 28 12:09:15 1997  Andrew Cagney  <cagney@b1.cygnus.com>
+
+       * sim-base.h (STATE_ARCHITECTURE, STATE_TARGET): Add to simulator
+       base type.
+
+       * sim-options.c (standard_options): Add --architecture=MACHINE and
+       --target=TARGET options.
+       (OPTION_ARCHITECTURE, OPTION_TARGET): Define.
+       (standard_option_handler): Handle architecture and target options.
+       (bfd.h): Include.
+       
+       * sim-utils.c (sim_analyze_program): Pass STATE_TARGET to
+       bfd_openr.
+       (sim_analyze_program): Set prog_bfd architecture from
+       STATE_ARCHITECTURE if known.
+
 Wed Aug 27 18:13:22 1997  Andrew Cagney  <cagney@b1.cygnus.com>
 
        * configure: Regenerated to track ../common/aclocal.m4 changes.
index ffbdc1640dd4cb28c4d6dceb597e1d4da8a46b2b..b21c3970e93c13d9e5083f0378b9d44d0a1d75da 100644 (file)
@@ -67,12 +67,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 typedef struct _sim_cpu sim_cpu;
 
 #include "sim-module.h"
+
 #include "sim-trace.h"
 #include "sim-profile.h"
 #include "sim-model.h"
 #include "sim-core.h"
 #include "sim-events.h"
 #include "sim-io.h"
+#include "sim-engine.h"
+#include "sim-watch.h"
 
 
 /* Global pointer to current state while sim_resume is running.
@@ -138,6 +141,14 @@ typedef struct {
   int verbose_p;
 #define STATE_VERBOSE_P(sd) ((sd)->base.verbose_p)
 
+  /* If non NULL, the BFD architecture specified on the command line */
+  const struct bfd_arch_info *architecture;
+#define STATE_ARCHITECTURE(sd) ((sd)->base.architecture)
+
+  /* If non NULL, the bfd target specified on the command line */
+  const char *target;
+#define STATE_TARGET(sd) ((sd)->base.target)
+
   /* In standalone simulator, this is the program's arguments passed
      on the command line.  */
   char **prog_argv;
@@ -171,6 +182,8 @@ typedef struct {
 #ifdef SIM_HAVE_FLATMEM
   unsigned int mem_size;
 #define STATE_MEM_SIZE(sd) ((sd)->base.mem_size)
+  unsigned int mem_base;
+#define STATE_MEM_BASE(sd) ((sd)->base.mem_base)
   unsigned char *memory;
 #define STATE_MEMORY(sd) ((sd)->base.memory)
 #endif
@@ -183,6 +196,14 @@ typedef struct {
 #define STATE_EVENTS(sd) (&(sd)->base.events)
   sim_events events;
 
+  /* generic halt/resume engine */
+  sim_engine engine;
+#define STATE_ENGINE(sd) (&(sd)->base.engine)
+
+  /* generic watchpoint support */
+  sim_watchpoints watchpoints;
+#define STATE_WATCHPOINTS(sd) (&(sd)->base.watchpoints)
+
   /* Marker for those wanting to do sanity checks.
      This should remain the last member of this struct to help catch
      miscompilation errors.  */
@@ -202,8 +223,8 @@ typedef struct {
 #define CPU_STATE(cpu) ((cpu)->base.state)
 
   /* Processor specific core data */
-#define CPU_CORE(cpu) (& (cpu)->base.core)
   sim_cpu_core core;
+#define CPU_CORE(cpu) (& (cpu)->base.core)
 
   /* Trace data.  See sim-trace.h.  */
   TRACE_DATA trace_data;
index 8ed5f6355b39c85c9fc2043aaaa6350f998afa78..8ace37a4de0db1be564319716050ce989ddb7c58 100644 (file)
@@ -36,6 +36,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "sim-io.h"
 #include "sim-assert.h"
 
+#include "bfd.h"
+
 /* Add a set of options to the simulator.
    TABLE is an array of OPTIONS terminated by a NULL `opt.name' entry.
    This is intended to be called by modules in their `install' handler.  */
@@ -84,6 +86,8 @@ static DECLARE_OPTION_HANDLER (standard_option_handler);
 #define OPTION_DEBUG_INSN      (OPTION_START + 0)
 #define OPTION_DEBUG_FILE      (OPTION_START + 1)
 #define OPTION_DO_COMMAND      (OPTION_START + 2)
+#define OPTION_ARCHITECTURE     (OPTION_START + 3)
+#define OPTION_TARGET           (OPTION_START + 4)
 
 static const OPTION standard_options[] =
 {
@@ -127,6 +131,14 @@ static const OPTION standard_options[] =
       'H', NULL, "Print help information",
       standard_option_handler },
 
+  { {"architecture", required_argument, NULL, OPTION_ARCHITECTURE},
+      '\0', "MACHINE", "Specify the architecture to use",
+      standard_option_handler },
+
+  { {"target", required_argument, NULL, OPTION_TARGET},
+      '\0', "BFDNAME", "Specify the object-code format for the object files",
+      standard_option_handler },
+
   { {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL }
 };
 
@@ -238,6 +250,24 @@ standard_option_handler (sd, opt, arg, is_command)
       sim_do_command (sd, arg);
       break;
 
+    case OPTION_ARCHITECTURE:
+      {
+       const struct bfd_arch_info *ap = bfd_scan_arch (arg);
+       if (ap == NULL)
+         {
+           sim_io_eprintf (sd, "Architecture `%s' unknown\n", arg);
+           return SIM_RC_FAIL;
+         }
+       STATE_ARCHITECTURE (sd) = ap;
+       break;
+      }
+
+    case OPTION_TARGET:
+      {
+       STATE_TARGET (sd) = strdup (arg);
+       break;
+      }
+
     case 'H':
       sim_print_help (sd, is_command);
       if (STATE_OPEN_KIND (sd) == SIM_OPEN_STANDALONE)
index a0b582da47d9cd67d4daf7e505c876878108fb47..b62317ce2af274cd2127d1db44319161ed3780d0 100644 (file)
@@ -174,7 +174,7 @@ sim_analyze_program (sd, prog_name, prog_bfd)
     return SIM_RC_OK;
 
   /* open a new copy of the prog_bfd */
-  prog_bfd = bfd_openr (prog_name, 0);
+  prog_bfd = bfd_openr (prog_name, STATE_TARGET (sd));
   if (prog_bfd == NULL)
     {
       sim_io_eprintf (sd, "%s: can't open \"%s\": %s\n", 
@@ -192,7 +192,8 @@ sim_analyze_program (sd, prog_name, prog_bfd)
       bfd_close (prog_bfd);
       return SIM_RC_FAIL;
     }
-
+  if (STATE_ARCHITECTURE (sd) != NULL)
+    bfd_set_arch_info (prog_bfd, STATE_ARCHITECTURE (sd));
 
   /* update the sim structure */
   if (STATE_PROG_BFD (sd) != NULL)