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 | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 14 | struct annotate_browser { |
| 15 | struct ui_browser b; |
| 16 | struct rb_root entries; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 17 | struct rb_node *curr_hot; |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 18 | struct objdump_line *selection; |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 19 | u64 start; |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 20 | int nr_asm_entries; |
| 21 | int nr_entries; |
| 22 | bool hide_src_code; |
Arnaldo Carvalho de Melo | e235f3f | 2012-04-02 13:21:55 -0300 | [diff] [blame] | 23 | bool use_offset; |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 24 | bool searching_backwards; |
| 25 | char search_bf[128]; |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 26 | }; |
| 27 | |
| 28 | struct objdump_line_rb_node { |
| 29 | struct rb_node rb_node; |
| 30 | double percent; |
| 31 | u32 idx; |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 32 | int idx_asm; |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | static inline |
| 36 | struct objdump_line_rb_node *objdump_line__rb(struct objdump_line *self) |
| 37 | { |
| 38 | return (struct objdump_line_rb_node *)(self + 1); |
| 39 | } |
| 40 | |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 41 | static bool objdump_line__filter(struct ui_browser *browser, void *entry) |
| 42 | { |
| 43 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); |
| 44 | |
| 45 | if (ab->hide_src_code) { |
| 46 | struct objdump_line *ol = list_entry(entry, struct objdump_line, node); |
| 47 | return ol->offset == -1; |
| 48 | } |
| 49 | |
| 50 | return false; |
| 51 | } |
| 52 | |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 53 | static void annotate_browser__write(struct ui_browser *self, void *entry, int row) |
| 54 | { |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 55 | struct annotate_browser *ab = container_of(self, struct annotate_browser, b); |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 56 | struct objdump_line *ol = list_entry(entry, struct objdump_line, node); |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 57 | bool current_entry = ui_browser__is_current_entry(self, row); |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 58 | bool change_color = (!ab->hide_src_code && |
| 59 | (!current_entry || (self->use_navkeypressed && |
| 60 | !self->navkeypressed))); |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 61 | int width = self->width; |
| 62 | |
| 63 | if (ol->offset != -1) { |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 64 | struct objdump_line_rb_node *olrb = objdump_line__rb(ol); |
Arnaldo Carvalho de Melo | 8f9bbc4 | 2010-08-11 14:51:47 -0300 | [diff] [blame] | 65 | ui_browser__set_percent_color(self, olrb->percent, current_entry); |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 66 | slsmg_printf(" %7.2f ", olrb->percent); |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 67 | } else { |
Arnaldo Carvalho de Melo | 8f9bbc4 | 2010-08-11 14:51:47 -0300 | [diff] [blame] | 68 | ui_browser__set_percent_color(self, 0, current_entry); |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 69 | slsmg_write_nstring(" ", 9); |
| 70 | } |
| 71 | |
| 72 | SLsmg_write_char(':'); |
| 73 | slsmg_write_nstring(" ", 8); |
Arnaldo Carvalho de Melo | c172f74 | 2011-10-18 14:31:35 -0200 | [diff] [blame] | 74 | |
| 75 | /* The scroll bar isn't being used */ |
| 76 | if (!self->navkeypressed) |
| 77 | width += 1; |
| 78 | |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 79 | if (ol->offset != -1 && change_color) |
| 80 | ui_browser__set_color(self, HE_COLORSET_CODE); |
Namhyung Kim | 58e817d | 2012-02-23 17:46:20 +0900 | [diff] [blame] | 81 | |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 82 | if (!*ol->line) |
| 83 | slsmg_write_nstring(" ", width - 18); |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 84 | else if (ol->offset == -1) |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 85 | slsmg_write_nstring(ol->line, width - 18); |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 86 | else { |
| 87 | char bf[64]; |
Arnaldo Carvalho de Melo | e235f3f | 2012-04-02 13:21:55 -0300 | [diff] [blame] | 88 | u64 addr = ol->offset; |
| 89 | int printed, color = -1; |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 90 | |
Arnaldo Carvalho de Melo | e235f3f | 2012-04-02 13:21:55 -0300 | [diff] [blame] | 91 | if (!ab->use_offset) |
| 92 | addr += ab->start; |
| 93 | |
| 94 | printed = scnprintf(bf, sizeof(bf), " %" PRIx64 ":", addr); |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 95 | if (change_color) |
| 96 | color = ui_browser__set_color(self, HE_COLORSET_ADDR); |
| 97 | slsmg_write_nstring(bf, printed); |
| 98 | if (change_color) |
| 99 | ui_browser__set_color(self, color); |
| 100 | slsmg_write_nstring(ol->line, width - 18 - printed); |
| 101 | } |
Arnaldo Carvalho de Melo | b99976e | 2011-02-09 13:59:14 -0200 | [diff] [blame] | 102 | |
Namhyung Kim | 58e817d | 2012-02-23 17:46:20 +0900 | [diff] [blame] | 103 | if (current_entry) |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 104 | ab->selection = ol; |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 105 | } |
| 106 | |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 107 | static double objdump_line__calc_percent(struct objdump_line *self, |
Arnaldo Carvalho de Melo | 2f525d0 | 2011-02-04 13:43:24 -0200 | [diff] [blame] | 108 | struct symbol *sym, int evidx) |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 109 | { |
| 110 | double percent = 0.0; |
| 111 | |
| 112 | if (self->offset != -1) { |
| 113 | int len = sym->end - sym->start; |
| 114 | unsigned int hits = 0; |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 115 | struct annotation *notes = symbol__annotation(sym); |
Arnaldo Carvalho de Melo | ce6f4fa | 2011-02-08 13:27:39 -0200 | [diff] [blame] | 116 | struct source_line *src_line = notes->src->lines; |
Arnaldo Carvalho de Melo | 2f525d0 | 2011-02-04 13:43:24 -0200 | [diff] [blame] | 117 | struct sym_hist *h = annotation__histogram(notes, evidx); |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 118 | s64 offset = self->offset; |
Arnaldo Carvalho de Melo | ce6f4fa | 2011-02-08 13:27:39 -0200 | [diff] [blame] | 119 | struct objdump_line *next; |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 120 | |
Arnaldo Carvalho de Melo | ce6f4fa | 2011-02-08 13:27:39 -0200 | [diff] [blame] | 121 | next = objdump__get_next_ip_line(¬es->src->source, self); |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 122 | while (offset < (s64)len && |
| 123 | (next == NULL || offset < next->offset)) { |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 124 | if (src_line) { |
| 125 | percent += src_line[offset].percent; |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 126 | } else |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 127 | hits += h->addr[offset]; |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 128 | |
| 129 | ++offset; |
| 130 | } |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 131 | /* |
| 132 | * If the percentage wasn't already calculated in |
| 133 | * symbol__get_source_line, do it now: |
| 134 | */ |
| 135 | if (src_line == NULL && h->sum) |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 136 | percent = 100.0 * hits / h->sum; |
| 137 | } |
| 138 | |
| 139 | return percent; |
| 140 | } |
| 141 | |
| 142 | static void objdump__insert_line(struct rb_root *self, |
| 143 | struct objdump_line_rb_node *line) |
| 144 | { |
| 145 | struct rb_node **p = &self->rb_node; |
| 146 | struct rb_node *parent = NULL; |
| 147 | struct objdump_line_rb_node *l; |
| 148 | |
| 149 | while (*p != NULL) { |
| 150 | parent = *p; |
| 151 | l = rb_entry(parent, struct objdump_line_rb_node, rb_node); |
| 152 | if (line->percent < l->percent) |
| 153 | p = &(*p)->rb_left; |
| 154 | else |
| 155 | p = &(*p)->rb_right; |
| 156 | } |
| 157 | rb_link_node(&line->rb_node, parent, p); |
| 158 | rb_insert_color(&line->rb_node, self); |
| 159 | } |
| 160 | |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 161 | static void annotate_browser__set_top(struct annotate_browser *self, |
Arnaldo Carvalho de Melo | b0ffb2c | 2012-04-03 15:32:45 -0300 | [diff] [blame] | 162 | struct objdump_line *pos, u32 idx) |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 163 | { |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 164 | unsigned back; |
| 165 | |
| 166 | ui_browser__refresh_dimensions(&self->b); |
| 167 | back = self->b.height / 2; |
Arnaldo Carvalho de Melo | b0ffb2c | 2012-04-03 15:32:45 -0300 | [diff] [blame] | 168 | self->b.top_idx = self->b.index = idx; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 169 | |
| 170 | while (self->b.top_idx != 0 && back != 0) { |
| 171 | pos = list_entry(pos->node.prev, struct objdump_line, node); |
| 172 | |
Arnaldo Carvalho de Melo | 08be4ee | 2012-04-03 21:35:35 -0300 | [diff] [blame] | 173 | if (objdump_line__filter(&self->b, &pos->node)) |
| 174 | continue; |
| 175 | |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 176 | --self->b.top_idx; |
| 177 | --back; |
| 178 | } |
| 179 | |
| 180 | self->b.top = pos; |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 181 | self->b.navkeypressed = true; |
Arnaldo Carvalho de Melo | b0ffb2c | 2012-04-03 15:32:45 -0300 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | static void annotate_browser__set_rb_top(struct annotate_browser *browser, |
| 185 | struct rb_node *nd) |
| 186 | { |
| 187 | struct objdump_line_rb_node *rbpos; |
| 188 | struct objdump_line *pos; |
| 189 | |
| 190 | rbpos = rb_entry(nd, struct objdump_line_rb_node, rb_node); |
| 191 | pos = ((struct objdump_line *)rbpos) - 1; |
| 192 | annotate_browser__set_top(browser, pos, rbpos->idx); |
| 193 | browser->curr_hot = nd; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 194 | } |
| 195 | |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 196 | static void annotate_browser__calc_percent(struct annotate_browser *browser, |
| 197 | int evidx) |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 198 | { |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 199 | struct map_symbol *ms = browser->b.priv; |
| 200 | struct symbol *sym = ms->sym; |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 201 | struct annotation *notes = symbol__annotation(sym); |
| 202 | struct objdump_line *pos; |
| 203 | |
| 204 | browser->entries = RB_ROOT; |
| 205 | |
| 206 | pthread_mutex_lock(¬es->lock); |
| 207 | |
| 208 | list_for_each_entry(pos, ¬es->src->source, node) { |
| 209 | struct objdump_line_rb_node *rbpos = objdump_line__rb(pos); |
| 210 | rbpos->percent = objdump_line__calc_percent(pos, sym, evidx); |
| 211 | if (rbpos->percent < 0.01) { |
| 212 | RB_CLEAR_NODE(&rbpos->rb_node); |
| 213 | continue; |
| 214 | } |
| 215 | objdump__insert_line(&browser->entries, rbpos); |
| 216 | } |
| 217 | pthread_mutex_unlock(¬es->lock); |
| 218 | |
| 219 | browser->curr_hot = rb_last(&browser->entries); |
| 220 | } |
| 221 | |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 222 | static bool annotate_browser__toggle_source(struct annotate_browser *browser) |
| 223 | { |
| 224 | struct objdump_line *ol; |
| 225 | struct objdump_line_rb_node *olrb; |
| 226 | off_t offset = browser->b.index - browser->b.top_idx; |
| 227 | |
| 228 | browser->b.seek(&browser->b, offset, SEEK_CUR); |
| 229 | ol = list_entry(browser->b.top, struct objdump_line, node); |
| 230 | olrb = objdump_line__rb(ol); |
| 231 | |
| 232 | if (browser->hide_src_code) { |
| 233 | if (olrb->idx_asm < offset) |
| 234 | offset = olrb->idx; |
| 235 | |
| 236 | browser->b.nr_entries = browser->nr_entries; |
| 237 | browser->hide_src_code = false; |
| 238 | browser->b.seek(&browser->b, -offset, SEEK_CUR); |
| 239 | browser->b.top_idx = olrb->idx - offset; |
| 240 | browser->b.index = olrb->idx; |
| 241 | } else { |
| 242 | if (olrb->idx_asm < 0) { |
| 243 | ui_helpline__puts("Only available for assembly lines."); |
| 244 | browser->b.seek(&browser->b, -offset, SEEK_CUR); |
| 245 | return false; |
| 246 | } |
| 247 | |
| 248 | if (olrb->idx_asm < offset) |
| 249 | offset = olrb->idx_asm; |
| 250 | |
| 251 | browser->b.nr_entries = browser->nr_asm_entries; |
| 252 | browser->hide_src_code = true; |
| 253 | browser->b.seek(&browser->b, -offset, SEEK_CUR); |
| 254 | browser->b.top_idx = olrb->idx_asm - offset; |
| 255 | browser->b.index = olrb->idx_asm; |
| 256 | } |
| 257 | |
| 258 | return true; |
| 259 | } |
| 260 | |
Arnaldo Carvalho de Melo | 6052170 | 2012-04-02 13:58:33 -0300 | [diff] [blame] | 261 | static bool annotate_browser__callq(struct annotate_browser *browser, |
| 262 | int evidx, void (*timer)(void *arg), |
| 263 | void *arg, int delay_secs) |
| 264 | { |
| 265 | struct map_symbol *ms = browser->b.priv; |
| 266 | struct symbol *sym = ms->sym; |
| 267 | struct annotation *notes; |
| 268 | struct symbol *target; |
| 269 | char *s = strstr(browser->selection->line, "callq "); |
| 270 | u64 ip; |
| 271 | |
| 272 | if (s == NULL) |
| 273 | return false; |
| 274 | |
| 275 | s = strchr(s, ' '); |
| 276 | if (s++ == NULL) { |
| 277 | ui_helpline__puts("Invallid callq instruction."); |
| 278 | return true; |
| 279 | } |
| 280 | |
| 281 | ip = strtoull(s, NULL, 16); |
| 282 | ip = ms->map->map_ip(ms->map, ip); |
| 283 | target = map__find_symbol(ms->map, ip, NULL); |
| 284 | if (target == NULL) { |
| 285 | ui_helpline__puts("The called function was not found."); |
| 286 | return true; |
| 287 | } |
| 288 | |
| 289 | notes = symbol__annotation(target); |
| 290 | pthread_mutex_lock(¬es->lock); |
| 291 | |
| 292 | if (notes->src == NULL && symbol__alloc_hist(target) < 0) { |
| 293 | pthread_mutex_unlock(¬es->lock); |
| 294 | ui__warning("Not enough memory for annotating '%s' symbol!\n", |
| 295 | target->name); |
| 296 | return true; |
| 297 | } |
| 298 | |
| 299 | pthread_mutex_unlock(¬es->lock); |
| 300 | symbol__tui_annotate(target, ms->map, evidx, timer, arg, delay_secs); |
| 301 | ui_browser__show_title(&browser->b, sym->name); |
| 302 | return true; |
| 303 | } |
| 304 | |
Arnaldo Carvalho de Melo | 08be4ee | 2012-04-03 21:35:35 -0300 | [diff] [blame] | 305 | static struct objdump_line * |
| 306 | annotate_browser__find_offset(struct annotate_browser *browser, |
| 307 | s64 offset, s64 *idx) |
| 308 | { |
| 309 | struct map_symbol *ms = browser->b.priv; |
| 310 | struct symbol *sym = ms->sym; |
| 311 | struct annotation *notes = symbol__annotation(sym); |
| 312 | struct objdump_line *pos; |
| 313 | |
| 314 | *idx = 0; |
| 315 | list_for_each_entry(pos, ¬es->src->source, node) { |
| 316 | if (pos->offset == offset) |
| 317 | return pos; |
| 318 | if (!objdump_line__filter(&browser->b, &pos->node)) |
| 319 | ++*idx; |
| 320 | } |
| 321 | |
| 322 | return NULL; |
| 323 | } |
| 324 | |
| 325 | static bool annotate_browser__jump(struct annotate_browser *browser) |
| 326 | { |
| 327 | const char *jumps[] = { "je ", "jne ", "ja ", "jmpq ", "js ", "jmp ", NULL }; |
| 328 | struct objdump_line *line; |
| 329 | s64 idx, offset; |
| 330 | char *s = NULL; |
| 331 | int i = 0; |
| 332 | |
| 333 | while (jumps[i]) { |
| 334 | s = strstr(browser->selection->line, jumps[i++]); |
| 335 | if (s) |
| 336 | break; |
| 337 | } |
| 338 | |
| 339 | if (s == NULL) |
| 340 | return false; |
| 341 | |
| 342 | s = strchr(s, '+'); |
| 343 | if (s++ == NULL) { |
| 344 | ui_helpline__puts("Invallid jump instruction."); |
| 345 | return true; |
| 346 | } |
| 347 | |
| 348 | offset = strtoll(s, NULL, 16); |
| 349 | line = annotate_browser__find_offset(browser, offset, &idx); |
| 350 | if (line == NULL) { |
| 351 | ui_helpline__puts("Invallid jump offset"); |
| 352 | return true; |
| 353 | } |
| 354 | |
| 355 | annotate_browser__set_top(browser, line, idx); |
| 356 | |
| 357 | return true; |
| 358 | } |
| 359 | |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 360 | static struct objdump_line * |
| 361 | annotate_browser__find_string(struct annotate_browser *browser, |
| 362 | char *s, s64 *idx) |
| 363 | { |
| 364 | struct map_symbol *ms = browser->b.priv; |
| 365 | struct symbol *sym = ms->sym; |
| 366 | struct annotation *notes = symbol__annotation(sym); |
| 367 | struct objdump_line *pos = browser->selection; |
| 368 | |
| 369 | *idx = browser->b.index; |
| 370 | list_for_each_entry_continue(pos, ¬es->src->source, node) { |
| 371 | if (objdump_line__filter(&browser->b, &pos->node)) |
| 372 | continue; |
| 373 | |
| 374 | ++*idx; |
| 375 | |
| 376 | if (pos->line && strstr(pos->line, s) != NULL) |
| 377 | return pos; |
| 378 | } |
| 379 | |
| 380 | return NULL; |
| 381 | } |
| 382 | |
| 383 | static bool __annotate_browser__search(struct annotate_browser *browser) |
| 384 | { |
| 385 | struct objdump_line *line; |
| 386 | s64 idx; |
| 387 | |
| 388 | line = annotate_browser__find_string(browser, browser->search_bf, &idx); |
| 389 | if (line == NULL) { |
| 390 | ui_helpline__puts("String not found!"); |
| 391 | return false; |
| 392 | } |
| 393 | |
| 394 | annotate_browser__set_top(browser, line, idx); |
| 395 | browser->searching_backwards = false; |
| 396 | return true; |
| 397 | } |
| 398 | |
| 399 | static struct objdump_line * |
| 400 | annotate_browser__find_string_reverse(struct annotate_browser *browser, |
| 401 | char *s, s64 *idx) |
| 402 | { |
| 403 | struct map_symbol *ms = browser->b.priv; |
| 404 | struct symbol *sym = ms->sym; |
| 405 | struct annotation *notes = symbol__annotation(sym); |
| 406 | struct objdump_line *pos = browser->selection; |
| 407 | |
| 408 | *idx = browser->b.index; |
| 409 | list_for_each_entry_continue_reverse(pos, ¬es->src->source, node) { |
| 410 | if (objdump_line__filter(&browser->b, &pos->node)) |
| 411 | continue; |
| 412 | |
| 413 | --*idx; |
| 414 | |
| 415 | if (pos->line && strstr(pos->line, s) != NULL) |
| 416 | return pos; |
| 417 | } |
| 418 | |
| 419 | return NULL; |
| 420 | } |
| 421 | |
| 422 | static bool __annotate_browser__search_reverse(struct annotate_browser *browser) |
| 423 | { |
| 424 | struct objdump_line *line; |
| 425 | s64 idx; |
| 426 | |
| 427 | line = annotate_browser__find_string_reverse(browser, browser->search_bf, &idx); |
| 428 | if (line == NULL) { |
| 429 | ui_helpline__puts("String not found!"); |
| 430 | return false; |
| 431 | } |
| 432 | |
| 433 | annotate_browser__set_top(browser, line, idx); |
| 434 | browser->searching_backwards = true; |
| 435 | return true; |
| 436 | } |
| 437 | |
| 438 | static bool annotate_browser__search_window(struct annotate_browser *browser, |
| 439 | int delay_secs) |
| 440 | { |
| 441 | if (ui_browser__input_window("Search", "String: ", browser->search_bf, |
| 442 | "ENTER: OK, ESC: Cancel", |
| 443 | delay_secs * 2) != K_ENTER || |
| 444 | !*browser->search_bf) |
| 445 | return false; |
| 446 | |
| 447 | return true; |
| 448 | } |
| 449 | |
| 450 | static bool annotate_browser__search(struct annotate_browser *browser, int delay_secs) |
| 451 | { |
| 452 | if (annotate_browser__search_window(browser, delay_secs)) |
| 453 | return __annotate_browser__search(browser); |
| 454 | |
| 455 | return false; |
| 456 | } |
| 457 | |
| 458 | static bool annotate_browser__continue_search(struct annotate_browser *browser, |
| 459 | int delay_secs) |
| 460 | { |
| 461 | if (!*browser->search_bf) |
| 462 | return annotate_browser__search(browser, delay_secs); |
| 463 | |
| 464 | return __annotate_browser__search(browser); |
| 465 | } |
| 466 | |
| 467 | static bool annotate_browser__search_reverse(struct annotate_browser *browser, |
| 468 | int delay_secs) |
| 469 | { |
| 470 | if (annotate_browser__search_window(browser, delay_secs)) |
| 471 | return __annotate_browser__search_reverse(browser); |
| 472 | |
| 473 | return false; |
| 474 | } |
| 475 | |
| 476 | static |
| 477 | bool annotate_browser__continue_search_reverse(struct annotate_browser *browser, |
| 478 | int delay_secs) |
| 479 | { |
| 480 | if (!*browser->search_bf) |
| 481 | return annotate_browser__search_reverse(browser, delay_secs); |
| 482 | |
| 483 | return __annotate_browser__search_reverse(browser); |
| 484 | } |
| 485 | |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 486 | 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] | 487 | void(*timer)(void *arg), |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 488 | void *arg, int delay_secs) |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 489 | { |
| 490 | struct rb_node *nd = NULL; |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 491 | struct map_symbol *ms = self->b.priv; |
| 492 | struct symbol *sym = ms->sym; |
Namhyung Kim | 824ac0e | 2012-02-23 17:46:23 +0900 | [diff] [blame] | 493 | const char *help = "<-/ESC: Exit, TAB/shift+TAB: Cycle hot lines, " |
| 494 | "H: Go to hottest line, ->/ENTER: Line action, " |
Arnaldo Carvalho de Melo | e235f3f | 2012-04-02 13:21:55 -0300 | [diff] [blame] | 495 | "O: Toggle offset view, " |
Namhyung Kim | 824ac0e | 2012-02-23 17:46:23 +0900 | [diff] [blame] | 496 | "S: Toggle source code view"; |
Arnaldo Carvalho de Melo | b50e003 | 2010-08-11 10:07:43 -0300 | [diff] [blame] | 497 | int key; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 498 | |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 499 | if (ui_browser__show(&self->b, sym->name, help) < 0) |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 500 | return -1; |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 501 | |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 502 | annotate_browser__calc_percent(self, evidx); |
| 503 | |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 504 | if (self->curr_hot) { |
Arnaldo Carvalho de Melo | b0ffb2c | 2012-04-03 15:32:45 -0300 | [diff] [blame] | 505 | annotate_browser__set_rb_top(self, self->curr_hot); |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 506 | self->b.navkeypressed = false; |
| 507 | } |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 508 | |
| 509 | nd = self->curr_hot; |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 510 | |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 511 | while (1) { |
Arnaldo Carvalho de Melo | 3af6e33 | 2011-10-13 08:52:46 -0300 | [diff] [blame] | 512 | key = ui_browser__run(&self->b, delay_secs); |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 513 | |
Arnaldo Carvalho de Melo | 81cce8d | 2011-10-05 19:11:32 -0300 | [diff] [blame] | 514 | if (delay_secs != 0) { |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 515 | annotate_browser__calc_percent(self, evidx); |
| 516 | /* |
| 517 | * Current line focus got out of the list of most active |
| 518 | * lines, NULL it so that if TAB|UNTAB is pressed, we |
| 519 | * move to curr_hot (current hottest line). |
| 520 | */ |
| 521 | if (nd != NULL && RB_EMPTY_NODE(nd)) |
| 522 | nd = NULL; |
| 523 | } |
| 524 | |
Arnaldo Carvalho de Melo | b50e003 | 2010-08-11 10:07:43 -0300 | [diff] [blame] | 525 | switch (key) { |
Arnaldo Carvalho de Melo | cf95800 | 2011-10-20 16:59:15 -0200 | [diff] [blame] | 526 | case K_TIMER: |
Arnaldo Carvalho de Melo | 81cce8d | 2011-10-05 19:11:32 -0300 | [diff] [blame] | 527 | if (timer != NULL) |
| 528 | timer(arg); |
| 529 | |
| 530 | if (delay_secs != 0) |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 531 | symbol__annotate_decay_histogram(sym, evidx); |
| 532 | continue; |
Arnaldo Carvalho de Melo | cf95800 | 2011-10-20 16:59:15 -0200 | [diff] [blame] | 533 | case K_TAB: |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 534 | if (nd != NULL) { |
| 535 | nd = rb_prev(nd); |
| 536 | if (nd == NULL) |
| 537 | nd = rb_last(&self->entries); |
| 538 | } else |
| 539 | nd = self->curr_hot; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 540 | break; |
Arnaldo Carvalho de Melo | cf95800 | 2011-10-20 16:59:15 -0200 | [diff] [blame] | 541 | case K_UNTAB: |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 542 | if (nd != NULL) |
| 543 | nd = rb_next(nd); |
| 544 | if (nd == NULL) |
| 545 | nd = rb_first(&self->entries); |
| 546 | else |
| 547 | nd = self->curr_hot; |
| 548 | break; |
| 549 | case 'H': |
Namhyung Kim | ef7c537 | 2012-02-23 17:46:21 +0900 | [diff] [blame] | 550 | case 'h': |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 551 | nd = self->curr_hot; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 552 | break; |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 553 | case 'S': |
Namhyung Kim | ef7c537 | 2012-02-23 17:46:21 +0900 | [diff] [blame] | 554 | case 's': |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 555 | if (annotate_browser__toggle_source(self)) |
| 556 | ui_helpline__puts(help); |
| 557 | continue; |
Arnaldo Carvalho de Melo | e235f3f | 2012-04-02 13:21:55 -0300 | [diff] [blame] | 558 | case 'O': |
| 559 | case 'o': |
| 560 | self->use_offset = !self->use_offset; |
| 561 | continue; |
Arnaldo Carvalho de Melo | d3d1f61 | 2012-04-07 17:10:30 -0300 | [diff] [blame] | 562 | case '/': |
| 563 | if (annotate_browser__search(self, delay_secs)) { |
| 564 | show_help: |
| 565 | ui_helpline__puts(help); |
| 566 | } |
| 567 | continue; |
| 568 | case 'n': |
| 569 | if (self->searching_backwards ? |
| 570 | annotate_browser__continue_search_reverse(self, delay_secs) : |
| 571 | annotate_browser__continue_search(self, delay_secs)) |
| 572 | goto show_help; |
| 573 | continue; |
| 574 | case '?': |
| 575 | if (annotate_browser__search_reverse(self, delay_secs)) |
| 576 | goto show_help; |
| 577 | continue; |
Arnaldo Carvalho de Melo | cf95800 | 2011-10-20 16:59:15 -0200 | [diff] [blame] | 578 | case K_ENTER: |
| 579 | case K_RIGHT: |
Arnaldo Carvalho de Melo | 6052170 | 2012-04-02 13:58:33 -0300 | [diff] [blame] | 580 | if (self->selection == NULL) |
Arnaldo Carvalho de Melo | 234a537 | 2011-10-06 09:45:29 -0300 | [diff] [blame] | 581 | 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] | 582 | else if (self->selection->offset == -1) |
Arnaldo Carvalho de Melo | 234a537 | 2011-10-06 09:45:29 -0300 | [diff] [blame] | 583 | ui_helpline__puts("Actions are only available for assembly lines."); |
Arnaldo Carvalho de Melo | 08be4ee | 2012-04-03 21:35:35 -0300 | [diff] [blame] | 584 | else if (!(annotate_browser__jump(self) || |
| 585 | annotate_browser__callq(self, evidx, timer, arg, delay_secs))) |
| 586 | ui_helpline__puts("Actions are only available for the 'callq' and jump instructions."); |
Arnaldo Carvalho de Melo | fe46e64 | 2011-10-19 13:18:13 -0200 | [diff] [blame] | 587 | continue; |
Arnaldo Carvalho de Melo | cf95800 | 2011-10-20 16:59:15 -0200 | [diff] [blame] | 588 | case K_LEFT: |
| 589 | case K_ESC: |
Arnaldo Carvalho de Melo | ed7e566 | 2011-10-13 08:31:22 -0300 | [diff] [blame] | 590 | case 'q': |
| 591 | case CTRL('c'): |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 592 | goto out; |
Arnaldo Carvalho de Melo | ed7e566 | 2011-10-13 08:31:22 -0300 | [diff] [blame] | 593 | default: |
| 594 | continue; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 595 | } |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 596 | |
| 597 | if (nd != NULL) |
Arnaldo Carvalho de Melo | b0ffb2c | 2012-04-03 15:32:45 -0300 | [diff] [blame] | 598 | annotate_browser__set_rb_top(self, nd); |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 599 | } |
| 600 | out: |
Arnaldo Carvalho de Melo | 59e8fe3 | 2010-08-10 15:44:20 -0300 | [diff] [blame] | 601 | ui_browser__hide(&self->b); |
Arnaldo Carvalho de Melo | b50e003 | 2010-08-11 10:07:43 -0300 | [diff] [blame] | 602 | return key; |
Arnaldo Carvalho de Melo | f1e9214 | 2010-08-10 15:14:53 -0300 | [diff] [blame] | 603 | } |
| 604 | |
Arnaldo Carvalho de Melo | d04b35f | 2011-11-11 22:17:32 -0200 | [diff] [blame] | 605 | 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] | 606 | void(*timer)(void *arg), void *arg, int delay_secs) |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 607 | { |
Arnaldo Carvalho de Melo | d04b35f | 2011-11-11 22:17:32 -0200 | [diff] [blame] | 608 | 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] | 609 | timer, arg, delay_secs); |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 610 | } |
| 611 | |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 612 | 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] | 613 | void(*timer)(void *arg), void *arg, |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 614 | int delay_secs) |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 615 | { |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 616 | struct objdump_line *pos, *n; |
Lin Ming | db9a9cbc | 2011-04-08 14:31:26 +0800 | [diff] [blame] | 617 | struct annotation *notes; |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 618 | struct map_symbol ms = { |
| 619 | .map = map, |
| 620 | .sym = sym, |
| 621 | }; |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 622 | struct annotate_browser browser = { |
| 623 | .b = { |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 624 | .refresh = ui_browser__list_head_refresh, |
| 625 | .seek = ui_browser__list_head_seek, |
| 626 | .write = annotate_browser__write, |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 627 | .filter = objdump_line__filter, |
Arnaldo Carvalho de Melo | 3495854 | 2011-10-05 19:35:54 -0300 | [diff] [blame] | 628 | .priv = &ms, |
Arnaldo Carvalho de Melo | c172f74 | 2011-10-18 14:31:35 -0200 | [diff] [blame] | 629 | .use_navkeypressed = true, |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 630 | }, |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 631 | }; |
| 632 | int ret; |
| 633 | |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 634 | if (sym == NULL) |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 635 | return -1; |
| 636 | |
Arnaldo Carvalho de Melo | 78f7def | 2011-02-04 09:45:46 -0200 | [diff] [blame] | 637 | if (map->dso->annotate_warned) |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 638 | return -1; |
| 639 | |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 640 | if (symbol__annotate(sym, map, sizeof(struct objdump_line_rb_node)) < 0) { |
Arnaldo Carvalho de Melo | ae55795 | 2011-10-26 08:00:55 -0200 | [diff] [blame] | 641 | ui__error("%s", ui_helpline__last_msg); |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 642 | return -1; |
| 643 | } |
| 644 | |
| 645 | ui_helpline__push("Press <- or ESC to exit"); |
| 646 | |
Lin Ming | db9a9cbc | 2011-04-08 14:31:26 +0800 | [diff] [blame] | 647 | notes = symbol__annotation(sym); |
Arnaldo Carvalho de Melo | 058b4cc | 2012-04-02 12:59:01 -0300 | [diff] [blame] | 648 | browser.start = map__rip_2objdump(map, sym->start); |
Lin Ming | db9a9cbc | 2011-04-08 14:31:26 +0800 | [diff] [blame] | 649 | |
Arnaldo Carvalho de Melo | ce6f4fa | 2011-02-08 13:27:39 -0200 | [diff] [blame] | 650 | list_for_each_entry(pos, ¬es->src->source, node) { |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 651 | struct objdump_line_rb_node *rbpos; |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 652 | size_t line_len = strlen(pos->line); |
Arnaldo Carvalho de Melo | c97cf42 | 2011-02-22 12:02:07 -0300 | [diff] [blame] | 653 | |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 654 | if (browser.b.width < line_len) |
| 655 | browser.b.width = line_len; |
| 656 | rbpos = objdump_line__rb(pos); |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 657 | rbpos->idx = browser.nr_entries++; |
| 658 | if (pos->offset != -1) |
| 659 | rbpos->idx_asm = browser.nr_asm_entries++; |
| 660 | else |
| 661 | rbpos->idx_asm = -1; |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 662 | } |
| 663 | |
Arnaldo Carvalho de Melo | 0361fc2 | 2011-10-14 12:31:21 -0300 | [diff] [blame] | 664 | browser.b.nr_entries = browser.nr_entries; |
Lin Ming | db9a9cbc | 2011-04-08 14:31:26 +0800 | [diff] [blame] | 665 | browser.b.entries = ¬es->src->source, |
Arnaldo Carvalho de Melo | 9222116 | 2010-08-09 15:30:40 -0300 | [diff] [blame] | 666 | browser.b.width += 18; /* Percentage */ |
Arnaldo Carvalho de Melo | d04b35f | 2011-11-11 22:17:32 -0200 | [diff] [blame] | 667 | ret = annotate_browser__run(&browser, evidx, timer, arg, delay_secs); |
Arnaldo Carvalho de Melo | ce6f4fa | 2011-02-08 13:27:39 -0200 | [diff] [blame] | 668 | 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] | 669 | list_del(&pos->node); |
| 670 | objdump_line__free(pos); |
| 671 | } |
Arnaldo Carvalho de Melo | 211ef12 | 2010-08-10 14:54:09 -0300 | [diff] [blame] | 672 | return ret; |
| 673 | } |