Namhyung Kim | aca7a94 | 2012-04-04 00:14:26 -0700 | [diff] [blame] | 1 | #include "../../util/util.h" |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 2 | #include "../browser.h" |
| 3 | #include "../helpline.h" |
| 4 | #include "../libslang.h" |
Arnaldo Carvalho de Melo | ae55795 | 2011-10-26 08:00:55 -0200 | [diff] [blame] | 5 | #include "../ui.h" |
| 6 | #include "../util.h" |
Namhyung Kim | aca7a94 | 2012-04-04 00:14:26 -0700 | [diff] [blame] | 7 | #include "../../util/annotate.h" |
| 8 | #include "../../util/hist.h" |
| 9 | #include "../../util/sort.h" |
| 10 | #include "../../util/symbol.h" |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 11 | #include <pthread.h> |
Arnaldo Carvalho de Melo | cf95800 | 2011-10-20 16:59:15 -0200 | [diff] [blame] | 12 | #include <newt.h> |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 13 | |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 14 | struct browser_disasm_line { |
| 15 | struct rb_node rb_node; |
| 16 | double percent; |
| 17 | u32 idx; |
| 18 | int idx_asm; |
| 19 | bool jump_target; |
| 20 | }; |
| 21 | |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 22 | struct annotate_browser { |
| 23 | struct ui_browser b; |
| 24 | struct rb_root entries; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 25 | struct rb_node *curr_hot; |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 26 | struct disasm_line *selection; |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 27 | struct disasm_line **offsets; |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 28 | u64 start; |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 29 | int nr_asm_entries; |
| 30 | int nr_entries; |
| 31 | bool hide_src_code; |
Arnaldo Carvalho de Melo | e235f3f | 2012-04-02 13:21:55 -0300 | [diff] [blame] | 32 | bool use_offset; |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 33 | bool searching_backwards; |
Arnaldo Carvalho de Melo | 61e04b3 | 2012-04-19 13:15:24 -0300 | [diff] [blame] | 34 | u8 offset_width; |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 35 | char search_bf[128]; |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 36 | }; |
| 37 | |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 38 | static inline struct browser_disasm_line *disasm_line__browser(struct disasm_line *dl) |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 39 | { |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 40 | return (struct browser_disasm_line *)(dl + 1); |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 41 | } |
| 42 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 43 | static bool disasm_line__filter(struct ui_browser *browser, void *entry) |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 44 | { |
| 45 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); |
| 46 | |
| 47 | if (ab->hide_src_code) { |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 48 | struct disasm_line *dl = list_entry(entry, struct disasm_line, node); |
| 49 | return dl->offset == -1; |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | return false; |
| 53 | } |
| 54 | |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 55 | static void annotate_browser__write(struct ui_browser *self, void *entry, int row) |
| 56 | { |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 57 | struct annotate_browser *ab = container_of(self, struct annotate_browser, b); |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 58 | struct disasm_line *dl = list_entry(entry, struct disasm_line, node); |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 59 | struct browser_disasm_line *bdl = disasm_line__browser(dl); |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 60 | bool current_entry = ui_browser__is_current_entry(self, row); |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 61 | bool change_color = (!ab->hide_src_code && |
| 62 | (!current_entry || (self->use_navkeypressed && |
| 63 | !self->navkeypressed))); |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 64 | int width = self->width; |
| 65 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 66 | if (dl->offset != -1) { |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 67 | ui_browser__set_percent_color(self, bdl->percent, current_entry); |
| 68 | slsmg_printf(" %7.2f ", bdl->percent); |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 69 | } else { |
Arnaldo Carvalho de Melo | 8f9bbc4 | 2010-08-11 14:51:47 -0300 | [diff] [blame] | 70 | ui_browser__set_percent_color(self, 0, current_entry); |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 71 | slsmg_write_nstring(" ", 9); |
| 72 | } |
| 73 | |
Arnaldo Carvalho de Melo | 59d038d | 2012-04-20 16:26:14 -0300 | [diff] [blame] | 74 | ui_browser__write_graph(self, SLSMG_VLINE_CHAR); |
Arnaldo Carvalho de Melo | cf2dacc | 2012-04-19 15:19:17 -0300 | [diff] [blame] | 75 | SLsmg_write_char(' '); |
Arnaldo Carvalho de Melo | c172f74 | 2011-10-18 14:31:35 -0200 | [diff] [blame] | 76 | |
| 77 | /* The scroll bar isn't being used */ |
| 78 | if (!self->navkeypressed) |
| 79 | width += 1; |
| 80 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 81 | if (dl->offset != -1 && change_color) |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 82 | ui_browser__set_color(self, HE_COLORSET_CODE); |
Namhyung Kim | 58e817d | 2012-02-23 17:46:20 +0900 | [diff] [blame] | 83 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 84 | if (!*dl->line) |
Arnaldo Carvalho de Melo | 8bf39cb | 2012-04-19 15:07:46 -0300 | [diff] [blame] | 85 | slsmg_write_nstring(" ", width - 10); |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 86 | else if (dl->offset == -1) |
Arnaldo Carvalho de Melo | 8bf39cb | 2012-04-19 15:07:46 -0300 | [diff] [blame] | 87 | slsmg_write_nstring(dl->line, width - 10); |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 88 | else { |
Arnaldo Carvalho de Melo | 8bf39cb | 2012-04-19 15:07:46 -0300 | [diff] [blame] | 89 | char bf[256]; |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 90 | u64 addr = dl->offset; |
Arnaldo Carvalho de Melo | e235f3f | 2012-04-02 13:21:55 -0300 | [diff] [blame] | 91 | int printed, color = -1; |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 92 | |
Arnaldo Carvalho de Melo | e235f3f | 2012-04-02 13:21:55 -0300 | [diff] [blame] | 93 | if (!ab->use_offset) |
| 94 | addr += ab->start; |
| 95 | |
Arnaldo Carvalho de Melo | 61e04b3 | 2012-04-19 13:15:24 -0300 | [diff] [blame] | 96 | if (!ab->use_offset) { |
Arnaldo Carvalho de Melo | a3f895b | 2012-04-24 14:24:28 -0300 | [diff] [blame] | 97 | printed = scnprintf(bf, sizeof(bf), " %" PRIx64 ":", addr); |
Arnaldo Carvalho de Melo | 61e04b3 | 2012-04-19 13:15:24 -0300 | [diff] [blame] | 98 | } else { |
| 99 | if (bdl->jump_target) { |
Arnaldo Carvalho de Melo | a3f895b | 2012-04-24 14:24:28 -0300 | [diff] [blame] | 100 | printed = scnprintf(bf, sizeof(bf), " %*" PRIx64 ":", |
Arnaldo Carvalho de Melo | 61e04b3 | 2012-04-19 13:15:24 -0300 | [diff] [blame] | 101 | ab->offset_width, addr); |
| 102 | } else { |
Arnaldo Carvalho de Melo | a3f895b | 2012-04-24 14:24:28 -0300 | [diff] [blame] | 103 | printed = scnprintf(bf, sizeof(bf), " %*s ", |
Arnaldo Carvalho de Melo | 61e04b3 | 2012-04-19 13:15:24 -0300 | [diff] [blame] | 104 | ab->offset_width, " "); |
| 105 | } |
| 106 | } |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 107 | |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 108 | if (change_color) |
| 109 | color = ui_browser__set_color(self, HE_COLORSET_ADDR); |
| 110 | slsmg_write_nstring(bf, printed); |
| 111 | if (change_color) |
| 112 | ui_browser__set_color(self, color); |
Arnaldo Carvalho de Melo | 28548d7 | 2012-04-19 10:16:27 -0300 | [diff] [blame] | 113 | if (dl->ins && dl->ins->ops->scnprintf) { |
Arnaldo Carvalho de Melo | 51a0d45 | 2012-04-20 15:40:20 -0300 | [diff] [blame] | 114 | if (ins__is_jump(dl->ins)) { |
Arnaldo Carvalho de Melo | 44d1a3e | 2012-04-25 08:00:23 -0300 | [diff] [blame] | 115 | bool fwd = dl->ops.target.offset > (u64)dl->offset; |
Arnaldo Carvalho de Melo | 51a0d45 | 2012-04-20 15:40:20 -0300 | [diff] [blame] | 116 | |
Arnaldo Carvalho de Melo | 59d038d | 2012-04-20 16:26:14 -0300 | [diff] [blame] | 117 | ui_browser__write_graph(self, fwd ? SLSMG_DARROW_CHAR : |
| 118 | SLSMG_UARROW_CHAR); |
Arnaldo Carvalho de Melo | 51a0d45 | 2012-04-20 15:40:20 -0300 | [diff] [blame] | 119 | SLsmg_write_char(' '); |
Arnaldo Carvalho de Melo | 88298f5 | 2012-04-27 15:10:54 -0300 | [diff] [blame^] | 120 | } else if (ins__is_call(dl->ins)) { |
| 121 | ui_browser__write_graph(self, SLSMG_RARROW_CHAR); |
| 122 | SLsmg_write_char(' '); |
Arnaldo Carvalho de Melo | 51a0d45 | 2012-04-20 15:40:20 -0300 | [diff] [blame] | 123 | } else { |
| 124 | slsmg_write_nstring(" ", 2); |
| 125 | } |
| 126 | |
Arnaldo Carvalho de Melo | c7e6ead | 2012-04-20 14:38:46 -0300 | [diff] [blame] | 127 | dl->ins->ops->scnprintf(dl->ins, bf, sizeof(bf), &dl->ops, |
| 128 | !ab->use_offset); |
Arnaldo Carvalho de Melo | 4ea08b5 | 2012-04-20 15:51:40 -0300 | [diff] [blame] | 129 | } else { |
| 130 | if (strcmp(dl->name, "retq")) { |
| 131 | slsmg_write_nstring(" ", 2); |
| 132 | } else { |
Arnaldo Carvalho de Melo | 59d038d | 2012-04-20 16:26:14 -0300 | [diff] [blame] | 133 | ui_browser__write_graph(self, SLSMG_LARROW_CHAR); |
Arnaldo Carvalho de Melo | 4ea08b5 | 2012-04-20 15:51:40 -0300 | [diff] [blame] | 134 | SLsmg_write_char(' '); |
| 135 | } |
Arnaldo Carvalho de Melo | 28548d7 | 2012-04-19 10:16:27 -0300 | [diff] [blame] | 136 | |
Arnaldo Carvalho de Melo | 4ea08b5 | 2012-04-20 15:51:40 -0300 | [diff] [blame] | 137 | scnprintf(bf, sizeof(bf), "%-6.6s %s", dl->name, dl->ops.raw); |
| 138 | } |
| 139 | |
| 140 | slsmg_write_nstring(bf, width - 12 - printed); |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 141 | } |
Arnaldo Carvalho de Melo | b99976e | 2011-02-09 13:59:14 -0200 | [diff] [blame] | 142 | |
Namhyung Kim | 58e817d | 2012-02-23 17:46:20 +0900 | [diff] [blame] | 143 | if (current_entry) |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 144 | ab->selection = dl; |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 145 | } |
| 146 | |
Arnaldo Carvalho de Melo | a3f895b | 2012-04-24 14:24:28 -0300 | [diff] [blame] | 147 | static void annotate_browser__draw_current_loop(struct ui_browser *browser) |
| 148 | { |
| 149 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); |
| 150 | struct map_symbol *ms = browser->priv; |
| 151 | struct symbol *sym = ms->sym; |
| 152 | struct annotation *notes = symbol__annotation(sym); |
| 153 | struct disasm_line *cursor = ab->selection, *pos = cursor, *target; |
| 154 | struct browser_disasm_line *bcursor = disasm_line__browser(cursor), |
| 155 | *btarget, *bpos; |
| 156 | unsigned int from, to, start_width = 2; |
| 157 | |
| 158 | list_for_each_entry_from(pos, ¬es->src->source, node) { |
Arnaldo Carvalho de Melo | 38b31bd | 2012-04-25 14:18:42 -0300 | [diff] [blame] | 159 | if (!pos->ins || !ins__is_jump(pos->ins) || |
| 160 | !disasm_line__has_offset(pos)) |
Arnaldo Carvalho de Melo | a3f895b | 2012-04-24 14:24:28 -0300 | [diff] [blame] | 161 | continue; |
| 162 | |
Arnaldo Carvalho de Melo | 44d1a3e | 2012-04-25 08:00:23 -0300 | [diff] [blame] | 163 | target = ab->offsets[pos->ops.target.offset]; |
Arnaldo Carvalho de Melo | a3f895b | 2012-04-24 14:24:28 -0300 | [diff] [blame] | 164 | if (!target) |
| 165 | continue; |
| 166 | |
| 167 | btarget = disasm_line__browser(target); |
| 168 | if (btarget->idx <= bcursor->idx) |
| 169 | goto found; |
| 170 | } |
| 171 | |
| 172 | return; |
| 173 | |
| 174 | found: |
| 175 | bpos = disasm_line__browser(pos); |
| 176 | if (ab->hide_src_code) { |
| 177 | from = bpos->idx_asm; |
| 178 | to = btarget->idx_asm; |
| 179 | } else { |
| 180 | from = (u64)bpos->idx; |
| 181 | to = (u64)btarget->idx; |
| 182 | } |
| 183 | |
| 184 | ui_browser__set_color(browser, HE_COLORSET_CODE); |
| 185 | |
| 186 | if (!bpos->jump_target) |
| 187 | start_width += ab->offset_width + 1; |
| 188 | |
| 189 | __ui_browser__line_arrow_up(browser, 10, from, to, start_width); |
| 190 | } |
| 191 | |
| 192 | static unsigned int annotate_browser__refresh(struct ui_browser *browser) |
| 193 | { |
| 194 | int ret = ui_browser__list_head_refresh(browser); |
| 195 | |
| 196 | annotate_browser__draw_current_loop(browser); |
| 197 | |
| 198 | return ret; |
| 199 | } |
| 200 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 201 | static double disasm_line__calc_percent(struct disasm_line *dl, struct symbol *sym, int evidx) |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 202 | { |
| 203 | double percent = 0.0; |
| 204 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 205 | if (dl->offset != -1) { |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 206 | int len = sym->end - sym->start; |
| 207 | unsigned int hits = 0; |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 208 | struct annotation *notes = symbol__annotation(sym); |
Arnaldo Carvalho de Melo | ce6f4fa | 2011-02-08 13:27:39 -0200 | [diff] [blame] | 209 | struct source_line *src_line = notes->src->lines; |
Arnaldo Carvalho de Melo | 2f525d0 | 2011-02-04 13:43:24 -0200 | [diff] [blame] | 210 | struct sym_hist *h = annotation__histogram(notes, evidx); |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 211 | s64 offset = dl->offset; |
| 212 | struct disasm_line *next; |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 213 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 214 | next = disasm__get_next_ip_line(¬es->src->source, dl); |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 215 | while (offset < (s64)len && |
| 216 | (next == NULL || offset < next->offset)) { |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 217 | if (src_line) { |
| 218 | percent += src_line[offset].percent; |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 219 | } else |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 220 | hits += h->addr[offset]; |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 221 | |
| 222 | ++offset; |
| 223 | } |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 224 | /* |
| 225 | * If the percentage wasn't already calculated in |
| 226 | * symbol__get_source_line, do it now: |
| 227 | */ |
| 228 | if (src_line == NULL && h->sum) |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 229 | percent = 100.0 * hits / h->sum; |
| 230 | } |
| 231 | |
| 232 | return percent; |
| 233 | } |
| 234 | |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 235 | static void disasm_rb_tree__insert(struct rb_root *root, struct browser_disasm_line *bdl) |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 236 | { |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 237 | struct rb_node **p = &root->rb_node; |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 238 | struct rb_node *parent = NULL; |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 239 | struct browser_disasm_line *l; |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 240 | |
| 241 | while (*p != NULL) { |
| 242 | parent = *p; |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 243 | l = rb_entry(parent, struct browser_disasm_line, rb_node); |
| 244 | if (bdl->percent < l->percent) |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 245 | p = &(*p)->rb_left; |
| 246 | else |
| 247 | p = &(*p)->rb_right; |
| 248 | } |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 249 | rb_link_node(&bdl->rb_node, parent, p); |
| 250 | rb_insert_color(&bdl->rb_node, root); |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 251 | } |
| 252 | |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 253 | static void annotate_browser__set_top(struct annotate_browser *self, |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 254 | struct disasm_line *pos, u32 idx) |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 255 | { |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 256 | unsigned back; |
| 257 | |
| 258 | ui_browser__refresh_dimensions(&self->b); |
| 259 | back = self->b.height / 2; |
Arnaldo Carvalho de Melo | b0ffb2c | 2012-04-03 15:32:45 -0300 | [diff] [blame] | 260 | self->b.top_idx = self->b.index = idx; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 261 | |
| 262 | while (self->b.top_idx != 0 && back != 0) { |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 263 | pos = list_entry(pos->node.prev, struct disasm_line, node); |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 264 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 265 | if (disasm_line__filter(&self->b, &pos->node)) |
Arnaldo Carvalho de Melo | 08be4ee | 2012-04-03 21:35:35 -0300 | [diff] [blame] | 266 | continue; |
| 267 | |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 268 | --self->b.top_idx; |
| 269 | --back; |
| 270 | } |
| 271 | |
| 272 | self->b.top = pos; |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 273 | self->b.navkeypressed = true; |
Arnaldo Carvalho de Melo | b0ffb2c | 2012-04-03 15:32:45 -0300 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | static void annotate_browser__set_rb_top(struct annotate_browser *browser, |
| 277 | struct rb_node *nd) |
| 278 | { |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 279 | struct browser_disasm_line *bpos; |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 280 | struct disasm_line *pos; |
Arnaldo Carvalho de Melo | b0ffb2c | 2012-04-03 15:32:45 -0300 | [diff] [blame] | 281 | |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 282 | bpos = rb_entry(nd, struct browser_disasm_line, rb_node); |
| 283 | pos = ((struct disasm_line *)bpos) - 1; |
| 284 | annotate_browser__set_top(browser, pos, bpos->idx); |
Arnaldo Carvalho de Melo | b0ffb2c | 2012-04-03 15:32:45 -0300 | [diff] [blame] | 285 | browser->curr_hot = nd; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 286 | } |
| 287 | |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 288 | static void annotate_browser__calc_percent(struct annotate_browser *browser, |
| 289 | int evidx) |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 290 | { |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 291 | struct map_symbol *ms = browser->b.priv; |
| 292 | struct symbol *sym = ms->sym; |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 293 | struct annotation *notes = symbol__annotation(sym); |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 294 | struct disasm_line *pos; |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 295 | |
| 296 | browser->entries = RB_ROOT; |
| 297 | |
| 298 | pthread_mutex_lock(¬es->lock); |
| 299 | |
| 300 | list_for_each_entry(pos, ¬es->src->source, node) { |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 301 | struct browser_disasm_line *bpos = disasm_line__browser(pos); |
| 302 | bpos->percent = disasm_line__calc_percent(pos, sym, evidx); |
| 303 | if (bpos->percent < 0.01) { |
| 304 | RB_CLEAR_NODE(&bpos->rb_node); |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 305 | continue; |
| 306 | } |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 307 | disasm_rb_tree__insert(&browser->entries, bpos); |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 308 | } |
| 309 | pthread_mutex_unlock(¬es->lock); |
| 310 | |
| 311 | browser->curr_hot = rb_last(&browser->entries); |
| 312 | } |
| 313 | |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 314 | static bool annotate_browser__toggle_source(struct annotate_browser *browser) |
| 315 | { |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 316 | struct disasm_line *dl; |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 317 | struct browser_disasm_line *bdl; |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 318 | off_t offset = browser->b.index - browser->b.top_idx; |
| 319 | |
| 320 | browser->b.seek(&browser->b, offset, SEEK_CUR); |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 321 | dl = list_entry(browser->b.top, struct disasm_line, node); |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 322 | bdl = disasm_line__browser(dl); |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 323 | |
| 324 | if (browser->hide_src_code) { |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 325 | if (bdl->idx_asm < offset) |
| 326 | offset = bdl->idx; |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 327 | |
| 328 | browser->b.nr_entries = browser->nr_entries; |
| 329 | browser->hide_src_code = false; |
| 330 | browser->b.seek(&browser->b, -offset, SEEK_CUR); |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 331 | browser->b.top_idx = bdl->idx - offset; |
| 332 | browser->b.index = bdl->idx; |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 333 | } else { |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 334 | if (bdl->idx_asm < 0) { |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 335 | ui_helpline__puts("Only available for assembly lines."); |
| 336 | browser->b.seek(&browser->b, -offset, SEEK_CUR); |
| 337 | return false; |
| 338 | } |
| 339 | |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 340 | if (bdl->idx_asm < offset) |
| 341 | offset = bdl->idx_asm; |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 342 | |
| 343 | browser->b.nr_entries = browser->nr_asm_entries; |
| 344 | browser->hide_src_code = true; |
| 345 | browser->b.seek(&browser->b, -offset, SEEK_CUR); |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 346 | browser->b.top_idx = bdl->idx_asm - offset; |
| 347 | browser->b.index = bdl->idx_asm; |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | return true; |
| 351 | } |
| 352 | |
Arnaldo Carvalho de Melo | 6052170 | 2012-04-02 13:58:33 -0300 | [diff] [blame] | 353 | static bool annotate_browser__callq(struct annotate_browser *browser, |
| 354 | int evidx, void (*timer)(void *arg), |
| 355 | void *arg, int delay_secs) |
| 356 | { |
| 357 | struct map_symbol *ms = browser->b.priv; |
Arnaldo Carvalho de Melo | 657bcaf | 2012-04-15 20:12:07 -0300 | [diff] [blame] | 358 | struct disasm_line *dl = browser->selection; |
Arnaldo Carvalho de Melo | 6052170 | 2012-04-02 13:58:33 -0300 | [diff] [blame] | 359 | struct symbol *sym = ms->sym; |
| 360 | struct annotation *notes; |
| 361 | struct symbol *target; |
Arnaldo Carvalho de Melo | 6052170 | 2012-04-02 13:58:33 -0300 | [diff] [blame] | 362 | u64 ip; |
| 363 | |
Arnaldo Carvalho de Melo | d86b059 | 2012-04-18 16:07:38 -0300 | [diff] [blame] | 364 | if (!ins__is_call(dl->ins)) |
Arnaldo Carvalho de Melo | 6052170 | 2012-04-02 13:58:33 -0300 | [diff] [blame] | 365 | return false; |
| 366 | |
Arnaldo Carvalho de Melo | 44d1a3e | 2012-04-25 08:00:23 -0300 | [diff] [blame] | 367 | ip = ms->map->map_ip(ms->map, dl->ops.target.addr); |
Arnaldo Carvalho de Melo | 6052170 | 2012-04-02 13:58:33 -0300 | [diff] [blame] | 368 | target = map__find_symbol(ms->map, ip, NULL); |
| 369 | if (target == NULL) { |
| 370 | ui_helpline__puts("The called function was not found."); |
| 371 | return true; |
| 372 | } |
| 373 | |
| 374 | notes = symbol__annotation(target); |
| 375 | pthread_mutex_lock(¬es->lock); |
| 376 | |
| 377 | if (notes->src == NULL && symbol__alloc_hist(target) < 0) { |
| 378 | pthread_mutex_unlock(¬es->lock); |
| 379 | ui__warning("Not enough memory for annotating '%s' symbol!\n", |
| 380 | target->name); |
| 381 | return true; |
| 382 | } |
| 383 | |
| 384 | pthread_mutex_unlock(¬es->lock); |
| 385 | symbol__tui_annotate(target, ms->map, evidx, timer, arg, delay_secs); |
| 386 | ui_browser__show_title(&browser->b, sym->name); |
| 387 | return true; |
| 388 | } |
| 389 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 390 | static |
| 391 | struct disasm_line *annotate_browser__find_offset(struct annotate_browser *browser, |
| 392 | s64 offset, s64 *idx) |
Arnaldo Carvalho de Melo | 08be4ee | 2012-04-03 21:35:35 -0300 | [diff] [blame] | 393 | { |
| 394 | struct map_symbol *ms = browser->b.priv; |
| 395 | struct symbol *sym = ms->sym; |
| 396 | struct annotation *notes = symbol__annotation(sym); |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 397 | struct disasm_line *pos; |
Arnaldo Carvalho de Melo | 08be4ee | 2012-04-03 21:35:35 -0300 | [diff] [blame] | 398 | |
| 399 | *idx = 0; |
| 400 | list_for_each_entry(pos, ¬es->src->source, node) { |
| 401 | if (pos->offset == offset) |
| 402 | return pos; |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 403 | if (!disasm_line__filter(&browser->b, &pos->node)) |
Arnaldo Carvalho de Melo | 08be4ee | 2012-04-03 21:35:35 -0300 | [diff] [blame] | 404 | ++*idx; |
| 405 | } |
| 406 | |
| 407 | return NULL; |
| 408 | } |
| 409 | |
| 410 | static bool annotate_browser__jump(struct annotate_browser *browser) |
| 411 | { |
Arnaldo Carvalho de Melo | 657bcaf | 2012-04-15 20:12:07 -0300 | [diff] [blame] | 412 | struct disasm_line *dl = browser->selection; |
Arnaldo Carvalho de Melo | 4f9d032 | 2012-04-18 13:58:34 -0300 | [diff] [blame] | 413 | s64 idx; |
Arnaldo Carvalho de Melo | 08be4ee | 2012-04-03 21:35:35 -0300 | [diff] [blame] | 414 | |
Arnaldo Carvalho de Melo | d86b059 | 2012-04-18 16:07:38 -0300 | [diff] [blame] | 415 | if (!ins__is_jump(dl->ins)) |
Arnaldo Carvalho de Melo | 08be4ee | 2012-04-03 21:35:35 -0300 | [diff] [blame] | 416 | return false; |
| 417 | |
Arnaldo Carvalho de Melo | 44d1a3e | 2012-04-25 08:00:23 -0300 | [diff] [blame] | 418 | dl = annotate_browser__find_offset(browser, dl->ops.target.offset, &idx); |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 419 | if (dl == NULL) { |
Arnaldo Carvalho de Melo | 08be4ee | 2012-04-03 21:35:35 -0300 | [diff] [blame] | 420 | ui_helpline__puts("Invallid jump offset"); |
| 421 | return true; |
| 422 | } |
| 423 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 424 | annotate_browser__set_top(browser, dl, idx); |
Arnaldo Carvalho de Melo | 08be4ee | 2012-04-03 21:35:35 -0300 | [diff] [blame] | 425 | |
| 426 | return true; |
| 427 | } |
| 428 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 429 | static |
| 430 | struct disasm_line *annotate_browser__find_string(struct annotate_browser *browser, |
| 431 | char *s, s64 *idx) |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 432 | { |
| 433 | struct map_symbol *ms = browser->b.priv; |
| 434 | struct symbol *sym = ms->sym; |
| 435 | struct annotation *notes = symbol__annotation(sym); |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 436 | struct disasm_line *pos = browser->selection; |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 437 | |
| 438 | *idx = browser->b.index; |
| 439 | list_for_each_entry_continue(pos, ¬es->src->source, node) { |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 440 | if (disasm_line__filter(&browser->b, &pos->node)) |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 441 | continue; |
| 442 | |
| 443 | ++*idx; |
| 444 | |
| 445 | if (pos->line && strstr(pos->line, s) != NULL) |
| 446 | return pos; |
| 447 | } |
| 448 | |
| 449 | return NULL; |
| 450 | } |
| 451 | |
| 452 | static bool __annotate_browser__search(struct annotate_browser *browser) |
| 453 | { |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 454 | struct disasm_line *dl; |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 455 | s64 idx; |
| 456 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 457 | dl = annotate_browser__find_string(browser, browser->search_bf, &idx); |
| 458 | if (dl == NULL) { |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 459 | ui_helpline__puts("String not found!"); |
| 460 | return false; |
| 461 | } |
| 462 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 463 | annotate_browser__set_top(browser, dl, idx); |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 464 | browser->searching_backwards = false; |
| 465 | return true; |
| 466 | } |
| 467 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 468 | static |
| 469 | struct disasm_line *annotate_browser__find_string_reverse(struct annotate_browser *browser, |
| 470 | char *s, s64 *idx) |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 471 | { |
| 472 | struct map_symbol *ms = browser->b.priv; |
| 473 | struct symbol *sym = ms->sym; |
| 474 | struct annotation *notes = symbol__annotation(sym); |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 475 | struct disasm_line *pos = browser->selection; |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 476 | |
| 477 | *idx = browser->b.index; |
| 478 | list_for_each_entry_continue_reverse(pos, ¬es->src->source, node) { |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 479 | if (disasm_line__filter(&browser->b, &pos->node)) |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 480 | continue; |
| 481 | |
| 482 | --*idx; |
| 483 | |
| 484 | if (pos->line && strstr(pos->line, s) != NULL) |
| 485 | return pos; |
| 486 | } |
| 487 | |
| 488 | return NULL; |
| 489 | } |
| 490 | |
| 491 | static bool __annotate_browser__search_reverse(struct annotate_browser *browser) |
| 492 | { |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 493 | struct disasm_line *dl; |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 494 | s64 idx; |
| 495 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 496 | dl = annotate_browser__find_string_reverse(browser, browser->search_bf, &idx); |
| 497 | if (dl == NULL) { |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 498 | ui_helpline__puts("String not found!"); |
| 499 | return false; |
| 500 | } |
| 501 | |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 502 | annotate_browser__set_top(browser, dl, idx); |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 503 | browser->searching_backwards = true; |
| 504 | return true; |
| 505 | } |
| 506 | |
| 507 | static bool annotate_browser__search_window(struct annotate_browser *browser, |
| 508 | int delay_secs) |
| 509 | { |
| 510 | if (ui_browser__input_window("Search", "String: ", browser->search_bf, |
| 511 | "ENTER: OK, ESC: Cancel", |
| 512 | delay_secs * 2) != K_ENTER || |
| 513 | !*browser->search_bf) |
| 514 | return false; |
| 515 | |
| 516 | return true; |
| 517 | } |
| 518 | |
| 519 | static bool annotate_browser__search(struct annotate_browser *browser, int delay_secs) |
| 520 | { |
| 521 | if (annotate_browser__search_window(browser, delay_secs)) |
| 522 | return __annotate_browser__search(browser); |
| 523 | |
| 524 | return false; |
| 525 | } |
| 526 | |
| 527 | static bool annotate_browser__continue_search(struct annotate_browser *browser, |
| 528 | int delay_secs) |
| 529 | { |
| 530 | if (!*browser->search_bf) |
| 531 | return annotate_browser__search(browser, delay_secs); |
| 532 | |
| 533 | return __annotate_browser__search(browser); |
| 534 | } |
| 535 | |
| 536 | static bool annotate_browser__search_reverse(struct annotate_browser *browser, |
| 537 | int delay_secs) |
| 538 | { |
| 539 | if (annotate_browser__search_window(browser, delay_secs)) |
| 540 | return __annotate_browser__search_reverse(browser); |
| 541 | |
| 542 | return false; |
| 543 | } |
| 544 | |
| 545 | static |
| 546 | bool annotate_browser__continue_search_reverse(struct annotate_browser *browser, |
| 547 | int delay_secs) |
| 548 | { |
| 549 | if (!*browser->search_bf) |
| 550 | return annotate_browser__search_reverse(browser, delay_secs); |
| 551 | |
| 552 | return __annotate_browser__search_reverse(browser); |
| 553 | } |
| 554 | |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 555 | static int annotate_browser__run(struct annotate_browser *self, int evidx, |
Arnaldo Carvalho de Melo | d04b35f | 2011-11-11 22:17:32 -0200 | [diff] [blame] | 556 | void(*timer)(void *arg), |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 557 | void *arg, int delay_secs) |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 558 | { |
| 559 | struct rb_node *nd = NULL; |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 560 | struct map_symbol *ms = self->b.priv; |
| 561 | struct symbol *sym = ms->sym; |
Namhyung Kim | 824ac0e | 2012-02-23 17:46:23 +0900 | [diff] [blame] | 562 | const char *help = "<-/ESC: Exit, TAB/shift+TAB: Cycle hot lines, " |
| 563 | "H: Go to hottest line, ->/ENTER: Line action, " |
Arnaldo Carvalho de Melo | e235f3f | 2012-04-02 13:21:55 -0300 | [diff] [blame] | 564 | "O: Toggle offset view, " |
Namhyung Kim | 824ac0e | 2012-02-23 17:46:23 +0900 | [diff] [blame] | 565 | "S: Toggle source code view"; |
Arnaldo Carvalho de Melo | b50e003 | 2010-08-11 10:07:43 -0300 | [diff] [blame] | 566 | int key; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 567 | |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 568 | if (ui_browser__show(&self->b, sym->name, help) < 0) |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 569 | return -1; |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 570 | |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 571 | annotate_browser__calc_percent(self, evidx); |
| 572 | |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 573 | if (self->curr_hot) { |
Arnaldo Carvalho de Melo | b0ffb2c | 2012-04-03 15:32:45 -0300 | [diff] [blame] | 574 | annotate_browser__set_rb_top(self, self->curr_hot); |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 575 | self->b.navkeypressed = false; |
| 576 | } |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 577 | |
| 578 | nd = self->curr_hot; |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 579 | |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 580 | while (1) { |
Arnaldo Carvalho de Melo | 3af6e33 | 2011-10-13 08:52:46 -0300 | [diff] [blame] | 581 | key = ui_browser__run(&self->b, delay_secs); |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 582 | |
Arnaldo Carvalho de Melo | 81cce8d | 2011-10-05 19:11:32 -0300 | [diff] [blame] | 583 | if (delay_secs != 0) { |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 584 | annotate_browser__calc_percent(self, evidx); |
| 585 | /* |
| 586 | * Current line focus got out of the list of most active |
| 587 | * lines, NULL it so that if TAB|UNTAB is pressed, we |
| 588 | * move to curr_hot (current hottest line). |
| 589 | */ |
| 590 | if (nd != NULL && RB_EMPTY_NODE(nd)) |
| 591 | nd = NULL; |
| 592 | } |
| 593 | |
Arnaldo Carvalho de Melo | b50e003 | 2010-08-11 10:07:43 -0300 | [diff] [blame] | 594 | switch (key) { |
Arnaldo Carvalho de Melo | cf95800 | 2011-10-20 16:59:15 -0200 | [diff] [blame] | 595 | case K_TIMER: |
Arnaldo Carvalho de Melo | 81cce8d | 2011-10-05 19:11:32 -0300 | [diff] [blame] | 596 | if (timer != NULL) |
| 597 | timer(arg); |
| 598 | |
| 599 | if (delay_secs != 0) |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 600 | symbol__annotate_decay_histogram(sym, evidx); |
| 601 | continue; |
Arnaldo Carvalho de Melo | cf95800 | 2011-10-20 16:59:15 -0200 | [diff] [blame] | 602 | case K_TAB: |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 603 | if (nd != NULL) { |
| 604 | nd = rb_prev(nd); |
| 605 | if (nd == NULL) |
| 606 | nd = rb_last(&self->entries); |
| 607 | } else |
| 608 | nd = self->curr_hot; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 609 | break; |
Arnaldo Carvalho de Melo | cf95800 | 2011-10-20 16:59:15 -0200 | [diff] [blame] | 610 | case K_UNTAB: |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 611 | if (nd != NULL) |
| 612 | nd = rb_next(nd); |
| 613 | if (nd == NULL) |
| 614 | nd = rb_first(&self->entries); |
| 615 | else |
| 616 | nd = self->curr_hot; |
| 617 | break; |
| 618 | case 'H': |
Namhyung Kim | ef7c537 | 2012-02-23 17:46:21 +0900 | [diff] [blame] | 619 | case 'h': |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 620 | nd = self->curr_hot; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 621 | break; |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 622 | case 'S': |
Namhyung Kim | ef7c537 | 2012-02-23 17:46:21 +0900 | [diff] [blame] | 623 | case 's': |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 624 | if (annotate_browser__toggle_source(self)) |
| 625 | ui_helpline__puts(help); |
| 626 | continue; |
Arnaldo Carvalho de Melo | e235f3f | 2012-04-02 13:21:55 -0300 | [diff] [blame] | 627 | case 'O': |
| 628 | case 'o': |
| 629 | self->use_offset = !self->use_offset; |
| 630 | continue; |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 631 | case '/': |
| 632 | if (annotate_browser__search(self, delay_secs)) { |
| 633 | show_help: |
| 634 | ui_helpline__puts(help); |
| 635 | } |
| 636 | continue; |
| 637 | case 'n': |
| 638 | if (self->searching_backwards ? |
| 639 | annotate_browser__continue_search_reverse(self, delay_secs) : |
| 640 | annotate_browser__continue_search(self, delay_secs)) |
| 641 | goto show_help; |
| 642 | continue; |
| 643 | case '?': |
| 644 | if (annotate_browser__search_reverse(self, delay_secs)) |
| 645 | goto show_help; |
| 646 | continue; |
Arnaldo Carvalho de Melo | cf95800 | 2011-10-20 16:59:15 -0200 | [diff] [blame] | 647 | case K_ENTER: |
| 648 | case K_RIGHT: |
Arnaldo Carvalho de Melo | 6052170 | 2012-04-02 13:58:33 -0300 | [diff] [blame] | 649 | if (self->selection == NULL) |
Arnaldo Carvalho de Melo | 234a537 | 2011-10-06 09:45:29 -0300 | [diff] [blame] | 650 | ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org"); |
Arnaldo Carvalho de Melo | 6052170 | 2012-04-02 13:58:33 -0300 | [diff] [blame] | 651 | else if (self->selection->offset == -1) |
Arnaldo Carvalho de Melo | 234a537 | 2011-10-06 09:45:29 -0300 | [diff] [blame] | 652 | ui_helpline__puts("Actions are only available for assembly lines."); |
Arnaldo Carvalho de Melo | c4cceae | 2012-04-20 15:57:15 -0300 | [diff] [blame] | 653 | else if (!self->selection->ins) { |
| 654 | if (strcmp(self->selection->name, "retq")) |
| 655 | goto show_sup_ins; |
| 656 | goto out; |
| 657 | } else if (!(annotate_browser__jump(self) || |
| 658 | annotate_browser__callq(self, evidx, timer, arg, delay_secs))) { |
| 659 | show_sup_ins: |
| 660 | ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions."); |
| 661 | } |
Arnaldo Carvalho de Melo | fe46e64 | 2011-10-19 13:18:13 -0200 | [diff] [blame] | 662 | continue; |
Arnaldo Carvalho de Melo | cf95800 | 2011-10-20 16:59:15 -0200 | [diff] [blame] | 663 | case K_LEFT: |
| 664 | case K_ESC: |
Arnaldo Carvalho de Melo | ed7e566 | 2011-10-13 08:31:22 -0300 | [diff] [blame] | 665 | case 'q': |
| 666 | case CTRL('c'): |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 667 | goto out; |
Arnaldo Carvalho de Melo | ed7e566 | 2011-10-13 08:31:22 -0300 | [diff] [blame] | 668 | default: |
| 669 | continue; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 670 | } |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 671 | |
| 672 | if (nd != NULL) |
Arnaldo Carvalho de Melo | b0ffb2c | 2012-04-03 15:32:45 -0300 | [diff] [blame] | 673 | annotate_browser__set_rb_top(self, nd); |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 674 | } |
| 675 | out: |
Arnaldo Carvalho de Melo | 59e8fe3 | 2010-08-10 15:44:20 -0300 | [diff] [blame] | 676 | ui_browser__hide(&self->b); |
Arnaldo Carvalho de Melo | b50e003 | 2010-08-11 10:07:43 -0300 | [diff] [blame] | 677 | return key; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 678 | } |
| 679 | |
Arnaldo Carvalho de Melo | d04b35f | 2011-11-11 22:17:32 -0200 | [diff] [blame] | 680 | int hist_entry__tui_annotate(struct hist_entry *he, int evidx, |
Arnaldo Carvalho de Melo | 81cce8d | 2011-10-05 19:11:32 -0300 | [diff] [blame] | 681 | void(*timer)(void *arg), void *arg, int delay_secs) |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 682 | { |
Arnaldo Carvalho de Melo | d04b35f | 2011-11-11 22:17:32 -0200 | [diff] [blame] | 683 | return symbol__tui_annotate(he->ms.sym, he->ms.map, evidx, |
Arnaldo Carvalho de Melo | 81cce8d | 2011-10-05 19:11:32 -0300 | [diff] [blame] | 684 | timer, arg, delay_secs); |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 685 | } |
| 686 | |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 687 | static void annotate_browser__mark_jump_targets(struct annotate_browser *browser, |
| 688 | size_t size) |
| 689 | { |
| 690 | u64 offset; |
| 691 | |
| 692 | for (offset = 0; offset < size; ++offset) { |
| 693 | struct disasm_line *dl = browser->offsets[offset], *dlt; |
| 694 | struct browser_disasm_line *bdlt; |
| 695 | |
Arnaldo Carvalho de Melo | 38b31bd | 2012-04-25 14:18:42 -0300 | [diff] [blame] | 696 | if (!dl || !dl->ins || !ins__is_jump(dl->ins) || |
| 697 | !disasm_line__has_offset(dl)) |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 698 | continue; |
| 699 | |
Arnaldo Carvalho de Melo | 44d1a3e | 2012-04-25 08:00:23 -0300 | [diff] [blame] | 700 | if (dl->ops.target.offset >= size) { |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 701 | ui__error("jump to after symbol!\n" |
| 702 | "size: %zx, jump target: %" PRIx64, |
Arnaldo Carvalho de Melo | 44d1a3e | 2012-04-25 08:00:23 -0300 | [diff] [blame] | 703 | size, dl->ops.target.offset); |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 704 | continue; |
| 705 | } |
| 706 | |
Arnaldo Carvalho de Melo | 44d1a3e | 2012-04-25 08:00:23 -0300 | [diff] [blame] | 707 | dlt = browser->offsets[dl->ops.target.offset]; |
Arnaldo Carvalho de Melo | 9481ede | 2012-04-25 07:48:42 -0300 | [diff] [blame] | 708 | /* |
| 709 | * FIXME: Oops, no jump target? Buggy disassembler? Or do we |
| 710 | * have to adjust to the previous offset? |
| 711 | */ |
| 712 | if (dlt == NULL) |
| 713 | continue; |
| 714 | |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 715 | bdlt = disasm_line__browser(dlt); |
| 716 | bdlt->jump_target = true; |
| 717 | } |
| 718 | |
| 719 | } |
| 720 | |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 721 | int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, |
Arnaldo Carvalho de Melo | d04b35f | 2011-11-11 22:17:32 -0200 | [diff] [blame] | 722 | void(*timer)(void *arg), void *arg, |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 723 | int delay_secs) |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 724 | { |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 725 | struct disasm_line *pos, *n; |
Lin Ming | db9a9cbc | 2011-04-08 14:31:26 +0800 | [diff] [blame] | 726 | struct annotation *notes; |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 727 | const size_t size = symbol__size(sym); |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 728 | struct map_symbol ms = { |
| 729 | .map = map, |
| 730 | .sym = sym, |
| 731 | }; |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 732 | struct annotate_browser browser = { |
| 733 | .b = { |
Arnaldo Carvalho de Melo | a3f895b | 2012-04-24 14:24:28 -0300 | [diff] [blame] | 734 | .refresh = annotate_browser__refresh, |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 735 | .seek = ui_browser__list_head_seek, |
| 736 | .write = annotate_browser__write, |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 737 | .filter = disasm_line__filter, |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 738 | .priv = &ms, |
Arnaldo Carvalho de Melo | c172f74 | 2011-10-18 14:31:35 -0200 | [diff] [blame] | 739 | .use_navkeypressed = true, |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 740 | }, |
Arnaldo Carvalho de Melo | 8bf39cb | 2012-04-19 15:07:46 -0300 | [diff] [blame] | 741 | .use_offset = true, |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 742 | }; |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 743 | int ret = -1; |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 744 | |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 745 | if (sym == NULL) |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 746 | return -1; |
| 747 | |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 748 | if (map->dso->annotate_warned) |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 749 | return -1; |
| 750 | |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 751 | browser.offsets = zalloc(size * sizeof(struct disasm_line *)); |
| 752 | if (browser.offsets == NULL) { |
| 753 | ui__error("Not enough memory!"); |
| 754 | return -1; |
| 755 | } |
| 756 | |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 757 | if (symbol__annotate(sym, map, sizeof(struct browser_disasm_line)) < 0) { |
Arnaldo Carvalho de Melo | ae55795 | 2011-10-26 08:00:55 -0200 | [diff] [blame] | 758 | ui__error("%s", ui_helpline__last_msg); |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 759 | goto out_free_offsets; |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 760 | } |
| 761 | |
| 762 | ui_helpline__push("Press <- or ESC to exit"); |
| 763 | |
Lin Ming | db9a9cbc | 2011-04-08 14:31:26 +0800 | [diff] [blame] | 764 | notes = symbol__annotation(sym); |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 765 | browser.start = map__rip_2objdump(map, sym->start); |
Lin Ming | db9a9cbc | 2011-04-08 14:31:26 +0800 | [diff] [blame] | 766 | |
Arnaldo Carvalho de Melo | ce6f4fa | 2011-02-08 13:27:39 -0200 | [diff] [blame] | 767 | list_for_each_entry(pos, ¬es->src->source, node) { |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 768 | struct browser_disasm_line *bpos; |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 769 | size_t line_len = strlen(pos->line); |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 770 | |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 771 | if (browser.b.width < line_len) |
| 772 | browser.b.width = line_len; |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 773 | bpos = disasm_line__browser(pos); |
| 774 | bpos->idx = browser.nr_entries++; |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 775 | if (pos->offset != -1) { |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 776 | bpos->idx_asm = browser.nr_asm_entries++; |
Arnaldo Carvalho de Melo | 97148a9 | 2012-04-20 15:17:50 -0300 | [diff] [blame] | 777 | /* |
| 778 | * FIXME: short term bandaid to cope with assembly |
| 779 | * routines that comes with labels in the same column |
| 780 | * as the address in objdump, sigh. |
| 781 | * |
| 782 | * E.g. copy_user_generic_unrolled |
| 783 | */ |
| 784 | if (pos->offset < (s64)size) |
| 785 | browser.offsets[pos->offset] = pos; |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 786 | } else |
Arnaldo Carvalho de Melo | 887c006 | 2012-04-19 10:29:53 -0300 | [diff] [blame] | 787 | bpos->idx_asm = -1; |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 788 | } |
| 789 | |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 790 | annotate_browser__mark_jump_targets(&browser, size); |
| 791 | |
Arnaldo Carvalho de Melo | 61e04b3 | 2012-04-19 13:15:24 -0300 | [diff] [blame] | 792 | browser.offset_width = hex_width(size); |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 793 | browser.b.nr_entries = browser.nr_entries; |
Lin Ming | db9a9cbc | 2011-04-08 14:31:26 +0800 | [diff] [blame] | 794 | browser.b.entries = ¬es->src->source, |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 795 | browser.b.width += 18; /* Percentage */ |
Arnaldo Carvalho de Melo | d04b35f | 2011-11-11 22:17:32 -0200 | [diff] [blame] | 796 | ret = annotate_browser__run(&browser, evidx, timer, arg, delay_secs); |
Arnaldo Carvalho de Melo | ce6f4fa | 2011-02-08 13:27:39 -0200 | [diff] [blame] | 797 | list_for_each_entry_safe(pos, n, ¬es->src->source, node) { |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 798 | list_del(&pos->node); |
Arnaldo Carvalho de Melo | 29ed6e7 | 2012-04-15 15:24:39 -0300 | [diff] [blame] | 799 | disasm_line__free(pos); |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 800 | } |
Arnaldo Carvalho de Melo | b793a40 | 2012-04-19 12:19:22 -0300 | [diff] [blame] | 801 | |
| 802 | out_free_offsets: |
| 803 | free(browser.offsets); |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 804 | return ret; |
| 805 | } |