From 217b7d41ea2038e52991b7a600a0b958330d8ae6 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Tue, 28 Mar 2023 16:55:40 -0700 Subject: perf annotate: Add init/exit to annotation_options remove default The annotation__default_options global variable was used to initialize annotation_options. Switch to the init/exit pattern as later changes will give ownership over strings and this will be necessary to avoid memory leaks. Committer note: Fix the GTK2=1 build, hist_entry__gtk_annotate() needs to receive a 'struct annotation_options' pointer. Signed-off-by: Ian Rogers Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Andres Freund Cc: German Gomez Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: Kan Liang Cc: Mark Rutland Cc: Namhyung Kim Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Peter Zijlstra Cc: Sandipan Das Cc: Tom Rix Cc: llvm@lists.linux.dev Link: https://lore.kernel.org/r/20230328235543.1082207-2-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'tools/perf/util/annotate.c') diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index db475e44f42f..a984bdae7811 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -55,14 +55,6 @@ #include -struct annotation_options annotation__default_options = { - .use_offset = true, - .jump_arrows = true, - .annotate_src = true, - .offset_level = ANNOTATION__OFFSET_JUMP_TARGETS, - .percent_type = PERCENT_PERIOD_LOCAL, -}; - static regex_t file_lineno; static struct ins_ops *ins__find(struct arch *arch, const char *name); @@ -3226,6 +3218,23 @@ static int annotation__config(const char *var, const char *value, void *data) return 0; } +void annotation_options__init(struct annotation_options *opt) +{ + memset(opt, 0, sizeof(*opt)); + + /* Default values. */ + opt->use_offset = true; + opt->jump_arrows = true; + opt->annotate_src = true; + opt->offset_level = ANNOTATION__OFFSET_JUMP_TARGETS; + opt->percent_type = PERCENT_PERIOD_LOCAL; +} + + +void annotation_options__exit(struct annotation_options *opt __maybe_unused) +{ +} + void annotation_config__init(struct annotation_options *opt) { perf_config(annotation__config, opt); -- cgit