diff options
author | Lin Ming <ming.m.lin@intel.com> | 2011-04-08 02:31:26 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-04-15 11:51:49 -0400 |
commit | db9a9cbc8142eed008e242e389938689c6feb1ba (patch) | |
tree | cb4311d8906cba65b0de09c18bd881986d0c2ed5 /tools | |
parent | e566b76ed30768140df8f0023904aed5a41244f7 (diff) |
perf hists browser: Fix seg fault when annotate null symbol
In hists browser, press hotkey 'a' to annotate current symbol.
Now it causes segment fault if 'a' is pressed on a null symbol.
Here are 2 small bugs:
- In perf_evsel__hists_browse, the condition check after 'a' is pressed
is not correct, we should check ->sym instead of ->map.
- In symbol__tui_annotate we must check whether sym is NULL or not
before getting annotation structure.
This patch fixes above 2 small bugs.
Link: http://lkml.kernel.org/r/1302244286.4106.36.camel@minggr.sh.intel.com
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/ui/browsers/annotate.c | 6 | ||||
-rw-r--r-- | tools/perf/util/ui/browsers/hists.c | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/tools/perf/util/ui/browsers/annotate.c b/tools/perf/util/ui/browsers/annotate.c index 8c17a8730e4a..15633d608133 100644 --- a/tools/perf/util/ui/browsers/annotate.c +++ b/tools/perf/util/ui/browsers/annotate.c | |||
@@ -256,10 +256,9 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, | |||
256 | int refresh) | 256 | int refresh) |
257 | { | 257 | { |
258 | struct objdump_line *pos, *n; | 258 | struct objdump_line *pos, *n; |
259 | struct annotation *notes = symbol__annotation(sym); | 259 | struct annotation *notes; |
260 | struct annotate_browser browser = { | 260 | struct annotate_browser browser = { |
261 | .b = { | 261 | .b = { |
262 | .entries = ¬es->src->source, | ||
263 | .refresh = ui_browser__list_head_refresh, | 262 | .refresh = ui_browser__list_head_refresh, |
264 | .seek = ui_browser__list_head_seek, | 263 | .seek = ui_browser__list_head_seek, |
265 | .write = annotate_browser__write, | 264 | .write = annotate_browser__write, |
@@ -281,6 +280,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, | |||
281 | 280 | ||
282 | ui_helpline__push("Press <- or ESC to exit"); | 281 | ui_helpline__push("Press <- or ESC to exit"); |
283 | 282 | ||
283 | notes = symbol__annotation(sym); | ||
284 | |||
284 | list_for_each_entry(pos, ¬es->src->source, node) { | 285 | list_for_each_entry(pos, ¬es->src->source, node) { |
285 | struct objdump_line_rb_node *rbpos; | 286 | struct objdump_line_rb_node *rbpos; |
286 | size_t line_len = strlen(pos->line); | 287 | size_t line_len = strlen(pos->line); |
@@ -291,6 +292,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, | |||
291 | rbpos->idx = browser.b.nr_entries++; | 292 | rbpos->idx = browser.b.nr_entries++; |
292 | } | 293 | } |
293 | 294 | ||
295 | browser.b.entries = ¬es->src->source, | ||
294 | browser.b.width += 18; /* Percentage */ | 296 | browser.b.width += 18; /* Percentage */ |
295 | ret = annotate_browser__run(&browser, evidx, refresh); | 297 | ret = annotate_browser__run(&browser, evidx, refresh); |
296 | list_for_each_entry_safe(pos, n, ¬es->src->source, node) { | 298 | list_for_each_entry_safe(pos, n, ¬es->src->source, node) { |
diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c index 798efdca3ead..5d767c622dfc 100644 --- a/tools/perf/util/ui/browsers/hists.c +++ b/tools/perf/util/ui/browsers/hists.c | |||
@@ -851,7 +851,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, | |||
851 | goto out_free_stack; | 851 | goto out_free_stack; |
852 | case 'a': | 852 | case 'a': |
853 | if (browser->selection == NULL || | 853 | if (browser->selection == NULL || |
854 | browser->selection->map == NULL || | 854 | browser->selection->sym == NULL || |
855 | browser->selection->map->dso->annotate_warned) | 855 | browser->selection->map->dso->annotate_warned) |
856 | continue; | 856 | continue; |
857 | goto do_annotate; | 857 | goto do_annotate; |