Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 205266
b: refs/heads/master
c: 9ed7e1b
h: refs/heads/master
v: v3
  • Loading branch information
Chase Douglas authored and Arnaldo Carvalho de Melo committed Jun 17, 2010
1 parent 0eea6e9 commit ba0290a
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cfc21cc641dae17a4ebda29ed093134358449577
refs/heads/master: 9ed7e1b85cd55dc46cb9410a23086bdaa2ff3eb9
4 changes: 4 additions & 0 deletions trunk/tools/perf/Documentation/perf-probe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ OPTIONS
--vmlinux=PATH::
Specify vmlinux path which has debuginfo (Dwarf binary).

-s::
--source=PATH::
Specify path to kernel source.

-v::
--verbose::
Be more verbose (show parsed arguments, etc).
Expand Down
2 changes: 2 additions & 0 deletions trunk/tools/perf/builtin-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ static const struct option options[] = {
"Show source code lines.", opt_show_lines),
OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
"file", "vmlinux pathname"),
OPT_STRING('s', "source", &symbol_conf.source_prefix,
"directory", "path to kernel source"),
#endif
OPT__DRY_RUN(&probe_event_dry_run),
OPT_INTEGER('\0', "max-probes", &params.max_probe_points,
Expand Down
58 changes: 55 additions & 3 deletions trunk/tools/perf/util/probe-finder.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "event.h"
#include "debug.h"
#include "util.h"
#include "symbol.h"
#include "probe-finder.h"

/* Kprobe tracer basic type is up to u64 */
Expand All @@ -57,6 +58,55 @@ static int strtailcmp(const char *s1, const char *s2)
return 0;
}

/*
* Find a src file from a DWARF tag path. Prepend optional source path prefix
* and chop off leading directories that do not exist. Result is passed back as
* a newly allocated path on success.
* Return 0 if file was found and readable, -errno otherwise.
*/
static int get_real_path(const char *raw_path, char **new_path)
{
if (!symbol_conf.source_prefix) {
if (access(raw_path, R_OK) == 0) {
*new_path = strdup(raw_path);
return 0;
} else
return -errno;
}

*new_path = malloc((strlen(symbol_conf.source_prefix) +
strlen(raw_path) + 2));
if (!*new_path)
return -ENOMEM;

for (;;) {
sprintf(*new_path, "%s/%s", symbol_conf.source_prefix,
raw_path);

if (access(*new_path, R_OK) == 0)
return 0;

switch (errno) {
case ENAMETOOLONG:
case ENOENT:
case EROFS:
case EFAULT:
raw_path = strchr(++raw_path, '/');
if (!raw_path) {
free(*new_path);
*new_path = NULL;
return -ENOENT;
}
continue;

default:
free(*new_path);
*new_path = NULL;
return -errno;
}
}
}

/* Line number list operations */

/* Add a line to line number list */
Expand Down Expand Up @@ -1096,11 +1146,13 @@ int find_perf_probe_point(int fd, unsigned long addr,
static int line_range_add_line(const char *src, unsigned int lineno,
struct line_range *lr)
{
int ret;

/* Copy real path */
if (!lr->path) {
lr->path = strdup(src);
if (lr->path == NULL)
return -ENOMEM;
ret = get_real_path(src, &lr->path);
if (ret != 0)
return ret;
}
return line_list__add_line(&lr->line_list, lineno);
}
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct symbol_conf {
full_paths,
show_cpu_utilization;
const char *vmlinux_name,
*source_prefix,
*field_sep;
const char *default_guest_vmlinux_name,
*default_guest_kallsyms,
Expand Down

0 comments on commit ba0290a

Please sign in to comment.