[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1466940078-65581-17-git-send-email-hekuang@huawei.com>
Date: Sun, 26 Jun 2016 11:21:08 +0000
From: He Kuang <hekuang@...wei.com>
To: <acme@...nel.org>, <peterz@...radead.org>, <mingo@...hat.com>,
<jolsa@...hat.com>, <brendan.d.gregg@...il.com>, <ast@...nel.org>,
<alexander.shishkin@...ux.intel.com>, <wangnan0@...wei.com>,
<hekuang@...wei.com>
CC: <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH v2 16/26] perf bpf: Add method for fetching nth ubpf vm
Same as bpf_program__fd() and bpf_program__nth_fd(), add methods for
fetching the nth ubpf entry.
Signed-off-by: He Kuang <hekuang@...wei.com>
Signed-off-by: Wang Nan <wangnan0@...wei.com>
---
tools/lib/bpf/libbpf.c | 14 ++++++++++++++
tools/lib/bpf/libbpf.h | 1 +
2 files changed, 15 insertions(+)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index b738ef2..7e77cc2 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1132,6 +1132,20 @@ int bpf_program__fd(struct bpf_program *prog)
return bpf_program__nth_fd(prog, 0);
}
+static void *bpf_program__nth_vm(struct bpf_program *prog, int n)
+{
+ void *ret;
+
+ prog->engine->get_nth(prog, n, &ret);
+
+ return ret;
+}
+
+void *bpf_program__vm(struct bpf_program *prog)
+{
+ return bpf_program__nth_vm(prog, 0);
+}
+
int bpf_program__set_prep(struct bpf_program *prog, int nr_instances,
bpf_program_prep_t prep)
{
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 996862f..b0e6c68 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -87,6 +87,7 @@ void *bpf_program__priv(struct bpf_program *prog);
const char *bpf_program__title(struct bpf_program *prog, bool needs_copy);
int bpf_program__fd(struct bpf_program *prog);
+void *bpf_program__vm(struct bpf_program *prog);
struct bpf_insn;
--
1.8.5.2
Powered by blists - more mailing lists