Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 299235
b: refs/heads/master
c: 31d68e7
h: refs/heads/master
i:
  299233: f8c3f0e
  299231: e2a6d69
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Apr 5, 2012
1 parent 17a7773 commit 33a1e78
Show file tree
Hide file tree
Showing 5 changed files with 39 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: 8493fe1daf15324eb13a4cc2f94e258716daa568
refs/heads/master: 31d68e7b66f168e623902e194af1e52b8cf75d71
35 changes: 34 additions & 1 deletion trunk/tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "util/debug.h"

#include <assert.h>
#include <elf.h>
#include <fcntl.h>

#include <stdio.h>
Expand All @@ -59,6 +60,7 @@
#include <sys/prctl.h>
#include <sys/wait.h>
#include <sys/uio.h>
#include <sys/utsname.h>
#include <sys/mman.h>

#include <linux/unistd.h>
Expand Down Expand Up @@ -162,12 +164,40 @@ static void __zero_source_counters(struct hist_entry *he)
symbol__annotate_zero_histograms(sym);
}

static void ui__warn_map_erange(struct map *map, struct symbol *sym, u64 ip)
{
struct utsname uts;
int err = uname(&uts);

ui__warning("Out of bounds address found:\n\n"
"Addr: %" PRIx64 "\n"
"DSO: %s %c\n"
"Map: %" PRIx64 "-%" PRIx64 "\n"
"Symbol: %" PRIx64 "-%" PRIx64 " %c %s\n"
"Arch: %s\n"
"Kernel: %s\n"
"Tools: %s\n\n"
"Not all samples will be on the annotation output.\n\n"
"Please report to linux-kernel@vger.kernel.org\n",
ip, map->dso->long_name, dso__symtab_origin(map->dso),
map->start, map->end, sym->start, sym->end,
sym->binding == STB_GLOBAL ? 'g' :
sym->binding == STB_LOCAL ? 'l' : 'w', sym->name,
err ? "[unknown]" : uts.machine,
err ? "[unknown]" : uts.release, perf_version_string);
if (use_browser <= 0)
sleep(5);

map->erange_warned = true;
}

static void perf_top__record_precise_ip(struct perf_top *top,
struct hist_entry *he,
int counter, u64 ip)
{
struct annotation *notes;
struct symbol *sym;
int err;

if (he == NULL || he->ms.sym == NULL ||
((top->sym_filter_entry == NULL ||
Expand All @@ -189,9 +219,12 @@ static void perf_top__record_precise_ip(struct perf_top *top,
}

ip = he->ms.map->map_ip(he->ms.map, ip);
symbol__inc_addr_samples(sym, he->ms.map, counter, ip);
err = symbol__inc_addr_samples(sym, he->ms.map, counter, ip);

pthread_mutex_unlock(&notes->lock);

if (err == -ERANGE && !he->ms.map->erange_warned)
ui__warn_map_erange(he->ms.map, sym, ip);
}

static void perf_top__show_details(struct perf_top *top)
Expand Down
4 changes: 2 additions & 2 deletions trunk/tools/perf/util/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ int symbol__inc_addr_samples(struct symbol *sym, struct map *map,

pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map, addr));

if (addr > sym->end)
return 0;
if (addr < sym->start || addr > sym->end)
return -ERANGE;

offset = addr - sym->start;
h = annotation__histogram(notes, evidx);
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void map__init(struct map *self, enum map_type type,
RB_CLEAR_NODE(&self->rb_node);
self->groups = NULL;
self->referenced = false;
self->erange_warned = false;
}

struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct map {
u64 end;
u8 /* enum map_type */ type;
bool referenced;
bool erange_warned;
u32 priv;
u64 pgoff;

Expand Down

0 comments on commit 33a1e78

Please sign in to comment.