public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] sim: bpf: invert sim_cpu storage
@ 2022-12-21  5:08 Michael Frysinger
  0 siblings, 0 replies; only message in thread
From: Michael Frysinger @ 2022-12-21  5:08 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ef7878a2865c4f8d084717c7d959704d8f7132d2

commit ef7878a2865c4f8d084717c7d959704d8f7132d2
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Tue Nov 1 18:49:48 2022 +0545

    sim: bpf: invert sim_cpu storage
    
    The cpu.h change is in generated cgen code, but that has been sent
    upstream too, so the next regen should include it automatically.

Diff:
---
 sim/bpf/cpu.h      |  2 +-
 sim/bpf/sim-if.c   |  2 +-
 sim/bpf/sim-main.h | 16 +++++++++++-----
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/sim/bpf/cpu.h b/sim/bpf/cpu.h
index 5dd42de6a75..fb5344e0b76 100644
--- a/sim/bpf/cpu.h
+++ b/sim/bpf/cpu.h
@@ -54,7 +54,7 @@ do { \
 CPU (h_pc) = (x);\
 ;} while (0)
   } hardware;
-#define CPU_CGEN_HW(cpu) (& (cpu)->cpu_data.hardware)
+#define CPU_CGEN_HW(cpu) (& BPF_SIM_CPU (cpu)->cpu_data.hardware)
 } BPFBF_CPU_DATA;
 
 /* Cover fns for register access.  */
diff --git a/sim/bpf/sim-if.c b/sim/bpf/sim-if.c
index 1501b42ff37..25ea76346ec 100644
--- a/sim/bpf/sim-if.c
+++ b/sim/bpf/sim-if.c
@@ -132,7 +132,7 @@ sim_open (SIM_OPEN_KIND kind,
   STATE_MACHS (sd) = bpf_sim_machs;
   STATE_MODEL_NAME (sd) = "bpf-def";
 
-  if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
+  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct bpf_sim_cpu)) != SIM_RC_OK)
     goto error;
 
   if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
diff --git a/sim/bpf/sim-main.h b/sim/bpf/sim-main.h
index 80538840886..5a29360e389 100644
--- a/sim/bpf/sim-main.h
+++ b/sim/bpf/sim-main.h
@@ -19,6 +19,8 @@
 #ifndef SIM_MAIN_H
 #define SIM_MAIN_H
 
+#define SIM_HAVE_COMMON_SIM_CPU
+
 #include "sim-basics.h"
 #include "cgen-types.h"
 #include "bpf-desc.h"
@@ -29,15 +31,19 @@
 #include "bpf-sim.h"
 #include "bpf-helpers.h"
 
-
-struct _sim_cpu
+struct bpf_sim_cpu
 {
-  sim_cpu_base base;
-  CGEN_CPU cgen_cpu;
-
+  /* CPU-model specific parts go here.
+     Note that in files that don't need to access these pieces WANT_CPU_FOO
+     won't be defined and thus these parts won't appear.  This is ok in the
+     sense that things work.  It is a source of bugs though.
+     One has to of course be careful to not take the size of this
+     struct and no structure members accessed in non-cpu specific files can
+     go after here.  */
 #if defined (WANT_CPU_BPFBF)
   BPFBF_CPU_DATA cpu_data;
 #endif
 };
+#define BPF_SIM_CPU(cpu) ((struct bpf_sim_cpu *) CPU_ARCH_DATA (cpu))
 
 #endif /* ! SIM_MAIN_H */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-21  5:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-21  5:08 [binutils-gdb] sim: bpf: invert sim_cpu storage Michael Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).