Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234397
b: refs/heads/master
c: f1e2701
h: refs/heads/master
i:
  234395: f01b5f3
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Feb 6, 2011
1 parent e14ebcf commit e97f407
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 20 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: d040bd363824f9f0ad6610b91ee6c65f292c066c
refs/heads/master: f1e2701de02cff6d988b1dd49960620d5720cb89
62 changes: 43 additions & 19 deletions trunk/tools/perf/util/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,50 +421,74 @@ static void symbol__annotate_hits(struct symbol *sym, int evidx)
printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->sum", h->sum);
}

int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx,
bool print_lines, bool full_paths, int min_pcnt,
int max_lines)
void symbol__annotate_printf(struct symbol *sym, struct map *map,
struct list_head *head, int evidx, bool full_paths,
int min_pcnt, int max_lines)
{
struct dso *dso = map->dso;
const char *filename = dso->long_name, *d_filename;
struct rb_root source_line = RB_ROOT;
struct objdump_line *pos, *n;
LIST_HEAD(head);
struct objdump_line *pos;
int printed = 2;
u64 len;

if (symbol__annotate(sym, map, &head, 0) < 0)
return -1;

if (full_paths)
d_filename = filename;
else
d_filename = basename(filename);

len = sym->end - sym->start;

if (print_lines) {
symbol__get_source_line(sym, map, evidx, &source_line,
len, filename);
print_summary(&source_line, filename);
}

printf(" Percent | Source code & Disassembly of %s\n", d_filename);
printf("------------------------------------------------\n");

if (verbose)
symbol__annotate_hits(sym, evidx);

list_for_each_entry_safe(pos, n, &head, node) {
objdump_line__print(pos, &head, sym, evidx, len, min_pcnt);
list_del(&pos->node);
objdump_line__free(pos);
list_for_each_entry(pos, head, node) {
objdump_line__print(pos, head, sym, evidx, len, min_pcnt);
if (max_lines && ++printed >= max_lines)
break;

}
}

void objdump_line_list__purge(struct list_head *head)
{
struct objdump_line *pos, *n;

list_for_each_entry_safe(pos, n, head, node) {
list_del(&pos->node);
objdump_line__free(pos);
}
}

int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx,
bool print_lines, bool full_paths, int min_pcnt,
int max_lines)
{
struct dso *dso = map->dso;
const char *filename = dso->long_name;
struct rb_root source_line = RB_ROOT;
LIST_HEAD(head);
u64 len;

if (symbol__annotate(sym, map, &head, 0) < 0)
return -1;

len = sym->end - sym->start;

if (print_lines) {
symbol__get_source_line(sym, map, evidx, &source_line,
len, filename);
print_summary(&source_line, filename);
}

symbol__annotate_printf(sym, map, &head, evidx, full_paths,
min_pcnt, max_lines);
if (print_lines)
symbol__free_source_line(sym, len);

objdump_line_list__purge(&head);

return 0;
}
4 changes: 4 additions & 0 deletions trunk/tools/perf/util/annotate.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ int symbol__alloc_hist(struct symbol *sym, int nevents);

int symbol__annotate(struct symbol *sym, struct map *map,
struct list_head *head, size_t privsize);
void symbol__annotate_printf(struct symbol *sym, struct map *map,
struct list_head *head, int evidx, bool full_paths,
int min_pcnt, int max_lines);
void objdump_line_list__purge(struct list_head *head);

int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx,
bool print_lines, bool full_paths, int min_pcnt,
Expand Down

0 comments on commit e97f407

Please sign in to comment.