perf tools: Set buildid dir under symfs when --symfs is provided
authorHe Kuang <hekuang@huawei.com>
Thu, 19 May 2016 11:47:37 +0000 (11:47 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 20 May 2016 14:43:58 +0000 (11:43 -0300)
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 <hekuang@huawei.com>
Acked-by: David Ahern <dsahern@gmail.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1463658462-85131-2-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-annotate.c
tools/perf/builtin-diff.c
tools/perf/builtin-report.c
tools/perf/builtin-script.c
tools/perf/builtin-timechart.c
tools/perf/util/dso.c
tools/perf/util/symbol.c
tools/perf/util/symbol.h

index 814158393656ca5348e6272ebc30f9449e0edfce..25c81734a9505604d8056ef897dd64975998ab66 100644 (file)
@@ -324,8 +324,9 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
        OPT_BOOLEAN(0, "skip-missing", &annotate.skip_missing,
                    "Skip symbols that cannot be annotated"),
        OPT_STRING('C', "cpu", &annotate.cpu_list, "cpu", "list of cpus to profile"),
-       OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
-                  "Look for files with symbols relative to this directory"),
+       OPT_CALLBACK(0, "symfs", NULL, "directory",
+                    "Look for files with symbols relative to this directory",
+                    symbol__config_symfs),
        OPT_BOOLEAN(0, "source", &symbol_conf.annotate_src,
                    "Interleave source code with assembly code (default)"),
        OPT_BOOLEAN(0, "asm-raw", &symbol_conf.annotate_asm_raw,
index 9ce354f469dce9e96d078ae5c352732cec59178c..f7645a42708eb2223069b3555df0a325c2c635d8 100644 (file)
@@ -812,8 +812,9 @@ static const struct option options[] = {
        OPT_STRING_NOEMPTY('t', "field-separator", &symbol_conf.field_sep, "separator",
                   "separator for columns, no spaces will be added between "
                   "columns '.' is reserved."),
-       OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
-                   "Look for files with symbols relative to this directory"),
+       OPT_CALLBACK(0, "symfs", NULL, "directory",
+                    "Look for files with symbols relative to this directory",
+                    symbol__config_symfs),
        OPT_UINTEGER('o', "order", &sort_compute, "Specify compute sorting."),
        OPT_CALLBACK(0, "percentage", NULL, "relative|absolute",
                     "How to display percentage of filtered entries", parse_filter_percentage),
index 9bc71c6a54f657b72dbafec38b45e073eca50b23..a87cb338bdf14b2d49c19b840fb99b3265e68997 100644 (file)
@@ -770,8 +770,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
                   "columns '.' is reserved."),
        OPT_BOOLEAN('U', "hide-unresolved", &symbol_conf.hide_unresolved,
                    "Only display entries resolved to a symbol"),
-       OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
-                   "Look for files with symbols relative to this directory"),
+       OPT_CALLBACK(0, "symfs", NULL, "directory",
+                    "Look for files with symbols relative to this directory",
+                    symbol__config_symfs),
        OPT_STRING('C', "cpu", &report.cpu_list, "cpu",
                   "list of cpus to profile"),
        OPT_BOOLEAN('I', "show-info", &report.show_full_info,
index 0a83f4bacc7cb03ebbda25fa350442b76b150cc4..e3ce2f34d3ad5276cc8f10d78b6590c41b56c179 100644 (file)
@@ -2010,8 +2010,9 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
                   "file", "kallsyms pathname"),
        OPT_BOOLEAN('G', "hide-call-graph", &no_callchain,
                    "When printing symbols do not display call chain"),
-       OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
-                   "Look for files with symbols relative to this directory"),
+       OPT_CALLBACK(0, "symfs", NULL, "directory",
+                    "Look for files with symbols relative to this directory",
+                    symbol__config_symfs),
        OPT_CALLBACK('F', "fields", NULL, "str",
                     "comma separated output fields prepend with 'type:'. "
                     "Valid types: hw,sw,trace,raw. "
index 40cc9bb3506c6d1b1625f2e37da795be36809ce3..733a55422d030037ab1c84bbf4b351c45074cd2c 100644 (file)
@@ -1945,8 +1945,9 @@ int cmd_timechart(int argc, const char **argv,
        OPT_CALLBACK('p', "process", NULL, "process",
                      "process selector. Pass a pid or process name.",
                       parse_process),
-       OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
-                   "Look for files with symbols relative to this directory"),
+       OPT_CALLBACK(0, "symfs", NULL, "directory",
+                    "Look for files with symbols relative to this directory",
+                    symbol__config_symfs),
        OPT_INTEGER('n', "proc-num", &tchart.proc_num,
                    "min. number of tasks to print"),
        OPT_BOOLEAN('t', "topology", &tchart.topology,
index 75b75615e2f881be286b043cdbcd256862db9d4b..5d286f5d7906798a6ffe1e5e91b8a52bf4bc1973 100644 (file)
@@ -63,9 +63,7 @@ int dso__read_binary_type_filename(const struct dso *dso,
                }
                break;
        case DSO_BINARY_TYPE__BUILD_ID_CACHE:
-               /* skip the locally configured cache if a symfs is given */
-               if (symbol_conf.symfs[0] ||
-                   (dso__build_id_filename(dso, filename, size) == NULL))
+               if (dso__build_id_filename(dso, filename, size) == NULL)
                        ret = -1;
                break;
 
index 2252b545ff434bc07423a15ef4f5731b3d02a86f..20f9cb32b703cd10330fa80ed328a16126a59a04 100644 (file)
@@ -2033,3 +2033,26 @@ void symbol__exit(void)
        symbol_conf.sym_list = symbol_conf.dso_list = symbol_conf.comm_list = NULL;
        symbol_conf.initialized = false;
 }
+
+int symbol__config_symfs(const struct option *opt __maybe_unused,
+                        const char *dir, int unset __maybe_unused)
+{
+       char *bf = NULL;
+       int ret;
+
+       symbol_conf.symfs = strdup(dir);
+       if (symbol_conf.symfs == NULL)
+               return -ENOMEM;
+
+       /* skip the locally configured cache if a symfs is given, and
+        * config buildid dir to symfs/.debug
+        */
+       ret = asprintf(&bf, "%s/%s", dir, ".debug");
+       if (ret < 0)
+               return -ENOMEM;
+
+       set_buildid_dir(bf);
+
+       free(bf);
+       return 0;
+}
index 25f2fd672c2e8080ea7417f0b62a12b1f27bdeee..fa415347dbf938f319ef86fc8e38c9ef45de3d2c 100644 (file)
@@ -290,6 +290,8 @@ bool symbol_type__is_a(char symbol_type, enum map_type map_type);
 bool symbol__restricted_filename(const char *filename,
                                 const char *restricted_filename);
 bool symbol__is_idle(struct symbol *sym);
+int symbol__config_symfs(const struct option *opt __maybe_unused,
+                        const char *dir, int unset __maybe_unused);
 
 int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
                  struct symsrc *runtime_ss, symbol_filter_t filter,