Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 1 | #define _GNU_SOURCE |
| 2 | #include <stdio.h> |
| 3 | #undef _GNU_SOURCE |
| 4 | |
| 5 | #include <stdlib.h> |
| 6 | #include <newt.h> |
Arnaldo Carvalho de Melo | 7081e08 | 2010-03-12 10:48:12 -0300 | [diff] [blame] | 7 | #include <sys/ttydefaults.h> |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 8 | |
| 9 | #include "cache.h" |
| 10 | #include "hist.h" |
| 11 | #include "session.h" |
| 12 | #include "sort.h" |
| 13 | #include "symbol.h" |
| 14 | |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 15 | struct ui_progress { |
| 16 | newtComponent form, scale; |
| 17 | }; |
| 18 | |
| 19 | struct ui_progress *ui_progress__new(const char *title, u64 total) |
| 20 | { |
| 21 | struct ui_progress *self = malloc(sizeof(*self)); |
| 22 | |
| 23 | if (self != NULL) { |
| 24 | int cols; |
| 25 | newtGetScreenSize(&cols, NULL); |
| 26 | cols -= 4; |
| 27 | newtCenteredWindow(cols, 1, title); |
| 28 | self->form = newtForm(NULL, NULL, 0); |
| 29 | if (self->form == NULL) |
| 30 | goto out_free_self; |
| 31 | self->scale = newtScale(0, 0, cols, total); |
| 32 | if (self->scale == NULL) |
| 33 | goto out_free_form; |
Arnaldo Carvalho de Melo | 7f82645 | 2010-05-10 10:51:25 -0300 | [diff] [blame] | 34 | newtFormAddComponent(self->form, self->scale); |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 35 | newtRefresh(); |
| 36 | } |
| 37 | |
| 38 | return self; |
| 39 | |
| 40 | out_free_form: |
| 41 | newtFormDestroy(self->form); |
| 42 | out_free_self: |
| 43 | free(self); |
| 44 | return NULL; |
| 45 | } |
| 46 | |
| 47 | void ui_progress__update(struct ui_progress *self, u64 curr) |
| 48 | { |
| 49 | newtScaleSet(self->scale, curr); |
| 50 | newtRefresh(); |
| 51 | } |
| 52 | |
| 53 | void ui_progress__delete(struct ui_progress *self) |
| 54 | { |
| 55 | newtFormDestroy(self->form); |
| 56 | newtPopWindow(); |
| 57 | free(self); |
| 58 | } |
| 59 | |
Arnaldo Carvalho de Melo | 3798ed7 | 2010-05-11 18:01:23 -0300 | [diff] [blame^] | 60 | static void ui_helpline__pop(void) |
| 61 | { |
| 62 | newtPopHelpLine(); |
| 63 | } |
| 64 | |
| 65 | static void ui_helpline__push(const char *msg) |
| 66 | { |
| 67 | newtPushHelpLine(msg); |
| 68 | } |
| 69 | |
| 70 | static void ui_helpline__vpush(const char *fmt, va_list ap) |
| 71 | { |
| 72 | char *s; |
| 73 | |
| 74 | if (vasprintf(&s, fmt, ap) < 0) |
| 75 | vfprintf(stderr, fmt, ap); |
| 76 | else { |
| 77 | ui_helpline__push(s); |
| 78 | free(s); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | static void ui_helpline__fpush(const char *fmt, ...) |
| 83 | { |
| 84 | va_list ap; |
| 85 | |
| 86 | va_start(ap, fmt); |
| 87 | ui_helpline__vpush(fmt, ap); |
| 88 | va_end(ap); |
| 89 | } |
| 90 | |
| 91 | static void ui_helpline__puts(const char *msg) |
| 92 | { |
| 93 | ui_helpline__pop(); |
| 94 | ui_helpline__push(msg); |
| 95 | } |
| 96 | |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 97 | static char browser__last_msg[1024]; |
| 98 | |
| 99 | int browser__show_help(const char *format, va_list ap) |
| 100 | { |
| 101 | int ret; |
| 102 | static int backlog; |
| 103 | |
| 104 | ret = vsnprintf(browser__last_msg + backlog, |
| 105 | sizeof(browser__last_msg) - backlog, format, ap); |
| 106 | backlog += ret; |
| 107 | |
| 108 | if (browser__last_msg[backlog - 1] == '\n') { |
Arnaldo Carvalho de Melo | 3798ed7 | 2010-05-11 18:01:23 -0300 | [diff] [blame^] | 109 | ui_helpline__puts(browser__last_msg); |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 110 | newtRefresh(); |
| 111 | backlog = 0; |
| 112 | } |
| 113 | |
| 114 | return ret; |
| 115 | } |
| 116 | |
Arnaldo Carvalho de Melo | 7081e08 | 2010-03-12 10:48:12 -0300 | [diff] [blame] | 117 | static void newt_form__set_exit_keys(newtComponent self) |
| 118 | { |
| 119 | newtFormAddHotKey(self, NEWT_KEY_ESCAPE); |
| 120 | newtFormAddHotKey(self, 'Q'); |
| 121 | newtFormAddHotKey(self, 'q'); |
| 122 | newtFormAddHotKey(self, CTRL('c')); |
| 123 | } |
| 124 | |
| 125 | static newtComponent newt_form__new(void) |
| 126 | { |
| 127 | newtComponent self = newtForm(NULL, NULL, 0); |
| 128 | if (self) |
| 129 | newt_form__set_exit_keys(self); |
| 130 | return self; |
| 131 | } |
| 132 | |
Arnaldo Carvalho de Melo | 8375319 | 2010-04-03 16:30:44 -0300 | [diff] [blame] | 133 | static int popup_menu(int argc, char * const argv[]) |
Arnaldo Carvalho de Melo | 53c5401 | 2010-03-24 16:40:14 -0300 | [diff] [blame] | 134 | { |
| 135 | struct newtExitStruct es; |
| 136 | int i, rc = -1, max_len = 5; |
| 137 | newtComponent listbox, form = newt_form__new(); |
| 138 | |
| 139 | if (form == NULL) |
| 140 | return -1; |
| 141 | |
| 142 | listbox = newtListbox(0, 0, argc, NEWT_FLAG_RETURNEXIT); |
| 143 | if (listbox == NULL) |
| 144 | goto out_destroy_form; |
| 145 | |
Arnaldo Carvalho de Melo | 7f82645 | 2010-05-10 10:51:25 -0300 | [diff] [blame] | 146 | newtFormAddComponent(form, listbox); |
Arnaldo Carvalho de Melo | 53c5401 | 2010-03-24 16:40:14 -0300 | [diff] [blame] | 147 | |
| 148 | for (i = 0; i < argc; ++i) { |
| 149 | int len = strlen(argv[i]); |
| 150 | if (len > max_len) |
| 151 | max_len = len; |
| 152 | if (newtListboxAddEntry(listbox, argv[i], (void *)(long)i)) |
| 153 | goto out_destroy_form; |
| 154 | } |
| 155 | |
| 156 | newtCenteredWindow(max_len, argc, NULL); |
| 157 | newtFormRun(form, &es); |
| 158 | rc = newtListboxGetCurrent(listbox) - NULL; |
| 159 | if (es.reason == NEWT_EXIT_HOTKEY) |
| 160 | rc = -1; |
| 161 | newtPopWindow(); |
| 162 | out_destroy_form: |
| 163 | newtFormDestroy(form); |
| 164 | return rc; |
| 165 | } |
| 166 | |
| 167 | static bool dialog_yesno(const char *msg) |
| 168 | { |
| 169 | /* newtWinChoice should really be accepting const char pointers... */ |
| 170 | char yes[] = "Yes", no[] = "No"; |
Arnaldo Carvalho de Melo | c0ed55d | 2010-04-05 12:04:23 -0300 | [diff] [blame] | 171 | return newtWinChoice(NULL, yes, no, (char *)msg) == 1; |
Arnaldo Carvalho de Melo | 53c5401 | 2010-03-24 16:40:14 -0300 | [diff] [blame] | 172 | } |
| 173 | |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 174 | /* |
| 175 | * When debugging newt problems it was useful to be able to "unroll" |
| 176 | * the calls to newtCheckBoxTreeAdd{Array,Item}, so that we can generate |
| 177 | * a source file with the sequence of calls to these methods, to then |
| 178 | * tweak the arrays to get the intended results, so I'm keeping this code |
| 179 | * here, may be useful again in the future. |
| 180 | */ |
| 181 | #undef NEWT_DEBUG |
| 182 | |
| 183 | static void newt_checkbox_tree__add(newtComponent tree, const char *str, |
| 184 | void *priv, int *indexes) |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 185 | { |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 186 | #ifdef NEWT_DEBUG |
| 187 | /* Print the newtCheckboxTreeAddArray to tinker with its index arrays */ |
| 188 | int i = 0, len = 40 - strlen(str); |
| 189 | |
| 190 | fprintf(stderr, |
| 191 | "\tnewtCheckboxTreeAddItem(tree, %*.*s\"%s\", (void *)%p, 0, ", |
| 192 | len, len, " ", str, priv); |
| 193 | while (indexes[i] != NEWT_ARG_LAST) { |
| 194 | if (indexes[i] != NEWT_ARG_APPEND) |
| 195 | fprintf(stderr, " %d,", indexes[i]); |
| 196 | else |
| 197 | fprintf(stderr, " %s,", "NEWT_ARG_APPEND"); |
| 198 | ++i; |
| 199 | } |
| 200 | fprintf(stderr, " %s", " NEWT_ARG_LAST);\n"); |
| 201 | fflush(stderr); |
| 202 | #endif |
| 203 | newtCheckboxTreeAddArray(tree, str, priv, 0, indexes); |
| 204 | } |
| 205 | |
| 206 | static char *callchain_list__sym_name(struct callchain_list *self, |
| 207 | char *bf, size_t bfsize) |
| 208 | { |
Arnaldo Carvalho de Melo | b3c9ac0 | 2010-03-24 16:40:18 -0300 | [diff] [blame] | 209 | if (self->ms.sym) |
| 210 | return self->ms.sym->name; |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 211 | |
| 212 | snprintf(bf, bfsize, "%#Lx", self->ip); |
| 213 | return bf; |
| 214 | } |
| 215 | |
| 216 | static void __callchain__append_graph_browser(struct callchain_node *self, |
| 217 | newtComponent tree, u64 total, |
| 218 | int *indexes, int depth) |
| 219 | { |
| 220 | struct rb_node *node; |
| 221 | u64 new_total, remaining; |
| 222 | int idx = 0; |
| 223 | |
| 224 | if (callchain_param.mode == CHAIN_GRAPH_REL) |
| 225 | new_total = self->children_hit; |
| 226 | else |
| 227 | new_total = total; |
| 228 | |
| 229 | remaining = new_total; |
| 230 | node = rb_first(&self->rb_root); |
| 231 | while (node) { |
| 232 | struct callchain_node *child = rb_entry(node, struct callchain_node, rb_node); |
| 233 | struct rb_node *next = rb_next(node); |
| 234 | u64 cumul = cumul_hits(child); |
| 235 | struct callchain_list *chain; |
| 236 | int first = true, printed = 0; |
| 237 | int chain_idx = -1; |
| 238 | remaining -= cumul; |
| 239 | |
| 240 | indexes[depth] = NEWT_ARG_APPEND; |
| 241 | indexes[depth + 1] = NEWT_ARG_LAST; |
| 242 | |
| 243 | list_for_each_entry(chain, &child->val, list) { |
| 244 | char ipstr[BITS_PER_LONG / 4 + 1], |
| 245 | *alloc_str = NULL; |
| 246 | const char *str = callchain_list__sym_name(chain, ipstr, sizeof(ipstr)); |
| 247 | |
| 248 | if (first) { |
| 249 | double percent = cumul * 100.0 / new_total; |
| 250 | |
| 251 | first = false; |
| 252 | if (asprintf(&alloc_str, "%2.2f%% %s", percent, str) < 0) |
| 253 | str = "Not enough memory!"; |
| 254 | else |
| 255 | str = alloc_str; |
| 256 | } else { |
| 257 | indexes[depth] = idx; |
| 258 | indexes[depth + 1] = NEWT_ARG_APPEND; |
| 259 | indexes[depth + 2] = NEWT_ARG_LAST; |
| 260 | ++chain_idx; |
| 261 | } |
Arnaldo Carvalho de Melo | d5679ae | 2010-03-24 16:40:19 -0300 | [diff] [blame] | 262 | newt_checkbox_tree__add(tree, str, &chain->ms, indexes); |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 263 | free(alloc_str); |
| 264 | ++printed; |
| 265 | } |
| 266 | |
| 267 | indexes[depth] = idx; |
| 268 | if (chain_idx != -1) |
| 269 | indexes[depth + 1] = chain_idx; |
| 270 | if (printed != 0) |
| 271 | ++idx; |
| 272 | __callchain__append_graph_browser(child, tree, new_total, indexes, |
| 273 | depth + (chain_idx != -1 ? 2 : 1)); |
| 274 | node = next; |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | static void callchain__append_graph_browser(struct callchain_node *self, |
| 279 | newtComponent tree, u64 total, |
| 280 | int *indexes, int parent_idx) |
| 281 | { |
| 282 | struct callchain_list *chain; |
| 283 | int i = 0; |
| 284 | |
| 285 | indexes[1] = NEWT_ARG_APPEND; |
| 286 | indexes[2] = NEWT_ARG_LAST; |
| 287 | |
| 288 | list_for_each_entry(chain, &self->val, list) { |
| 289 | char ipstr[BITS_PER_LONG / 4 + 1], *str; |
| 290 | |
| 291 | if (chain->ip >= PERF_CONTEXT_MAX) |
| 292 | continue; |
| 293 | |
| 294 | if (!i++ && sort__first_dimension == SORT_SYM) |
| 295 | continue; |
| 296 | |
| 297 | str = callchain_list__sym_name(chain, ipstr, sizeof(ipstr)); |
Arnaldo Carvalho de Melo | d5679ae | 2010-03-24 16:40:19 -0300 | [diff] [blame] | 298 | newt_checkbox_tree__add(tree, str, &chain->ms, indexes); |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | indexes[1] = parent_idx; |
| 302 | indexes[2] = NEWT_ARG_APPEND; |
| 303 | indexes[3] = NEWT_ARG_LAST; |
| 304 | __callchain__append_graph_browser(self, tree, total, indexes, 2); |
| 305 | } |
| 306 | |
| 307 | static void hist_entry__append_callchain_browser(struct hist_entry *self, |
| 308 | newtComponent tree, u64 total, int parent_idx) |
| 309 | { |
| 310 | struct rb_node *rb_node; |
| 311 | int indexes[1024] = { [0] = parent_idx, }; |
| 312 | int idx = 0; |
| 313 | struct callchain_node *chain; |
| 314 | |
| 315 | rb_node = rb_first(&self->sorted_chain); |
| 316 | while (rb_node) { |
| 317 | chain = rb_entry(rb_node, struct callchain_node, rb_node); |
| 318 | switch (callchain_param.mode) { |
| 319 | case CHAIN_FLAT: |
| 320 | break; |
| 321 | case CHAIN_GRAPH_ABS: /* falldown */ |
| 322 | case CHAIN_GRAPH_REL: |
| 323 | callchain__append_graph_browser(chain, tree, total, indexes, idx++); |
| 324 | break; |
| 325 | case CHAIN_NONE: |
| 326 | default: |
| 327 | break; |
| 328 | } |
| 329 | rb_node = rb_next(rb_node); |
| 330 | } |
| 331 | } |
| 332 | |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 333 | static size_t hist_entry__append_browser(struct hist_entry *self, |
| 334 | newtComponent tree, u64 total) |
| 335 | { |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 336 | char s[256]; |
| 337 | size_t ret; |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 338 | |
| 339 | if (symbol_conf.exclude_other && !self->parent) |
| 340 | return 0; |
| 341 | |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 342 | ret = hist_entry__snprintf(self, s, sizeof(s), NULL, |
| 343 | false, 0, false, total); |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 344 | if (symbol_conf.use_callchain) { |
| 345 | int indexes[2]; |
| 346 | |
| 347 | indexes[0] = NEWT_ARG_APPEND; |
| 348 | indexes[1] = NEWT_ARG_LAST; |
Arnaldo Carvalho de Melo | d5679ae | 2010-03-24 16:40:19 -0300 | [diff] [blame] | 349 | newt_checkbox_tree__add(tree, s, &self->ms, indexes); |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 350 | } else |
Arnaldo Carvalho de Melo | d5679ae | 2010-03-24 16:40:19 -0300 | [diff] [blame] | 351 | newtListboxAppendEntry(tree, s, &self->ms); |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 352 | |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 353 | return ret; |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 354 | } |
| 355 | |
Arnaldo Carvalho de Melo | 533c46c | 2010-04-03 11:54:35 -0300 | [diff] [blame] | 356 | static void map_symbol__annotate_browser(const struct map_symbol *self, |
| 357 | const char *input_name) |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 358 | { |
| 359 | FILE *fp; |
Arnaldo Carvalho de Melo | cb7afb7 | 2010-03-12 12:46:47 -0300 | [diff] [blame] | 360 | int cols, rows; |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 361 | newtComponent form, tree; |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 362 | struct newtExitStruct es; |
| 363 | char *str; |
| 364 | size_t line_len, max_line_len = 0; |
| 365 | size_t max_usable_width; |
| 366 | char *line = NULL; |
| 367 | |
Arnaldo Carvalho de Melo | d5679ae | 2010-03-24 16:40:19 -0300 | [diff] [blame] | 368 | if (self->sym == NULL) |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 369 | return; |
| 370 | |
Arnaldo Carvalho de Melo | 533c46c | 2010-04-03 11:54:35 -0300 | [diff] [blame] | 371 | if (asprintf(&str, "perf annotate -i \"%s\" -d \"%s\" %s 2>&1 | expand", |
| 372 | input_name, self->map->dso->name, self->sym->name) < 0) |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 373 | return; |
| 374 | |
| 375 | fp = popen(str, "r"); |
| 376 | if (fp == NULL) |
| 377 | goto out_free_str; |
| 378 | |
Arnaldo Carvalho de Melo | 3798ed7 | 2010-05-11 18:01:23 -0300 | [diff] [blame^] | 379 | ui_helpline__push("Press ESC to exit"); |
Arnaldo Carvalho de Melo | cb7afb7 | 2010-03-12 12:46:47 -0300 | [diff] [blame] | 380 | newtGetScreenSize(&cols, &rows); |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 381 | tree = newtListbox(0, 0, rows - 5, NEWT_FLAG_SCROLL); |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 382 | |
| 383 | while (!feof(fp)) { |
| 384 | if (getline(&line, &line_len, fp) < 0 || !line_len) |
| 385 | break; |
| 386 | while (line_len != 0 && isspace(line[line_len - 1])) |
| 387 | line[--line_len] = '\0'; |
| 388 | |
| 389 | if (line_len > max_line_len) |
| 390 | max_line_len = line_len; |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 391 | newtListboxAppendEntry(tree, line, NULL); |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 392 | } |
| 393 | fclose(fp); |
| 394 | free(line); |
| 395 | |
Arnaldo Carvalho de Melo | cb7afb7 | 2010-03-12 12:46:47 -0300 | [diff] [blame] | 396 | max_usable_width = cols - 22; |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 397 | if (max_line_len > max_usable_width) |
| 398 | max_line_len = max_usable_width; |
| 399 | |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 400 | newtListboxSetWidth(tree, max_line_len); |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 401 | |
Arnaldo Carvalho de Melo | d5679ae | 2010-03-24 16:40:19 -0300 | [diff] [blame] | 402 | newtCenteredWindow(max_line_len + 2, rows - 5, self->sym->name); |
Arnaldo Carvalho de Melo | 7081e08 | 2010-03-12 10:48:12 -0300 | [diff] [blame] | 403 | form = newt_form__new(); |
Arnaldo Carvalho de Melo | 7f82645 | 2010-05-10 10:51:25 -0300 | [diff] [blame] | 404 | newtFormAddComponent(form, tree); |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 405 | |
| 406 | newtFormRun(form, &es); |
| 407 | newtFormDestroy(form); |
| 408 | newtPopWindow(); |
Arnaldo Carvalho de Melo | 3798ed7 | 2010-05-11 18:01:23 -0300 | [diff] [blame^] | 409 | ui_helpline__pop(); |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 410 | out_free_str: |
| 411 | free(str); |
| 412 | } |
| 413 | |
Arnaldo Carvalho de Melo | 53c5401 | 2010-03-24 16:40:14 -0300 | [diff] [blame] | 414 | static const void *newt__symbol_tree_get_current(newtComponent self) |
| 415 | { |
| 416 | if (symbol_conf.use_callchain) |
| 417 | return newtCheckboxTreeGetCurrent(self); |
| 418 | return newtListboxGetCurrent(self); |
| 419 | } |
| 420 | |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 421 | static void hist_browser__selection(newtComponent self, void *data) |
Arnaldo Carvalho de Melo | 53c5401 | 2010-03-24 16:40:14 -0300 | [diff] [blame] | 422 | { |
Arnaldo Carvalho de Melo | d5679ae | 2010-03-24 16:40:19 -0300 | [diff] [blame] | 423 | const struct map_symbol **symbol_ptr = data; |
Arnaldo Carvalho de Melo | 53c5401 | 2010-03-24 16:40:14 -0300 | [diff] [blame] | 424 | *symbol_ptr = newt__symbol_tree_get_current(self); |
| 425 | } |
| 426 | |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 427 | struct hist_browser { |
| 428 | newtComponent form, tree; |
Arnaldo Carvalho de Melo | d5679ae | 2010-03-24 16:40:19 -0300 | [diff] [blame] | 429 | const struct map_symbol *selection; |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 430 | }; |
| 431 | |
| 432 | static struct hist_browser *hist_browser__new(void) |
| 433 | { |
| 434 | struct hist_browser *self = malloc(sizeof(*self)); |
| 435 | |
Arnaldo Carvalho de Melo | 8375319 | 2010-04-03 16:30:44 -0300 | [diff] [blame] | 436 | if (self != NULL) |
| 437 | self->form = NULL; |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 438 | |
| 439 | return self; |
| 440 | } |
| 441 | |
| 442 | static void hist_browser__delete(struct hist_browser *self) |
| 443 | { |
| 444 | newtFormDestroy(self->form); |
| 445 | newtPopWindow(); |
| 446 | free(self); |
| 447 | } |
| 448 | |
Arnaldo Carvalho de Melo | b09e019 | 2010-05-11 11:10:15 -0300 | [diff] [blame] | 449 | static int hist_browser__populate(struct hist_browser *self, struct hists *hists, |
| 450 | const char *title) |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 451 | { |
| 452 | int max_len = 0, idx, cols, rows; |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 453 | struct ui_progress *progress; |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 454 | struct rb_node *nd; |
| 455 | u64 curr_hist = 0; |
Arnaldo Carvalho de Melo | 8375319 | 2010-04-03 16:30:44 -0300 | [diff] [blame] | 456 | char seq[] = "."; |
| 457 | char str[256]; |
| 458 | |
| 459 | if (self->form) { |
| 460 | newtFormDestroy(self->form); |
| 461 | newtPopWindow(); |
| 462 | } |
| 463 | |
| 464 | snprintf(str, sizeof(str), "Samples: %Ld ", |
Arnaldo Carvalho de Melo | b09e019 | 2010-05-11 11:10:15 -0300 | [diff] [blame] | 465 | hists->stats.total); |
Arnaldo Carvalho de Melo | 8375319 | 2010-04-03 16:30:44 -0300 | [diff] [blame] | 466 | newtDrawRootText(0, 0, str); |
| 467 | |
| 468 | newtGetScreenSize(NULL, &rows); |
| 469 | |
| 470 | if (symbol_conf.use_callchain) |
| 471 | self->tree = newtCheckboxTreeMulti(0, 0, rows - 5, seq, |
| 472 | NEWT_FLAG_SCROLL); |
| 473 | else |
| 474 | self->tree = newtListbox(0, 0, rows - 5, |
| 475 | (NEWT_FLAG_SCROLL | |
| 476 | NEWT_FLAG_RETURNEXIT)); |
| 477 | |
| 478 | newtComponentAddCallback(self->tree, hist_browser__selection, |
| 479 | &self->selection); |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 480 | |
Arnaldo Carvalho de Melo | b09e019 | 2010-05-11 11:10:15 -0300 | [diff] [blame] | 481 | progress = ui_progress__new("Adding entries to the browser...", |
| 482 | hists->nr_entries); |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 483 | if (progress == NULL) |
| 484 | return -1; |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 485 | |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 486 | idx = 0; |
Arnaldo Carvalho de Melo | b09e019 | 2010-05-11 11:10:15 -0300 | [diff] [blame] | 487 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 488 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
Arnaldo Carvalho de Melo | 8375319 | 2010-04-03 16:30:44 -0300 | [diff] [blame] | 489 | int len; |
| 490 | |
| 491 | if (h->filtered) |
| 492 | continue; |
| 493 | |
Arnaldo Carvalho de Melo | b09e019 | 2010-05-11 11:10:15 -0300 | [diff] [blame] | 494 | len = hist_entry__append_browser(h, self->tree, hists->stats.total); |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 495 | if (len > max_len) |
| 496 | max_len = len; |
Arnaldo Carvalho de Melo | d5679ae | 2010-03-24 16:40:19 -0300 | [diff] [blame] | 497 | if (symbol_conf.use_callchain) |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 498 | hist_entry__append_callchain_browser(h, self->tree, |
Arnaldo Carvalho de Melo | b09e019 | 2010-05-11 11:10:15 -0300 | [diff] [blame] | 499 | hists->stats.total, idx++); |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 500 | ++curr_hist; |
| 501 | if (curr_hist % 5) |
| 502 | ui_progress__update(progress, curr_hist); |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 503 | } |
| 504 | |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 505 | ui_progress__delete(progress); |
| 506 | |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 507 | newtGetScreenSize(&cols, &rows); |
| 508 | |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 509 | if (max_len > cols) |
| 510 | max_len = cols - 3; |
| 511 | |
| 512 | if (!symbol_conf.use_callchain) |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 513 | newtListboxSetWidth(self->tree, max_len); |
Arnaldo Carvalho de Melo | 4ded2b2 | 2010-03-22 17:52:49 -0300 | [diff] [blame] | 514 | |
| 515 | newtCenteredWindow(max_len + (symbol_conf.use_callchain ? 5 : 0), |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 516 | rows - 5, title); |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 517 | self->form = newt_form__new(); |
Arnaldo Carvalho de Melo | 8375319 | 2010-04-03 16:30:44 -0300 | [diff] [blame] | 518 | if (self->form == NULL) |
| 519 | return -1; |
| 520 | |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 521 | newtFormAddHotKey(self->form, 'A'); |
| 522 | newtFormAddHotKey(self->form, 'a'); |
| 523 | newtFormAddHotKey(self->form, NEWT_KEY_RIGHT); |
| 524 | newtFormAddComponents(self->form, self->tree, NULL); |
| 525 | self->selection = newt__symbol_tree_get_current(self->tree); |
| 526 | |
| 527 | return 0; |
| 528 | } |
| 529 | |
Arnaldo Carvalho de Melo | a5e29ac | 2010-04-03 22:44:37 -0300 | [diff] [blame] | 530 | static struct thread *hist_browser__selected_thread(struct hist_browser *self) |
| 531 | { |
| 532 | int *indexes; |
| 533 | |
| 534 | if (!symbol_conf.use_callchain) |
| 535 | goto out; |
| 536 | |
| 537 | indexes = newtCheckboxTreeFindItem(self->tree, (void *)self->selection); |
| 538 | if (indexes) { |
| 539 | bool is_hist_entry = indexes[1] == NEWT_ARG_LAST; |
| 540 | free(indexes); |
| 541 | if (is_hist_entry) |
| 542 | goto out; |
| 543 | } |
| 544 | return NULL; |
| 545 | out: |
| 546 | return *(struct thread **)(self->selection + 1); |
| 547 | } |
| 548 | |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 549 | static int hist_browser__title(char *bf, size_t size, const char *input_name, |
| 550 | const struct dso *dso, const struct thread *thread) |
| 551 | { |
| 552 | int printed = 0; |
| 553 | |
| 554 | if (thread) |
| 555 | printed += snprintf(bf + printed, size - printed, |
| 556 | "Thread: %s(%d)", |
| 557 | (thread->comm_set ? thread->comm : ""), |
| 558 | thread->pid); |
| 559 | if (dso) |
| 560 | printed += snprintf(bf + printed, size - printed, |
| 561 | "%sDSO: %s", thread ? " " : "", |
| 562 | dso->short_name); |
| 563 | return printed ?: snprintf(bf, size, "Report: %s", input_name); |
| 564 | } |
| 565 | |
Arnaldo Carvalho de Melo | b09e019 | 2010-05-11 11:10:15 -0300 | [diff] [blame] | 566 | int hists__browse(struct hists *self, const char *helpline, const char *input_name) |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 567 | { |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 568 | struct hist_browser *browser = hist_browser__new(); |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 569 | const struct thread *thread_filter = NULL; |
| 570 | const struct dso *dso_filter = NULL; |
| 571 | struct newtExitStruct es; |
| 572 | char msg[160]; |
| 573 | int err = -1; |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 574 | |
| 575 | if (browser == NULL) |
| 576 | return -1; |
| 577 | |
Arnaldo Carvalho de Melo | 3798ed7 | 2010-05-11 18:01:23 -0300 | [diff] [blame^] | 578 | ui_helpline__push(helpline); |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 579 | |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 580 | hist_browser__title(msg, sizeof(msg), input_name, |
| 581 | dso_filter, thread_filter); |
Arnaldo Carvalho de Melo | b09e019 | 2010-05-11 11:10:15 -0300 | [diff] [blame] | 582 | if (hist_browser__populate(browser, self, msg) < 0) |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 583 | goto out; |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 584 | |
| 585 | while (1) { |
Arnaldo Carvalho de Melo | a5e29ac | 2010-04-03 22:44:37 -0300 | [diff] [blame] | 586 | const struct thread *thread; |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 587 | const struct dso *dso; |
Arnaldo Carvalho de Melo | 8375319 | 2010-04-03 16:30:44 -0300 | [diff] [blame] | 588 | char *options[16]; |
| 589 | int nr_options = 0, choice = 0, i, |
Arnaldo Carvalho de Melo | a5e29ac | 2010-04-03 22:44:37 -0300 | [diff] [blame] | 590 | annotate = -2, zoom_dso = -2, zoom_thread = -2; |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 591 | |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 592 | newtFormRun(browser->form, &es); |
Arnaldo Carvalho de Melo | 53c5401 | 2010-03-24 16:40:14 -0300 | [diff] [blame] | 593 | if (es.reason == NEWT_EXIT_HOTKEY) { |
Arnaldo Carvalho de Melo | d5679ae | 2010-03-24 16:40:19 -0300 | [diff] [blame] | 594 | if (toupper(es.u.key) == 'A') |
| 595 | goto do_annotate; |
Arnaldo Carvalho de Melo | 53c5401 | 2010-03-24 16:40:14 -0300 | [diff] [blame] | 596 | if (es.u.key == NEWT_KEY_ESCAPE || |
| 597 | toupper(es.u.key) == 'Q' || |
| 598 | es.u.key == CTRL('c')) { |
| 599 | if (dialog_yesno("Do you really want to exit?")) |
| 600 | break; |
| 601 | else |
| 602 | continue; |
| 603 | } |
| 604 | } |
| 605 | |
Arnaldo Carvalho de Melo | 8375319 | 2010-04-03 16:30:44 -0300 | [diff] [blame] | 606 | if (browser->selection->sym != NULL && |
| 607 | asprintf(&options[nr_options], "Annotate %s", |
| 608 | browser->selection->sym->name) > 0) |
| 609 | annotate = nr_options++; |
Arnaldo Carvalho de Melo | 53c5401 | 2010-03-24 16:40:14 -0300 | [diff] [blame] | 610 | |
Arnaldo Carvalho de Melo | a5e29ac | 2010-04-03 22:44:37 -0300 | [diff] [blame] | 611 | thread = hist_browser__selected_thread(browser); |
| 612 | if (thread != NULL && |
| 613 | asprintf(&options[nr_options], "Zoom %s %s(%d) thread", |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 614 | (thread_filter ? "out of" : "into"), |
| 615 | (thread->comm_set ? thread->comm : ""), |
| 616 | thread->pid) > 0) |
Arnaldo Carvalho de Melo | a5e29ac | 2010-04-03 22:44:37 -0300 | [diff] [blame] | 617 | zoom_thread = nr_options++; |
| 618 | |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 619 | dso = browser->selection->map ? browser->selection->map->dso : NULL; |
| 620 | if (dso != NULL && |
| 621 | asprintf(&options[nr_options], "Zoom %s %s DSO", |
| 622 | (dso_filter ? "out of" : "into"), |
| 623 | (dso->kernel ? "the Kernel" : dso->short_name)) > 0) |
| 624 | zoom_dso = nr_options++; |
| 625 | |
Arnaldo Carvalho de Melo | 8375319 | 2010-04-03 16:30:44 -0300 | [diff] [blame] | 626 | options[nr_options++] = (char *)"Exit"; |
| 627 | |
Arnaldo Carvalho de Melo | 53c5401 | 2010-03-24 16:40:14 -0300 | [diff] [blame] | 628 | choice = popup_menu(nr_options, options); |
Arnaldo Carvalho de Melo | 8375319 | 2010-04-03 16:30:44 -0300 | [diff] [blame] | 629 | |
| 630 | for (i = 0; i < nr_options - 1; ++i) |
| 631 | free(options[i]); |
| 632 | |
Arnaldo Carvalho de Melo | 53c5401 | 2010-03-24 16:40:14 -0300 | [diff] [blame] | 633 | if (choice == nr_options - 1) |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 634 | break; |
Arnaldo Carvalho de Melo | a5e29ac | 2010-04-03 22:44:37 -0300 | [diff] [blame] | 635 | |
| 636 | if (choice == -1) |
| 637 | continue; |
Arnaldo Carvalho de Melo | d5679ae | 2010-03-24 16:40:19 -0300 | [diff] [blame] | 638 | do_annotate: |
Arnaldo Carvalho de Melo | 8375319 | 2010-04-03 16:30:44 -0300 | [diff] [blame] | 639 | if (choice == annotate) { |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 640 | if (browser->selection->map->dso->origin == DSO__ORIG_KERNEL) { |
Arnaldo Carvalho de Melo | 3798ed7 | 2010-05-11 18:01:23 -0300 | [diff] [blame^] | 641 | ui_helpline__puts("No vmlinux file found, can't " |
Arnaldo Carvalho de Melo | d5679ae | 2010-03-24 16:40:19 -0300 | [diff] [blame] | 642 | "annotate with just a " |
| 643 | "kallsyms file"); |
| 644 | continue; |
| 645 | } |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 646 | map_symbol__annotate_browser(browser->selection, input_name); |
Arnaldo Carvalho de Melo | a5e29ac | 2010-04-03 22:44:37 -0300 | [diff] [blame] | 647 | } else if (choice == zoom_dso) { |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 648 | if (dso_filter) { |
Arnaldo Carvalho de Melo | 3798ed7 | 2010-05-11 18:01:23 -0300 | [diff] [blame^] | 649 | ui_helpline__pop(); |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 650 | dso_filter = NULL; |
| 651 | } else { |
Arnaldo Carvalho de Melo | 3798ed7 | 2010-05-11 18:01:23 -0300 | [diff] [blame^] | 652 | ui_helpline__fpush("To zoom out press -> + \"Zoom out of %s DSO\"", |
| 653 | dso->kernel ? "the Kernel" : dso->short_name); |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 654 | dso_filter = dso; |
| 655 | } |
Arnaldo Carvalho de Melo | b09e019 | 2010-05-11 11:10:15 -0300 | [diff] [blame] | 656 | hists__filter_by_dso(self, dso_filter); |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 657 | hist_browser__title(msg, sizeof(msg), input_name, |
| 658 | dso_filter, thread_filter); |
Arnaldo Carvalho de Melo | b09e019 | 2010-05-11 11:10:15 -0300 | [diff] [blame] | 659 | if (hist_browser__populate(browser, self, msg) < 0) |
Arnaldo Carvalho de Melo | 8375319 | 2010-04-03 16:30:44 -0300 | [diff] [blame] | 660 | goto out; |
Arnaldo Carvalho de Melo | a5e29ac | 2010-04-03 22:44:37 -0300 | [diff] [blame] | 661 | } else if (choice == zoom_thread) { |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 662 | if (thread_filter) { |
Arnaldo Carvalho de Melo | 3798ed7 | 2010-05-11 18:01:23 -0300 | [diff] [blame^] | 663 | ui_helpline__pop(); |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 664 | thread_filter = NULL; |
| 665 | } else { |
Arnaldo Carvalho de Melo | 3798ed7 | 2010-05-11 18:01:23 -0300 | [diff] [blame^] | 666 | ui_helpline__fpush("To zoom out press -> + \"Zoom out of %s(%d) thread\"", |
| 667 | thread->comm_set ? thread->comm : "", |
| 668 | thread->pid); |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 669 | thread_filter = thread; |
| 670 | } |
Arnaldo Carvalho de Melo | b09e019 | 2010-05-11 11:10:15 -0300 | [diff] [blame] | 671 | hists__filter_by_thread(self, thread_filter); |
Arnaldo Carvalho de Melo | 6e7ab4c | 2010-04-05 12:02:18 -0300 | [diff] [blame] | 672 | hist_browser__title(msg, sizeof(msg), input_name, |
| 673 | dso_filter, thread_filter); |
Arnaldo Carvalho de Melo | b09e019 | 2010-05-11 11:10:15 -0300 | [diff] [blame] | 674 | if (hist_browser__populate(browser, self, msg) < 0) |
Arnaldo Carvalho de Melo | a5e29ac | 2010-04-03 22:44:37 -0300 | [diff] [blame] | 675 | goto out; |
Arnaldo Carvalho de Melo | d5679ae | 2010-03-24 16:40:19 -0300 | [diff] [blame] | 676 | } |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 677 | } |
Arnaldo Carvalho de Melo | e65713e | 2010-04-03 11:25:56 -0300 | [diff] [blame] | 678 | err = 0; |
| 679 | out: |
| 680 | hist_browser__delete(browser); |
| 681 | return err; |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 682 | } |
| 683 | |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 684 | void setup_browser(void) |
| 685 | { |
| 686 | if (!isatty(1)) |
| 687 | return; |
| 688 | |
| 689 | use_browser = true; |
| 690 | newtInit(); |
| 691 | newtCls(); |
Arnaldo Carvalho de Melo | 3798ed7 | 2010-05-11 18:01:23 -0300 | [diff] [blame^] | 692 | ui_helpline__puts(" "); |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 693 | } |
| 694 | |
Arnaldo Carvalho de Melo | f3a1f0e | 2010-03-22 13:10:25 -0300 | [diff] [blame] | 695 | void exit_browser(bool wait_for_ok) |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 696 | { |
Arnaldo Carvalho de Melo | f3a1f0e | 2010-03-22 13:10:25 -0300 | [diff] [blame] | 697 | if (use_browser) { |
| 698 | if (wait_for_ok) { |
| 699 | char title[] = "Fatal Error", ok[] = "Ok"; |
| 700 | newtWinMessage(title, ok, browser__last_msg); |
| 701 | } |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 702 | newtFinished(); |
Arnaldo Carvalho de Melo | f3a1f0e | 2010-03-22 13:10:25 -0300 | [diff] [blame] | 703 | } |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 704 | } |