Skip to content

Commit 19af800

Browse files
author
Jakub Brnak
committed
perf disasm: Define stubs for the LLVM and capstone disassemblers
JIRA: https://issues.redhat.com/browse/RHEL-83785 upstream ======== commit 1f7393a Author: Arnaldo Carvalho de Melo <acme@redhat.com> Date: Mon Nov 11 12:17:33 2024 -0300 description =========== This reduces the number of ifdefs in the main symbol__disassemble() method and paves the way for allowing the user to configure the disassemblers of preference. Acked-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Aditya Bodkhe <Aditya.Bodkhe1@ibm.com> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Steinar H. Gunderson <sesse@google.com> Link: https://lore.kernel.org/r/20241111151734.1018476-3-acme@kernel.org [ Applied fixes from Masami Hiramatsu and Aditya Bodkhe for when capstone devel files are not available ] Link: https://lore.kernel.org/r/B78FB6DF-24E9-4A3C-91C9-535765EC0E2A@ibm.com Link: https://lore.kernel.org/r/173145729034.2747044.453926054000880254.stgit@mhiramat.roam.corp.google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Jakub Brnak <jbrnak@redhat.com>
1 parent 76c30e1 commit 19af800

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

tools/perf/util/disasm.c

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,15 @@ read_symbol(const char *filename, struct map *map, struct symbol *sym,
14231423
}
14241424
#endif
14251425

1426+
#if !defined(HAVE_LIBCAPSTONE_SUPPORT) || !defined(HAVE_LIBLLVM_SUPPORT)
1427+
static void symbol__disassembler_missing(const char *disassembler, const char *filename,
1428+
struct symbol *sym)
1429+
{
1430+
pr_debug("The %s disassembler isn't linked in for %s in %s\n",
1431+
disassembler, sym->name, filename);
1432+
}
1433+
#endif
1434+
14261435
#ifdef HAVE_LIBCAPSTONE_SUPPORT
14271436
static void print_capstone_detail(cs_insn *insn, char *buf, size_t len,
14281437
struct annotate_args *args, u64 addr)
@@ -1723,7 +1732,21 @@ static int symbol__disassemble_capstone(char *filename, struct symbol *sym,
17231732
count = -1;
17241733
goto out;
17251734
}
1726-
#endif
1735+
#else // HAVE_LIBCAPSTONE_SUPPORT
1736+
static int symbol__disassemble_capstone(char *filename, struct symbol *sym,
1737+
struct annotate_args *args __maybe_unused)
1738+
{
1739+
symbol__disassembler_missing("capstone", filename, sym);
1740+
return -1;
1741+
}
1742+
1743+
static int symbol__disassemble_capstone_powerpc(char *filename, struct symbol *sym,
1744+
struct annotate_args *args __maybe_unused)
1745+
{
1746+
symbol__disassembler_missing("capstone powerpc", filename, sym);
1747+
return -1;
1748+
}
1749+
#endif // HAVE_LIBCAPSTONE_SUPPORT
17271750

17281751
static int symbol__disassemble_raw(char *filename, struct symbol *sym,
17291752
struct annotate_args *args)
@@ -1991,7 +2014,14 @@ static int symbol__disassemble_llvm(char *filename, struct symbol *sym,
19912014
free(line_storage);
19922015
return ret;
19932016
}
1994-
#endif
2017+
#else // HAVE_LIBLLVM_SUPPORT
2018+
static int symbol__disassemble_llvm(char *filename, struct symbol *sym,
2019+
struct annotate_args *args __maybe_unused)
2020+
{
2021+
symbol__disassembler_missing("LLVM", filename, sym);
2022+
return -1;
2023+
}
2024+
#endif // HAVE_LIBLLVM_SUPPORT
19952025

19962026
/*
19972027
* Possibly create a new version of line with tabs expanded. Returns the
@@ -2250,24 +2280,21 @@ int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
22502280
err = symbol__disassemble_raw(symfs_filename, sym, args);
22512281
if (err == 0)
22522282
goto out_remove_tmp;
2253-
#ifdef HAVE_LIBCAPSTONE_SUPPORT
2283+
22542284
err = symbol__disassemble_capstone_powerpc(symfs_filename, sym, args);
22552285
if (err == 0)
22562286
goto out_remove_tmp;
2257-
#endif
22582287
}
22592288
}
22602289

2261-
#ifdef HAVE_LIBLLVM_SUPPORT
22622290
err = symbol__disassemble_llvm(symfs_filename, sym, args);
22632291
if (err == 0)
22642292
goto out_remove_tmp;
2265-
#endif
2266-
#ifdef HAVE_LIBCAPSTONE_SUPPORT
2293+
22672294
err = symbol__disassemble_capstone(symfs_filename, sym, args);
22682295
if (err == 0)
22692296
goto out_remove_tmp;
2270-
#endif
2297+
22712298
err = symbol__disassemble_objdump(symfs_filename, sym, args);
22722299

22732300
out_remove_tmp:

0 commit comments

Comments
 (0)