sim: bpf: include more local headers & fix broken funcs
authorMike Frysinger <vapier@gentoo.org>
Sun, 27 Jun 2021 03:18:40 +0000 (23:18 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sun, 27 Jun 2021 14:53:15 +0000 (10:53 -0400)
Various files were not including the relevant headers, or some funcs
were missing prototypes entirely, leading to mismatch between the
actual definition of the functions.  Add includes to a few places and
fix the broken functions that are uncovered as a result.  Fixing some
compile warnings (e.g. missing prototypes) often find real bugs.

sim/bpf/ChangeLog
sim/bpf/bpf-helpers.c
sim/bpf/bpf-helpers.h
sim/bpf/bpf.c
sim/bpf/sim-main.h

index b53b986472d3cb21c7c77d9215dffdc4a1281c09..039f2c7b4bc716491b078e93b02823c8c8ba1376 100644 (file)
@@ -1,3 +1,16 @@
+2021-06-27  Mike Frysinger  <vapier@gentoo.org>
+
+       * bpf-helpers.c: Include bpf-helpers.h.
+       * bpf-helpers.h (bpf_trace_printk): Change return type to int.
+       (bpfbf_breakpoint): New prototype.
+       * bpf.c: Include decode-be.h & decode-le.h.
+       (bpfbf_ebpfle_init_idesc_table): Delete prototype.
+       (bpfbf_ebpfbe_init_idesc_table): Delete prototype.
+       (bpfbf_model_insn_after): Add 3rd argument.
+       (bpf_def_model_init): Add 1st argument.
+       (bpfbf_prepare_run): Mark static.
+       * sim-main.h: Include bpf-helpers.h.
+
 2021-06-27  Mike Frysinger  <vapier@gentoo.org>
 
        * bpf-helpers.c (bpf_trace_printk): Add casts to every value printf.
index d72c22a09beebf309f57748589ae9b771e5af208..e33f520355153655f55250f1caf8a70da94c6ec9 100644 (file)
@@ -32,6 +32,8 @@
 #include "cgen-ops.h"
 #include "cpu.h"
 
+#include "bpf-helpers.h"
+
 /* bpf_trace_printk is a printk-like facility for debugging.
 
    In the kernel, it appends a line to the Linux's tracing debugging
index 686a53497e03f97597e2d65c381caca5e56fac2f..73cfbb7fa9c752d0aedf593bbdbd50fd74a16147 100644 (file)
@@ -26,6 +26,8 @@ enum bpf_kernel_helper
 #undef DEF_HELPER
   };
 
-void bpf_trace_printk (SIM_CPU *current_cpu);
+int bpf_trace_printk (SIM_CPU *current_cpu);
+
+VOID bpfbf_breakpoint (SIM_CPU *current_cpu);
 
 #endif /* ! BPF_HELPERS_H */
index 9e78960ddcc517d44e2c9c7ad967f2be7a9a5b34..de77da851eeec80b96848bc41b59dd26a302fb27 100644 (file)
 #include "cpuall.h"
 #include "decode.h"
 
+#include "decode-be.h"
+#include "decode-le.h"
+
 #include "defs-le.h"  /* For SCACHE */
 #include "bpf-helpers.h"
 
-/* It is not possible to include both defs-le.h and defs-be.h due to
-   duplicated definitions, so we need a bunch of forward declarations
-   here.  */
-extern void bpfbf_ebpfle_init_idesc_table (SIM_CPU *);
-extern void bpfbf_ebpfbe_init_idesc_table (SIM_CPU *);
-
 uint64_t skb_data_offset;
 
 IDESC *bpf_idesc_le;
@@ -84,7 +81,7 @@ bpfbf_model_insn_before (SIM_CPU *current_cpu, int first_p)
 }
 
 void
-bpfbf_model_insn_after (SIM_CPU *current_cpu, int first_p)
+bpfbf_model_insn_after (SIM_CPU *current_cpu, int first_p, int cycles)
 {
   /* XXX */
 }
@@ -209,7 +206,7 @@ bpfbf_breakpoint (SIM_CPU *current_cpu)
    several ISAs.  This should be fixed in CGEN.  */
 
 static void
-bpf_def_model_init (void)
+bpf_def_model_init (SIM_CPU *cpu)
 {
   /* Do nothing.  */
 }
@@ -220,7 +217,7 @@ bpfbf_prepare_run (SIM_CPU *cpu)
   /* Nothing.  */
 }
 
-void
+static void
 bpf_engine_run_full (SIM_CPU *cpu)
 {
   if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE)
index 571c14c67bc51a316c414598104acf1df2113181..dd56268256465fe69168d22ddb33de7ed125e3cc 100644 (file)
@@ -27,6 +27,7 @@
 #include "sim-base.h"
 #include "cgen-sim.h"
 #include "bpf-sim.h"
+#include "bpf-helpers.h"
 
 
 struct _sim_cpu
This page took 0.027384 seconds and 4 git commands to generate.