diff options
Diffstat (limited to 'tools/perf/util/ui/browsers/map.c')
-rw-r--r-- | tools/perf/util/ui/browsers/map.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/tools/perf/util/ui/browsers/map.c b/tools/perf/util/ui/browsers/map.c index 142b825b42bf..8462bffe20bc 100644 --- a/tools/perf/util/ui/browsers/map.c +++ b/tools/perf/util/ui/browsers/map.c | |||
@@ -1,6 +1,6 @@ | |||
1 | #include "../libslang.h" | 1 | #include "../libslang.h" |
2 | #include <elf.h> | 2 | #include <elf.h> |
3 | #include <newt.h> | 3 | #include <inttypes.h> |
4 | #include <sys/ttydefaults.h> | 4 | #include <sys/ttydefaults.h> |
5 | #include <ctype.h> | 5 | #include <ctype.h> |
6 | #include <string.h> | 6 | #include <string.h> |
@@ -41,13 +41,12 @@ static int ui_entry__read(const char *title, char *bf, size_t size, int width) | |||
41 | out_free_form: | 41 | out_free_form: |
42 | newtPopWindow(); | 42 | newtPopWindow(); |
43 | newtFormDestroy(form); | 43 | newtFormDestroy(form); |
44 | return 0; | 44 | return err; |
45 | } | 45 | } |
46 | 46 | ||
47 | struct map_browser { | 47 | struct map_browser { |
48 | struct ui_browser b; | 48 | struct ui_browser b; |
49 | struct map *map; | 49 | struct map *map; |
50 | u16 namelen; | ||
51 | u8 addrlen; | 50 | u8 addrlen; |
52 | }; | 51 | }; |
53 | 52 | ||
@@ -56,14 +55,16 @@ static void map_browser__write(struct ui_browser *self, void *nd, int row) | |||
56 | struct symbol *sym = rb_entry(nd, struct symbol, rb_node); | 55 | struct symbol *sym = rb_entry(nd, struct symbol, rb_node); |
57 | struct map_browser *mb = container_of(self, struct map_browser, b); | 56 | struct map_browser *mb = container_of(self, struct map_browser, b); |
58 | bool current_entry = ui_browser__is_current_entry(self, row); | 57 | bool current_entry = ui_browser__is_current_entry(self, row); |
59 | int color = ui_browser__percent_color(0, current_entry); | 58 | int width; |
60 | 59 | ||
61 | SLsmg_set_color(color); | 60 | ui_browser__set_percent_color(self, 0, current_entry); |
62 | slsmg_printf("%*llx %*llx %c ", | 61 | slsmg_printf("%*" PRIx64 " %*" PRIx64 " %c ", |
63 | mb->addrlen, sym->start, mb->addrlen, sym->end, | 62 | mb->addrlen, sym->start, mb->addrlen, sym->end, |
64 | sym->binding == STB_GLOBAL ? 'g' : | 63 | sym->binding == STB_GLOBAL ? 'g' : |
65 | sym->binding == STB_LOCAL ? 'l' : 'w'); | 64 | sym->binding == STB_LOCAL ? 'l' : 'w'); |
66 | slsmg_write_nstring(sym->name, mb->namelen); | 65 | width = self->width - ((mb->addrlen * 2) + 4); |
66 | if (width > 0) | ||
67 | slsmg_write_nstring(sym->name, width); | ||
67 | } | 68 | } |
68 | 69 | ||
69 | /* FIXME uber-kludgy, see comment on cmd_report... */ | 70 | /* FIXME uber-kludgy, see comment on cmd_report... */ |
@@ -98,31 +99,29 @@ static int map_browser__search(struct map_browser *self) | |||
98 | return 0; | 99 | return 0; |
99 | } | 100 | } |
100 | 101 | ||
101 | static int map_browser__run(struct map_browser *self, struct newtExitStruct *es) | 102 | static int map_browser__run(struct map_browser *self) |
102 | { | 103 | { |
104 | int key; | ||
105 | |||
103 | if (ui_browser__show(&self->b, self->map->dso->long_name, | 106 | if (ui_browser__show(&self->b, self->map->dso->long_name, |
104 | "Press <- or ESC to exit, %s / to search", | 107 | "Press <- or ESC to exit, %s / to search", |
105 | verbose ? "" : "restart with -v to use") < 0) | 108 | verbose ? "" : "restart with -v to use") < 0) |
106 | return -1; | 109 | return -1; |
107 | 110 | ||
108 | newtFormAddHotKey(self->b.form, NEWT_KEY_LEFT); | ||
109 | newtFormAddHotKey(self->b.form, NEWT_KEY_ENTER); | ||
110 | if (verbose) | 111 | if (verbose) |
111 | newtFormAddHotKey(self->b.form, '/'); | 112 | ui_browser__add_exit_key(&self->b, '/'); |
112 | 113 | ||
113 | while (1) { | 114 | while (1) { |
114 | ui_browser__run(&self->b, es); | 115 | key = ui_browser__run(&self->b); |
115 | 116 | ||
116 | if (es->reason != NEWT_EXIT_HOTKEY) | 117 | if (verbose && key == '/') |
117 | break; | ||
118 | if (verbose && es->u.key == '/') | ||
119 | map_browser__search(self); | 118 | map_browser__search(self); |
120 | else | 119 | else |
121 | break; | 120 | break; |
122 | } | 121 | } |
123 | 122 | ||
124 | ui_browser__hide(&self->b); | 123 | ui_browser__hide(&self->b); |
125 | return 0; | 124 | return key; |
126 | } | 125 | } |
127 | 126 | ||
128 | int map__browse(struct map *self) | 127 | int map__browse(struct map *self) |
@@ -136,7 +135,6 @@ int map__browse(struct map *self) | |||
136 | }, | 135 | }, |
137 | .map = self, | 136 | .map = self, |
138 | }; | 137 | }; |
139 | struct newtExitStruct es; | ||
140 | struct rb_node *nd; | 138 | struct rb_node *nd; |
141 | char tmp[BITS_PER_LONG / 4]; | 139 | char tmp[BITS_PER_LONG / 4]; |
142 | u64 maxaddr = 0; | 140 | u64 maxaddr = 0; |
@@ -144,8 +142,6 @@ int map__browse(struct map *self) | |||
144 | for (nd = rb_first(mb.b.entries); nd; nd = rb_next(nd)) { | 142 | for (nd = rb_first(mb.b.entries); nd; nd = rb_next(nd)) { |
145 | struct symbol *pos = rb_entry(nd, struct symbol, rb_node); | 143 | struct symbol *pos = rb_entry(nd, struct symbol, rb_node); |
146 | 144 | ||
147 | if (mb.namelen < pos->namelen) | ||
148 | mb.namelen = pos->namelen; | ||
149 | if (maxaddr < pos->end) | 145 | if (maxaddr < pos->end) |
150 | maxaddr = pos->end; | 146 | maxaddr = pos->end; |
151 | if (verbose) { | 147 | if (verbose) { |
@@ -155,7 +151,6 @@ int map__browse(struct map *self) | |||
155 | ++mb.b.nr_entries; | 151 | ++mb.b.nr_entries; |
156 | } | 152 | } |
157 | 153 | ||
158 | mb.addrlen = snprintf(tmp, sizeof(tmp), "%llx", maxaddr); | 154 | mb.addrlen = snprintf(tmp, sizeof(tmp), "%" PRIx64, maxaddr); |
159 | mb.b.width += mb.addrlen * 2 + 4 + mb.namelen; | 155 | return map_browser__run(&mb); |
160 | return map_browser__run(&mb, &es); | ||
161 | } | 156 | } |