aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/builtin-annotate.c
diff options
context:
space:
mode:
authorIan Rogers <[email protected]>2023-03-28 16:55:41 -0700
committerArnaldo Carvalho de Melo <[email protected]>2023-04-04 09:39:56 -0300
commit56d9117c5004e7192d8062da67fef220e4fdcd19 (patch)
tree065234f28e25cabfb0a12f17da5f9c0e3c6e6871 /tools/perf/builtin-annotate.c
parent217b7d41ea2038e52991b7a600a0b958330d8ae6 (diff)
perf annotate: Own objdump_path and disassembler_style strings
Make struct annotation_options own the strings objdump_path and disassembler_style, freeing them on exit. Add missing strdup for disassembler_style when read from a config file. Committer notes: Converted free(obj->member) to zfree(&obj->member) in annotation_options__exit() Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Andres Freund <[email protected]> Cc: German Gomez <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Sandipan Das <[email protected]> Cc: Tom Rix <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r--tools/perf/builtin-annotate.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 997a1e65d090..5b31c4ee8d06 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -517,6 +517,7 @@ int cmd_annotate(int argc, const char **argv)
struct itrace_synth_opts itrace_synth_opts = {
.set = 0,
};
+ const char *disassembler_style = NULL, *objdump_path = NULL;
struct option options[] = {
OPT_STRING('i', "input", &input_name, "file",
"input file name"),
@@ -561,13 +562,13 @@ int cmd_annotate(int argc, const char **argv)
"Interleave source code with assembly code (default)"),
OPT_BOOLEAN(0, "asm-raw", &annotate.opts.show_asm_raw,
"Display raw encoding of assembly instructions (default)"),
- OPT_STRING('M', "disassembler-style", &annotate.opts.disassembler_style, "disassembler style",
+ OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
"Specify disassembler style (e.g. -M intel for intel syntax)"),
OPT_STRING(0, "prefix", &annotate.opts.prefix, "prefix",
"Add prefix to source file path names in programs (with --prefix-strip)"),
OPT_STRING(0, "prefix-strip", &annotate.opts.prefix_strip, "N",
"Strip first N entries of source file path name in programs (with --prefix)"),
- OPT_STRING(0, "objdump", &annotate.opts.objdump_path, "path",
+ OPT_STRING(0, "objdump", &objdump_path, "path",
"objdump binary to use for disassembly and annotations"),
OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
"Enable symbol demangling"),
@@ -618,6 +619,17 @@ int cmd_annotate(int argc, const char **argv)
annotate.sym_hist_filter = argv[0];
}
+ if (disassembler_style) {
+ annotate.opts.disassembler_style = strdup(disassembler_style);
+ if (!annotate.opts.disassembler_style)
+ return -ENOMEM;
+ }
+ if (objdump_path) {
+ annotate.opts.objdump_path = strdup(objdump_path);
+ if (!annotate.opts.objdump_path)
+ return -ENOMEM;
+ }
+
if (annotate_check_args(&annotate.opts) < 0)
return -EINVAL;