aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/browsers/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/ui/browsers/map.c')
-rw-r--r--tools/perf/ui/browsers/map.c60
1 files changed, 18 insertions, 42 deletions
diff --git a/tools/perf/ui/browsers/map.c b/tools/perf/ui/browsers/map.c
index 98851d55a53e..95c7cfb8f2c6 100644
--- a/tools/perf/ui/browsers/map.c
+++ b/tools/perf/ui/browsers/map.c
@@ -1,6 +1,5 @@
1#include "../libslang.h" 1#include "../libslang.h"
2#include <elf.h> 2#include <elf.h>
3#include <newt.h>
4#include <inttypes.h> 3#include <inttypes.h>
5#include <sys/ttydefaults.h> 4#include <sys/ttydefaults.h>
6#include <string.h> 5#include <string.h>
@@ -10,41 +9,9 @@
10#include "../../util/symbol.h" 9#include "../../util/symbol.h"
11#include "../browser.h" 10#include "../browser.h"
12#include "../helpline.h" 11#include "../helpline.h"
12#include "../keysyms.h"
13#include "map.h" 13#include "map.h"
14 14
15static int ui_entry__read(const char *title, char *bf, size_t size, int width)
16{
17 struct newtExitStruct es;
18 newtComponent form, entry;
19 const char *result;
20 int err = -1;
21
22 newtCenteredWindow(width, 1, title);
23 form = newtForm(NULL, NULL, 0);
24 if (form == NULL)
25 return -1;
26
27 entry = newtEntry(0, 0, "0x", width, &result, NEWT_FLAG_SCROLL);
28 if (entry == NULL)
29 goto out_free_form;
30
31 newtFormAddComponent(form, entry);
32 newtFormAddHotKey(form, NEWT_KEY_ENTER);
33 newtFormAddHotKey(form, NEWT_KEY_ESCAPE);
34 newtFormAddHotKey(form, NEWT_KEY_LEFT);
35 newtFormAddHotKey(form, CTRL('c'));
36 newtFormRun(form, &es);
37
38 if (result != NULL) {
39 strncpy(bf, result, size);
40 err = 0;
41 }
42out_free_form:
43 newtPopWindow();
44 newtFormDestroy(form);
45 return err;
46}
47
48struct map_browser { 15struct map_browser {
49 struct ui_browser b; 16 struct ui_browser b;
50 struct map *map; 17 struct map *map;
@@ -78,10 +45,11 @@ static int map_browser__search(struct map_browser *self)
78{ 45{
79 char target[512]; 46 char target[512];
80 struct symbol *sym; 47 struct symbol *sym;
81 int err = ui_entry__read("Search by name/addr", target, sizeof(target), 40); 48 int err = ui_browser__input_window("Search by name/addr",
82 49 "Prefix with 0x to search by address",
83 if (err) 50 target, "ENTER: OK, ESC: Cancel", 0);
84 return err; 51 if (err != K_ENTER)
52 return -1;
85 53
86 if (target[0] == '0' && tolower(target[1]) == 'x') { 54 if (target[0] == '0' && tolower(target[1]) == 'x') {
87 u64 addr = strtoull(target, NULL, 16); 55 u64 addr = strtoull(target, NULL, 16);
@@ -112,12 +80,20 @@ static int map_browser__run(struct map_browser *self)
112 while (1) { 80 while (1) {
113 key = ui_browser__run(&self->b, 0); 81 key = ui_browser__run(&self->b, 0);
114 82
115 if (verbose && key == '/') 83 switch (key) {
116 map_browser__search(self); 84 case '/':
117 else 85 if (verbose)
86 map_browser__search(self);
87 default:
118 break; 88 break;
89 case K_LEFT:
90 case K_ESC:
91 case 'q':
92 case CTRL('c'):
93 goto out;
94 }
119 } 95 }
120 96out:
121 ui_browser__hide(&self->b); 97 ui_browser__hide(&self->b);
122 return key; 98 return key;
123} 99}