perf annotate: Use capstone_init and remove open_capstone_handle from disasm.c
authorAthira Rajeev <atrajeev@linux.vnet.ibm.com>
Thu, 18 Jul 2024 08:43:56 +0000 (14:13 +0530)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 31 Jul 2024 19:12:59 +0000 (16:12 -0300)
capstone_init is made availbale for all archs to use and updated to
enable support for CS_ARCH_PPC as well. Patch removes
open_capstone_handle and uses capstone_init in all the places.

Committer notes:

Avoid including capstone/capstone.h from print_insn.h to not break the
build in builtin-script.c due to the namespace clash with libbpf:

  /usr/include/capstone/bpf.h:94:14: error: 'bpf_insn' defined as wrong kind of tag

Reviewed-by: Kajol Jain <kjain@linux.ibm.com>
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Tested-by: Kajol Jain <kjain@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Akanksha J N <akanksha@linux.ibm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Segher Boessenkool <segher@kernel.crashing.org>
Link: https://lore.kernel.org/lkml/20240718084358.72242-14-atrajeev@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/disasm.c
tools/perf/util/print_insn.c
tools/perf/util/print_insn.h

index 3d25443e11620784b07b2e63fc3dcb848b6543f9..7a11edefe1bd262d106f0b7f54130fc76a450106 100644 (file)
@@ -1512,6 +1512,8 @@ symbol__disassemble_bpf_image(struct symbol *sym,
 #ifdef HAVE_LIBCAPSTONE_SUPPORT
 #include <capstone/capstone.h>
 
+int capstone_init(struct machine *machine, csh *cs_handle, bool is64, bool disassembler_style);
+
 static int open_capstone_handle(struct annotate_args *args, bool is_64bit,
                                csh *handle)
 {
index a76aae81d7a01bb2f2f3c27234241829ca925f6e..a33a7726422da98fe611172b216a2d4d1f2f2c2b 100644 (file)
@@ -32,6 +32,8 @@ size_t sample__fprintf_insn_raw(struct perf_sample *sample, FILE *fp)
 #ifdef HAVE_LIBCAPSTONE_SUPPORT
 #include <capstone/capstone.h>
 
+int capstone_init(struct machine *machine, csh *cs_handle, bool is64, bool disassembler_style);
+
 int capstone_init(struct machine *machine, csh *cs_handle, bool is64, bool disassembler_style)
 {
        cs_arch arch;
index 2c8ee41c4a5d3d167cc2a54dff05cc1e5f132b29..07d11af3fc1cbe7da44ce50066d3126952dd2530 100644 (file)
@@ -19,9 +19,4 @@ ssize_t fprintf_insn_asm(struct machine *machine, struct thread *thread, u8 cpum
                         bool is64bit, const uint8_t *code, size_t code_size,
                         uint64_t ip, int *lenp, int print_opts, FILE *fp);
 
-#ifdef HAVE_LIBCAPSTONE_SUPPORT
-#include <capstone/capstone.h>
-int capstone_init(struct machine *machine, csh *cs_handle, bool is64, bool disassembler_style);
-#endif
-
 #endif /* PERF_PRINT_INSN_H */