Commit 339a2afc authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'perf-fixes-for-linus' of...

Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  perf tools: Fix fallback to cplus_demangle() when bfd_demangle() is not available
  perf annotate: Fix handling of goto labels that are valid hex numbers
  tracing: Properly align linker defined symbols
  perf symbols: Fix directory descriptor leaking
  perf: Fix various display bugs with parent filtering
parents b37fa16e 8a4fd31e
...@@ -63,6 +63,12 @@ ...@@ -63,6 +63,12 @@
/* Align . to a 8 byte boundary equals to maximum function alignment. */ /* Align . to a 8 byte boundary equals to maximum function alignment. */
#define ALIGN_FUNCTION() . = ALIGN(8) #define ALIGN_FUNCTION() . = ALIGN(8)
/*
* Align to a 32 byte boundary equal to the
* alignment gcc 4.5 uses for a struct
*/
#define STRUCT_ALIGN() . = ALIGN(32)
/* The actual configuration determine if the init/exit sections /* The actual configuration determine if the init/exit sections
* are handled as text/data or they can be discarded (which * are handled as text/data or they can be discarded (which
* often happens at runtime) * often happens at runtime)
...@@ -166,7 +172,11 @@ ...@@ -166,7 +172,11 @@
LIKELY_PROFILE() \ LIKELY_PROFILE() \
BRANCH_PROFILE() \ BRANCH_PROFILE() \
TRACE_PRINTKS() \ TRACE_PRINTKS() \
\
STRUCT_ALIGN(); \
FTRACE_EVENTS() \ FTRACE_EVENTS() \
\
STRUCT_ALIGN(); \
TRACE_SYSCALLS() TRACE_SYSCALLS()
/* /*
......
...@@ -600,30 +600,32 @@ endif ...@@ -600,30 +600,32 @@ endif
ifdef NO_DEMANGLE ifdef NO_DEMANGLE
BASIC_CFLAGS += -DNO_DEMANGLE BASIC_CFLAGS += -DNO_DEMANGLE
else ifdef HAVE_CPLUS_DEMANGLE
EXTLIBS += -liberty
BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
else else
has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y") ifdef HAVE_CPLUS_DEMANGLE
EXTLIBS += -liberty
ifeq ($(has_bfd),y) BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
EXTLIBS += -lbfd
else else
has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y") has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y")
ifeq ($(has_bfd_iberty),y)
EXTLIBS += -lbfd -liberty ifeq ($(has_bfd),y)
EXTLIBS += -lbfd
else else
has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y") has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y")
ifeq ($(has_bfd_iberty_z),y) ifeq ($(has_bfd_iberty),y)
EXTLIBS += -lbfd -liberty -lz EXTLIBS += -lbfd -liberty
else else
has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y") has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y")
ifeq ($(has_cplus_demangle),y) ifeq ($(has_bfd_iberty_z),y)
EXTLIBS += -liberty EXTLIBS += -lbfd -liberty -lz
BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
else else
msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y")
BASIC_CFLAGS += -DNO_DEMANGLE ifeq ($(has_cplus_demangle),y)
EXTLIBS += -liberty
BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
else
msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
BASIC_CFLAGS += -DNO_DEMANGLE
endif
endif endif
endif endif
endif endif
......
...@@ -631,9 +631,14 @@ int hist_entry__fprintf(struct hist_entry *self, struct hists *pair_hists, ...@@ -631,9 +631,14 @@ int hist_entry__fprintf(struct hist_entry *self, struct hists *pair_hists,
u64 session_total) u64 session_total)
{ {
char bf[512]; char bf[512];
hist_entry__snprintf(self, bf, sizeof(bf), pair_hists, int ret;
show_displacement, displacement,
true, session_total); ret = hist_entry__snprintf(self, bf, sizeof(bf), pair_hists,
show_displacement, displacement,
true, session_total);
if (!ret)
return 0;
return fprintf(fp, "%s\n", bf); return fprintf(fp, "%s\n", bf);
} }
...@@ -762,6 +767,7 @@ size_t hists__fprintf(struct hists *self, struct hists *pair, ...@@ -762,6 +767,7 @@ size_t hists__fprintf(struct hists *self, struct hists *pair,
print_entries: print_entries:
for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) {
struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
int cnt;
if (show_displacement) { if (show_displacement) {
if (h->pair != NULL) if (h->pair != NULL)
...@@ -771,8 +777,13 @@ size_t hists__fprintf(struct hists *self, struct hists *pair, ...@@ -771,8 +777,13 @@ size_t hists__fprintf(struct hists *self, struct hists *pair,
displacement = 0; displacement = 0;
++position; ++position;
} }
ret += hist_entry__fprintf(h, pair, show_displacement, cnt = hist_entry__fprintf(h, pair, show_displacement,
displacement, fp, self->stats.total_period); displacement, fp, self->stats.total_period);
/* Ignore those that didn't match the parent filter */
if (!cnt)
continue;
ret += cnt;
if (symbol_conf.use_callchain) if (symbol_conf.use_callchain)
ret += hist_entry__fprintf_callchain(h, fp, self->stats.total_period); ret += hist_entry__fprintf_callchain(h, fp, self->stats.total_period);
...@@ -965,13 +976,17 @@ static int hist_entry__parse_objdump_line(struct hist_entry *self, FILE *file, ...@@ -965,13 +976,17 @@ static int hist_entry__parse_objdump_line(struct hist_entry *self, FILE *file,
* Parse hexa addresses followed by ':' * Parse hexa addresses followed by ':'
*/ */
line_ip = strtoull(tmp, &tmp2, 16); line_ip = strtoull(tmp, &tmp2, 16);
if (*tmp2 != ':' || tmp == tmp2) if (*tmp2 != ':' || tmp == tmp2 || tmp2[1] == '\0')
line_ip = -1; line_ip = -1;
} }
if (line_ip != -1) { if (line_ip != -1) {
u64 start = map__rip_2objdump(self->ms.map, sym->start); u64 start = map__rip_2objdump(self->ms.map, sym->start),
end = map__rip_2objdump(self->ms.map, sym->end);
offset = line_ip - start; offset = line_ip - start;
if (offset < 0 || (u64)line_ip > end)
offset = -1;
} }
objdump_line = objdump_line__new(offset, line); objdump_line = objdump_line__new(offset, line);
......
...@@ -1443,6 +1443,7 @@ static int map_groups__set_modules_path_dir(struct map_groups *self, ...@@ -1443,6 +1443,7 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
{ {
struct dirent *dent; struct dirent *dent;
DIR *dir = opendir(dir_name); DIR *dir = opendir(dir_name);
int ret = 0;
if (!dir) { if (!dir) {
pr_debug("%s: cannot open %s dir\n", __func__, dir_name); pr_debug("%s: cannot open %s dir\n", __func__, dir_name);
...@@ -1465,8 +1466,9 @@ static int map_groups__set_modules_path_dir(struct map_groups *self, ...@@ -1465,8 +1466,9 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
snprintf(path, sizeof(path), "%s/%s", snprintf(path, sizeof(path), "%s/%s",
dir_name, dent->d_name); dir_name, dent->d_name);
if (map_groups__set_modules_path_dir(self, path) < 0) ret = map_groups__set_modules_path_dir(self, path);
goto failure; if (ret < 0)
goto out;
} else { } else {
char *dot = strrchr(dent->d_name, '.'), char *dot = strrchr(dent->d_name, '.'),
dso_name[PATH_MAX]; dso_name[PATH_MAX];
...@@ -1487,17 +1489,18 @@ static int map_groups__set_modules_path_dir(struct map_groups *self, ...@@ -1487,17 +1489,18 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
dir_name, dent->d_name); dir_name, dent->d_name);
long_name = strdup(path); long_name = strdup(path);
if (long_name == NULL) if (long_name == NULL) {
goto failure; ret = -1;
goto out;
}
dso__set_long_name(map->dso, long_name); dso__set_long_name(map->dso, long_name);
dso__kernel_module_get_build_id(map->dso, ""); dso__kernel_module_get_build_id(map->dso, "");
} }
} }
return 0; out:
failure:
closedir(dir); closedir(dir);
return -1; return ret;
} }
static char *get_kernel_version(const char *root_dir) static char *get_kernel_version(const char *root_dir)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment