summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/newt.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-08-10 14:54:09 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-08-10 16:09:41 -0300
commit211ef12771e759a08e10c3c606e6a8b1663519e7 (patch)
treef9881f574f9a7508ce47d125daad0a089bef5add /tools/perf/util/newt.c
parent34cea7f7c0620c964676eece258ef431a6608bce (diff)
perf ui: Move annotate browser to util/ui/browsers/
LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/newt.c')
-rw-r--r--tools/perf/util/newt.c132
1 files changed, 2 insertions, 130 deletions
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c
index c0986d34295..f1882589c82 100644
--- a/tools/perf/util/newt.c
+++ b/tools/perf/util/newt.c
@@ -1,16 +1,7 @@
#define _GNU_SOURCE
#include <stdio.h>
#undef _GNU_SOURCE
-/*
- * slang versions <= 2.0.6 have a "#if HAVE_LONG_LONG" that breaks
- * the build if it isn't defined. Use the equivalent one that glibc
- * has on features.h.
- */
-#include <features.h>
-#ifndef HAVE_LONG_LONG
-#define HAVE_LONG_LONG __GLIBC_HAVE_LONG_LONG
-#endif
-#include <slang.h>
+#include "ui/libslang.h"
#include <signal.h>
#include <stdlib.h>
#include <elf.h>
@@ -26,17 +17,6 @@
#include "ui/browser.h"
#include "ui/helpline.h"
-#if SLANG_VERSION < 20104
-#define slsmg_printf(msg, args...) SLsmg_printf((char *)msg, ##args)
-#define slsmg_write_nstring(msg, len) SLsmg_write_nstring((char *)msg, len)
-#define sltt_set_color(obj, name, fg, bg) SLtt_set_color(obj,(char *)name,\
- (char *)fg, (char *)bg)
-#else
-#define slsmg_printf SLsmg_printf
-#define slsmg_write_nstring SLsmg_write_nstring
-#define sltt_set_color SLtt_set_color
-#endif
-
newtComponent newt_form__new(void);
static int ui_entry__read(const char *title, char *bf, size_t size, int width)
@@ -72,7 +52,7 @@ out_free_form:
return 0;
}
-static char browser__last_msg[1024];
+char browser__last_msg[1024];
int browser__show_help(const char *format, va_list ap)
{
@@ -192,66 +172,6 @@ static bool dialog_yesno(const char *msg)
return newtWinChoice(NULL, yes, no, (char *)msg) == 1;
}
-static void ui__error_window(const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- newtWinMessagev((char *)"Error", (char *)"Ok", (char *)fmt, ap);
- va_end(ap);
-}
-
-static void annotate_browser__write(struct ui_browser *self, void *entry, int row)
-{
- 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 = ol->offset;
- struct objdump_line *next = objdump__get_next_ip_line(self->entries, ol);
-
- while (offset < (s64)len &&
- (next == NULL || offset < next->offset)) {
- if (sym_ext) {
- percent += sym_ext[offset].percent;
- } else
- hits += h->ip[offset];
-
- ++offset;
- }
-
- if (sym_ext == NULL && h->sum)
- percent = 100.0 * hits / h->sum;
-
- color = ui_browser__percent_color(percent, current_entry);
- SLsmg_set_color(color);
- slsmg_printf(" %7.2f ", percent);
- if (!current_entry)
- SLsmg_set_color(HE_COLORSET_CODE);
- } else {
- int color = ui_browser__percent_color(0, current_entry);
- SLsmg_set_color(color);
- slsmg_write_nstring(" ", 9);
- }
-
- SLsmg_write_char(':');
- slsmg_write_nstring(" ", 8);
- if (!*ol->line)
- slsmg_write_nstring(" ", width - 18);
- else
- slsmg_write_nstring(ol->line, width - 18);
-}
-
static char *callchain_list__sym_name(struct callchain_list *self,
char *bf, size_t bfsize)
{
@@ -262,54 +182,6 @@ static char *callchain_list__sym_name(struct callchain_list *self,
return bf;
}
-int hist_entry__tui_annotate(struct hist_entry *self)
-{
- 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)
- return -1;
-
- if (self->ms.map->dso->annotate_warned)
- return -1;
-
- if (hist_entry__annotate(self, &head) < 0) {
- ui__error_window(browser__last_msg);
- return -1;
- }
-
- ui_helpline__push("Press <- or ESC to exit");
-
- list_for_each_entry(pos, &head, node) {
- size_t line_len = strlen(pos->line);
- if (browser.width < line_len)
- browser.width = line_len;
- ++browser.nr_entries;
- }
-
- browser.width += 18; /* Percentage */
- ui_browser__show(&browser, self->ms.sym->name);
- newtFormAddHotKey(browser.form, ' ');
- ret = ui_browser__run(&browser, &es);
- newtFormDestroy(browser.form);
- newtPopWindow();
- list_for_each_entry_safe(pos, n, &head, node) {
- list_del(&pos->node);
- objdump_line__free(pos);
- }
- ui_helpline__pop();
- return ret;
-}
-
/* -------------------------------------------------------------------- */
struct map_browser {