perf tools: Add symfs option for off-box analysis using specified tree
PATCH 1/1 perf tools: Add symfs option for off-box analysis using specified tree
The symfs argument allows analysis of perf.data file using a locally accessible filesystem tree with debug symbols - e.g., tree created during image builds, sshfs mount, loop mounted KVM disk images, USB keys, initrds, etc. Anything with an OS tree can be analyzed from anywhere without the need to populate a local data store with build-ids.
Signed-off-by David Ahern <[email protected]>
--- tools/perf/builtin-annotate.c | 16 +++++-- tools/perf/builtin-diff.c | 2 + tools/perf/builtin-report.c | 2 + tools/perf/builtin-timechart.c | 2 + tools/perf/util/hist.c | 14 +++++- tools/perf/util/symbol.c | 82 +++++++++++++++++++++++++--------------- tools/perf/util/symbol.h | 1 + 7 files changed, 80 insertions(+), 39 deletions(-)
tools/perf/builtin-annotate.c +11 -5
@@ -280,7 +280,8 @@ static int hist_entry__tty_annotate(struct hist_entry *he)struct map *map = he->ms.map;struct dso *dso = map->dso;struct symbol *sym = he->ms.sym; -const char *filename = dso->long_name, *d_filename; +const char *filename = dso->long_name; +char d_filename[PATH_MAX ];u64 len;LIST_HEAD (head);struct objdump_line *pos, *n;
@@ -288,10 +289,13 @@ static int hist_entry__tty_annotate(struct hist_entry *he)if (hist_entry__annotate (he, &head,0 ) <0 )return -1 ; -if (full_paths) - d_filename = filename; -else - d_filename =basename (filename); +if (full_paths) { +snprintf (d_filename,sizeof (d_filename),"%s%s" , + symbol_conf.symfs, filename); + }else { +snprintf (d_filename,sizeof (d_filename),"%s/%s" , + symbol_conf.symfs,basename (filename)); + } len = sym->end - sym->start;
@@ -437,6 +441,8 @@ static const struct option options[] = { "print matching source lines (may be slow)"),OPT_BOOLEAN ('P' ,"full-paths" , &full_paths,"Don't shorten the displayed pathnames" ), +OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , +"Look for files with symbols relative to this directory" ), OPT_END() };
tools/perf/builtin-diff.c +2 -0
@@ -191,6 +191,8 @@ static const struct option options[] = {OPT_STRING ('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_END() };
tools/perf/builtin-report.c +2 -0
@@ -480,6 +480,8 @@ static const struct option options[] = { "columns '.' is reserved."),OPT_BOOLEAN ('U' ,"hide-unresolved" , &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_END() };
tools/perf/builtin-timechart.c +2 -0
@@ -1018,6 +1018,8 @@ static const struct option options[] = {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_END() };
tools/perf/util/hist.c +11 -3
@@ -1092,6 +1092,12 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head,FILE *file;int err =0 ;u64 len; +char symfs_filename[PATH_MAX ]; + +if (filename) { +snprintf (symfs_filename,sizeof (symfs_filename),"%s%s" , + symbol_conf.symfs, filename); + }if (filename ==NULL ) {if (dso->has_build_id) {
@@ -1100,9 +1106,9 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head,return -ENOMEM ; } goto fallback; - }else if (readlink (filename, command,sizeof (command)) <0 || + }else if (readlink (symfs_filename, command,sizeof (command)) <0 ||strstr (command,"[kernel.kallsyms]" ) || -access (filename,R_OK )) { +access (symfs_filename,R_OK )) {free (filename); fallback:/*
@@ -1111,6 +1117,8 @@ fallback:* DSO is the same as when 'perf record' ran. */ filename = dso->long_name; +snprintf (symfs_filename,sizeof (symfs_filename),"%s%s" , + symbol_conf.symfs, filename); free_filename = false; }
@@ -1137,7 +1145,7 @@ fallback:"objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS -C %s|grep -v %s|expand" ,map__rip_2objdump (map, sym->start),map__rip_2objdump (map, sym->end), - filename, filename); + symfs_filename, filename);pr_debug ("Executing: %s\n" , command);
tools/perf/util/symbol.c +51 -31
147 lines not on this page · raw message
tools/perf/util/symbol.h +1 -0
@@ -86,6 +86,7 @@ struct symbol_conf {struct strlist *dso_list, *comm_list, *sym_list; +const char *symfs; };extern struct symbol_conf symbol_conf;
Signature · 1 line
1.7.2.3