Newer
Older
switch (disasm_line__print(pos, sym, start, evidx, len,

Arnaldo Carvalho de Melo
committed
min_pcnt, printed, max_lines,
queue)) {
case 0:
++printed;
if (context) {
printed += queue_len;
queue = NULL;
queue_len = 0;
}
break;
case 1:
/* filtered by max_lines */
++more;
break;
case -1:
default:
/*
* Filtered by min_pcnt or non IP lines when
* context != 0
*/
if (!context)
break;
if (queue_len == context)
queue = list_entry(queue->node.next, typeof(*queue), node);
else
++queue_len;
break;
}
}
return more;
}

Arnaldo Carvalho de Melo
committed
void symbol__annotate_zero_histogram(struct symbol *sym, int evidx)
{
struct annotation *notes = symbol__annotation(sym);
struct sym_hist *h = annotation__histogram(notes, evidx);
memset(h, 0, notes->src->sizeof_sym_hist);
}
void symbol__annotate_decay_histogram(struct symbol *sym, int evidx)
{
struct annotation *notes = symbol__annotation(sym);
struct sym_hist *h = annotation__histogram(notes, evidx);
int len = symbol__size(sym), offset;
h->sum = 0;
for (offset = 0; offset < len; ++offset) {
h->addr[offset] = h->addr[offset] * 7 / 8;
h->sum += h->addr[offset];

Arnaldo Carvalho de Melo
committed
}
}
void disasm__purge(struct list_head *head)

Arnaldo Carvalho de Melo
committed
{
struct disasm_line *pos, *n;

Arnaldo Carvalho de Melo
committed
list_for_each_entry_safe(pos, n, head, node) {
list_del(&pos->node);
disasm_line__free(pos);

Arnaldo Carvalho de Melo
committed
}
}
static size_t disasm_line__fprintf(struct disasm_line *dl, FILE *fp)
{
size_t printed;
if (dl->offset == -1)
return fprintf(fp, "%s\n", dl->line);
printed = fprintf(fp, "%#" PRIx64 " %s", dl->offset, dl->name);
if (dl->ops.raw[0] != '\0') {
printed += fprintf(fp, "%.*s %s\n", 6 - (int)printed, " ",
}
return printed + fprintf(fp, "\n");
}
size_t disasm__fprintf(struct list_head *head, FILE *fp)
{
struct disasm_line *pos;
size_t printed = 0;
list_for_each_entry(pos, head, node)
printed += disasm_line__fprintf(pos, fp);
return printed;
}

Arnaldo Carvalho de Melo
committed
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;
u64 len;
if (symbol__annotate(sym, map, 0) < 0)

Arnaldo Carvalho de Melo
committed
return -1;
len = symbol__size(sym);

Arnaldo Carvalho de Melo
committed
if (print_lines) {
symbol__get_source_line(sym, map, evidx, &source_line,
len, filename);
print_summary(&source_line, filename);
symbol__annotate_printf(sym, map, evidx, full_paths,
min_pcnt, max_lines, 0);
if (print_lines)
symbol__free_source_line(sym, len);
disasm__purge(&symbol__annotation(sym)->src->source);

Arnaldo Carvalho de Melo
committed
return 0;
}