From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 11/13] sim: bpf: include more local headers & fix broken funcs
Date: Sat, 26 Jun 2021 23:30:49 -0400 [thread overview]
Message-ID: <20210627033051.3150-11-vapier@gentoo.org> (raw)
In-Reply-To: <20210627033051.3150-1-vapier@gentoo.org>
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/bpf-helpers.c | 2 ++
sim/bpf/bpf-helpers.h | 4 +++-
sim/bpf/bpf.c | 15 ++++++---------
sim/bpf/sim-main.h | 1 +
4 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/sim/bpf/bpf-helpers.c b/sim/bpf/bpf-helpers.c
index d72c22a09bee..e33f52035515 100644
--- a/sim/bpf/bpf-helpers.c
+++ b/sim/bpf/bpf-helpers.c
@@ -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
diff --git a/sim/bpf/bpf-helpers.h b/sim/bpf/bpf-helpers.h
index 686a53497e03..73cfbb7fa9c7 100644
--- a/sim/bpf/bpf-helpers.h
+++ b/sim/bpf/bpf-helpers.h
@@ -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 */
diff --git a/sim/bpf/bpf.c b/sim/bpf/bpf.c
index 9e78960ddcc5..de77da851eee 100644
--- a/sim/bpf/bpf.c
+++ b/sim/bpf/bpf.c
@@ -30,15 +30,12 @@
#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)
diff --git a/sim/bpf/sim-main.h b/sim/bpf/sim-main.h
index 571c14c67bc5..dd5626825646 100644
--- a/sim/bpf/sim-main.h
+++ b/sim/bpf/sim-main.h
@@ -27,6 +27,7 @@
#include "sim-base.h"
#include "cgen-sim.h"
#include "bpf-sim.h"
+#include "bpf-helpers.h"
struct _sim_cpu
--
2.31.1
next prev parent reply other threads:[~2021-06-27 3:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-27 3:30 [PATCH 01/13] sim: bpf: fix mixed decls & code warnings (and style) Mike Frysinger
2021-06-27 3:30 ` [PATCH 02/13] sim: bpf: add explicit casts when using explicit formats Mike Frysinger
2021-06-27 3:30 ` [PATCH 03/13] sim: cgen: sync prototypes with implementation Mike Frysinger
2021-06-27 3:30 ` [PATCH 04/13] sim: cgen: always leverage the ops prototypes Mike Frysinger
2021-06-27 3:30 ` [PATCH 05/13] sim: cgen: always leverage the mem prototypes Mike Frysinger
2021-06-27 3:30 ` [PATCH 06/13] sim: cgen: constify trace strings Mike Frysinger
2021-06-27 3:30 ` [PATCH 07/13] sim: cgen: add printf attributes in a few more calls Mike Frysinger
2021-06-27 3:30 ` [PATCH 08/13] sim: cgen: add asserts to fix unused engine warnings Mike Frysinger
2021-06-27 3:30 ` [PATCH 09/13] sim: cgen: suppress trace non-literal printf warning Mike Frysinger
2021-06-27 3:30 ` [PATCH 10/13] sim: bpf: delete unused function Mike Frysinger
2021-06-27 3:30 ` Mike Frysinger [this message]
2021-06-27 3:30 ` [PATCH 12/13] sim: bpf/cris: include cgen-mem in decoders Mike Frysinger
2021-06-27 3:30 ` [PATCH 13/13] sim: bpf: enable -Werror usage Mike Frysinger
2021-06-27 4:32 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210627033051.3150-11-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).