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>
This commit is contained in:
parent
e566b76ed3
commit
db9a9cbc81
|
@ -256,10 +256,9 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
|
||||||
int refresh)
|
int refresh)
|
||||||
{
|
{
|
||||||
struct objdump_line *pos, *n;
|
struct objdump_line *pos, *n;
|
||||||
struct annotation *notes = symbol__annotation(sym);
|
struct annotation *notes;
|
||||||
struct annotate_browser browser = {
|
struct annotate_browser browser = {
|
||||||
.b = {
|
.b = {
|
||||||
.entries = ¬es->src->source,
|
|
||||||
.refresh = ui_browser__list_head_refresh,
|
.refresh = ui_browser__list_head_refresh,
|
||||||
.seek = ui_browser__list_head_seek,
|
.seek = ui_browser__list_head_seek,
|
||||||
.write = annotate_browser__write,
|
.write = annotate_browser__write,
|
||||||
|
@ -281,6 +280,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
|
||||||
|
|
||||||
ui_helpline__push("Press <- or ESC to exit");
|
ui_helpline__push("Press <- or ESC to exit");
|
||||||
|
|
||||||
|
notes = symbol__annotation(sym);
|
||||||
|
|
||||||
list_for_each_entry(pos, ¬es->src->source, node) {
|
list_for_each_entry(pos, ¬es->src->source, node) {
|
||||||
struct objdump_line_rb_node *rbpos;
|
struct objdump_line_rb_node *rbpos;
|
||||||
size_t line_len = strlen(pos->line);
|
size_t line_len = strlen(pos->line);
|
||||||
|
@ -291,6 +292,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
|
||||||
rbpos->idx = browser.b.nr_entries++;
|
rbpos->idx = browser.b.nr_entries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
browser.b.entries = ¬es->src->source,
|
||||||
browser.b.width += 18; /* Percentage */
|
browser.b.width += 18; /* Percentage */
|
||||||
ret = annotate_browser__run(&browser, evidx, refresh);
|
ret = annotate_browser__run(&browser, evidx, refresh);
|
||||||
list_for_each_entry_safe(pos, n, ¬es->src->source, node) {
|
list_for_each_entry_safe(pos, n, ¬es->src->source, node) {
|
||||||
|
|
|
@ -851,7 +851,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel,
|
||||||
goto out_free_stack;
|
goto out_free_stack;
|
||||||
case 'a':
|
case 'a':
|
||||||
if (browser->selection == NULL ||
|
if (browser->selection == NULL ||
|
||||||
browser->selection->map == NULL ||
|
browser->selection->sym == NULL ||
|
||||||
browser->selection->map->dso->annotate_warned)
|
browser->selection->map->dso->annotate_warned)
|
||||||
continue;
|
continue;
|
||||||
goto do_annotate;
|
goto do_annotate;
|
||||||
|
|
Loading…
Reference in a new issue