Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 205309
b: refs/heads/master
c: 86a8c63
h: refs/heads/master
i:
  205307: 41b39cd
v: v3
  • Loading branch information
Frederic Weisbecker committed Jul 15, 2010
1 parent f15f7bd commit e0d6338
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 164 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: 8217563359878d11ef03cc76bc935ada89d73efd
refs/heads/master: 86a8c63f75a4582c44465e2bf71bc2df175cee77
2 changes: 1 addition & 1 deletion trunk/MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -5644,7 +5644,7 @@ TRACING
M: Steven Rostedt <rostedt@goodmis.org>
M: Frederic Weisbecker <fweisbec@gmail.com>
M: Ingo Molnar <mingo@redhat.com>
T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git tracing/core
T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git perf/core
S: Maintained
F: Documentation/trace/ftrace.txt
F: arch/*/*/*/ftrace.h
Expand Down
4 changes: 0 additions & 4 deletions trunk/tools/perf/arch/sh/Makefile

This file was deleted.

55 changes: 0 additions & 55 deletions trunk/tools/perf/arch/sh/util/dwarf-regs.c

This file was deleted.

69 changes: 0 additions & 69 deletions trunk/tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,65 +195,6 @@ static int try_to_find_kprobe_trace_events(struct perf_probe_event *pev,
return ntevs;
}

/*
* 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, const char *comp_dir,
char **new_path)
{
const char *prefix = symbol_conf.source_prefix;

if (!prefix) {
if (raw_path[0] != '/' && comp_dir)
/* If not an absolute path, try to use comp_dir */
prefix = comp_dir;
else {
if (access(raw_path, R_OK) == 0) {
*new_path = strdup(raw_path);
return 0;
} else
return -errno;
}
}

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

for (;;) {
sprintf(*new_path, "%s/%s", prefix, raw_path);

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

if (!symbol_conf.source_prefix)
/* In case of searching comp_dir, don't retry */
return -errno;

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;
}
}
}

#define LINEBUF_SIZE 256
#define NR_ADDITIONAL_LINES 2

Expand Down Expand Up @@ -303,7 +244,6 @@ int show_line_range(struct line_range *lr)
struct line_node *ln;
FILE *fp;
int fd, ret;
char *tmp;

/* Search a line range */
ret = init_vmlinux();
Expand All @@ -326,15 +266,6 @@ int show_line_range(struct line_range *lr)
return ret;
}

/* Convert source file path */
tmp = lr->path;
ret = get_real_path(tmp, lr->comp_dir, &lr->path);
free(tmp); /* Free old path */
if (ret < 0) {
pr_warning("Failed to find source file. (%d)\n", ret);
return ret;
}

setup_pager();

if (lr->function)
Expand Down
1 change: 0 additions & 1 deletion trunk/tools/perf/util/probe-event.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ struct line_range {
int end; /* End line number */
int offset; /* Start line offset */
char *path; /* Real path name */
char *comp_dir; /* Compile directory */
struct list_head line_list; /* Visible lines */
};

Expand Down
96 changes: 63 additions & 33 deletions trunk/tools/perf/util/probe-finder.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,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 @@ -144,21 +193,12 @@ static const char *cu_find_realpath(Dwarf_Die *cu_die, const char *fname)
return src;
}

/* Get DW_AT_comp_dir (should be NULL with older gcc) */
static const char *cu_get_comp_dir(Dwarf_Die *cu_die)
{
Dwarf_Attribute attr;
if (dwarf_attr(cu_die, DW_AT_comp_dir, &attr) == NULL)
return NULL;
return dwarf_formstring(&attr);
}

/* Compare diename and tname */
static bool die_compare_name(Dwarf_Die *dw_die, const char *tname)
{
const char *name;
name = dwarf_diename(dw_die);
return name ? (strcmp(tname, name) == 0) : false;
return name ? strcmp(tname, name) : -1;
}

/* Get type die, but skip qualifiers and typedef */
Expand Down Expand Up @@ -329,7 +369,7 @@ static int __die_find_variable_cb(Dwarf_Die *die_mem, void *data)
tag = dwarf_tag(die_mem);
if ((tag == DW_TAG_formal_parameter ||
tag == DW_TAG_variable) &&
die_compare_name(die_mem, name))
(die_compare_name(die_mem, name) == 0))
return DIE_FIND_CB_FOUND;

return DIE_FIND_CB_CONTINUE;
Expand All @@ -348,7 +388,7 @@ static int __die_find_member_cb(Dwarf_Die *die_mem, void *data)
const char *name = data;

if ((dwarf_tag(die_mem) == DW_TAG_member) &&
die_compare_name(die_mem, name))
(die_compare_name(die_mem, name) == 0))
return DIE_FIND_CB_FOUND;

return DIE_FIND_CB_SIBLING;
Expand Down Expand Up @@ -506,8 +546,8 @@ static int convert_variable_type(Dwarf_Die *vr_die,
return -ENOMEM;
}
}
if (!die_compare_name(&type, "char") &&
!die_compare_name(&type, "unsigned char")) {
if (die_compare_name(&type, "char") != 0 &&
die_compare_name(&type, "unsigned char") != 0) {
pr_warning("Failed to cast into string: "
"%s is not (unsigned) char *.",
dwarf_diename(vr_die));
Expand Down Expand Up @@ -1017,7 +1057,7 @@ static int probe_point_search_cb(Dwarf_Die *sp_die, void *data)

/* Check tag and diename */
if (dwarf_tag(sp_die) != DW_TAG_subprogram ||
!die_compare_name(sp_die, pp->function))
die_compare_name(sp_die, pp->function) != 0)
return DWARF_CB_OK;

pf->fname = dwarf_decl_file(sp_die);
Expand Down Expand Up @@ -1216,11 +1256,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)
{
/* Copy source path */
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 Expand Up @@ -1340,7 +1382,7 @@ static int line_range_search_cb(Dwarf_Die *sp_die, void *data)
struct line_range *lr = lf->lr;

if (dwarf_tag(sp_die) == DW_TAG_subprogram &&
die_compare_name(sp_die, lr->function)) {
die_compare_name(sp_die, lr->function) == 0) {
lf->fname = dwarf_decl_file(sp_die);
dwarf_decl_line(sp_die, &lr->offset);
pr_debug("fname: %s, lineno:%d\n", lf->fname, lr->offset);
Expand Down Expand Up @@ -1383,7 +1425,6 @@ int find_line_range(int fd, struct line_range *lr)
size_t cuhl;
Dwarf_Die *diep;
Dwarf *dbg;
const char *comp_dir;

dbg = dwarf_begin(fd, DWARF_C_READ);
if (!dbg) {
Expand Down Expand Up @@ -1419,18 +1460,7 @@ int find_line_range(int fd, struct line_range *lr)
}
off = noff;
}

/* Store comp_dir */
if (lf.found) {
comp_dir = cu_get_comp_dir(&lf.cu_die);
if (comp_dir) {
lr->comp_dir = strdup(comp_dir);
if (!lr->comp_dir)
ret = -ENOMEM;
}
}

pr_debug("path: %s\n", lr->path);
pr_debug("path: %lx\n", (unsigned long)lr->path);
dwarf_end(dbg);

return (ret < 0) ? ret : lf.found;
Expand Down

0 comments on commit e0d6338

Please sign in to comment.