Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 209254
b: refs/heads/master
c: 4373098
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Aug 6, 2010
1 parent e93ebe9 commit a62e579
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 26 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: 449e5b247ca7c9dc9fc3391b7eebfefdeb2ce1fc
refs/heads/master: 43730982c3e9355dd8bd6b31f0a0a3508ad4209d
8 changes: 8 additions & 0 deletions trunk/tools/perf/util/include/linux/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ static inline void list_del_range(struct list_head *begin,
begin->prev->next = end->next;
end->next->prev = begin->prev;
}

/**
* list_for_each_from - iterate over a list from one of its nodes
* @pos: the &struct list_head to use as a loop cursor, from where to start
* @head: the head for your list.
*/
#define list_for_each_from(pos, head) \
for (; prefetch(pos->next), pos != (head); pos = pos->next)
#endif
49 changes: 24 additions & 25 deletions trunk/tools/perf/util/newt.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,20 +456,24 @@ static int ui_browser__show(struct ui_browser *self, const char *title)
return 0;
}

static int objdump_line__show(struct objdump_line *self, struct list_head *head,
int width, struct hist_entry *he, int len,
bool current_entry)
static void annotate_browser__write(struct ui_browser *self, void *entry, int row)
{
if (self->offset != -1) {
struct objdump_line *ol = rb_entry(entry, struct objdump_line, node);
bool current_entry = ui_browser__is_current_entry(self, row);
int width = self->width;

if (ol->offset != -1) {
struct hist_entry *he = self->priv;
struct symbol *sym = he->ms.sym;
int len = he->ms.sym->end - he->ms.sym->start;
unsigned int hits = 0;
double percent = 0.0;
int color;
struct sym_priv *priv = symbol__priv(sym);
struct sym_ext *sym_ext = priv->ext;
struct sym_hist *h = priv->hist;
s64 offset = self->offset;
struct objdump_line *next = objdump__get_next_ip_line(head, self);
s64 offset = ol->offset;
struct objdump_line *next = objdump__get_next_ip_line(self->entries, ol);

while (offset < (s64)len &&
(next == NULL || offset < next->offset)) {
Expand Down Expand Up @@ -497,12 +501,10 @@ static int objdump_line__show(struct objdump_line *self, struct list_head *head,

SLsmg_write_char(':');
slsmg_write_nstring(" ", 8);
if (!*self->line)
if (!*ol->line)
slsmg_write_nstring(" ", width - 18);
else
slsmg_write_nstring(self->line, width - 18);

return 0;
slsmg_write_nstring(ol->line, width - 18);
}

static int ui_browser__refresh(struct ui_browser *self)
Expand Down Expand Up @@ -607,24 +609,20 @@ static char *callchain_list__sym_name(struct callchain_list *self,
return bf;
}

static unsigned int hist_entry__annotate_browser_refresh(struct ui_browser *self)
static unsigned int ui_browser__list_head_refresh(struct ui_browser *self)
{
struct objdump_line *pos;
struct list_head *pos;
struct list_head *head = self->entries;
struct hist_entry *he = self->priv;
int row = 0;
int len = he->ms.sym->end - he->ms.sym->start;

if (self->first_visible_entry == NULL || self->first_visible_entry == self->entries)
self->first_visible_entry = head->next;

pos = list_entry(self->first_visible_entry, struct objdump_line, node);
pos = self->first_visible_entry;

list_for_each_entry_from(pos, head, node) {
bool current_entry = ui_browser__is_current_entry(self, row);
list_for_each_from(pos, head) {
SLsmg_gotorc(self->top + row, self->left);
objdump_line__show(pos, head, self->width,
he, len, current_entry);
self->write(self, pos, row);
if (++row == self->height)
break;
}
Expand All @@ -634,10 +632,16 @@ static unsigned int hist_entry__annotate_browser_refresh(struct ui_browser *self

int hist_entry__tui_annotate(struct hist_entry *self)
{
struct ui_browser browser;
struct newtExitStruct es;
struct objdump_line *pos, *n;
LIST_HEAD(head);
struct ui_browser browser = {
.entries = &head,
.refresh = ui_browser__list_head_refresh,
.seek = ui_browser__list_head_seek,
.write = annotate_browser__write,
.priv = self,
};
int ret;

if (self->ms.sym == NULL)
Expand All @@ -653,11 +657,6 @@ int hist_entry__tui_annotate(struct hist_entry *self)

ui_helpline__push("Press <- or ESC to exit");

memset(&browser, 0, sizeof(browser));
browser.entries = &head;
browser.refresh = hist_entry__annotate_browser_refresh;
browser.seek = ui_browser__list_head_seek;
browser.priv = self;
list_for_each_entry(pos, &head, node) {
size_t line_len = strlen(pos->line);
if (browser.width < line_len)
Expand Down

0 comments on commit a62e579

Please sign in to comment.