Re: [PATCH v2 3/5] perf annotate: Split out util/disasm.c

From: Arnaldo Carvalho de Melo
Date: Wed Apr 03 2024 - 10:13:49 EST


On Tue, Apr 02, 2024 at 04:03:33PM -0700, Namhyung Kim wrote:
> On Tue, Apr 2, 2024 at 3:11 PM Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote:
> >
> > On Tue, Apr 02, 2024 at 07:08:04PM -0300, Arnaldo Carvalho de Melo wrote:
> > > On Fri, Mar 29, 2024 at 02:58:10PM -0700, Namhyung Kim wrote:
> > > > The util/annotate.c code has both disassembly and sample annotation
> > > > related codes. Factor out the disasm part so that it can be handled
> > > > more easily.
> > > >
> > > > No functional changes intended.
> > > >
> > >
> > > Unsure if here, will check and fix later, detected with:
> > >
> > > make -C tools/perf build-test'
> >
> > did it, added the missing env.h header to disasm.c

> Thanks a lot!

Three more, also fixed:

util/disasm.c: In function ‘symbol__disassemble_bpf’:
util/disasm.c:1203:9: error: implicit declaration of function ‘perf_exe’ [-Werror=implicit-function-declaration]
1203 | perf_exe(tpath, sizeof(tpath));
| ^~~~~~~~



diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
index 3438c31437f46e71..c2664215554d0bb3 100644
--- a/tools/perf/util/disasm.c
+++ b/tools/perf/util/disasm.c
@@ -21,6 +21,7 @@
#include "maps.h"
#include "srcline.h"
#include "symbol.h"
+#include "util.h"

static regex_t file_lineno;

util/disasm.c:1229:32: error: invalid use of undefined type ‘struct bpf_prog_info_node’
1229 | info_linear = info_node->info_linear;
| ^~
util/disasm.c: In function ‘symbol__disassemble_bpf’:
util/disasm.c:1230:32: error: invalid use of undefined type ‘struct bpf_prog_info_node’
1230 | info_linear = info_node->info_linear;
| ^~


diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
index c2664215554d0bb3..5b5407525b31f47f 100644
--- a/tools/perf/util/disasm.c
+++ b/tools/perf/util/disasm.c
@@ -1170,6 +1170,8 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil
#include <linux/btf.h>
#include <tools/dis-asm-compat.h>

+#include "bpf-event.h"
+
static int symbol__disassemble_bpf(struct symbol *sym,
struct annotate_args *args)
{

util/disasm.c: In function ‘symbol__disassemble_bpf’:
util/disasm.c:1235:54: error: invalid use of undefined type ‘struct perf_bpil’
1235 | info.buffer = (void *)(uintptr_t)(info_linear->info.jited_prog_insns);
|

diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
index a88d33fd38a58e4a..a1219eb930aaeb5a 100644
--- a/tools/perf/util/disasm.c
+++ b/tools/perf/util/disasm.c
@@ -1173,6 +1173,7 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil
#include <tools/dis-asm-compat.h>

#include "bpf-event.h"
+#include "bpf-utils.h"

static int symbol__disassemble_bpf(struct symbol *sym,
struct annotate_args *args)