diff --git a/[refs] b/[refs] index 57ca14a76395..429dfe0721f6 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 8217563359878d11ef03cc76bc935ada89d73efd +refs/heads/master: 86a8c63f75a4582c44465e2bf71bc2df175cee77 diff --git a/trunk/MAINTAINERS b/trunk/MAINTAINERS index 9f90de2e00f8..99e9b20e8f0e 100644 --- a/trunk/MAINTAINERS +++ b/trunk/MAINTAINERS @@ -5644,7 +5644,7 @@ TRACING M: Steven Rostedt M: Frederic Weisbecker M: Ingo Molnar -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 diff --git a/trunk/tools/perf/arch/sh/Makefile b/trunk/tools/perf/arch/sh/Makefile deleted file mode 100644 index 15130b50dfe3..000000000000 --- a/trunk/tools/perf/arch/sh/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -ifndef NO_DWARF -PERF_HAVE_DWARF_REGS := 1 -LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o -endif diff --git a/trunk/tools/perf/arch/sh/util/dwarf-regs.c b/trunk/tools/perf/arch/sh/util/dwarf-regs.c deleted file mode 100644 index a11edb007a6c..000000000000 --- a/trunk/tools/perf/arch/sh/util/dwarf-regs.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Mapping of DWARF debug register numbers into register names. - * - * Copyright (C) 2010 Matt Fleming - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#include -#include - -/* - * Generic dwarf analysis helpers - */ - -#define SH_MAX_REGS 18 -const char *sh_regs_table[SH_MAX_REGS] = { - "r0", - "r1", - "r2", - "r3", - "r4", - "r5", - "r6", - "r7", - "r8", - "r9", - "r10", - "r11", - "r12", - "r13", - "r14", - "r15", - "pc", - "pr", -}; - -/* Return architecture dependent register string (for kprobe-tracer) */ -const char *get_arch_regstr(unsigned int n) -{ - return (n <= SH_MAX_REGS) ? sh_regs_table[n] : NULL; -} diff --git a/trunk/tools/perf/util/probe-event.c b/trunk/tools/perf/util/probe-event.c index 4445a1e7052f..09cf5465e10a 100644 --- a/trunk/tools/perf/util/probe-event.c +++ b/trunk/tools/perf/util/probe-event.c @@ -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 @@ -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(); @@ -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) diff --git a/trunk/tools/perf/util/probe-event.h b/trunk/tools/perf/util/probe-event.h index ed362acff4b6..bc06d3e8bafa 100644 --- a/trunk/tools/perf/util/probe-event.h +++ b/trunk/tools/perf/util/probe-event.h @@ -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 */ }; diff --git a/trunk/tools/perf/util/probe-finder.c b/trunk/tools/perf/util/probe-finder.c index f88070ea5b90..3e64e1fa1051 100644 --- a/trunk/tools/perf/util/probe-finder.c +++ b/trunk/tools/perf/util/probe-finder.c @@ -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 */ @@ -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 */ @@ -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; @@ -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; @@ -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)); @@ -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); @@ -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); } @@ -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); @@ -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) { @@ -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;