5 * slang versions <= 2.0.6 have a "#if HAVE_LONG_LONG" that breaks
6 * the build if it isn't defined. Use the equivalent one that glibc
10 #ifndef HAVE_LONG_LONG
11 #define HAVE_LONG_LONG __GLIBC_HAVE_LONG_LONG
16 #include <sys/ttydefaults.h>
25 #if SLANG_VERSION < 20104
26 #define slsmg_printf(msg, args...) SLsmg_printf((char *)msg, ##args)
27 #define slsmg_write_nstring(msg, len) SLsmg_write_nstring((char *)msg, len)
28 #define sltt_set_color(obj, name, fg, bg) SLtt_set_color(obj,(char *)name,\
29 (char *)fg, (char *)bg)
31 #define slsmg_printf SLsmg_printf
32 #define slsmg_write_nstring SLsmg_write_nstring
33 #define sltt_set_color SLtt_set_color
37 newtComponent form, scale;
40 struct ui_progress *ui_progress__new(const char *title, u64 total)
42 struct ui_progress *self = malloc(sizeof(*self));
46 newtGetScreenSize(&cols, NULL);
48 newtCenteredWindow(cols, 1, title);
49 self->form = newtForm(NULL, NULL, 0);
50 if (self->form == NULL)
52 self->scale = newtScale(0, 0, cols, total);
53 if (self->scale == NULL)
55 newtFormAddComponent(self->form, self->scale);
62 newtFormDestroy(self->form);
68 void ui_progress__update(struct ui_progress *self, u64 curr)
70 newtScaleSet(self->scale, curr);
74 void ui_progress__delete(struct ui_progress *self)
76 newtFormDestroy(self->form);
81 static void ui_helpline__pop(void)
86 static void ui_helpline__push(const char *msg)
88 newtPushHelpLine(msg);
91 static void ui_helpline__vpush(const char *fmt, va_list ap)
95 if (vasprintf(&s, fmt, ap) < 0)
96 vfprintf(stderr, fmt, ap);
103 static void ui_helpline__fpush(const char *fmt, ...)
108 ui_helpline__vpush(fmt, ap);
112 static void ui_helpline__puts(const char *msg)
115 ui_helpline__push(msg);
118 static char browser__last_msg[1024];
120 int browser__show_help(const char *format, va_list ap)
125 ret = vsnprintf(browser__last_msg + backlog,
126 sizeof(browser__last_msg) - backlog, format, ap);
129 if (browser__last_msg[backlog - 1] == '\n') {
130 ui_helpline__puts(browser__last_msg);
138 static void newt_form__set_exit_keys(newtComponent self)
140 newtFormAddHotKey(self, NEWT_KEY_LEFT);
141 newtFormAddHotKey(self, NEWT_KEY_ESCAPE);
142 newtFormAddHotKey(self, 'Q');
143 newtFormAddHotKey(self, 'q');
144 newtFormAddHotKey(self, CTRL('c'));
147 static newtComponent newt_form__new(void)
149 newtComponent self = newtForm(NULL, NULL, 0);
151 newt_form__set_exit_keys(self);
155 static int popup_menu(int argc, char * const argv[])
157 struct newtExitStruct es;
158 int i, rc = -1, max_len = 5;
159 newtComponent listbox, form = newt_form__new();
164 listbox = newtListbox(0, 0, argc, NEWT_FLAG_RETURNEXIT);
166 goto out_destroy_form;
168 newtFormAddComponent(form, listbox);
170 for (i = 0; i < argc; ++i) {
171 int len = strlen(argv[i]);
174 if (newtListboxAddEntry(listbox, argv[i], (void *)(long)i))
175 goto out_destroy_form;
178 newtCenteredWindow(max_len, argc, NULL);
179 newtFormRun(form, &es);
180 rc = newtListboxGetCurrent(listbox) - NULL;
181 if (es.reason == NEWT_EXIT_HOTKEY)
185 newtFormDestroy(form);
189 static int ui__help_window(const char *text)
191 struct newtExitStruct es;
192 newtComponent tb, form = newt_form__new();
194 int max_len = 0, nr_lines = 0;
202 const char *sep = strchr(t, '\n');
206 sep = strchr(t, '\0');
216 tb = newtTextbox(0, 0, max_len, nr_lines, 0);
218 goto out_destroy_form;
220 newtTextboxSetText(tb, text);
221 newtFormAddComponent(form, tb);
222 newtCenteredWindow(max_len, nr_lines, NULL);
223 newtFormRun(form, &es);
227 newtFormDestroy(form);
231 static bool dialog_yesno(const char *msg)
233 /* newtWinChoice should really be accepting const char pointers... */
234 char yes[] = "Yes", no[] = "No";
235 return newtWinChoice(NULL, yes, no, (char *)msg) == 1;
238 #define HE_COLORSET_TOP 50
239 #define HE_COLORSET_MEDIUM 51
240 #define HE_COLORSET_NORMAL 52
241 #define HE_COLORSET_SELECTED 53
242 #define HE_COLORSET_CODE 54
244 static int ui_browser__percent_color(double percent, bool current)
247 return HE_COLORSET_SELECTED;
248 if (percent >= MIN_RED)
249 return HE_COLORSET_TOP;
250 if (percent >= MIN_GREEN)
251 return HE_COLORSET_MEDIUM;
252 return HE_COLORSET_NORMAL;
256 newtComponent form, sb;
257 u64 index, first_visible_entry_idx;
258 void *first_visible_entry, *entries;
259 u16 top, left, width, height;
264 static void ui_browser__refresh_dimensions(struct ui_browser *self)
267 newtGetScreenSize(&cols, &rows);
269 if (self->width > cols - 4)
270 self->width = cols - 4;
271 self->height = rows - 5;
272 if (self->height > self->nr_entries)
273 self->height = self->nr_entries;
274 self->top = (rows - self->height) / 2;
275 self->left = (cols - self->width) / 2;
278 static void ui_browser__reset_index(struct ui_browser *self)
280 self->index = self->first_visible_entry_idx = 0;
281 self->first_visible_entry = NULL;
284 static int objdump_line__show(struct objdump_line *self, struct list_head *head,
285 int width, struct hist_entry *he, int len,
288 if (self->offset != -1) {
289 struct symbol *sym = he->ms.sym;
290 unsigned int hits = 0;
291 double percent = 0.0;
293 struct sym_priv *priv = symbol__priv(sym);
294 struct sym_ext *sym_ext = priv->ext;
295 struct sym_hist *h = priv->hist;
296 s64 offset = self->offset;
297 struct objdump_line *next = objdump__get_next_ip_line(head, self);
299 while (offset < (s64)len &&
300 (next == NULL || offset < next->offset)) {
302 percent += sym_ext[offset].percent;
304 hits += h->ip[offset];
309 if (sym_ext == NULL && h->sum)
310 percent = 100.0 * hits / h->sum;
312 color = ui_browser__percent_color(percent, current_entry);
313 SLsmg_set_color(color);
314 slsmg_printf(" %7.2f ", percent);
316 SLsmg_set_color(HE_COLORSET_CODE);
318 int color = ui_browser__percent_color(0, current_entry);
319 SLsmg_set_color(color);
320 slsmg_write_nstring(" ", 9);
323 SLsmg_write_char(':');
324 slsmg_write_nstring(" ", 8);
326 slsmg_write_nstring(" ", width - 18);
328 slsmg_write_nstring(self->line, width - 18);
333 static int ui_browser__refresh_entries(struct ui_browser *self)
335 struct objdump_line *pos;
336 struct list_head *head = self->entries;
337 struct hist_entry *he = self->priv;
339 int len = he->ms.sym->end - he->ms.sym->start;
341 if (self->first_visible_entry == NULL || self->first_visible_entry == self->entries)
342 self->first_visible_entry = head->next;
344 pos = list_entry(self->first_visible_entry, struct objdump_line, node);
346 list_for_each_entry_from(pos, head, node) {
347 bool current_entry = (self->first_visible_entry_idx + row) == self->index;
348 SLsmg_gotorc(self->top + row, self->left);
349 objdump_line__show(pos, head, self->width,
350 he, len, current_entry);
351 if (++row == self->height)
355 SLsmg_set_color(HE_COLORSET_NORMAL);
356 SLsmg_fill_region(self->top + row, self->left,
357 self->height - row, self->width, ' ');
362 static int ui_browser__run(struct ui_browser *self, const char *title,
363 struct newtExitStruct *es)
366 newtFormDestroy(self->form);
370 ui_browser__refresh_dimensions(self);
371 newtCenteredWindow(self->width + 2, self->height, title);
372 self->form = newt_form__new();
373 if (self->form == NULL)
376 self->sb = newtVerticalScrollbar(self->width + 1, 0, self->height,
378 HE_COLORSET_SELECTED);
379 if (self->sb == NULL)
382 newtFormAddHotKey(self->form, NEWT_KEY_UP);
383 newtFormAddHotKey(self->form, NEWT_KEY_DOWN);
384 newtFormAddHotKey(self->form, NEWT_KEY_PGUP);
385 newtFormAddHotKey(self->form, NEWT_KEY_PGDN);
386 newtFormAddHotKey(self->form, ' ');
387 newtFormAddHotKey(self->form, NEWT_KEY_HOME);
388 newtFormAddHotKey(self->form, NEWT_KEY_END);
390 if (ui_browser__refresh_entries(self) < 0)
392 newtFormAddComponent(self->form, self->sb);
397 newtFormRun(self->form, es);
399 if (es->reason != NEWT_EXIT_HOTKEY)
403 if (self->index == self->nr_entries - 1)
406 if (self->index == self->first_visible_entry_idx + self->height) {
407 struct list_head *pos = self->first_visible_entry;
408 ++self->first_visible_entry_idx;
409 self->first_visible_entry = pos->next;
413 if (self->index == 0)
416 if (self->index < self->first_visible_entry_idx) {
417 struct list_head *pos = self->first_visible_entry;
418 --self->first_visible_entry_idx;
419 self->first_visible_entry = pos->prev;
424 if (self->first_visible_entry_idx + self->height > self->nr_entries - 1)
427 offset = self->height;
428 if (self->index + offset > self->nr_entries - 1)
429 offset = self->nr_entries - 1 - self->index;
430 self->index += offset;
431 self->first_visible_entry_idx += offset;
434 struct list_head *pos = self->first_visible_entry;
435 self->first_visible_entry = pos->next;
440 if (self->first_visible_entry_idx == 0)
443 if (self->first_visible_entry_idx < self->height)
444 offset = self->first_visible_entry_idx;
446 offset = self->height;
448 self->index -= offset;
449 self->first_visible_entry_idx -= offset;
452 struct list_head *pos = self->first_visible_entry;
453 self->first_visible_entry = pos->prev;
457 ui_browser__reset_index(self);
460 struct list_head *head = self->entries;
461 offset = self->height - 1;
463 if (offset > self->nr_entries)
464 offset = self->nr_entries;
466 self->index = self->first_visible_entry_idx = self->nr_entries - 1 - offset;
467 self->first_visible_entry = head->prev;
468 while (offset-- != 0) {
469 struct list_head *pos = self->first_visible_entry;
470 self->first_visible_entry = pos->prev;
474 case NEWT_KEY_ESCAPE:
483 if (ui_browser__refresh_entries(self) < 0)
490 * When debugging newt problems it was useful to be able to "unroll"
491 * the calls to newtCheckBoxTreeAdd{Array,Item}, so that we can generate
492 * a source file with the sequence of calls to these methods, to then
493 * tweak the arrays to get the intended results, so I'm keeping this code
494 * here, may be useful again in the future.
498 static void newt_checkbox_tree__add(newtComponent tree, const char *str,
499 void *priv, int *indexes)
502 /* Print the newtCheckboxTreeAddArray to tinker with its index arrays */
503 int i = 0, len = 40 - strlen(str);
506 "\tnewtCheckboxTreeAddItem(tree, %*.*s\"%s\", (void *)%p, 0, ",
507 len, len, " ", str, priv);
508 while (indexes[i] != NEWT_ARG_LAST) {
509 if (indexes[i] != NEWT_ARG_APPEND)
510 fprintf(stderr, " %d,", indexes[i]);
512 fprintf(stderr, " %s,", "NEWT_ARG_APPEND");
515 fprintf(stderr, " %s", " NEWT_ARG_LAST);\n");
518 newtCheckboxTreeAddArray(tree, str, priv, 0, indexes);
521 static char *callchain_list__sym_name(struct callchain_list *self,
522 char *bf, size_t bfsize)
525 return self->ms.sym->name;
527 snprintf(bf, bfsize, "%#Lx", self->ip);
531 static void __callchain__append_graph_browser(struct callchain_node *self,
532 newtComponent tree, u64 total,
533 int *indexes, int depth)
535 struct rb_node *node;
536 u64 new_total, remaining;
539 if (callchain_param.mode == CHAIN_GRAPH_REL)
540 new_total = self->children_hit;
544 remaining = new_total;
545 node = rb_first(&self->rb_root);
547 struct callchain_node *child = rb_entry(node, struct callchain_node, rb_node);
548 struct rb_node *next = rb_next(node);
549 u64 cumul = cumul_hits(child);
550 struct callchain_list *chain;
551 int first = true, printed = 0;
555 indexes[depth] = NEWT_ARG_APPEND;
556 indexes[depth + 1] = NEWT_ARG_LAST;
558 list_for_each_entry(chain, &child->val, list) {
559 char ipstr[BITS_PER_LONG / 4 + 1],
561 const char *str = callchain_list__sym_name(chain, ipstr, sizeof(ipstr));
564 double percent = cumul * 100.0 / new_total;
567 if (asprintf(&alloc_str, "%2.2f%% %s", percent, str) < 0)
568 str = "Not enough memory!";
572 indexes[depth] = idx;
573 indexes[depth + 1] = NEWT_ARG_APPEND;
574 indexes[depth + 2] = NEWT_ARG_LAST;
577 newt_checkbox_tree__add(tree, str, &chain->ms, indexes);
582 indexes[depth] = idx;
584 indexes[depth + 1] = chain_idx;
587 __callchain__append_graph_browser(child, tree, new_total, indexes,
588 depth + (chain_idx != -1 ? 2 : 1));
593 static void callchain__append_graph_browser(struct callchain_node *self,
594 newtComponent tree, u64 total,
595 int *indexes, int parent_idx)
597 struct callchain_list *chain;
600 indexes[1] = NEWT_ARG_APPEND;
601 indexes[2] = NEWT_ARG_LAST;
603 list_for_each_entry(chain, &self->val, list) {
604 char ipstr[BITS_PER_LONG / 4 + 1], *str;
606 if (chain->ip >= PERF_CONTEXT_MAX)
609 if (!i++ && sort__first_dimension == SORT_SYM)
612 str = callchain_list__sym_name(chain, ipstr, sizeof(ipstr));
613 newt_checkbox_tree__add(tree, str, &chain->ms, indexes);
616 indexes[1] = parent_idx;
617 indexes[2] = NEWT_ARG_APPEND;
618 indexes[3] = NEWT_ARG_LAST;
619 __callchain__append_graph_browser(self, tree, total, indexes, 2);
622 static void hist_entry__append_callchain_browser(struct hist_entry *self,
623 newtComponent tree, u64 total, int parent_idx)
625 struct rb_node *rb_node;
626 int indexes[1024] = { [0] = parent_idx, };
628 struct callchain_node *chain;
630 rb_node = rb_first(&self->sorted_chain);
632 chain = rb_entry(rb_node, struct callchain_node, rb_node);
633 switch (callchain_param.mode) {
636 case CHAIN_GRAPH_ABS: /* falldown */
637 case CHAIN_GRAPH_REL:
638 callchain__append_graph_browser(chain, tree, total, indexes, idx++);
644 rb_node = rb_next(rb_node);
648 static size_t hist_entry__append_browser(struct hist_entry *self,
649 newtComponent tree, u64 total)
654 if (symbol_conf.exclude_other && !self->parent)
657 ret = hist_entry__snprintf(self, s, sizeof(s), NULL,
658 false, 0, false, total);
659 if (symbol_conf.use_callchain) {
662 indexes[0] = NEWT_ARG_APPEND;
663 indexes[1] = NEWT_ARG_LAST;
664 newt_checkbox_tree__add(tree, s, &self->ms, indexes);
666 newtListboxAppendEntry(tree, s, &self->ms);
671 static void hist_entry__annotate_browser(struct hist_entry *self)
673 struct ui_browser browser;
674 struct newtExitStruct es;
675 struct objdump_line *pos, *n;
678 if (self->ms.sym == NULL)
681 if (hist_entry__annotate(self, &head) < 0)
684 ui_helpline__push("Press <- or ESC to exit");
686 memset(&browser, 0, sizeof(browser));
687 browser.entries = &head;
689 list_for_each_entry(pos, &head, node) {
690 size_t line_len = strlen(pos->line);
691 if (browser.width < line_len)
692 browser.width = line_len;
693 ++browser.nr_entries;
696 browser.width += 18; /* Percentage */
697 ui_browser__run(&browser, self->ms.sym->name, &es);
698 newtFormDestroy(browser.form);
700 list_for_each_entry_safe(pos, n, &head, node) {
701 list_del(&pos->node);
702 objdump_line__free(pos);
707 static const void *newt__symbol_tree_get_current(newtComponent self)
709 if (symbol_conf.use_callchain)
710 return newtCheckboxTreeGetCurrent(self);
711 return newtListboxGetCurrent(self);
714 static void hist_browser__selection(newtComponent self, void *data)
716 const struct map_symbol **symbol_ptr = data;
717 *symbol_ptr = newt__symbol_tree_get_current(self);
720 struct hist_browser {
721 newtComponent form, tree;
722 const struct map_symbol *selection;
725 static struct hist_browser *hist_browser__new(void)
727 struct hist_browser *self = malloc(sizeof(*self));
735 static void hist_browser__delete(struct hist_browser *self)
737 newtFormDestroy(self->form);
742 static int hist_browser__populate(struct hist_browser *self, struct hists *hists,
745 int max_len = 0, idx, cols, rows;
746 struct ui_progress *progress;
749 char seq[] = ".", unit;
751 unsigned long nr_events = hists->stats.nr_events[PERF_RECORD_SAMPLE];
754 newtFormDestroy(self->form);
758 nr_events = convert_unit(nr_events, &unit);
759 snprintf(str, sizeof(str), "Events: %lu%c ",
761 newtDrawRootText(0, 0, str);
763 newtGetScreenSize(NULL, &rows);
765 if (symbol_conf.use_callchain)
766 self->tree = newtCheckboxTreeMulti(0, 0, rows - 5, seq,
769 self->tree = newtListbox(0, 0, rows - 5,
771 NEWT_FLAG_RETURNEXIT));
773 newtComponentAddCallback(self->tree, hist_browser__selection,
776 progress = ui_progress__new("Adding entries to the browser...",
778 if (progress == NULL)
782 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
783 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
789 len = hist_entry__append_browser(h, self->tree, hists->stats.total_period);
792 if (symbol_conf.use_callchain)
793 hist_entry__append_callchain_browser(h, self->tree,
794 hists->stats.total_period, idx++);
797 ui_progress__update(progress, curr_hist);
800 ui_progress__delete(progress);
802 newtGetScreenSize(&cols, &rows);
807 if (!symbol_conf.use_callchain)
808 newtListboxSetWidth(self->tree, max_len);
810 newtCenteredWindow(max_len + (symbol_conf.use_callchain ? 5 : 0),
812 self->form = newt_form__new();
813 if (self->form == NULL)
816 newtFormAddHotKey(self->form, 'A');
817 newtFormAddHotKey(self->form, 'a');
818 newtFormAddHotKey(self->form, 'D');
819 newtFormAddHotKey(self->form, 'd');
820 newtFormAddHotKey(self->form, 'T');
821 newtFormAddHotKey(self->form, 't');
822 newtFormAddHotKey(self->form, '?');
823 newtFormAddHotKey(self->form, 'H');
824 newtFormAddHotKey(self->form, 'h');
825 newtFormAddHotKey(self->form, NEWT_KEY_F1);
826 newtFormAddHotKey(self->form, NEWT_KEY_RIGHT);
827 newtFormAddComponents(self->form, self->tree, NULL);
828 self->selection = newt__symbol_tree_get_current(self->tree);
833 static struct hist_entry *hist_browser__selected_entry(struct hist_browser *self)
837 if (!symbol_conf.use_callchain)
840 indexes = newtCheckboxTreeFindItem(self->tree, (void *)self->selection);
842 bool is_hist_entry = indexes[1] == NEWT_ARG_LAST;
849 return container_of(self->selection, struct hist_entry, ms);
852 static struct thread *hist_browser__selected_thread(struct hist_browser *self)
854 struct hist_entry *he = hist_browser__selected_entry(self);
855 return he ? he->thread : NULL;
858 static int hist_browser__title(char *bf, size_t size, const char *input_name,
859 const struct dso *dso, const struct thread *thread)
864 printed += snprintf(bf + printed, size - printed,
866 (thread->comm_set ? thread->comm : ""),
869 printed += snprintf(bf + printed, size - printed,
870 "%sDSO: %s", thread ? " " : "",
872 return printed ?: snprintf(bf, size, "Report: %s", input_name);
875 int hists__browse(struct hists *self, const char *helpline, const char *input_name)
877 struct hist_browser *browser = hist_browser__new();
878 struct pstack *fstack = pstack__new(2);
879 const struct thread *thread_filter = NULL;
880 const struct dso *dso_filter = NULL;
881 struct newtExitStruct es;
888 fstack = pstack__new(2);
892 ui_helpline__push(helpline);
894 hist_browser__title(msg, sizeof(msg), input_name,
895 dso_filter, thread_filter);
896 if (hist_browser__populate(browser, self, msg) < 0)
900 const struct thread *thread;
901 const struct dso *dso;
903 int nr_options = 0, choice = 0, i,
904 annotate = -2, zoom_dso = -2, zoom_thread = -2;
906 newtFormRun(browser->form, &es);
908 thread = hist_browser__selected_thread(browser);
909 dso = browser->selection->map ? browser->selection->map->dso : NULL;
911 if (es.reason == NEWT_EXIT_HOTKEY) {
912 if (es.u.key == NEWT_KEY_F1)
915 switch (toupper(es.u.key)) {
917 if (browser->selection->map == NULL &&
918 browser->selection->map->dso->annotate_warned)
928 ui__help_window("-> Zoom into DSO/Threads & Annotate current symbol\n"
930 "a Annotate current symbol\n"
931 "h/?/F1 Show this window\n"
932 "d Zoom into current DSO\n"
933 "t Zoom into current Thread\n"
934 "q/CTRL+C Exit browser");
938 if (toupper(es.u.key) == 'Q' ||
939 es.u.key == CTRL('c'))
941 if (es.u.key == NEWT_KEY_ESCAPE) {
942 if (dialog_yesno("Do you really want to exit?"))
948 if (es.u.key == NEWT_KEY_LEFT) {
951 if (pstack__empty(fstack))
953 top = pstack__pop(fstack);
954 if (top == &dso_filter)
956 if (top == &thread_filter)
957 goto zoom_out_thread;
962 if (browser->selection->sym != NULL &&
963 !browser->selection->map->dso->annotate_warned &&
964 asprintf(&options[nr_options], "Annotate %s",
965 browser->selection->sym->name) > 0)
966 annotate = nr_options++;
968 if (thread != NULL &&
969 asprintf(&options[nr_options], "Zoom %s %s(%d) thread",
970 (thread_filter ? "out of" : "into"),
971 (thread->comm_set ? thread->comm : ""),
973 zoom_thread = nr_options++;
976 asprintf(&options[nr_options], "Zoom %s %s DSO",
977 (dso_filter ? "out of" : "into"),
978 (dso->kernel ? "the Kernel" : dso->short_name)) > 0)
979 zoom_dso = nr_options++;
981 options[nr_options++] = (char *)"Exit";
983 choice = popup_menu(nr_options, options);
985 for (i = 0; i < nr_options - 1; ++i)
988 if (choice == nr_options - 1)
994 if (choice == annotate) {
995 struct hist_entry *he;
997 if (browser->selection->map->dso->origin == DSO__ORIG_KERNEL) {
998 browser->selection->map->dso->annotate_warned = 1;
999 ui_helpline__puts("No vmlinux file found, can't "
1000 "annotate with just a "
1005 he = hist_browser__selected_entry(browser);
1009 hist_entry__annotate_browser(he);
1010 } else if (choice == zoom_dso) {
1013 pstack__remove(fstack, &dso_filter);
1020 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s DSO\"",
1021 dso->kernel ? "the Kernel" : dso->short_name);
1023 pstack__push(fstack, &dso_filter);
1025 hists__filter_by_dso(self, dso_filter);
1026 hist_browser__title(msg, sizeof(msg), input_name,
1027 dso_filter, thread_filter);
1028 if (hist_browser__populate(browser, self, msg) < 0)
1030 } else if (choice == zoom_thread) {
1032 if (thread_filter) {
1033 pstack__remove(fstack, &thread_filter);
1036 thread_filter = NULL;
1038 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s(%d) thread\"",
1039 thread->comm_set ? thread->comm : "",
1041 thread_filter = thread;
1042 pstack__push(fstack, &thread_filter);
1044 hists__filter_by_thread(self, thread_filter);
1045 hist_browser__title(msg, sizeof(msg), input_name,
1046 dso_filter, thread_filter);
1047 if (hist_browser__populate(browser, self, msg) < 0)
1053 pstack__delete(fstack);
1055 hist_browser__delete(browser);
1059 static struct newtPercentTreeColors {
1060 const char *topColorFg, *topColorBg;
1061 const char *mediumColorFg, *mediumColorBg;
1062 const char *normalColorFg, *normalColorBg;
1063 const char *selColorFg, *selColorBg;
1064 const char *codeColorFg, *codeColorBg;
1065 } defaultPercentTreeColors = {
1067 "green", "lightgray",
1068 "black", "lightgray",
1069 "lightgray", "magenta",
1070 "blue", "lightgray",
1073 void setup_browser(void)
1075 struct newtPercentTreeColors *c = &defaultPercentTreeColors;
1077 if (!isatty(1) || !use_browser) {
1085 ui_helpline__puts(" ");
1086 sltt_set_color(HE_COLORSET_TOP, NULL, c->topColorFg, c->topColorBg);
1087 sltt_set_color(HE_COLORSET_MEDIUM, NULL, c->mediumColorFg, c->mediumColorBg);
1088 sltt_set_color(HE_COLORSET_NORMAL, NULL, c->normalColorFg, c->normalColorBg);
1089 sltt_set_color(HE_COLORSET_SELECTED, NULL, c->selColorFg, c->selColorBg);
1090 sltt_set_color(HE_COLORSET_CODE, NULL, c->codeColorFg, c->codeColorBg);
1093 void exit_browser(bool wait_for_ok)
1095 if (use_browser > 0) {
1097 char title[] = "Fatal Error", ok[] = "Ok";
1098 newtWinMessage(title, ok, browser__last_msg);