perf annotate: Introduce strerror for handling symbol__disassemble() errors
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: ee51d851392e1fe3e8be30b3c5847f34da343424 Gitweb: http://git.kernel.org/tip/ee51d851392e1fe3e8be30b3c5847f34da343424 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Fri, 29 Jul 2016 16:27:18 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 1 Aug 2016 18:18:16 -0300
perf annotate: Introduce strerror for handling symbol__disassemble() errors
We were just using pr_error() which makes it difficult for non stdio UIs to provide errors using its widgets, as they need to somehow catch what was passed to pr_error().
Fix it by introducing a __strerror() interface like the ones used elsewhere, for instance target__strerror().
This is just the initial step, more work will be done, but first some error handling bugs noticed while working on this need to be dealt with.
Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/builtin-top.c | 4 +++ tools/perf/ui/browsers/annotate.c | 9 ++++-- tools/perf/ui/gtk/annotate.c | 8 +++-- tools/perf/util/annotate.c | 68 ++++++++++++++++++++++++--------------- tools/perf/util/annotate.h | 20 ++++++++++++ 5 files changed, 78 insertions(+), 31 deletions(-)
tools/perf/builtin-top.c +4 -0
@@ -132,6 +132,10 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)if (err ==0 ) { out_assign: top->sym_filter_entry = he; + }else { +char msg[BUFSIZ ]; +symbol__strerror_disassemble (sym, map, err, msg,sizeof (msg)); +pr_err ("Couldn't annotate %s: %s\n" , sym->name, msg); }pthread_mutex_unlock (¬es->lock);
tools/perf/ui/browsers/annotate.c +6 -3
@@ -1026,7 +1026,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, .use_navkeypressed = true, }, }; -int ret =-1 ; +int ret =-1 , err;int nr_pcnt =1 ;size_t sizeof_bdl =sizeof (struct browser_disasm_line );
@@ -1050,8 +1050,11 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, (nr_pcnt -1 ); } -if (symbol__disassemble (sym, map, sizeof_bdl) <0 ) { -ui__error ("%s" , ui_helpline__last_msg); + err =symbol__disassemble (sym, map, sizeof_bdl); +if (err) { +char msg[BUFSIZ ]; +symbol__strerror_disassemble (sym, map, err, msg,sizeof (msg)); +ui__error ("Couldn't annotate %s:\n%s" , sym->name, msg); goto out_free_offsets; }
tools/perf/ui/gtk/annotate.c +6 -2
@@ -162,12 +162,16 @@ static int symbol__gtk_annotate(struct symbol *sym, struct map *map,GtkWidget *notebook;GtkWidget *scrolled_window;GtkWidget *tab_label; +int err;if (map->dso->annotate_warned)return -1 ; -if (symbol__disassemble (sym, map,0 ) <0 ) { -ui__error ("%s" , ui_helpline__current); + err =symbol__disassemble (sym, map,0 ); +if (err) { +char msg[BUFSIZ ]; +symbol__strerror_disassemble (sym, map, err, msg,sizeof (msg)); +ui__error ("Couldn't annotate %s: %s\n" , sym->name, msg);return -1 ; }
tools/perf/util/annotate.c +42 -26
86 lines not on this page · raw message
tools/perf/util/annotate.h +20 -0
@@ -157,6 +157,26 @@ void symbol__annotate_zero_histograms(struct symbol *sym);int symbol__disassemble (struct symbol *sym,struct map *map,size_t privsize); +enum symbol_disassemble_errno { +SYMBOL_ANNOTATE_ERRNO__SUCCESS =0 , + +/* +* Choose an arbitrary negative big number not to clash with standard +* errno since SUS requires the errno has distinct positive values. +* See 'Issue 6' in the link below. +* +* http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html +*/ + __SYMBOL_ANNOTATE_ERRNO__START =-10000 , + +SYMBOL_ANNOTATE_ERRNO__NO_VMLINUX = __SYMBOL_ANNOTATE_ERRNO__START, + + __SYMBOL_ANNOTATE_ERRNO__END, +}; + +int symbol__strerror_disassemble (struct symbol *sym,struct map *map, +int errnum,char *buf,size_t buflen); +int symbol__annotate_init (struct map *map,struct symbol *sym); int symbol__annotate_printf(struct symbol *sym, struct map *map, struct perf_evsel *evsel, bool full_paths,