sim: sim_do_commandf: fix call to va_end [PR sim/19273]
[binutils-gdb.git] / sim / common / sim-base.h
index f3af30553a2a924a80f59e92003e58b25fd571d0..21f61f4dc1f8a21ee85b5d424207274a983e7291 100644 (file)
@@ -1,22 +1,23 @@
 /* Simulator pseudo baseclass.
-   Copyright (C) 1997-1998 Free Software Foundation, Inc.
+
+   Copyright 1997-2015 Free Software Foundation, Inc.
+
    Contributed by Cygnus Support.
 
 This file is part of GDB, the GNU debugger.
 
 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
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
 /* Simulator state pseudo baseclass.
@@ -27,12 +28,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
    information), include ``sim-base.h'':
 
      #include "sim-basics.h"
-     typedef address_word sim_cia;
      /-* If `sim_cia' is not an integral value (e.g. a struct), define
          CIA_ADDR to return the integral value.  *-/
+     /-* typedef struct {...} sim_cia; *-/
      /-* #define CIA_ADDR(cia) (...) *-/
      #include "sim-base.h"
-   
+
    finally, two data types `struct _sim_cpu' and `struct sim_state'
    are defined:
 
@@ -42,12 +43,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
      };
 
      struct sim_state {
-       sim_cpu cpu[MAX_NR_PROCESSORS];
-     #if (WITH_SMP)
-     #define STATE_CPU(sd,n) (&(sd)->cpu[n])
-     #else
-     #define STATE_CPU(sd,n) (&(sd)->cpu[0])
-     #endif
+       sim_cpu *cpu[MAX_NR_PROCESSORS];
        ... simulator specific members ...
        sim_state_base base;
      };
@@ -70,11 +66,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
    (e.g. for delay slot handling).  */
 #ifndef CIA_ADDR
 #define CIA_ADDR(cia) (cia)
+typedef address_word sim_cia;
 #endif
 #ifndef INVALID_INSTRUCTION_ADDRESS
 #define INVALID_INSTRUCTION_ADDRESS ((address_word)0 - 1)
 #endif
 
+/* TODO: Probably should just delete SIM_CPU.  */
+typedef struct _sim_cpu SIM_CPU;
 typedef struct _sim_cpu sim_cpu;
 
 #include "sim-module.h"
@@ -90,9 +89,6 @@ typedef struct _sim_cpu sim_cpu;
 #include "sim-engine.h"
 #include "sim-watch.h"
 #include "sim-memopt.h"
-#ifdef SIM_HAVE_BREAKPOINTS
-#include "sim-break.h"
-#endif
 #include "sim-cpu.h"
 
 /* Global pointer to current state while sim_resume is running.
@@ -118,6 +114,15 @@ extern struct sim_state *current_state;
 #endif
 
 
+/* We require all sims to dynamically allocate cpus.  See comment up top about
+   struct sim_state.  */
+#if (WITH_SMP)
+# define STATE_CPU(sd, n) ((sd)->cpu[n])
+#else
+# define STATE_CPU(sd, n) ((sd)->cpu[0])
+#endif
+
+
 typedef struct {
 
   /* Simulator's argv[0].  */
@@ -172,23 +177,23 @@ typedef struct {
 #define STATE_PROG_ARGV(sd) ((sd)->base.prog_argv)
 
   /* The program's bfd.  */
-  struct _bfd *prog_bfd;
+  struct bfd *prog_bfd;
 #define STATE_PROG_BFD(sd) ((sd)->base.prog_bfd)
 
   /* Symbol table for prog_bfd */
-  struct symbol_cache_entry **prog_syms;
+  struct bfd_symbol **prog_syms;
 #define STATE_PROG_SYMS(sd) ((sd)->base.prog_syms)
 
   /* The program's text section.  */
-  struct sec *text_section;
+  struct bfd_section *text_section;
   /* Starting and ending text section addresses from the bfd.  */
-  SIM_ADDR text_start, text_end;
+  bfd_vma text_start, text_end;
 #define STATE_TEXT_SECTION(sd) ((sd)->base.text_section)
 #define STATE_TEXT_START(sd) ((sd)->base.text_start)
 #define STATE_TEXT_END(sd) ((sd)->base.text_end)
 
   /* Start address, set when the program is loaded from the bfd.  */
-  SIM_ADDR start_addr;
+  bfd_vma start_addr;
 #define STATE_START_ADDR(sd) ((sd)->base.start_addr)
 
   /* Size of the simulator's cache, if any.
@@ -227,16 +232,11 @@ typedef struct {
   sim_watchpoints watchpoints;
 #define STATE_WATCHPOINTS(sd) (&(sd)->base.watchpoints)
 
-  /* Pointer to list of breakpoints */
-  struct sim_breakpoint *breakpoints;
-#define STATE_BREAKPOINTS(sd) ((sd)->base.breakpoints)
-
 #if WITH_HW
   struct sim_hw *hw;
 #define STATE_HW(sd) ((sd)->base.hw)
 #endif
 
-
   /* Should image loads be performed using the LMA or VMA?  Older
      simulators use the VMA while newer simulators prefer the LMA. */
   int load_at_lma_p;
@@ -251,7 +251,7 @@ typedef struct {
 } sim_state_base;
 
 /* Functions for allocating/freeing a sim_state.  */
-SIM_DESC sim_state_alloc PARAMS ((SIM_OPEN_KIND kind, host_callback *callback));
-void sim_state_free PARAMS ((SIM_DESC));
+SIM_DESC sim_state_alloc (SIM_OPEN_KIND kind, host_callback *callback);
+void sim_state_free (SIM_DESC);
 
 #endif /* SIM_BASE_H */