Skip to content

Commit a706670

Browse files
He Kuangacmel
authored andcommitted
perf tools: Set buildid dir under symfs when --symfs is provided
This patch moves the reference of buildid dir to 'symfs/.debug' and skips the local buildid dir when '--symfs' is given, so that every single file opened by perf is relative to symfs directory now. Signed-off-by: He Kuang <[email protected]> Acked-by: David Ahern <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ekaterina Tumanova <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Kan Liang <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Pekka Enberg <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Sukadev Bhattiprolu <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent caa36ed commit a706670

File tree

8 files changed

+41
-13
lines changed

8 files changed

+41
-13
lines changed

tools/perf/builtin-annotate.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,9 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
324324
OPT_BOOLEAN(0, "skip-missing", &annotate.skip_missing,
325325
"Skip symbols that cannot be annotated"),
326326
OPT_STRING('C', "cpu", &annotate.cpu_list, "cpu", "list of cpus to profile"),
327-
OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
328-
"Look for files with symbols relative to this directory"),
327+
OPT_CALLBACK(0, "symfs", NULL, "directory",
328+
"Look for files with symbols relative to this directory",
329+
symbol__config_symfs),
329330
OPT_BOOLEAN(0, "source", &symbol_conf.annotate_src,
330331
"Interleave source code with assembly code (default)"),
331332
OPT_BOOLEAN(0, "asm-raw", &symbol_conf.annotate_asm_raw,

tools/perf/builtin-diff.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,9 @@ static const struct option options[] = {
812812
OPT_STRING_NOEMPTY('t', "field-separator", &symbol_conf.field_sep, "separator",
813813
"separator for columns, no spaces will be added between "
814814
"columns '.' is reserved."),
815-
OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
816-
"Look for files with symbols relative to this directory"),
815+
OPT_CALLBACK(0, "symfs", NULL, "directory",
816+
"Look for files with symbols relative to this directory",
817+
symbol__config_symfs),
817818
OPT_UINTEGER('o', "order", &sort_compute, "Specify compute sorting."),
818819
OPT_CALLBACK(0, "percentage", NULL, "relative|absolute",
819820
"How to display percentage of filtered entries", parse_filter_percentage),

tools/perf/builtin-report.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
770770
"columns '.' is reserved."),
771771
OPT_BOOLEAN('U', "hide-unresolved", &symbol_conf.hide_unresolved,
772772
"Only display entries resolved to a symbol"),
773-
OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
774-
"Look for files with symbols relative to this directory"),
773+
OPT_CALLBACK(0, "symfs", NULL, "directory",
774+
"Look for files with symbols relative to this directory",
775+
symbol__config_symfs),
775776
OPT_STRING('C', "cpu", &report.cpu_list, "cpu",
776777
"list of cpus to profile"),
777778
OPT_BOOLEAN('I', "show-info", &report.show_full_info,

tools/perf/builtin-script.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,8 +2010,9 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
20102010
"file", "kallsyms pathname"),
20112011
OPT_BOOLEAN('G', "hide-call-graph", &no_callchain,
20122012
"When printing symbols do not display call chain"),
2013-
OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
2014-
"Look for files with symbols relative to this directory"),
2013+
OPT_CALLBACK(0, "symfs", NULL, "directory",
2014+
"Look for files with symbols relative to this directory",
2015+
symbol__config_symfs),
20152016
OPT_CALLBACK('F', "fields", NULL, "str",
20162017
"comma separated output fields prepend with 'type:'. "
20172018
"Valid types: hw,sw,trace,raw. "

tools/perf/builtin-timechart.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,8 +1945,9 @@ int cmd_timechart(int argc, const char **argv,
19451945
OPT_CALLBACK('p', "process", NULL, "process",
19461946
"process selector. Pass a pid or process name.",
19471947
parse_process),
1948-
OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
1949-
"Look for files with symbols relative to this directory"),
1948+
OPT_CALLBACK(0, "symfs", NULL, "directory",
1949+
"Look for files with symbols relative to this directory",
1950+
symbol__config_symfs),
19501951
OPT_INTEGER('n', "proc-num", &tchart.proc_num,
19511952
"min. number of tasks to print"),
19521953
OPT_BOOLEAN('t', "topology", &tchart.topology,

tools/perf/util/dso.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ int dso__read_binary_type_filename(const struct dso *dso,
6363
}
6464
break;
6565
case DSO_BINARY_TYPE__BUILD_ID_CACHE:
66-
/* skip the locally configured cache if a symfs is given */
67-
if (symbol_conf.symfs[0] ||
68-
(dso__build_id_filename(dso, filename, size) == NULL))
66+
if (dso__build_id_filename(dso, filename, size) == NULL)
6967
ret = -1;
7068
break;
7169

tools/perf/util/symbol.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,3 +2033,26 @@ void symbol__exit(void)
20332033
symbol_conf.sym_list = symbol_conf.dso_list = symbol_conf.comm_list = NULL;
20342034
symbol_conf.initialized = false;
20352035
}
2036+
2037+
int symbol__config_symfs(const struct option *opt __maybe_unused,
2038+
const char *dir, int unset __maybe_unused)
2039+
{
2040+
char *bf = NULL;
2041+
int ret;
2042+
2043+
symbol_conf.symfs = strdup(dir);
2044+
if (symbol_conf.symfs == NULL)
2045+
return -ENOMEM;
2046+
2047+
/* skip the locally configured cache if a symfs is given, and
2048+
* config buildid dir to symfs/.debug
2049+
*/
2050+
ret = asprintf(&bf, "%s/%s", dir, ".debug");
2051+
if (ret < 0)
2052+
return -ENOMEM;
2053+
2054+
set_buildid_dir(bf);
2055+
2056+
free(bf);
2057+
return 0;
2058+
}

tools/perf/util/symbol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ bool symbol_type__is_a(char symbol_type, enum map_type map_type);
290290
bool symbol__restricted_filename(const char *filename,
291291
const char *restricted_filename);
292292
bool symbol__is_idle(struct symbol *sym);
293+
int symbol__config_symfs(const struct option *opt __maybe_unused,
294+
const char *dir, int unset __maybe_unused);
293295

294296
int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
295297
struct symsrc *runtime_ss, symbol_filter_t filter,

0 commit comments

Comments
 (0)