perf annotate: Add support for event group view (v2)
Namhyung Kim
maintainercover perf annotate: Add support for event group view (v2)
Hi all,
This patchset implements event group view on perf annotate. It's basically a rebased version and major difference to prior version is the GTK annotation browser support.
Here goes an example:
$ perf annotate --group --stdio
Percent | Source code & Disassembly of libpthread-2.15.so
--------------------------------------------------------------------------------
:
:
:
: Disassembly of section .text:
:
: 000000387dc0aa50 <__pthread_mutex_unlock_usercnt>:
crtstuff.c:0
8.08 2.40 5.29 : 387dc0aa50: mov %rdi,%rdx
0.00 0.00 0.00 : 387dc0aa53: mov 0x10(%rdi),%edi
0.00 0.00 0.00 : 387dc0aa56: mov %edi,%eax
crtstuff.c:0
0.00 0.80 0.00 : 387dc0aa58: and $0x7f,%eax
3.03 2.40 3.53 : 387dc0aa5b: test $0x7c,%dil
0.00 0.00 0.00 : 387dc0aa5f: jne 387dc0aaa9 <__pthread_mutex_unlock_use
0.00 0.00 0.00 : 387dc0aa61: test %eax,%eax
0.00 0.00 0.00 : 387dc0aa63: jne 387dc0aa85 <__pthread_mutex_unlock_use
0.00 0.00 0.00 : 387dc0aa65: and $0x80,%edi
0.00 0.00 0.00 : 387dc0aa6b: test %esi,%esi
crtstuff.c:0
3.03 5.60 7.06 : 387dc0aa6d: movl $0x0,0x8(%rdx)
crtstuff.c:0
0.00 0.00 0.59 : 387dc0aa74: je 387dc0aa7a <__pthread_mutex_unlock_use
0.00 0.00 0.00 : 387dc0aa76: subl $0x1,0xc(%rdx)
crtstuff.c:0
2.02 5.60 1.18 : 387dc0aa7a: mov %edi,%esi
0.00 0.00 0.00 : 387dc0aa7c: lock decl (%rdx)
83.84 83.20 82.35 : 387dc0aa7f: jne 387dc0aada <_L_unlock_586>
0.00 0.00 0.00 : 387dc0aa81: nop
0.00 0.00 0.00 : 387dc0aa82: xor %eax,%eax
0.00 0.00 0.00 : 387dc0aa84: retq ...
You can access it via perf/annotate-group-v2 branch on my tree
git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
Any comments are welcome, thanks
Namhyung
Namhyung Kim (12):
perf annotate: Pass evsel instead of evidx on annotation functions perf annotate: Add a comment on the symbol__parse_objdump_line() perf annotate: Factor out disasm__calc_percent()
perf annotate: Cleanup disasm__calc_percent()
perf annotate: Add basic support to event group view perf evsel: Introduce perf_evsel__is_group_event() helper perf annotate: Factor out struct source_line_percent perf annotate: Support event group view for --print-line perf annotate browser: Make browser_disasm_line->percent an array perf annotate browser: Use disasm__calc_percent()
perf annotate browser: Support event group view on TUI perf annotate/gtk: Support event group view on GTK
tools/perf/Documentation/perf-annotate.txt | 3 + tools/perf/builtin-annotate.c | 23 ++- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 2 +- tools/perf/ui/browsers/annotate.c | 139 +++++++++------ tools/perf/ui/browsers/hists.c | 6 +- tools/perf/ui/gtk/annotate.c | 26 ++- tools/perf/ui/gtk/hists.c | 7 +- tools/perf/ui/hist.c | 7 +- tools/perf/util/annotate.c | 262 ++++++++++++++++++++++------- tools/perf/util/annotate.h | 49 +++--- tools/perf/util/evsel.h | 24 +++ tools/perf/util/hist.h | 5 +- 13 files changed, 389 insertions(+), 166 deletions(-)
Signature · 1 line
1.7.11.7
Namhyung Kim
maintainerPATCH 1/12 perf annotate: Pass evsel instead of evidx on annotation functions
From: Namhyung Kim <[email protected]>
Pass evsel instead of evidx. This is a preparation for supporting event group view in annotation and no functional change is intended.
--- tools/perf/builtin-annotate.c | 16 +++++++++------- tools/perf/builtin-top.c | 2 +- tools/perf/ui/browsers/annotate.c | 30 +++++++++++++++++------------- tools/perf/ui/browsers/hists.c | 2 +- tools/perf/ui/gtk/annotate.c | 10 ++++++---- tools/perf/util/annotate.c | 36 +++++++++++++++++++----------------- tools/perf/util/annotate.h | 36 +++++++++++++++++++----------------- tools/perf/util/hist.h | 5 +++-- 8 files changed, 75 insertions(+), 62 deletions(-)
tools/perf/builtin-annotate.c +9 -7
@@ -109,14 +109,16 @@ static int process_sample_event(struct perf_tool *tool,return 0 ; } -static int hist_entry__tty_annotate (struct hist_entry *he,int evidx, +static int hist_entry__tty_annotate (struct hist_entry *he, +struct perf_evsel *evsel,struct perf_annotate *ann) { -return symbol__tty_annotate (he->ms.sym, he->ms.map, evidx, +return symbol__tty_annotate (he->ms.sym, he->ms.map, evsel, ann->print_line, ann->full_paths,0 ,0 ); } -static void hists__find_annotations (struct hists *self,int evidx, +static void hists__find_annotations (struct hists *self, +struct perf_evsel *evsel,struct perf_annotate *ann) {struct rb_node *nd =rb_first (&self->entries), *next;
@@ -142,14 +144,14 @@ find_next:if (use_browser ==2 ) {int ret; - ret =hist_entry__gtk_annotate (he, evidx,NULL ); + ret =hist_entry__gtk_annotate (he, evsel,NULL );if (!ret || !ann->skip_missing)return ;/* skip missing symbols */ nd =rb_next (nd); }else if (use_browser ==1 ) { - key =hist_entry__tui_annotate (he, evidx,NULL ); + key =hist_entry__tui_annotate (he, evsel,NULL );switch (key) {case -1 :if (!ann->skip_missing)
@@ -168,7 +170,7 @@ find_next:if (next !=NULL ) nd = next; }else { -hist_entry__tty_annotate (he, evidx, ann); +hist_entry__tty_annotate (he, evsel, ann); nd =rb_next (nd);/* * Since we have a hist_entry per IP for the same
@@ -230,7 +232,7 @@ static int __cmd_annotate(struct perf_annotate *ann) total_nr_samples += nr_samples;hists__collapse_resort (hists);hists__output_resort (hists); -hists__find_annotations (hists, pos->idx, ann); +hists__find_annotations (hists, pos, ann); } }
tools/perf/builtin-top.c +1 -1
@@ -231,7 +231,7 @@ static void perf_top__show_details(struct perf_top *top)printf ("Showing %s for %s\n" ,perf_evsel__name (top->sym_evsel), symbol->name);printf (" Events Pcnt (>=%d%%)\n" , top->sym_pcnt_filter); - more =symbol__annotate_printf (symbol, he->ms.map, top->sym_evsel->idx, + more =symbol__annotate_printf (symbol, he->ms.map, top->sym_evsel,0 , top->sym_pcnt_filter, top->print_entries,4 );if (top->zero)symbol__annotate_zero_histogram (symbol, top->sym_evsel->idx);
tools/perf/ui/browsers/annotate.c +17 -13
@@ -8,6 +8,7 @@#include "../../util/hist.h" #include "../../util/sort.h" #include "../../util/symbol.h" +#include "../../util/evsel.h" #include <pthread.h> #include <newt.h>
@@ -331,7 +332,7 @@ static void annotate_browser__set_rb_top(struct annotate_browser *browser, }static void annotate_browser__calc_percent (struct annotate_browser *browser, -int evidx) +struct perf_evsel *evsel) {struct map_symbol *ms = browser->b.priv;struct symbol *sym = ms->sym;
@@ -344,7 +345,7 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,list_for_each_entry (pos, ¬es->src->source, node) {struct browser_disasm_line *bpos =disasm_line__browser (pos); - bpos->percent =disasm_line__calc_percent (pos, sym, evidx); + bpos->percent =disasm_line__calc_percent (pos, sym, evsel->idx);if (bpos->percent <0.01 ) {RB_CLEAR_NODE (&bpos->rb_node);continue ;
@@ -401,7 +402,8 @@ static void annotate_browser__init_asm_mode(struct annotate_browser *browser) browser->b.nr_entries = browser->nr_asm_entries; } -static bool annotate_browser__callq (struct annotate_browser *browser,int evidx, +static bool annotate_browser__callq (struct annotate_browser *browser, +struct perf_evsel *evsel,struct hist_browser_timer *hbt) {struct map_symbol *ms = browser->b.priv;
@@ -432,7 +434,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser, int evidx, }pthread_mutex_unlock (¬es->lock); -symbol__tui_annotate (target, ms->map, evidx, hbt); +symbol__tui_annotate (target, ms->map, evsel, hbt);ui_browser__show_title (&browser->b, sym->name);return true; }
@@ -615,7 +617,8 @@ static void annotate_browser__update_addr_width(struct annotate_browser *browser browser->addr_width += browser->jumps_width +1 ; } -static int annotate_browser__run (struct annotate_browser *browser,int evidx, +static int annotate_browser__run (struct annotate_browser *browser, +struct perf_evsel *evsel,struct hist_browser_timer *hbt) {struct rb_node *nd =NULL ;
@@ -628,7 +631,7 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx,if (ui_browser__show (&browser->b, sym->name, help) <0 )return -1 ; -annotate_browser__calc_percent (browser, evidx); +annotate_browser__calc_percent (browser, evsel);if (browser->curr_hot) {annotate_browser__set_rb_top (browser, browser->curr_hot);
@@ -641,7 +644,7 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx, key =ui_browser__run (&browser->b, delay_secs);if (delay_secs !=0 ) { -annotate_browser__calc_percent (browser, evidx); +annotate_browser__calc_percent (browser, evsel);/* * Current line focus got out of the list of most active * lines, NULL it so that if TAB|UNTAB is pressed, we
@@ -657,7 +660,7 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx, hbt->timer (hbt->arg);if (delay_secs !=0 ) -symbol__annotate_decay_histogram (sym, evidx); +symbol__annotate_decay_histogram (sym, evsel->idx);continue ;case K_TAB :if (nd !=NULL ) {
@@ -754,7 +757,7 @@ show_help: goto show_sup_ins; goto out; }else if (!(annotate_browser__jump (browser) || -annotate_browser__callq (browser, evidx, hbt))) { +annotate_browser__callq (browser, evsel, hbt))) { show_sup_ins:ui_helpline__puts ("Actions are only available for 'callq', 'retq' & jump instructions." ); }
@@ -776,10 +779,10 @@ out:return key; } -int hist_entry__tui_annotate (struct hist_entry *he,int evidx, +int hist_entry__tui_annotate (struct hist_entry *he,struct perf_evsel *evsel,struct hist_browser_timer *hbt) { -return symbol__tui_annotate (he->ms.sym, he->ms.map, evidx, hbt); +return symbol__tui_annotate (he->ms.sym, he->ms.map, evsel, hbt); } static void annotate_browser__mark_jump_targets(struct annotate_browser *browser,
@@ -826,7 +829,8 @@ static inline int width_jumps(int n)return 1 ; } -int symbol__tui_annotate (struct symbol *sym,struct map *map,int evidx, +int symbol__tui_annotate (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,struct hist_browser_timer *hbt) {struct disasm_line *pos, *n;
@@ -909,7 +913,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,annotate_browser__update_addr_width (&browser); - ret =annotate_browser__run (&browser, evidx, hbt); + ret =annotate_browser__run (&browser, evsel, hbt);list_for_each_entry_safe (pos, n, ¬es->src->source, node) {list_del (&pos->node);disasm_line__free (pos);
tools/perf/ui/browsers/hists.c +1 -1
@@ -1599,7 +1599,7 @@ do_annotate:* Don't let this be freed, say, by hists__decay_entry. */ he->used = true; - err =hist_entry__tui_annotate (he, evsel->idx, hbt); + err =hist_entry__tui_annotate (he, evsel, hbt); he->used = false;/* * offer option to annotate the other branch source or target
tools/perf/ui/gtk/annotate.c +6 -4
@@ -1,6 +1,7 @@#include "gtk.h" #include "util/debug.h" #include "util/annotate.h" +#include "util/evsel.h" #include "ui/helpline.h"
@@ -85,7 +86,7 @@ static int perf_gtk__get_line(char *buf, size_t size, struct disasm_line *dl) }static int perf_gtk__annotate_symbol (GtkWidget *window,struct symbol *sym, -struct map *map,int evidx, +struct map *map,struct perf_evsel *evsel,struct hist_browser_timer *hbt__maybe_unused ) {struct disasm_line *pos, *n;
@@ -121,7 +122,7 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,gtk_list_store_append (store, &iter); -if (perf_gtk__get_percent (s,sizeof (s), sym, pos, evidx)) +if (perf_gtk__get_percent (s,sizeof (s), sym, pos, evsel->idx))gtk_list_store_set (store, &iter,ANN_COL__PERCENT , s,-1 );if (perf_gtk__get_offset (s,sizeof (s), sym, map, pos))gtk_list_store_set (store, &iter,ANN_COL__OFFSET , s,-1 );
@@ -139,7 +140,8 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,return 0 ; } -int symbol__gtk_annotate (struct symbol *sym,struct map *map,int evidx, +int symbol__gtk_annotate (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,struct hist_browser_timer *hbt) {GtkWidget *window;
@@ -206,7 +208,7 @@ int symbol__gtk_annotate(struct symbol *sym, struct map *map, int evidx,gtk_notebook_append_page (GTK_NOTEBOOK (notebook), scrolled_window, tab_label); -perf_gtk__annotate_symbol (scrolled_window, sym, map, evidx, hbt); +perf_gtk__annotate_symbol (scrolled_window, sym, map, evsel, hbt);return 0 ; }
tools/perf/util/annotate.c +19 -17
@@ -14,6 +14,7 @@#include "symbol.h" #include "debug.h" #include "annotate.h" +#include "evsel.h" #include <pthread.h> #include <linux/bitops.h>
@@ -603,7 +604,7 @@ struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disa }static int disasm_line__print (struct disasm_line *dl,struct symbol *sym,u64 start, -int evidx,u64 len,int min_pcnt,int printed, +struct perf_evsel *evsel,u64 len,int min_pcnt,int printed,int max_lines,struct disasm_line *queue) {static const char *prev_line;
@@ -616,7 +617,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 stconst char *color;struct annotation *notes =symbol__annotation (sym);struct source_line *src_line = notes->src->lines; -struct sym_hist *h =annotation__histogram (notes, evidx); +struct sym_hist *h =annotation__histogram (notes, evsel->idx);s64 offset = dl->offset;const u64 addr = start + offset;struct disasm_line *next;
@@ -648,7 +649,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 stlist_for_each_entry_from (queue, ¬es->src->source, node) {if (queue == dl)break ; -disasm_line__print (queue, sym, start, evidx, len, +disasm_line__print (queue, sym, start, evsel, len,0 ,0 ,1 ,NULL ); } }
@@ -935,7 +936,8 @@ static void symbol__free_source_line(struct symbol *sym, int len)/* Get the filename:line for the colored entries */ static int symbol__get_source_line (struct symbol *sym,struct map *map, -int evidx,struct rb_root *root,int len, +struct perf_evsel *evsel, +struct rb_root *root,int len,const char *filename) {u64 start;
@@ -943,7 +945,7 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,char cmd[PATH_MAX *2 ];struct source_line *src_line;struct annotation *notes =symbol__annotation (sym); -struct sym_hist *h =annotation__histogram (notes, evidx); +struct sym_hist *h =annotation__histogram (notes, evsel->idx);struct rb_root tmp_root =RB_ROOT ;if (!h->sum)
@@ -1018,10 +1020,10 @@ static void print_summary(struct rb_root *root, const char *filename) } } -static void symbol__annotate_hits (struct symbol *sym,int evidx) +static void symbol__annotate_hits (struct symbol *sym,struct perf_evsel *evsel) {struct annotation *notes =symbol__annotation (sym); -struct sym_hist *h =annotation__histogram (notes, evidx); +struct sym_hist *h =annotation__histogram (notes, evsel->idx);u64 len =symbol__size (sym), offset;for (offset =0 ; offset < len; ++offset)
@@ -1031,9 +1033,9 @@ static void symbol__annotate_hits(struct symbol *sym, int evidx)printf ("%*s: %" PRIu64"\n" ,BITS_PER_LONG /2 ,"h->sum" , h->sum); } -int symbol__annotate_printf (struct symbol *sym,struct map *map,int evidx, -bool full_paths,int min_pcnt,int max_lines, -int context) +int symbol__annotate_printf (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,bool full_paths, +int min_pcnt,int max_lines,int context) {struct dso *dso = map->dso;char *filename;
@@ -1060,7 +1062,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,printf ("------------------------------------------------\n" );if (verbose) -symbol__annotate_hits (sym, evidx); +symbol__annotate_hits (sym, evsel);list_for_each_entry (pos, ¬es->src->source, node) {if (context && queue ==NULL ) {
@@ -1068,7 +1070,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx, queue_len =0 ; } -switch (disasm_line__print (pos, sym, start, evidx, len, +switch (disasm_line__print (pos, sym, start, evsel, len, min_pcnt, printed, max_lines, queue)) {case 0 :
@@ -1163,9 +1165,9 @@ size_t disasm__fprintf(struct list_head *head, FILE *fp)return printed; } -int symbol__tty_annotate (struct symbol *sym,struct map *map,int evidx, -bool print_lines,bool full_paths,int min_pcnt, -int max_lines) +int symbol__tty_annotate (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,bool print_lines, +bool full_paths,int min_pcnt,int max_lines) {struct dso *dso = map->dso;const char *filename = dso->long_name;
@@ -1178,12 +1180,12 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, len =symbol__size (sym);if (print_lines) { -symbol__get_source_line (sym, map, evidx, &source_line, +symbol__get_source_line (sym, map, evsel, &source_line, len, filename);print_summary (&source_line, filename); } -symbol__annotate_printf (sym, map, evidx, full_paths, +symbol__annotate_printf (sym, map, evsel, full_paths, min_pcnt, max_lines,0 );if (print_lines)symbol__free_source_line (sym, len);
tools/perf/util/annotate.h +19 -17
@@ -130,47 +130,49 @@ void symbol__annotate_zero_histograms(struct symbol *sym);int symbol__annotate (struct symbol *sym,struct map *map,size_t privsize);int symbol__annotate_init (struct map *map__maybe_unused ,struct symbol *sym); -int symbol__annotate_printf (struct symbol *sym,struct map *map,int evidx, -bool full_paths,int min_pcnt,int max_lines, -int context); +int symbol__annotate_printf (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,bool full_paths, +int min_pcnt,int max_lines,int context);void symbol__annotate_zero_histogram (struct symbol *sym,int evidx);void symbol__annotate_decay_histogram (struct symbol *sym,int evidx);void disasm__purge (struct list_head *head); -int symbol__tty_annotate (struct symbol *sym,struct map *map,int evidx, -bool print_lines,bool full_paths,int min_pcnt, -int max_lines); +int symbol__tty_annotate (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,bool print_lines, +bool full_paths,int min_pcnt,int max_lines);#ifdef NEWT_SUPPORT -int symbol__tui_annotate (struct symbol *sym,struct map *map,int evidx, +int symbol__tui_annotate (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,struct hist_browser_timer *hbt);#else static inline int symbol__tui_annotate (struct symbol *sym__maybe_unused , -struct map *map__maybe_unused , -int evidx__maybe_unused , -struct hist_browser_timer *hbt -__maybe_unused ) +struct map *map__maybe_unused , +struct perf_evsel *evsel__maybe_unused , +struct hist_browser_timer *hbt +__maybe_unused ) {return 0 ; }#endif #ifdef GTK2_SUPPORT -int symbol__gtk_annotate (struct symbol *sym,struct map *map,int evidx, +int symbol__gtk_annotate (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,struct hist_browser_timer *hbt); -static inline int hist_entry__gtk_annotate (struct hist_entry *he,int evidx, +static inline int hist_entry__gtk_annotate (struct hist_entry *he, +struct perf_evsel *evsel,struct hist_browser_timer *hbt) { -return symbol__gtk_annotate (he->ms.sym, he->ms.map, evidx, hbt); +return symbol__gtk_annotate (he->ms.sym, he->ms.map, evsel, hbt); }void perf_gtk__show_annotations (void );#else static inline int hist_entry__gtk_annotate (struct hist_entry *he__maybe_unused , -int evidx__maybe_unused , -struct hist_browser_timer *hbt -__maybe_unused ) +struct perf_evsel *evsel__maybe_unused , +struct hist_browser_timer *hbt__maybe_unused ) {return 0 ; }
tools/perf/util/hist.h +3 -2
@@ -177,7 +177,7 @@ struct hist_browser_timer {#ifdef NEWT_SUPPORT #include "../ui/keysyms.h" -int hist_entry__tui_annotate (struct hist_entry *he,int evidx, +int hist_entry__tui_annotate (struct hist_entry *he,struct perf_evsel *evsel,struct hist_browser_timer *hbt); int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
@@ -196,7 +196,8 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused,static inline int hist_entry__tui_annotate (struct hist_entry *self__maybe_unused , -int evidx__maybe_unused , +struct perf_evsel *evsel +__maybe_unused ,struct hist_browser_timer *hbt__maybe_unused ) {
Signature · 1 line
1.7.11.7
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf annotate: Pass evsel instead of evidx on annotation functions
perf annotate: Pass evsel instead of evidx on annotation functions
Commit-ID: db8fd07a541fc2d5e8076f0151286e19591465b3 Gitweb: http://git.kernel.org/tip/db8fd07a541fc2d5e8076f0151286e19591465b3 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 5 Mar 2013 14:53:21 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 15 Mar 2013 13:06:04 -0300
perf annotate: Pass evsel instead of evidx on annotation functions
Pass evsel instead of evidx. This is a preparation for supporting event group view in annotation and no functional change is intended.
--- tools/perf/builtin-annotate.c | 16 +++++++++------- tools/perf/builtin-top.c | 2 +- tools/perf/ui/browsers/annotate.c | 30 +++++++++++++++++------------- tools/perf/ui/browsers/hists.c | 2 +- tools/perf/ui/gtk/annotate.c | 10 ++++++---- tools/perf/util/annotate.c | 36 +++++++++++++++++++----------------- tools/perf/util/annotate.h | 36 +++++++++++++++++++----------------- tools/perf/util/hist.h | 5 +++-- 8 files changed, 75 insertions(+), 62 deletions(-)
tools/perf/builtin-annotate.c +9 -7
@@ -109,14 +109,16 @@ static int process_sample_event(struct perf_tool *tool,return 0 ; } -static int hist_entry__tty_annotate (struct hist_entry *he,int evidx, +static int hist_entry__tty_annotate (struct hist_entry *he, +struct perf_evsel *evsel,struct perf_annotate *ann) { -return symbol__tty_annotate (he->ms.sym, he->ms.map, evidx, +return symbol__tty_annotate (he->ms.sym, he->ms.map, evsel, ann->print_line, ann->full_paths,0 ,0 ); } -static void hists__find_annotations (struct hists *self,int evidx, +static void hists__find_annotations (struct hists *self, +struct perf_evsel *evsel,struct perf_annotate *ann) {struct rb_node *nd =rb_first (&self->entries), *next;
@@ -142,14 +144,14 @@ find_next:if (use_browser ==2 ) {int ret; - ret =hist_entry__gtk_annotate (he, evidx,NULL ); + ret =hist_entry__gtk_annotate (he, evsel,NULL );if (!ret || !ann->skip_missing)return ;/* skip missing symbols */ nd =rb_next (nd); }else if (use_browser ==1 ) { - key =hist_entry__tui_annotate (he, evidx,NULL ); + key =hist_entry__tui_annotate (he, evsel,NULL );switch (key) {case -1 :if (!ann->skip_missing)
@@ -168,7 +170,7 @@ find_next:if (next !=NULL ) nd = next; }else { -hist_entry__tty_annotate (he, evidx, ann); +hist_entry__tty_annotate (he, evsel, ann); nd =rb_next (nd);/* * Since we have a hist_entry per IP for the same
@@ -230,7 +232,7 @@ static int __cmd_annotate(struct perf_annotate *ann) total_nr_samples += nr_samples;hists__collapse_resort (hists);hists__output_resort (hists); -hists__find_annotations (hists, pos->idx, ann); +hists__find_annotations (hists, pos, ann); } }
tools/perf/builtin-top.c +1 -1
@@ -231,7 +231,7 @@ static void perf_top__show_details(struct perf_top *top)printf ("Showing %s for %s\n" ,perf_evsel__name (top->sym_evsel), symbol->name);printf (" Events Pcnt (>=%d%%)\n" , top->sym_pcnt_filter); - more =symbol__annotate_printf (symbol, he->ms.map, top->sym_evsel->idx, + more =symbol__annotate_printf (symbol, he->ms.map, top->sym_evsel,0 , top->sym_pcnt_filter, top->print_entries,4 );if (top->zero)symbol__annotate_zero_histogram (symbol, top->sym_evsel->idx);
tools/perf/ui/browsers/annotate.c +17 -13
@@ -8,6 +8,7 @@#include "../../util/hist.h" #include "../../util/sort.h" #include "../../util/symbol.h" +#include "../../util/evsel.h" #include <pthread.h> #include <newt.h>
@@ -331,7 +332,7 @@ static void annotate_browser__set_rb_top(struct annotate_browser *browser, }static void annotate_browser__calc_percent (struct annotate_browser *browser, -int evidx) +struct perf_evsel *evsel) {struct map_symbol *ms = browser->b.priv;struct symbol *sym = ms->sym;
@@ -344,7 +345,7 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,list_for_each_entry (pos, ¬es->src->source, node) {struct browser_disasm_line *bpos =disasm_line__browser (pos); - bpos->percent =disasm_line__calc_percent (pos, sym, evidx); + bpos->percent =disasm_line__calc_percent (pos, sym, evsel->idx);if (bpos->percent <0.01 ) {RB_CLEAR_NODE (&bpos->rb_node);continue ;
@@ -401,7 +402,8 @@ static void annotate_browser__init_asm_mode(struct annotate_browser *browser) browser->b.nr_entries = browser->nr_asm_entries; } -static bool annotate_browser__callq (struct annotate_browser *browser,int evidx, +static bool annotate_browser__callq (struct annotate_browser *browser, +struct perf_evsel *evsel,struct hist_browser_timer *hbt) {struct map_symbol *ms = browser->b.priv;
@@ -432,7 +434,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser, int evidx, }pthread_mutex_unlock (¬es->lock); -symbol__tui_annotate (target, ms->map, evidx, hbt); +symbol__tui_annotate (target, ms->map, evsel, hbt);ui_browser__show_title (&browser->b, sym->name);return true; }
@@ -615,7 +617,8 @@ static void annotate_browser__update_addr_width(struct annotate_browser *browser browser->addr_width += browser->jumps_width +1 ; } -static int annotate_browser__run (struct annotate_browser *browser,int evidx, +static int annotate_browser__run (struct annotate_browser *browser, +struct perf_evsel *evsel,struct hist_browser_timer *hbt) {struct rb_node *nd =NULL ;
@@ -628,7 +631,7 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx,if (ui_browser__show (&browser->b, sym->name, help) <0 )return -1 ; -annotate_browser__calc_percent (browser, evidx); +annotate_browser__calc_percent (browser, evsel);if (browser->curr_hot) {annotate_browser__set_rb_top (browser, browser->curr_hot);
@@ -641,7 +644,7 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx, key =ui_browser__run (&browser->b, delay_secs);if (delay_secs !=0 ) { -annotate_browser__calc_percent (browser, evidx); +annotate_browser__calc_percent (browser, evsel);/* * Current line focus got out of the list of most active * lines, NULL it so that if TAB|UNTAB is pressed, we
@@ -657,7 +660,7 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx, hbt->timer (hbt->arg);if (delay_secs !=0 ) -symbol__annotate_decay_histogram (sym, evidx); +symbol__annotate_decay_histogram (sym, evsel->idx);continue ;case K_TAB :if (nd !=NULL ) {
@@ -754,7 +757,7 @@ show_help: goto show_sup_ins; goto out; }else if (!(annotate_browser__jump (browser) || -annotate_browser__callq (browser, evidx, hbt))) { +annotate_browser__callq (browser, evsel, hbt))) { show_sup_ins:ui_helpline__puts ("Actions are only available for 'callq', 'retq' & jump instructions." ); }
@@ -776,10 +779,10 @@ out:return key; } -int hist_entry__tui_annotate (struct hist_entry *he,int evidx, +int hist_entry__tui_annotate (struct hist_entry *he,struct perf_evsel *evsel,struct hist_browser_timer *hbt) { -return symbol__tui_annotate (he->ms.sym, he->ms.map, evidx, hbt); +return symbol__tui_annotate (he->ms.sym, he->ms.map, evsel, hbt); } static void annotate_browser__mark_jump_targets(struct annotate_browser *browser,
@@ -826,7 +829,8 @@ static inline int width_jumps(int n)return 1 ; } -int symbol__tui_annotate (struct symbol *sym,struct map *map,int evidx, +int symbol__tui_annotate (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,struct hist_browser_timer *hbt) {struct disasm_line *pos, *n;
@@ -909,7 +913,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,annotate_browser__update_addr_width (&browser); - ret =annotate_browser__run (&browser, evidx, hbt); + ret =annotate_browser__run (&browser, evsel, hbt);list_for_each_entry_safe (pos, n, ¬es->src->source, node) {list_del (&pos->node);disasm_line__free (pos);
tools/perf/ui/browsers/hists.c +1 -1
@@ -1599,7 +1599,7 @@ do_annotate:* Don't let this be freed, say, by hists__decay_entry. */ he->used = true; - err =hist_entry__tui_annotate (he, evsel->idx, hbt); + err =hist_entry__tui_annotate (he, evsel, hbt); he->used = false;/* * offer option to annotate the other branch source or target
tools/perf/ui/gtk/annotate.c +6 -4
@@ -1,6 +1,7 @@#include "gtk.h" #include "util/debug.h" #include "util/annotate.h" +#include "util/evsel.h" #include "ui/helpline.h"
@@ -85,7 +86,7 @@ static int perf_gtk__get_line(char *buf, size_t size, struct disasm_line *dl) }static int perf_gtk__annotate_symbol (GtkWidget *window,struct symbol *sym, -struct map *map,int evidx, +struct map *map,struct perf_evsel *evsel,struct hist_browser_timer *hbt__maybe_unused ) {struct disasm_line *pos, *n;
@@ -121,7 +122,7 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,gtk_list_store_append (store, &iter); -if (perf_gtk__get_percent (s,sizeof (s), sym, pos, evidx)) +if (perf_gtk__get_percent (s,sizeof (s), sym, pos, evsel->idx))gtk_list_store_set (store, &iter,ANN_COL__PERCENT , s,-1 );if (perf_gtk__get_offset (s,sizeof (s), sym, map, pos))gtk_list_store_set (store, &iter,ANN_COL__OFFSET , s,-1 );
@@ -139,7 +140,8 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,return 0 ; } -int symbol__gtk_annotate (struct symbol *sym,struct map *map,int evidx, +int symbol__gtk_annotate (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,struct hist_browser_timer *hbt) {GtkWidget *window;
@@ -206,7 +208,7 @@ int symbol__gtk_annotate(struct symbol *sym, struct map *map, int evidx,gtk_notebook_append_page (GTK_NOTEBOOK (notebook), scrolled_window, tab_label); -perf_gtk__annotate_symbol (scrolled_window, sym, map, evidx, hbt); +perf_gtk__annotate_symbol (scrolled_window, sym, map, evsel, hbt);return 0 ; }
tools/perf/util/annotate.c +19 -17
@@ -14,6 +14,7 @@#include "symbol.h" #include "debug.h" #include "annotate.h" +#include "evsel.h" #include <pthread.h> #include <linux/bitops.h>
@@ -603,7 +604,7 @@ struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disa }static int disasm_line__print (struct disasm_line *dl,struct symbol *sym,u64 start, -int evidx,u64 len,int min_pcnt,int printed, +struct perf_evsel *evsel,u64 len,int min_pcnt,int printed,int max_lines,struct disasm_line *queue) {static const char *prev_line;
@@ -616,7 +617,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 stconst char *color;struct annotation *notes =symbol__annotation (sym);struct source_line *src_line = notes->src->lines; -struct sym_hist *h =annotation__histogram (notes, evidx); +struct sym_hist *h =annotation__histogram (notes, evsel->idx);s64 offset = dl->offset;const u64 addr = start + offset;struct disasm_line *next;
@@ -648,7 +649,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 stlist_for_each_entry_from (queue, ¬es->src->source, node) {if (queue == dl)break ; -disasm_line__print (queue, sym, start, evidx, len, +disasm_line__print (queue, sym, start, evsel, len,0 ,0 ,1 ,NULL ); } }
@@ -935,7 +936,8 @@ static void symbol__free_source_line(struct symbol *sym, int len)/* Get the filename:line for the colored entries */ static int symbol__get_source_line (struct symbol *sym,struct map *map, -int evidx,struct rb_root *root,int len, +struct perf_evsel *evsel, +struct rb_root *root,int len,const char *filename) {u64 start;
@@ -943,7 +945,7 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,char cmd[PATH_MAX *2 ];struct source_line *src_line;struct annotation *notes =symbol__annotation (sym); -struct sym_hist *h =annotation__histogram (notes, evidx); +struct sym_hist *h =annotation__histogram (notes, evsel->idx);struct rb_root tmp_root =RB_ROOT ;if (!h->sum)
@@ -1018,10 +1020,10 @@ static void print_summary(struct rb_root *root, const char *filename) } } -static void symbol__annotate_hits (struct symbol *sym,int evidx) +static void symbol__annotate_hits (struct symbol *sym,struct perf_evsel *evsel) {struct annotation *notes =symbol__annotation (sym); -struct sym_hist *h =annotation__histogram (notes, evidx); +struct sym_hist *h =annotation__histogram (notes, evsel->idx);u64 len =symbol__size (sym), offset;for (offset =0 ; offset < len; ++offset)
@@ -1031,9 +1033,9 @@ static void symbol__annotate_hits(struct symbol *sym, int evidx)printf ("%*s: %" PRIu64"\n" ,BITS_PER_LONG /2 ,"h->sum" , h->sum); } -int symbol__annotate_printf (struct symbol *sym,struct map *map,int evidx, -bool full_paths,int min_pcnt,int max_lines, -int context) +int symbol__annotate_printf (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,bool full_paths, +int min_pcnt,int max_lines,int context) {struct dso *dso = map->dso;char *filename;
@@ -1060,7 +1062,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,printf ("------------------------------------------------\n" );if (verbose) -symbol__annotate_hits (sym, evidx); +symbol__annotate_hits (sym, evsel);list_for_each_entry (pos, ¬es->src->source, node) {if (context && queue ==NULL ) {
@@ -1068,7 +1070,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx, queue_len =0 ; } -switch (disasm_line__print (pos, sym, start, evidx, len, +switch (disasm_line__print (pos, sym, start, evsel, len, min_pcnt, printed, max_lines, queue)) {case 0 :
@@ -1163,9 +1165,9 @@ size_t disasm__fprintf(struct list_head *head, FILE *fp)return printed; } -int symbol__tty_annotate (struct symbol *sym,struct map *map,int evidx, -bool print_lines,bool full_paths,int min_pcnt, -int max_lines) +int symbol__tty_annotate (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,bool print_lines, +bool full_paths,int min_pcnt,int max_lines) {struct dso *dso = map->dso;const char *filename = dso->long_name;
@@ -1178,12 +1180,12 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, len =symbol__size (sym);if (print_lines) { -symbol__get_source_line (sym, map, evidx, &source_line, +symbol__get_source_line (sym, map, evsel, &source_line, len, filename);print_summary (&source_line, filename); } -symbol__annotate_printf (sym, map, evidx, full_paths, +symbol__annotate_printf (sym, map, evsel, full_paths, min_pcnt, max_lines,0 );if (print_lines)symbol__free_source_line (sym, len);
tools/perf/util/annotate.h +19 -17
@@ -130,47 +130,49 @@ void symbol__annotate_zero_histograms(struct symbol *sym);int symbol__annotate (struct symbol *sym,struct map *map,size_t privsize);int symbol__annotate_init (struct map *map__maybe_unused ,struct symbol *sym); -int symbol__annotate_printf (struct symbol *sym,struct map *map,int evidx, -bool full_paths,int min_pcnt,int max_lines, -int context); +int symbol__annotate_printf (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,bool full_paths, +int min_pcnt,int max_lines,int context);void symbol__annotate_zero_histogram (struct symbol *sym,int evidx);void symbol__annotate_decay_histogram (struct symbol *sym,int evidx);void disasm__purge (struct list_head *head); -int symbol__tty_annotate (struct symbol *sym,struct map *map,int evidx, -bool print_lines,bool full_paths,int min_pcnt, -int max_lines); +int symbol__tty_annotate (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,bool print_lines, +bool full_paths,int min_pcnt,int max_lines);#ifdef NEWT_SUPPORT -int symbol__tui_annotate (struct symbol *sym,struct map *map,int evidx, +int symbol__tui_annotate (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,struct hist_browser_timer *hbt);#else static inline int symbol__tui_annotate (struct symbol *sym__maybe_unused , -struct map *map__maybe_unused , -int evidx__maybe_unused , -struct hist_browser_timer *hbt -__maybe_unused ) +struct map *map__maybe_unused , +struct perf_evsel *evsel__maybe_unused , +struct hist_browser_timer *hbt +__maybe_unused ) {return 0 ; }#endif #ifdef GTK2_SUPPORT -int symbol__gtk_annotate (struct symbol *sym,struct map *map,int evidx, +int symbol__gtk_annotate (struct symbol *sym,struct map *map, +struct perf_evsel *evsel,struct hist_browser_timer *hbt); -static inline int hist_entry__gtk_annotate (struct hist_entry *he,int evidx, +static inline int hist_entry__gtk_annotate (struct hist_entry *he, +struct perf_evsel *evsel,struct hist_browser_timer *hbt) { -return symbol__gtk_annotate (he->ms.sym, he->ms.map, evidx, hbt); +return symbol__gtk_annotate (he->ms.sym, he->ms.map, evsel, hbt); }void perf_gtk__show_annotations (void );#else static inline int hist_entry__gtk_annotate (struct hist_entry *he__maybe_unused , -int evidx__maybe_unused , -struct hist_browser_timer *hbt -__maybe_unused ) +struct perf_evsel *evsel__maybe_unused , +struct hist_browser_timer *hbt__maybe_unused ) {return 0 ; }
tools/perf/util/hist.h +3 -2
@@ -177,7 +177,7 @@ struct hist_browser_timer {#ifdef NEWT_SUPPORT #include "../ui/keysyms.h" -int hist_entry__tui_annotate (struct hist_entry *he,int evidx, +int hist_entry__tui_annotate (struct hist_entry *he,struct perf_evsel *evsel,struct hist_browser_timer *hbt); int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
@@ -196,7 +196,8 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused,static inline int hist_entry__tui_annotate (struct hist_entry *self__maybe_unused , -int evidx__maybe_unused , +struct perf_evsel *evsel +__maybe_unused ,struct hist_browser_timer *hbt__maybe_unused ) {
Namhyung Kim
maintainerPATCH 2/12 perf annotate: Add a comment on the symbol__parse_objdump_line()
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
The symbol__parse_objdump_line() parses result of the objdump run but it's hard to follow if one doesn't know the output format of the objdump. Add a head comment on the function to help her.
--- tools/perf/util/annotate.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
tools/perf/util/annotate.c +20 -0
@@ -689,6 +689,26 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 streturn 0 ; } +/* +* symbol__parse_objdump_line() parses objdump output (with -d --no-show-raw) +* which looks like following +* +* 0000000000415500 <_init>: +* 415500: sub $0x8,%rsp +* 415504: mov 0x2f5ad5(%rip),%rax # 70afe0 <_DYNAMIC+0x2f8> +* 41550b: test %rax,%rax +* 41550e: je 415515 <_init+0x15> +* 415510: callq 416e70 <__gmon_start__@plt> +* 415515: add $0x8,%rsp +* 415519: retq +* +* it will be parsed and saved into struct disasm_line as +* <offset> <name> <ops.raw> +* +* The offset will be a relative offset from the start of the symbol and -1 +* means that it's not a disassembly line so should be treated differently. +* The ops.raw part will be parsed further according to type of the instruction. +*/ static int symbol__parse_objdump_line (struct symbol *sym,struct map *map,FILE *file,size_t privsize) {
Signature · 1 line
1.7.11.7
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf annotate: Add a comment on the symbol__parse_objdump_line()
perf annotate: Add a comment on the symbol__parse_objdump_line()
Commit-ID: 3aec150af3de6c00570bdacf45bf5a999ab9cf1d Gitweb: http://git.kernel.org/tip/3aec150af3de6c00570bdacf45bf5a999ab9cf1d Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 5 Mar 2013 14:53:22 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 15 Mar 2013 13:06:04 -0300
perf annotate: Add a comment on the symbol__parse_objdump_line()
The symbol__parse_objdump_line() parses result of the objdump run but it's hard to follow if one doesn't know the output format of the objdump. Add a head comment on the function to help her.
--- tools/perf/util/annotate.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
tools/perf/util/annotate.c +20 -0
@@ -689,6 +689,26 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 streturn 0 ; } +/* +* symbol__parse_objdump_line() parses objdump output (with -d --no-show-raw) +* which looks like following +* +* 0000000000415500 <_init>: +* 415500: sub $0x8,%rsp +* 415504: mov 0x2f5ad5(%rip),%rax # 70afe0 <_DYNAMIC+0x2f8> +* 41550b: test %rax,%rax +* 41550e: je 415515 <_init+0x15> +* 415510: callq 416e70 <__gmon_start__@plt> +* 415515: add $0x8,%rsp +* 415519: retq +* +* it will be parsed and saved into struct disasm_line as +* <offset> <name> <ops.raw> +* +* The offset will be a relative offset from the start of the symbol and -1 +* means that it's not a disassembly line so should be treated differently. +* The ops.raw part will be parsed further according to type of the instruction. +*/ static int symbol__parse_objdump_line (struct symbol *sym,struct map *map,FILE *file,size_t privsize) {
Namhyung Kim
maintainerPATCH 3/12 perf annotate: Factor out disasm__calc_percent()
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
Factor out calculation of histogram of a symbol into disasm__calc_percent. It'll be used for later changes.
--- tools/perf/util/annotate.c | 49 ++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 19 deletions(-)
tools/perf/util/annotate.c +30 -19
@@ -603,6 +603,33 @@ struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disareturn NULL ; } +static double disasm__calc_percent (struct disasm_line *next, +struct annotation *notes,int evidx, +s64 offset,u64 len,const char **path) +{ +struct source_line *src_line = notes->src->lines; +struct sym_hist *h =annotation__histogram (notes, evidx); +unsigned int hits =0 ; +double percent =0.0 ; + +while (offset < (s64 )len && + (next ==NULL || offset < next->offset)) { +if (src_line) { +if (*path ==NULL ) + *path = src_line[offset].path; + percent += src_line[offset].percent; + }else + hits += h->addr[offset]; + + ++offset; + } + +if (src_line ==NULL && h->sum) + percent =100.0 * hits / h->sum; + +return percent; +} +static int disasm_line__print (struct disasm_line *dl,struct symbol *sym,u64 start,struct perf_evsel *evsel,u64 len,int min_pcnt,int printed,int max_lines,struct disasm_line *queue)
@@ -612,33 +639,17 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 stif (dl->offset !=-1 ) {const char *path =NULL ; -unsigned int hits =0 ; -double percent =0.0 ; +double percent;const char *color;struct annotation *notes =symbol__annotation (sym); -struct source_line *src_line = notes->src->lines; -struct sym_hist *h =annotation__histogram (notes, evsel->idx);s64 offset = dl->offset;const u64 addr = start + offset;struct disasm_line *next; next =disasm__get_next_ip_line (¬es->src->source, dl); -while (offset < (s64 )len && - (next ==NULL || offset < next->offset)) { -if (src_line) { -if (path ==NULL ) - path = src_line[offset].path; - percent += src_line[offset].percent; - }else - hits += h->addr[offset]; - - ++offset; - } - -if (src_line ==NULL && h->sum) - percent =100.0 * hits / h->sum; - + percent =disasm__calc_percent (next, notes, evsel->idx, + offset, len, &path);if (percent < min_pcnt)return -1 ;
Signature · 1 line
1.7.11.7
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf annotate: Factor out disasm__calc_percent()
perf annotate: Factor out disasm__calc_percent()
Commit-ID: e5ccf9f45d8bff6bfeafa561d2238b0e4beb415e Gitweb: http://git.kernel.org/tip/e5ccf9f45d8bff6bfeafa561d2238b0e4beb415e Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 5 Mar 2013 14:53:23 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 15 Mar 2013 13:06:04 -0300
perf annotate: Factor out disasm__calc_percent()
Factor out calculation of histogram of a symbol into disasm__calc_percent. It'll be used for later changes.
--- tools/perf/util/annotate.c | 49 ++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 19 deletions(-)
tools/perf/util/annotate.c +30 -19
@@ -603,6 +603,33 @@ struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disareturn NULL ; } +static double disasm__calc_percent (struct disasm_line *next, +struct annotation *notes,int evidx, +s64 offset,u64 len,const char **path) +{ +struct source_line *src_line = notes->src->lines; +struct sym_hist *h =annotation__histogram (notes, evidx); +unsigned int hits =0 ; +double percent =0.0 ; + +while (offset < (s64 )len && + (next ==NULL || offset < next->offset)) { +if (src_line) { +if (*path ==NULL ) + *path = src_line[offset].path; + percent += src_line[offset].percent; + }else + hits += h->addr[offset]; + + ++offset; + } + +if (src_line ==NULL && h->sum) + percent =100.0 * hits / h->sum; + +return percent; +} +static int disasm_line__print (struct disasm_line *dl,struct symbol *sym,u64 start,struct perf_evsel *evsel,u64 len,int min_pcnt,int printed,int max_lines,struct disasm_line *queue)
@@ -612,33 +639,17 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 stif (dl->offset !=-1 ) {const char *path =NULL ; -unsigned int hits =0 ; -double percent =0.0 ; +double percent;const char *color;struct annotation *notes =symbol__annotation (sym); -struct source_line *src_line = notes->src->lines; -struct sym_hist *h =annotation__histogram (notes, evsel->idx);s64 offset = dl->offset;const u64 addr = start + offset;struct disasm_line *next; next =disasm__get_next_ip_line (¬es->src->source, dl); -while (offset < (s64 )len && - (next ==NULL || offset < next->offset)) { -if (src_line) { -if (path ==NULL ) - path = src_line[offset].path; - percent += src_line[offset].percent; - }else - hits += h->addr[offset]; - - ++offset; - } - -if (src_line ==NULL && h->sum) - percent =100.0 * hits / h->sum; - + percent =disasm__calc_percent (next, notes, evsel->idx, + offset, len, &path);if (percent < min_pcnt)return -1 ;
Namhyung Kim
maintainerPATCH 4/12 perf annotate: Cleanup disasm__calc_percent()
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
The loop end condition is calculated from next disasm_line or the symbol size if it's the last disasm_line. But it doesn't need to be calculated at every iteration. Moving it out of the function can simplify code a bit. Also the src_line doesn't need to be checked in every time.
--- tools/perf/util/annotate.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
tools/perf/util/annotate.c +15 -15
@@ -603,29 +603,28 @@ struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disareturn NULL ; } -static double disasm__calc_percent (struct disasm_line *next, -struct annotation *notes,int evidx, -s64 offset,u64 len,const char **path) +static double disasm__calc_percent (struct annotation *notes,int evidx, +s64 offset,s64 end,const char **path) {struct source_line *src_line = notes->src->lines;struct sym_hist *h =annotation__histogram (notes, evidx);unsigned int hits =0 ;double percent =0.0 ; -while (offset < (s64 )len && - (next ==NULL || offset < next->offset)) { -if (src_line) { +if (src_line) { +while (offset < end) {if (*path ==NULL ) *path = src_line[offset].path; - percent += src_line[offset].percent; - }else - hits += h->addr[offset]; - ++offset; - } + percent += src_line[offset++].percent; + } + }else { +while (offset < end) + hits += h->addr[offset++]; -if (src_line ==NULL && h->sum) - percent =100.0 * hits / h->sum; +if (h->sum) + percent =100.0 * hits / h->sum; + }return percent; }
@@ -648,8 +647,9 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st next =disasm__get_next_ip_line (¬es->src->source, dl); - percent =disasm__calc_percent (next, notes, evsel->idx, - offset, len, &path); + percent =disasm__calc_percent (notes, evsel->idx, offset, + next ? next->offset : (s64 ) len, + &path);if (percent < min_pcnt)return -1 ;
Signature · 1 line
1.7.11.7
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf annotate: Cleanup disasm__calc_percent()
perf annotate: Cleanup disasm__calc_percent()
Commit-ID: bd64fcb8805d8e4575f95f0df22f43b74418a4ec Gitweb: http://git.kernel.org/tip/bd64fcb8805d8e4575f95f0df22f43b74418a4ec Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 5 Mar 2013 14:53:24 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 15 Mar 2013 13:06:05 -0300
perf annotate: Cleanup disasm__calc_percent()
The loop end condition is calculated from next disasm_line or the symbol size if it's the last disasm_line. But it doesn't need to be calculated at every iteration. Moving it out of the function can simplify code a bit. Also the src_line doesn't need to be checked in every time.
--- tools/perf/util/annotate.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
tools/perf/util/annotate.c +15 -15
@@ -603,29 +603,28 @@ struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disareturn NULL ; } -static double disasm__calc_percent (struct disasm_line *next, -struct annotation *notes,int evidx, -s64 offset,u64 len,const char **path) +static double disasm__calc_percent (struct annotation *notes,int evidx, +s64 offset,s64 end,const char **path) {struct source_line *src_line = notes->src->lines;struct sym_hist *h =annotation__histogram (notes, evidx);unsigned int hits =0 ;double percent =0.0 ; -while (offset < (s64 )len && - (next ==NULL || offset < next->offset)) { -if (src_line) { +if (src_line) { +while (offset < end) {if (*path ==NULL ) *path = src_line[offset].path; - percent += src_line[offset].percent; - }else - hits += h->addr[offset]; - ++offset; - } + percent += src_line[offset++].percent; + } + }else { +while (offset < end) + hits += h->addr[offset++]; -if (src_line ==NULL && h->sum) - percent =100.0 * hits / h->sum; +if (h->sum) + percent =100.0 * hits / h->sum; + }return percent; }
@@ -648,8 +647,9 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st next =disasm__get_next_ip_line (¬es->src->source, dl); - percent =disasm__calc_percent (next, notes, evsel->idx, - offset, len, &path); + percent =disasm__calc_percent (notes, evsel->idx, offset, + next ? next->offset : (s64 ) len, + &path);if (percent < min_pcnt)return -1 ;
Namhyung Kim
maintainerPATCH 5/12 perf annotate: Add basic support to event group view
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
Add --group option to enable event grouping. When enabled, all the group members information will be shown with the leader so skip non-leader events.
It only supports --stdio output currently. Later patches will extend additional features.
$ perf annotate --group --stdio
...
Percent | Source code & Disassembly of libpthread-2.15.so
--------------------------------------------------------------------------------
:
:
:
: Disassembly of section .text:
:
: 000000387dc0aa50 <__pthread_mutex_unlock_usercnt>:
8.08 2.40 5.29 : 387dc0aa50: mov %rdi,%rdx
0.00 0.00 0.00 : 387dc0aa53: mov 0x10(%rdi),%edi
0.00 0.00 0.00 : 387dc0aa56: mov %edi,%eax
0.00 0.80 0.00 : 387dc0aa58: and $0x7f,%eax
3.03 2.40 3.53 : 387dc0aa5b: test $0x7c,%dil
0.00 0.00 0.00 : 387dc0aa5f: jne 387dc0aaa9 <__pthread_mutex_unlock_use
0.00 0.00 0.00 : 387dc0aa61: test %eax,%eax
0.00 0.00 0.00 : 387dc0aa63: jne 387dc0aa85 <__pthread_mutex_unlock_use
0.00 0.00 0.00 : 387dc0aa65: and $0x80,%edi
0.00 0.00 0.00 : 387dc0aa6b: test %esi,%esi
3.03 5.60 7.06 : 387dc0aa6d: movl $0x0,0x8(%rdx)
0.00 0.00 0.59 : 387dc0aa74: je 387dc0aa7a <__pthread_mutex_unlock_use
0.00 0.00 0.00 : 387dc0aa76: subl $0x1,0xc(%rdx)
2.02 5.60 1.18 : 387dc0aa7a: mov %edi,%esi
0.00 0.00 0.00 : 387dc0aa7c: lock decl (%rdx)
83.84 83.20 82.35 : 387dc0aa7f: jne 387dc0aada <_L_unlock_586>
0.00 0.00 0.00 : 387dc0aa81: nop
0.00 0.00 0.00 : 387dc0aa82: xor %eax,%eax
0.00 0.00 0.00 : 387dc0aa84: retq
...--- tools/perf/Documentation/perf-annotate.txt | 3 ++ tools/perf/builtin-annotate.c | 7 ++++ tools/perf/util/annotate.c | 64 +++++++++++++++++++++++++----- 3 files changed, 63 insertions(+), 11 deletions(-)
tools/perf/Documentation/perf-annotate.txt +3 -0
@@ -93,6 +93,9 @@ OPTIONS --skip-missing:: Skip symbols that cannot be annotated. +--group:: + Show event group information together + SEE ALSO -------- linkperf:perf-record[1], linkperf:perf-report[1]
tools/perf/builtin-annotate.c +7 -0
@@ -232,6 +232,11 @@ static int __cmd_annotate(struct perf_annotate *ann) total_nr_samples += nr_samples;hists__collapse_resort (hists);hists__output_resort (hists); + +if (symbol_conf.event_group && + !perf_evsel__is_group_leader (pos)) +continue ; +hists__find_annotations (hists, pos, ann); } }
@@ -314,6 +319,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) "Specify disassembler style (e.g. -M intel for intel syntax)"),OPT_STRING (0 ,"objdump" , &objdump_path,"path" ,"objdump binary to use for disassembly and annotations" ), +OPT_BOOLEAN (0 ,"group" , &symbol_conf.event_group, +"Show event group information together" ), OPT_END() };
tools/perf/util/annotate.c +53 -11
112 lines not on this page · raw message
Signature · 1 line
1.7.11.7
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf annotate: Add basic support to event group view
perf annotate: Add basic support to event group view
Commit-ID: b1dd443296b4f8c6869eba790eec950f80392aea Gitweb: http://git.kernel.org/tip/b1dd443296b4f8c6869eba790eec950f80392aea Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 5 Mar 2013 14:53:25 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 15 Mar 2013 13:06:05 -0300
perf annotate: Add basic support to event group view
Add --group option to enable event grouping. When enabled, all the group members information will be shown with the leader so skip non-leader events.
It only supports --stdio output currently. Later patches will extend additional features.
$ perf annotate --group --stdio
...
Percent | Source code & Disassembly of libpthread-2.15.so
--------------------------------------------------------------------------------
:
:
:
: Disassembly of section .text:
:
: 000000387dc0aa50 <__pthread_mutex_unlock_usercnt>:
8.08 2.40 5.29 : 387dc0aa50: mov %rdi,%rdx
0.00 0.00 0.00 : 387dc0aa53: mov 0x10(%rdi),%edi
0.00 0.00 0.00 : 387dc0aa56: mov %edi,%eax
0.00 0.80 0.00 : 387dc0aa58: and $0x7f,%eax
3.03 2.40 3.53 : 387dc0aa5b: test $0x7c,%dil
0.00 0.00 0.00 : 387dc0aa5f: jne 387dc0aaa9 <__pthread_mutex_unlock_use
0.00 0.00 0.00 : 387dc0aa61: test %eax,%eax
0.00 0.00 0.00 : 387dc0aa63: jne 387dc0aa85 <__pthread_mutex_unlock_use
0.00 0.00 0.00 : 387dc0aa65: and $0x80,%edi
0.00 0.00 0.00 : 387dc0aa6b: test %esi,%esi
3.03 5.60 7.06 : 387dc0aa6d: movl $0x0,0x8(%rdx)
0.00 0.00 0.59 : 387dc0aa74: je 387dc0aa7a <__pthread_mutex_unlock_use
0.00 0.00 0.00 : 387dc0aa76: subl $0x1,0xc(%rdx)
2.02 5.60 1.18 : 387dc0aa7a: mov %edi,%esi
0.00 0.00 0.00 : 387dc0aa7c: lock decl (%rdx)
83.84 83.20 82.35 : 387dc0aa7f: jne 387dc0aada <_L_unlock_586>
0.00 0.00 0.00 : 387dc0aa81: nop
0.00 0.00 0.00 : 387dc0aa82: xor %eax,%eax
0.00 0.00 0.00 : 387dc0aa84: retq
...--- tools/perf/Documentation/perf-annotate.txt | 3 ++ tools/perf/builtin-annotate.c | 7 ++++ tools/perf/util/annotate.c | 64 +++++++++++++++++++++++++----- 3 files changed, 63 insertions(+), 11 deletions(-)
tools/perf/Documentation/perf-annotate.txt +3 -0
@@ -93,6 +93,9 @@ OPTIONS --skip-missing:: Skip symbols that cannot be annotated. +--group:: + Show event group information together + SEE ALSO -------- linkperf:perf-record[1], linkperf:perf-report[1]
tools/perf/builtin-annotate.c +7 -0
@@ -232,6 +232,11 @@ static int __cmd_annotate(struct perf_annotate *ann) total_nr_samples += nr_samples;hists__collapse_resort (hists);hists__output_resort (hists); + +if (symbol_conf.event_group && + !perf_evsel__is_group_leader (pos)) +continue ; +hists__find_annotations (hists, pos, ann); } }
@@ -314,6 +319,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) "Specify disassembler style (e.g. -M intel for intel syntax)"),OPT_STRING (0 ,"objdump" , &objdump_path,"path" ,"objdump binary to use for disassembly and annotations" ), +OPT_BOOLEAN (0 ,"group" , &symbol_conf.event_group, +"Show event group information together" ), OPT_END() };
tools/perf/util/annotate.c +53 -11
112 lines not on this page · raw message
Namhyung Kim
maintainerPATCH 6/12 perf evsel: Introduce perf_evsel__is_group_event() helper
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
The perf_evsel__is_group_event function is for checking whether given evsel needs event group view support or not. Please note that it's different to the existing perf_evsel__is_group_leader() which checks only the given evsel is a leader or a standalone (i.e. non-group) event regardless of event group feature.
--- tools/perf/builtin-report.c | 2 +- tools/perf/ui/browsers/hists.c | 4 ++-- tools/perf/ui/gtk/hists.c | 7 ++----- tools/perf/ui/hist.c | 7 ++----- tools/perf/util/annotate.c | 9 +++------ tools/perf/util/evsel.h | 24 ++++++++++++++++++++++++ 6 files changed, 34 insertions(+), 19 deletions(-)
tools/perf/builtin-report.c +1 -1
@@ -314,7 +314,7 @@ static size_t hists__fprintf_nr_sample_events(struct hists *self,char buf[512 ];size_t size =sizeof (buf); -if (symbol_conf.event_group && evsel->nr_members >1 ) { +if (perf_evsel__is_group_event (evsel)) {struct perf_evsel *pos;perf_evsel__group_desc (evsel, buf, size);
tools/perf/ui/browsers/hists.c +2 -2
@@ -1193,7 +1193,7 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size,char buf[512 ];size_t buflen =sizeof (buf); -if (symbol_conf.event_group && evsel->nr_members >1 ) { +if (perf_evsel__is_group_event (evsel)) {struct perf_evsel *pos;perf_evsel__group_desc (evsel, buf, buflen);
@@ -1709,7 +1709,7 @@ static void perf_evsel_menu__write(struct ui_browser *browser,ui_browser__set_color (browser, current_entry ?HE_COLORSET_SELECTED :HE_COLORSET_NORMAL ); -if (symbol_conf.event_group && evsel->nr_members >1 ) { +if (perf_evsel__is_group_event (evsel)) {struct perf_evsel *pos; ev_name =perf_evsel__group_name (evsel);
tools/perf/ui/gtk/hists.c +2 -5
@@ -32,21 +32,18 @@ static int __hpp__color_fmt(struct perf_hpp *hpp, struct hist_entry *he,int ret;double percent =0.0 ;struct hists *hists = he->hists; +struct perf_evsel *evsel =hists_to_evsel (hists);if (hists->stats.total_period) percent =100.0 *get_field (he) / hists->stats.total_period; ret =__percent_color_snprintf (hpp->buf, hpp->size, percent); -if (symbol_conf.event_group) { +if (perf_evsel__is_group_event (evsel)) {int prev_idx, idx_delta; -struct perf_evsel *evsel =hists_to_evsel (hists);struct hist_entry *pair;int nr_members = evsel->nr_members; -if (nr_members <=1 ) -return ret; - prev_idx =perf_evsel__group_idx (evsel);list_for_each_entry (pair, &he->pairs.head, pairs.node) {
tools/perf/ui/hist.c +2 -5
@@ -16,6 +16,7 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, {int ret;struct hists *hists = he->hists; +struct perf_evsel *evsel =hists_to_evsel (hists);if (fmt_percent) {double percent =0.0 ;
@@ -28,15 +29,11 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, }else ret =print_fn (hpp->buf, hpp->size, fmt,get_field (he)); -if (symbol_conf.event_group) { +if (perf_evsel__is_group_event (evsel)) {int prev_idx, idx_delta; -struct perf_evsel *evsel =hists_to_evsel (hists);struct hist_entry *pair;int nr_members = evsel->nr_members; -if (nr_members <=1 ) -return ret; - prev_idx =perf_evsel__group_idx (evsel);list_for_each_entry (pair, &he->pairs.head, pairs.node) {
tools/perf/util/annotate.c +3 -6
@@ -649,9 +649,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st next =disasm__get_next_ip_line (¬es->src->source, dl); -if (symbol_conf.event_group && -perf_evsel__is_group_leader (evsel) && - evsel->nr_members >1 ) { +if (perf_evsel__is_group_event (evsel)) { nr_percent = evsel->nr_members; ppercents =calloc (nr_percent,sizeof (double ));if (ppercents ==NULL )
@@ -721,8 +719,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 stif (queue)return -1 ; -if (symbol_conf.event_group && -perf_evsel__is_group_leader (evsel)) +if (perf_evsel__is_group_event (evsel)) width *= evsel->nr_members;if (!*dl->line)
@@ -1126,7 +1123,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, len =symbol__size (sym); namelen =strlen (d_filename); -if (symbol_conf.event_group &&perf_evsel__is_group_leader (evsel)) +if (perf_evsel__is_group_event (evsel)) width *= evsel->nr_members; printf(" %-*.*s| Source code & Disassembly of %s\n",
tools/perf/util/evsel.h +24 -0
@@ -9,6 +9,7 @@#include "xyarray.h" #include "cgroup.h" #include "hist.h" +#include "symbol.h" struct perf_counts_values { union {
@@ -246,11 +247,34 @@ static inline struct perf_evsel *perf_evsel__next(struct perf_evsel *evsel) return list_entry(evsel->node.next, struct perf_evsel, node); } +/** +* perf_evsel__is_group_leader - Return whether given evsel is a leader event +* +* @evsel - evsel selector to be tested +* +* Return %true if @evsel is a group leader or a stand-alone event +*/ static inline bool perf_evsel__is_group_leader (const struct perf_evsel *evsel) {return evsel->leader == evsel; } +/** +* perf_evsel__is_group_event - Return whether given evsel is a group event +* +* @evsel - evsel selector to be tested +* +* Return %true iff event group view is enabled and @evsel is a actual group +* leader which has other members in the group +*/ +static inline bool perf_evsel__is_group_event (struct perf_evsel *evsel) +{ +if (!symbol_conf.event_group) +return false; + +return perf_evsel__is_group_leader (evsel) && evsel->nr_members >1 ; +} +struct perf_attr_details {bool freq;bool verbose;
Signature · 1 line
1.7.11.7
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf evsel: Introduce perf_evsel__is_group_event( ) helper
perf evsel: Introduce perf_evsel__is_group_event() helper
Commit-ID: 759ff497e0e6749437b6723f8d26de0b1833c199 Gitweb: http://git.kernel.org/tip/759ff497e0e6749437b6723f8d26de0b1833c199 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 5 Mar 2013 14:53:26 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 15 Mar 2013 13:06:05 -0300
perf evsel: Introduce perf_evsel__is_group_event() helper
The perf_evsel__is_group_event function is for checking whether given evsel needs event group view support or not. Please note that it's different to the existing perf_evsel__is_group_leader() which checks only the given evsel is a leader or a standalone (i.e. non-group) event regardless of event group feature.
--- tools/perf/builtin-report.c | 2 +- tools/perf/ui/browsers/hists.c | 4 ++-- tools/perf/ui/gtk/hists.c | 7 ++----- tools/perf/ui/hist.c | 7 ++----- tools/perf/util/annotate.c | 9 +++------ tools/perf/util/evsel.h | 24 ++++++++++++++++++++++++ 6 files changed, 34 insertions(+), 19 deletions(-)
tools/perf/builtin-report.c +1 -1
@@ -314,7 +314,7 @@ static size_t hists__fprintf_nr_sample_events(struct hists *self,char buf[512 ];size_t size =sizeof (buf); -if (symbol_conf.event_group && evsel->nr_members >1 ) { +if (perf_evsel__is_group_event (evsel)) {struct perf_evsel *pos;perf_evsel__group_desc (evsel, buf, size);
tools/perf/ui/browsers/hists.c +2 -2
@@ -1193,7 +1193,7 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size,char buf[512 ];size_t buflen =sizeof (buf); -if (symbol_conf.event_group && evsel->nr_members >1 ) { +if (perf_evsel__is_group_event (evsel)) {struct perf_evsel *pos;perf_evsel__group_desc (evsel, buf, buflen);
@@ -1709,7 +1709,7 @@ static void perf_evsel_menu__write(struct ui_browser *browser,ui_browser__set_color (browser, current_entry ?HE_COLORSET_SELECTED :HE_COLORSET_NORMAL ); -if (symbol_conf.event_group && evsel->nr_members >1 ) { +if (perf_evsel__is_group_event (evsel)) {struct perf_evsel *pos; ev_name =perf_evsel__group_name (evsel);
tools/perf/ui/gtk/hists.c +2 -5
@@ -32,21 +32,18 @@ static int __hpp__color_fmt(struct perf_hpp *hpp, struct hist_entry *he,int ret;double percent =0.0 ;struct hists *hists = he->hists; +struct perf_evsel *evsel =hists_to_evsel (hists);if (hists->stats.total_period) percent =100.0 *get_field (he) / hists->stats.total_period; ret =__percent_color_snprintf (hpp->buf, hpp->size, percent); -if (symbol_conf.event_group) { +if (perf_evsel__is_group_event (evsel)) {int prev_idx, idx_delta; -struct perf_evsel *evsel =hists_to_evsel (hists);struct hist_entry *pair;int nr_members = evsel->nr_members; -if (nr_members <=1 ) -return ret; - prev_idx =perf_evsel__group_idx (evsel);list_for_each_entry (pair, &he->pairs.head, pairs.node) {
tools/perf/ui/hist.c +2 -5
@@ -16,6 +16,7 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, {int ret;struct hists *hists = he->hists; +struct perf_evsel *evsel =hists_to_evsel (hists);if (fmt_percent) {double percent =0.0 ;
@@ -28,15 +29,11 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, }else ret =print_fn (hpp->buf, hpp->size, fmt,get_field (he)); -if (symbol_conf.event_group) { +if (perf_evsel__is_group_event (evsel)) {int prev_idx, idx_delta; -struct perf_evsel *evsel =hists_to_evsel (hists);struct hist_entry *pair;int nr_members = evsel->nr_members; -if (nr_members <=1 ) -return ret; - prev_idx =perf_evsel__group_idx (evsel);list_for_each_entry (pair, &he->pairs.head, pairs.node) {
tools/perf/util/annotate.c +3 -6
@@ -649,9 +649,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st next =disasm__get_next_ip_line (¬es->src->source, dl); -if (symbol_conf.event_group && -perf_evsel__is_group_leader (evsel) && - evsel->nr_members >1 ) { +if (perf_evsel__is_group_event (evsel)) { nr_percent = evsel->nr_members; ppercents =calloc (nr_percent,sizeof (double ));if (ppercents ==NULL )
@@ -721,8 +719,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 stif (queue)return -1 ; -if (symbol_conf.event_group && -perf_evsel__is_group_leader (evsel)) +if (perf_evsel__is_group_event (evsel)) width *= evsel->nr_members;if (!*dl->line)
@@ -1126,7 +1123,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, len =symbol__size (sym); namelen =strlen (d_filename); -if (symbol_conf.event_group &&perf_evsel__is_group_leader (evsel)) +if (perf_evsel__is_group_event (evsel)) width *= evsel->nr_members; printf(" %-*.*s| Source code & Disassembly of %s\n",
tools/perf/util/evsel.h +24 -0
@@ -9,6 +9,7 @@#include "xyarray.h" #include "cgroup.h" #include "hist.h" +#include "symbol.h" struct perf_counts_values { union {
@@ -246,11 +247,34 @@ static inline struct perf_evsel *perf_evsel__next(struct perf_evsel *evsel) return list_entry(evsel->node.next, struct perf_evsel, node); } +/** +* perf_evsel__is_group_leader - Return whether given evsel is a leader event +* +* @evsel - evsel selector to be tested +* +* Return %true if @evsel is a group leader or a stand-alone event +*/ static inline bool perf_evsel__is_group_leader (const struct perf_evsel *evsel) {return evsel->leader == evsel; } +/** +* perf_evsel__is_group_event - Return whether given evsel is a group event +* +* @evsel - evsel selector to be tested +* +* Return %true iff event group view is enabled and @evsel is a actual group +* leader which has other members in the group +*/ +static inline bool perf_evsel__is_group_event (struct perf_evsel *evsel) +{ +if (!symbol_conf.event_group) +return false; + +return perf_evsel__is_group_leader (evsel) && evsel->nr_members >1 ; +} +struct perf_attr_details {bool freq;bool verbose;
Namhyung Kim
maintainerPATCH 7/12 perf annotate: Factor out struct source_line_percent
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
The source_line_percent struct contains percentage value of the symbol histogram. This is a preparation of event group view change.
--- tools/perf/ui/browsers/annotate.c | 2 +- tools/perf/util/annotate.c | 14 +++++++------- tools/perf/util/annotate.h | 8 ++++++-- 3 files changed, 14 insertions(+), 10 deletions(-)
tools/perf/ui/browsers/annotate.c +1 -1
@@ -257,7 +257,7 @@ static double disasm_line__calc_percent(struct disasm_line *dl, struct symbol *swhile (offset < (s64 )len && (next ==NULL || offset < next->offset)) {if (src_line) { - percent += src_line[offset].percent; + percent += src_line[offset].p[0 ].percent; }else hits += h->addr[offset];
tools/perf/util/annotate.c +7 -7
@@ -616,7 +616,7 @@ static double disasm__calc_percent(struct annotation *notes, int evidx,if (*path ==NULL ) *path = src_line[offset].path; - percent += src_line[offset++].percent; + percent += src_line[offset++].p[0 ].percent; } }else {while (offset < end)
@@ -929,7 +929,7 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin ret =strcmp (iter->path, src_line->path);if (ret ==0 ) { - iter->percent_sum += src_line->percent; + iter->p[0 ].percent_sum += src_line->p[0 ].percent;return ; }
@@ -939,7 +939,7 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin p = &(*p)->rb_right; } - src_line->percent_sum = src_line->percent; + src_line->p[0 ].percent_sum = src_line->p[0 ].percent;rb_link_node (&src_line->node, parent, p);rb_insert_color (&src_line->node, root);
@@ -955,7 +955,7 @@ static void __resort_source_line(struct rb_root *root, struct source_line *src_l parent = *p; iter = rb_entry(parent, struct source_line, node); -if (src_line->percent_sum > iter->percent_sum) +if (src_line->p[0 ].percent_sum > iter->p[0 ].percent_sum) p = &(*p)->rb_left;else p = &(*p)->rb_right;
@@ -1025,8 +1025,8 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,u64 offset;FILE *fp; - src_line[i].percent =100.0 * h->addr[i] / h->sum; -if (src_line[i].percent <=0.5 ) + src_line[i].p[0 ].percent =100.0 * h->addr[i] / h->sum; +if (src_line[i].p[0 ].percent <=0.5 )continue ; offset = start + i;
@@ -1073,7 +1073,7 @@ static void print_summary(struct rb_root *root, const char *filename)char *path; src_line = rb_entry(node, struct source_line, node); - percent = src_line->percent_sum; + percent = src_line->p[0 ].percent_sum; color =get_percent_color (percent); path = src_line->path;
tools/perf/util/annotate.h +6 -2
@@ -74,11 +74,15 @@ struct sym_hist {u64 addr[0 ]; }; -struct source_line { -struct rb_node node; +struct source_line_percent {double percent;double percent_sum; +}; + +struct source_line { +struct rb_node node;char *path; +struct source_line_percent p[1 ]; };/** struct annotated_source - symbols with hits have this attached as in sannotation
Signature · 1 line
1.7.11.7
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf annotate: Factor out struct source_line_percent
perf annotate: Factor out struct source_line_percent
Commit-ID: c5a8368ca667d22a6e45396f23a5392d90396f39 Gitweb: http://git.kernel.org/tip/c5a8368ca667d22a6e45396f23a5392d90396f39 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 5 Mar 2013 14:53:27 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 15 Mar 2013 13:06:06 -0300
perf annotate: Factor out struct source_line_percent
The source_line_percent struct contains percentage value of the symbol histogram. This is a preparation of event group view change.
--- tools/perf/ui/browsers/annotate.c | 2 +- tools/perf/util/annotate.c | 14 +++++++------- tools/perf/util/annotate.h | 8 ++++++-- 3 files changed, 14 insertions(+), 10 deletions(-)
tools/perf/ui/browsers/annotate.c +1 -1
@@ -257,7 +257,7 @@ static double disasm_line__calc_percent(struct disasm_line *dl, struct symbol *swhile (offset < (s64 )len && (next ==NULL || offset < next->offset)) {if (src_line) { - percent += src_line[offset].percent; + percent += src_line[offset].p[0 ].percent; }else hits += h->addr[offset];
tools/perf/util/annotate.c +7 -7
@@ -616,7 +616,7 @@ static double disasm__calc_percent(struct annotation *notes, int evidx,if (*path ==NULL ) *path = src_line[offset].path; - percent += src_line[offset++].percent; + percent += src_line[offset++].p[0 ].percent; } }else {while (offset < end)
@@ -929,7 +929,7 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin ret =strcmp (iter->path, src_line->path);if (ret ==0 ) { - iter->percent_sum += src_line->percent; + iter->p[0 ].percent_sum += src_line->p[0 ].percent;return ; }
@@ -939,7 +939,7 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin p = &(*p)->rb_right; } - src_line->percent_sum = src_line->percent; + src_line->p[0 ].percent_sum = src_line->p[0 ].percent;rb_link_node (&src_line->node, parent, p);rb_insert_color (&src_line->node, root);
@@ -955,7 +955,7 @@ static void __resort_source_line(struct rb_root *root, struct source_line *src_l parent = *p; iter = rb_entry(parent, struct source_line, node); -if (src_line->percent_sum > iter->percent_sum) +if (src_line->p[0 ].percent_sum > iter->p[0 ].percent_sum) p = &(*p)->rb_left;else p = &(*p)->rb_right;
@@ -1025,8 +1025,8 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,u64 offset;FILE *fp; - src_line[i].percent =100.0 * h->addr[i] / h->sum; -if (src_line[i].percent <=0.5 ) + src_line[i].p[0 ].percent =100.0 * h->addr[i] / h->sum; +if (src_line[i].p[0 ].percent <=0.5 )continue ; offset = start + i;
@@ -1073,7 +1073,7 @@ static void print_summary(struct rb_root *root, const char *filename)char *path; src_line = rb_entry(node, struct source_line, node); - percent = src_line->percent_sum; + percent = src_line->p[0 ].percent_sum; color =get_percent_color (percent); path = src_line->path;
tools/perf/util/annotate.h +6 -2
@@ -74,11 +74,15 @@ struct sym_hist {u64 addr[0 ]; }; -struct source_line { -struct rb_node node; +struct source_line_percent {double percent;double percent_sum; +}; + +struct source_line { +struct rb_node node;char *path; +struct source_line_percent p[1 ]; };/** struct annotated_source - symbols with hits have this attached as in sannotation
Namhyung Kim
maintainerPATCH 8/12 perf annotate: Support event group view for --print-line
In reply to Namhyung KimDynamically allocate source_line_percent according to a number of group members and save nr_pcnt to the struct source_line. This way we can handle multiple events in a general manner.
However since the size of struct source_line is not fixed anymore, iterating whole source_line should care about its size.
$ perf annotate --group --stdio --print-line
Sorted summary for file /lib/ld-2.11.1.so
----------------------------------------------
33.33 0.00 /build/buildd/eglibc-2.11.1/elf/rtld.c:381
33.33 0.00 /build/buildd/eglibc-2.11.1/elf/dynamic-link.h:128
33.33 0.00 /build/buildd/eglibc-2.11.1/elf/do-rel.h:105
0.00 75.00 /build/buildd/eglibc-2.11.1/elf/dynamic-link.h:137
0.00 25.00 /build/buildd/eglibc-2.11.1/elf/dynamic-link.h:187...
--- tools/perf/util/annotate.c | 130 +++++++++++++++++++++++++++++++++------------ tools/perf/util/annotate.h | 1 + 2 files changed, 98 insertions(+), 33 deletions(-)
tools/perf/util/annotate.c +97 -33
@@ -607,18 +607,26 @@ static double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset, s64 end, const char **path) { struct source_line *src_line = notes->src->lines; -struct sym_hist *h =annotation__histogram (notes, evidx); -unsigned int hits =0 ;double percent =0.0 ;if (src_line) { +size_t sizeof_src_line =sizeof (*src_line) + +sizeof (src_line->p) * (src_line->nr_pcnt -1 ); +while (offset < end) { + src_line = (void *)notes->src->lines + + (sizeof_src_line * offset); +if (*path ==NULL ) - *path = src_line[offset].path; + *path = src_line->path; - percent += src_line[offset++].p[0 ].percent; + percent += src_line->p[evidx].percent; + offset++; } }else { +struct sym_hist *h =annotation__histogram (notes, evidx); +unsigned int hits =0 ; +while (offset < end) hits += h->addr[offset++];
@@ -658,9 +666,10 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 stfor (i =0 ; i < nr_percent; i++) { percent =disasm__calc_percent (notes, - evsel->idx + i, offset, - next ? next->offset : (s64 ) len, - &path); + notes->src->lines ? i : evsel->idx + i, + offset, + next ? next->offset : (s64 ) len, + &path); ppercents[i] = percent;if (percent > max_percent)
@@ -921,7 +930,7 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_linstruct source_line *iter;struct rb_node **p = &root->rb_node;struct rb_node *parent =NULL ; -int ret; +int i, ret;while (*p !=NULL ) { parent = *p;
@@ -929,7 +938,8 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin ret =strcmp (iter->path, src_line->path);if (ret ==0 ) { - iter->p[0 ].percent_sum += src_line->p[0 ].percent; +for (i =0 ; i < src_line->nr_pcnt; i++) + iter->p[i].percent_sum += src_line->p[i].percent;return ; }
@@ -939,12 +949,26 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin p = &(*p)->rb_right; } - src_line->p[0 ].percent_sum = src_line->p[0 ].percent; +for (i =0 ; i < src_line->nr_pcnt; i++) + src_line->p[i].percent_sum = src_line->p[i].percent;rb_link_node (&src_line->node, parent, p);rb_insert_color (&src_line->node, root); } +static int cmp_source_line (struct source_line *a,struct source_line *b) +{ +int i; + +for (i =0 ; i < a->nr_pcnt; i++) { +if (a->p[i].percent_sum == b->p[i].percent_sum) +continue ; +return a->p[i].percent_sum > b->p[i].percent_sum; + } + +return 0 ; +} +static void __resort_source_line (struct rb_root *root,struct source_line *src_line) {struct source_line *iter;
@@ -955,7 +979,7 @@ static void __resort_source_line(struct rb_root *root, struct source_line *src_l parent = *p; iter = rb_entry(parent, struct source_line, node); -if (src_line->p[0 ].percent_sum > iter->p[0 ].percent_sum) +if (cmp_source_line (src_line, iter)) p = &(*p)->rb_left;else p = &(*p)->rb_right;
@@ -987,12 +1011,18 @@ static void symbol__free_source_line(struct symbol *sym, int len) {struct annotation *notes =symbol__annotation (sym);struct source_line *src_line = notes->src->lines; +size_t sizeof_src_line;int i; -for (i =0 ; i < len; i++) -free (src_line[i].path); + sizeof_src_line =sizeof (*src_line) + + (sizeof (src_line->p) * (src_line->nr_pcnt -1 )); -free (src_line); +for (i =0 ; i < len; i++) { +free (src_line->path); + src_line = (void *)src_line + sizeof_src_line; + } + +free (notes->src->lines); notes->src->lines =NULL ; }
@@ -1003,17 +1033,30 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, const char *filename) {u64 start; -int i; +int i, k; +int evidx = evsel->idx;char cmd[PATH_MAX *2 ];struct source_line *src_line;struct annotation *notes =symbol__annotation (sym); -struct sym_hist *h =annotation__histogram (notes, evsel->idx); +struct sym_hist *h =annotation__histogram (notes, evidx);struct rb_root tmp_root =RB_ROOT ; +int nr_pcnt =1 ; +u64 h_sum = h->sum; +size_t sizeof_src_line =sizeof (struct source_line ); + +if (perf_evsel__is_group_event (evsel)) { +for (i =1 ; i < evsel->nr_members; i++) { + h =annotation__histogram (notes, evidx + i); + h_sum += h->sum; + } + nr_pcnt = evsel->nr_members; + sizeof_src_line += (nr_pcnt -1 ) *sizeof (src_line->p); + } -if (!h->sum) +if (!h_sum)return 0 ; - src_line = notes->src->lines =calloc (len,sizeof (struct source_line )); + src_line = notes->src->lines =calloc (len, sizeof_src_line);if (!notes->src->lines)return -1 ;
@@ -1024,29 +1067,41 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,size_t line_len;u64 offset;FILE *fp; +double percent_max =0.0 ; - src_line[i].p[0 ].percent =100.0 * h->addr[i] / h->sum; -if (src_line[i].p[0 ].percent <=0.5 ) -continue ; + src_line->nr_pcnt = nr_pcnt; + +for (k =0 ; k < nr_pcnt; k++) { + h =annotation__histogram (notes, evidx + k); + src_line->p[k].percent =100.0 * h->addr[i] / h->sum; + +if (src_line->p[k].percent > percent_max) + percent_max = src_line->p[k].percent; + } + +if (percent_max <=0.5 ) + goto next; offset = start + i;sprintf (cmd,"addr2line -e %s %016" PRIx64, filename, offset); fp =popen (cmd,"r" );if (!fp) -continue ; + goto next;if (getline (&path, &line_len, fp) <0 || !line_len) - goto next; + goto next_close; - src_line[i].path =malloc (sizeof (char ) * line_len +1 ); -if (!src_line[i].path) - goto next; + src_line->path =malloc (sizeof (char ) * line_len +1 ); +if (!src_line->path) + goto next_close; -strcpy (src_line[i].path, path); -insert_source_line (&tmp_root, &src_line[i]); +strcpy (src_line->path, path); +insert_source_line (&tmp_root, src_line); - next: + next_close:pclose (fp); + next: + src_line = (void *)src_line + sizeof_src_line; }resort_source_line (root, &tmp_root);
@@ -1068,16 +1123,25 @@ static void print_summary(struct rb_root *root, const char *filename) node =rb_first (root);while (node) { -double percent; +double percent, percent_max =0.0 ;const char *color;char *path; +int i; src_line = rb_entry(node, struct source_line, node); - percent = src_line->p[0 ].percent_sum; - color =get_percent_color (percent); +for (i =0 ; i < src_line->nr_pcnt; i++) { + percent = src_line->p[i].percent_sum; + color =get_percent_color (percent); +color_fprintf (stdout, color," %7.2f" , percent); + +if (percent > percent_max) + percent_max = percent; + } + path = src_line->path; + color =get_percent_color (percent_max); +color_fprintf (stdout, color," %s" , path); -color_fprintf (stdout, color," %7.2f %s" , percent, path); node =rb_next (node); } }
tools/perf/util/annotate.h +1 -0
@@ -82,6 +82,7 @@ struct source_line_percent {struct source_line {struct rb_node node;char *path; +int nr_pcnt;struct source_line_percent p[1 ]; };
Signature · 1 line
1.7.11.7
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf annotate: Support event group view for --print-line
perf annotate: Support event group view for --print-line
Commit-ID: 1491c22a5f8563951d3a798758f82b471ecbf501 Gitweb: http://git.kernel.org/tip/1491c22a5f8563951d3a798758f82b471ecbf501 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 5 Mar 2013 14:53:28 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 15 Mar 2013 13:06:06 -0300
perf annotate: Support event group view for --print-line
Dynamically allocate source_line_percent according to a number of group members and save nr_pcnt to the struct source_line. This way we can handle multiple events in a general manner.
However since the size of struct source_line is not fixed anymore, iterating whole source_line should care about its size.
$ perf annotate --group --stdio --print-line
Sorted summary for file /lib/ld-2.11.1.so
----------------------------------------------
33.33 0.00 /build/buildd/eglibc-2.11.1/elf/rtld.c:381
33.33 0.00 /build/buildd/eglibc-2.11.1/elf/dynamic-link.h:128
33.33 0.00 /build/buildd/eglibc-2.11.1/elf/do-rel.h:105
0.00 75.00 /build/buildd/eglibc-2.11.1/elf/dynamic-link.h:137
0.00 25.00 /build/buildd/eglibc-2.11.1/elf/dynamic-link.h:187...
--- tools/perf/util/annotate.c | 130 +++++++++++++++++++++++++++++++++------------ tools/perf/util/annotate.h | 1 + 2 files changed, 98 insertions(+), 33 deletions(-)
tools/perf/util/annotate.c +97 -33
@@ -607,18 +607,26 @@ static double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset, s64 end, const char **path) { struct source_line *src_line = notes->src->lines; -struct sym_hist *h =annotation__histogram (notes, evidx); -unsigned int hits =0 ;double percent =0.0 ;if (src_line) { +size_t sizeof_src_line =sizeof (*src_line) + +sizeof (src_line->p) * (src_line->nr_pcnt -1 ); +while (offset < end) { + src_line = (void *)notes->src->lines + + (sizeof_src_line * offset); +if (*path ==NULL ) - *path = src_line[offset].path; + *path = src_line->path; - percent += src_line[offset++].p[0 ].percent; + percent += src_line->p[evidx].percent; + offset++; } }else { +struct sym_hist *h =annotation__histogram (notes, evidx); +unsigned int hits =0 ; +while (offset < end) hits += h->addr[offset++];
@@ -658,9 +666,10 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 stfor (i =0 ; i < nr_percent; i++) { percent =disasm__calc_percent (notes, - evsel->idx + i, offset, - next ? next->offset : (s64 ) len, - &path); + notes->src->lines ? i : evsel->idx + i, + offset, + next ? next->offset : (s64 ) len, + &path); ppercents[i] = percent;if (percent > max_percent)
@@ -921,7 +930,7 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_linstruct source_line *iter;struct rb_node **p = &root->rb_node;struct rb_node *parent =NULL ; -int ret; +int i, ret;while (*p !=NULL ) { parent = *p;
@@ -929,7 +938,8 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin ret =strcmp (iter->path, src_line->path);if (ret ==0 ) { - iter->p[0 ].percent_sum += src_line->p[0 ].percent; +for (i =0 ; i < src_line->nr_pcnt; i++) + iter->p[i].percent_sum += src_line->p[i].percent;return ; }
@@ -939,12 +949,26 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin p = &(*p)->rb_right; } - src_line->p[0 ].percent_sum = src_line->p[0 ].percent; +for (i =0 ; i < src_line->nr_pcnt; i++) + src_line->p[i].percent_sum = src_line->p[i].percent;rb_link_node (&src_line->node, parent, p);rb_insert_color (&src_line->node, root); } +static int cmp_source_line (struct source_line *a,struct source_line *b) +{ +int i; + +for (i =0 ; i < a->nr_pcnt; i++) { +if (a->p[i].percent_sum == b->p[i].percent_sum) +continue ; +return a->p[i].percent_sum > b->p[i].percent_sum; + } + +return 0 ; +} +static void __resort_source_line (struct rb_root *root,struct source_line *src_line) {struct source_line *iter;
@@ -955,7 +979,7 @@ static void __resort_source_line(struct rb_root *root, struct source_line *src_l parent = *p; iter = rb_entry(parent, struct source_line, node); -if (src_line->p[0 ].percent_sum > iter->p[0 ].percent_sum) +if (cmp_source_line (src_line, iter)) p = &(*p)->rb_left;else p = &(*p)->rb_right;
@@ -987,12 +1011,18 @@ static void symbol__free_source_line(struct symbol *sym, int len) {struct annotation *notes =symbol__annotation (sym);struct source_line *src_line = notes->src->lines; +size_t sizeof_src_line;int i; -for (i =0 ; i < len; i++) -free (src_line[i].path); + sizeof_src_line =sizeof (*src_line) + + (sizeof (src_line->p) * (src_line->nr_pcnt -1 )); -free (src_line); +for (i =0 ; i < len; i++) { +free (src_line->path); + src_line = (void *)src_line + sizeof_src_line; + } + +free (notes->src->lines); notes->src->lines =NULL ; }
@@ -1003,17 +1033,30 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, const char *filename) {u64 start; -int i; +int i, k; +int evidx = evsel->idx;char cmd[PATH_MAX *2 ];struct source_line *src_line;struct annotation *notes =symbol__annotation (sym); -struct sym_hist *h =annotation__histogram (notes, evsel->idx); +struct sym_hist *h =annotation__histogram (notes, evidx);struct rb_root tmp_root =RB_ROOT ; +int nr_pcnt =1 ; +u64 h_sum = h->sum; +size_t sizeof_src_line =sizeof (struct source_line ); + +if (perf_evsel__is_group_event (evsel)) { +for (i =1 ; i < evsel->nr_members; i++) { + h =annotation__histogram (notes, evidx + i); + h_sum += h->sum; + } + nr_pcnt = evsel->nr_members; + sizeof_src_line += (nr_pcnt -1 ) *sizeof (src_line->p); + } -if (!h->sum) +if (!h_sum)return 0 ; - src_line = notes->src->lines =calloc (len,sizeof (struct source_line )); + src_line = notes->src->lines =calloc (len, sizeof_src_line);if (!notes->src->lines)return -1 ;
@@ -1024,29 +1067,41 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,size_t line_len;u64 offset;FILE *fp; +double percent_max =0.0 ; - src_line[i].p[0 ].percent =100.0 * h->addr[i] / h->sum; -if (src_line[i].p[0 ].percent <=0.5 ) -continue ; + src_line->nr_pcnt = nr_pcnt; + +for (k =0 ; k < nr_pcnt; k++) { + h =annotation__histogram (notes, evidx + k); + src_line->p[k].percent =100.0 * h->addr[i] / h->sum; + +if (src_line->p[k].percent > percent_max) + percent_max = src_line->p[k].percent; + } + +if (percent_max <=0.5 ) + goto next; offset = start + i;sprintf (cmd,"addr2line -e %s %016" PRIx64, filename, offset); fp =popen (cmd,"r" );if (!fp) -continue ; + goto next;if (getline (&path, &line_len, fp) <0 || !line_len) - goto next; + goto next_close; - src_line[i].path =malloc (sizeof (char ) * line_len +1 ); -if (!src_line[i].path) - goto next; + src_line->path =malloc (sizeof (char ) * line_len +1 ); +if (!src_line->path) + goto next_close; -strcpy (src_line[i].path, path); -insert_source_line (&tmp_root, &src_line[i]); +strcpy (src_line->path, path); +insert_source_line (&tmp_root, src_line); - next: + next_close:pclose (fp); + next: + src_line = (void *)src_line + sizeof_src_line; }resort_source_line (root, &tmp_root);
@@ -1068,16 +1123,25 @@ static void print_summary(struct rb_root *root, const char *filename) node =rb_first (root);while (node) { -double percent; +double percent, percent_max =0.0 ;const char *color;char *path; +int i; src_line = rb_entry(node, struct source_line, node); - percent = src_line->p[0 ].percent_sum; - color =get_percent_color (percent); +for (i =0 ; i < src_line->nr_pcnt; i++) { + percent = src_line->p[i].percent_sum; + color =get_percent_color (percent); +color_fprintf (stdout, color," %7.2f" , percent); + +if (percent > percent_max) + percent_max = percent; + } + path = src_line->path; + color =get_percent_color (percent_max); +color_fprintf (stdout, color," %s" , path); -color_fprintf (stdout, color," %7.2f %s" , percent, path); node =rb_next (node); } }
tools/perf/util/annotate.h +1 -0
@@ -82,6 +82,7 @@ struct source_line_percent {struct source_line {struct rb_node node;char *path; +int nr_pcnt;struct source_line_percent p[1 ]; };
Namhyung Kim
maintainerPATCH 9/12 perf annotate browser: Make browser_disasm_line->percent an array
In reply to Namhyung KimMake percent field of struct browser_disasm_line an array and move it to the last. This is a preparation of event group view feature.
--- tools/perf/ui/browsers/annotate.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
tools/perf/ui/browsers/annotate.c +7 -7
@@ -14,10 +14,10 @@struct browser_disasm_line {struct rb_node rb_node; -double percent;u32 idx;int idx_asm;int jump_sources; +double percent[1 ]; }; static struct annotate_browser_opt {
@@ -97,9 +97,9 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, intint width = browser->width, printed;char bf[256 ]; -if (dl->offset !=-1 && bdl->percent !=0.0 ) { -ui_browser__set_percent_color (browser, bdl->percent, current_entry); -slsmg_printf ("%6.2f " , bdl->percent); +if (dl->offset !=-1 && bdl->percent[0 ] !=0.0 ) { +ui_browser__set_percent_color (browser, bdl->percent[0 ], current_entry); +slsmg_printf ("%6.2f " , bdl->percent[0 ]); }else {ui_browser__set_percent_color (browser,0 , current_entry);slsmg_write_nstring (" " ,7 );
@@ -283,7 +283,7 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct browser_disasm_lwhile (*p !=NULL ) { parent = *p; l = rb_entry(parent, struct browser_disasm_line, rb_node); -if (bdl->percent < l->percent) +if (bdl->percent[0 ] < l->percent[0 ]) p = &(*p)->rb_left;else p = &(*p)->rb_right;
@@ -345,8 +345,8 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,list_for_each_entry (pos, ¬es->src->source, node) {struct browser_disasm_line *bpos =disasm_line__browser (pos); - bpos->percent =disasm_line__calc_percent (pos, sym, evsel->idx); -if (bpos->percent <0.01 ) { + bpos->percent[0 ] =disasm_line__calc_percent (pos, sym, evsel->idx); +if (bpos->percent[0 ] <0.01 ) {RB_CLEAR_NODE (&bpos->rb_node);continue ; }
Signature · 1 line
1.7.11.7
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf annotate browser: Make browser_disasm_line-> percent an array
perf annotate browser: Make browser_disasm_line->percent an array
Commit-ID: ab77df672cdbf7a0235a9de3289c173e2fce68e5 Gitweb: http://git.kernel.org/tip/ab77df672cdbf7a0235a9de3289c173e2fce68e5 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 5 Mar 2013 14:53:29 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 15 Mar 2013 13:06:06 -0300
perf annotate browser: Make browser_disasm_line->percent an array
Make percent field of struct browser_disasm_line an array and move it to the last. This is a preparation of event group view feature.
--- tools/perf/ui/browsers/annotate.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
tools/perf/ui/browsers/annotate.c +7 -7
@@ -14,10 +14,10 @@struct browser_disasm_line {struct rb_node rb_node; -double percent;u32 idx;int idx_asm;int jump_sources; +double percent[1 ]; }; static struct annotate_browser_opt {
@@ -97,9 +97,9 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, intint width = browser->width, printed;char bf[256 ]; -if (dl->offset !=-1 && bdl->percent !=0.0 ) { -ui_browser__set_percent_color (browser, bdl->percent, current_entry); -slsmg_printf ("%6.2f " , bdl->percent); +if (dl->offset !=-1 && bdl->percent[0 ] !=0.0 ) { +ui_browser__set_percent_color (browser, bdl->percent[0 ], current_entry); +slsmg_printf ("%6.2f " , bdl->percent[0 ]); }else {ui_browser__set_percent_color (browser,0 , current_entry);slsmg_write_nstring (" " ,7 );
@@ -283,7 +283,7 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct browser_disasm_lwhile (*p !=NULL ) { parent = *p; l = rb_entry(parent, struct browser_disasm_line, rb_node); -if (bdl->percent < l->percent) +if (bdl->percent[0 ] < l->percent[0 ]) p = &(*p)->rb_left;else p = &(*p)->rb_right;
@@ -345,8 +345,8 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,list_for_each_entry (pos, ¬es->src->source, node) {struct browser_disasm_line *bpos =disasm_line__browser (pos); - bpos->percent =disasm_line__calc_percent (pos, sym, evsel->idx); -if (bpos->percent <0.01 ) { + bpos->percent[0 ] =disasm_line__calc_percent (pos, sym, evsel->idx); +if (bpos->percent[0 ] <0.01 ) {RB_CLEAR_NODE (&bpos->rb_node);continue ; }
Namhyung Kim
maintainerPATCH 10/12 perf annotate browser: Use disasm__calc_percent()
In reply to Namhyung KimThe disasm_line__calc_percent() which was used by annotate browser code almost duplicates disasm__calc_percent. Let's get rid of the code duplication.
--- tools/perf/ui/browsers/annotate.c | 50 +++++++++++---------------------------- tools/perf/util/annotate.c | 4 ++-- tools/perf/util/annotate.h | 4 ++++ 3 files changed, 20 insertions(+), 38 deletions(-)
tools/perf/ui/browsers/annotate.c +14 -36
@@ -240,40 +240,6 @@ static unsigned int annotate_browser__refresh(struct ui_browser *browser)return ret; } -static double disasm_line__calc_percent (struct disasm_line *dl,struct symbol *sym,int evidx) -{ -double percent =0.0 ; - -if (dl->offset !=-1 ) { -int len = sym->end - sym->start; -unsigned int hits =0 ; -struct annotation *notes =symbol__annotation (sym); -struct source_line *src_line = notes->src->lines; -struct sym_hist *h =annotation__histogram (notes, evidx); -s64 offset = dl->offset; -struct disasm_line *next; - - next =disasm__get_next_ip_line (¬es->src->source, dl); -while (offset < (s64 )len && - (next ==NULL || offset < next->offset)) { -if (src_line) { - percent += src_line[offset].p[0 ].percent; - }else - hits += h->addr[offset]; - - ++offset; - } -/* -* If the percentage wasn't already calculated in -* symbol__get_source_line, do it now: -*/ -if (src_line ==NULL && h->sum) - percent =100.0 * hits / h->sum; - } - -return percent; -} -static void disasm_rb_tree__insert (struct rb_root *root,struct browser_disasm_line *bdl) {struct rb_node **p = &root->rb_node;
@@ -337,7 +303,8 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,struct map_symbol *ms = browser->b.priv;struct symbol *sym = ms->sym;struct annotation *notes =symbol__annotation (sym); -struct disasm_line *pos; +struct disasm_line *pos, *next; +s64 len =symbol__size (sym); browser->entries =RB_ROOT ;
@@ -345,7 +312,18 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,list_for_each_entry (pos, ¬es->src->source, node) {struct browser_disasm_line *bpos =disasm_line__browser (pos); - bpos->percent[0 ] =disasm_line__calc_percent (pos, sym, evsel->idx); +const char *path =NULL ; + +if (pos->offset ==-1 ) { +RB_CLEAR_NODE (&bpos->rb_node); +continue ; + } + + next =disasm__get_next_ip_line (¬es->src->source, pos); + bpos->percent[0 ] =disasm__calc_percent (notes, evsel->idx, + pos->offset, next ? next->offset : len, + &path); +if (bpos->percent[0 ] <0.01 ) {RB_CLEAR_NODE (&bpos->rb_node);continue ;
tools/perf/util/annotate.c +2 -2
@@ -603,8 +603,8 @@ struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disareturn NULL ; } -static double disasm__calc_percent (struct annotation *notes,int evidx, -s64 offset,s64 end,const char **path) +double disasm__calc_percent (struct annotation *notes,int evidx,s64 offset, +s64 end,const char **path) {struct source_line *src_line = notes->src->lines;double percent =0.0 ;
tools/perf/util/annotate.h +4 -0
@@ -50,6 +50,8 @@ bool ins__is_jump(const struct ins *ins);bool ins__is_call (const struct ins *ins);int ins__scnprintf (struct ins *ins,char *bf,size_t size,struct ins_operands *ops); +struct annotation ; +struct disasm_line {struct list_head node;s64 offset;
@@ -68,6 +70,8 @@ void disasm_line__free(struct disasm_line *dl);struct disasm_line *disasm__get_next_ip_line (struct list_head *head,struct disasm_line *pos);int disasm_line__scnprintf (struct disasm_line *dl,char *bf,size_t size,bool raw);size_t disasm__fprintf (struct list_head *head,FILE *fp); +double disasm__calc_percent (struct annotation *notes,int evidx,s64 offset, +s64 end,const char **path);struct sym_hist {u64 sum;
Signature · 1 line
1.7.11.7
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf annotate browser: Use disasm__calc_percent()
perf annotate browser: Use disasm__calc_percent()
Commit-ID: e64aa75bf5559be3ce72e53ae28b76a2f633ca06 Gitweb: http://git.kernel.org/tip/e64aa75bf5559be3ce72e53ae28b76a2f633ca06 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 5 Mar 2013 14:53:30 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 15 Mar 2013 13:06:06 -0300
perf annotate browser: Use disasm__calc_percent()
The disasm_line__calc_percent() which was used by annotate browser code almost duplicates disasm__calc_percent. Let's get rid of the code duplication.
--- tools/perf/ui/browsers/annotate.c | 50 +++++++++++---------------------------- tools/perf/util/annotate.c | 4 ++-- tools/perf/util/annotate.h | 4 ++++ 3 files changed, 20 insertions(+), 38 deletions(-)
tools/perf/ui/browsers/annotate.c +14 -36
@@ -240,40 +240,6 @@ static unsigned int annotate_browser__refresh(struct ui_browser *browser)return ret; } -static double disasm_line__calc_percent (struct disasm_line *dl,struct symbol *sym,int evidx) -{ -double percent =0.0 ; - -if (dl->offset !=-1 ) { -int len = sym->end - sym->start; -unsigned int hits =0 ; -struct annotation *notes =symbol__annotation (sym); -struct source_line *src_line = notes->src->lines; -struct sym_hist *h =annotation__histogram (notes, evidx); -s64 offset = dl->offset; -struct disasm_line *next; - - next =disasm__get_next_ip_line (¬es->src->source, dl); -while (offset < (s64 )len && - (next ==NULL || offset < next->offset)) { -if (src_line) { - percent += src_line[offset].p[0 ].percent; - }else - hits += h->addr[offset]; - - ++offset; - } -/* -* If the percentage wasn't already calculated in -* symbol__get_source_line, do it now: -*/ -if (src_line ==NULL && h->sum) - percent =100.0 * hits / h->sum; - } - -return percent; -} -static void disasm_rb_tree__insert (struct rb_root *root,struct browser_disasm_line *bdl) {struct rb_node **p = &root->rb_node;
@@ -337,7 +303,8 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,struct map_symbol *ms = browser->b.priv;struct symbol *sym = ms->sym;struct annotation *notes =symbol__annotation (sym); -struct disasm_line *pos; +struct disasm_line *pos, *next; +s64 len =symbol__size (sym); browser->entries =RB_ROOT ;
@@ -345,7 +312,18 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,list_for_each_entry (pos, ¬es->src->source, node) {struct browser_disasm_line *bpos =disasm_line__browser (pos); - bpos->percent[0 ] =disasm_line__calc_percent (pos, sym, evsel->idx); +const char *path =NULL ; + +if (pos->offset ==-1 ) { +RB_CLEAR_NODE (&bpos->rb_node); +continue ; + } + + next =disasm__get_next_ip_line (¬es->src->source, pos); + bpos->percent[0 ] =disasm__calc_percent (notes, evsel->idx, + pos->offset, next ? next->offset : len, + &path); +if (bpos->percent[0 ] <0.01 ) {RB_CLEAR_NODE (&bpos->rb_node);continue ;
tools/perf/util/annotate.c +2 -2
@@ -603,8 +603,8 @@ struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disareturn NULL ; } -static double disasm__calc_percent (struct annotation *notes,int evidx, -s64 offset,s64 end,const char **path) +double disasm__calc_percent (struct annotation *notes,int evidx,s64 offset, +s64 end,const char **path) {struct source_line *src_line = notes->src->lines;double percent =0.0 ;
tools/perf/util/annotate.h +4 -0
@@ -50,6 +50,8 @@ bool ins__is_jump(const struct ins *ins);bool ins__is_call (const struct ins *ins);int ins__scnprintf (struct ins *ins,char *bf,size_t size,struct ins_operands *ops); +struct annotation ; +struct disasm_line {struct list_head node;s64 offset;
@@ -68,6 +70,8 @@ void disasm_line__free(struct disasm_line *dl);struct disasm_line *disasm__get_next_ip_line (struct list_head *head,struct disasm_line *pos);int disasm_line__scnprintf (struct disasm_line *dl,char *bf,size_t size,bool raw);size_t disasm__fprintf (struct list_head *head,FILE *fp); +double disasm__calc_percent (struct annotation *notes,int evidx,s64 offset, +s64 end,const char **path);struct sym_hist {u64 sum;
Namhyung Kim
maintainerPATCH 11/12 perf annotate browser: Support event group view on TUI
In reply to Namhyung KimDynamically allocate browser_disasm_line according to a number of group members and save nr_pcnt to the struct. This way we can handle multiple events in a general manner.
--- tools/perf/ui/browsers/annotate.c | 67 +++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 10 deletions(-)
tools/perf/ui/browsers/annotate.c +57 -10
@@ -17,6 +17,7 @@ struct browser_disasm_line {u32 idx;int idx_asm;int jump_sources; +int nr_pcnt;double percent[1 ]; };
@@ -95,14 +96,24 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int (!current_entry || (browser->use_navkeypressed && !browser->navkeypressed)));int width = browser->width, printed; +int i, pcnt_width =7 * bdl->nr_pcnt; +double percent_max =0.0 ;char bf[256 ]; -if (dl->offset !=-1 && bdl->percent[0 ] !=0.0 ) { -ui_browser__set_percent_color (browser, bdl->percent[0 ], current_entry); -slsmg_printf ("%6.2f " , bdl->percent[0 ]); +for (i =0 ; i < bdl->nr_pcnt; i++) { +if (bdl->percent[i] > percent_max) + percent_max = bdl->percent[i]; + } + +if (dl->offset !=-1 && percent_max !=0.0 ) { +for (i =0 ; i < bdl->nr_pcnt; i++) { +ui_browser__set_percent_color (browser, bdl->percent[i], + current_entry); +slsmg_printf ("%6.2f " , bdl->percent[i]); + } }else {ui_browser__set_percent_color (browser,0 , current_entry); -slsmg_write_nstring (" " ,7 ); +slsmg_write_nstring (" " , pcnt_width); }SLsmg_write_char (' ' );
@@ -112,12 +123,12 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int width +=1 ;if (!*dl->line) -slsmg_write_nstring (" " , width -7 ); +slsmg_write_nstring (" " , width - pcnt_width);else if (dl->offset ==-1 ) { printed =scnprintf (bf,sizeof (bf),"%*s " , ab->addr_width," " );slsmg_write_nstring (bf, printed); -slsmg_write_nstring (dl->line, width - printed -6 ); +slsmg_write_nstring (dl->line, width - printed - pcnt_width +1 ); }else {u64 addr = dl->offset;int color =-1 ;
@@ -176,7 +187,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int }disasm_line__scnprintf (dl, bf,sizeof (bf), !annotate_browser__opts.use_offset); -slsmg_write_nstring (bf, width -10 - printed); +slsmg_write_nstring (bf, width - pcnt_width -3 - printed); }if (current_entry)
@@ -201,6 +212,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)unsigned int from, to;struct map_symbol *ms = ab->b.priv;struct symbol *sym = ms->sym; +u8 pcnt_width =7 ;/* PLT symbols contain external offsets */ if (strstr (sym->name,"@plt" ))
@@ -224,22 +236,48 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) to = (u64 )btarget->idx; } + pcnt_width *= bcursor->nr_pcnt; +ui_browser__set_color (browser,HE_COLORSET_CODE ); -__ui_browser__line_arrow (browser,9 + ab->addr_width, from, to); +__ui_browser__line_arrow (browser, pcnt_width +2 + ab->addr_width, + from, to); }static unsigned int annotate_browser__refresh (struct ui_browser *browser) { +struct annotate_browser *ab; +struct disasm_line *cursor; +struct browser_disasm_line *bcursor;int ret =ui_browser__list_head_refresh (browser); +int pcnt_width; + + ab = container_of(browser, struct annotate_browser, b); + cursor = ab->offsets[0 ]; + bcursor =disasm_line__browser (cursor); + + pcnt_width =7 * bcursor->nr_pcnt;if (annotate_browser__opts.jump_arrows)annotate_browser__draw_current_jump (browser);ui_browser__set_color (browser,HE_COLORSET_NORMAL ); -__ui_browser__vline (browser,7 ,0 , browser->height -1 ); +__ui_browser__vline (browser, pcnt_width,0 , browser->height -1 );return ret; } +static int disasm__cmp (struct browser_disasm_line *a, +struct browser_disasm_line *b) +{ +int i; + +for (i =0 ; i < a->nr_pcnt; i++) { +if (a->percent[i] == b->percent[i]) +continue ; +return a->percent[i] < b->percent[i]; + } +return 0 ; +} +static void disasm_rb_tree__insert (struct rb_root *root,struct browser_disasm_line *bdl) {struct rb_node **p = &root->rb_node;
@@ -249,7 +287,8 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct browser_disasm_lwhile (*p !=NULL ) { parent = *p; l = rb_entry(parent, struct browser_disasm_line, rb_node); -if (bdl->percent[0 ] < l->percent[0 ]) + +if (disasm__cmp (bdl, l)) p = &(*p)->rb_left;else p = &(*p)->rb_right;
@@ -829,6 +868,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, }, };int ret =-1 ; +int nr_pcnt =1 ; +size_t sizeof_bdl =sizeof (struct browser_disasm_line );if (sym ==NULL )return -1 ;
@@ -844,6 +885,11 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,return -1 ; } +if (perf_evsel__is_group_event (evsel)) { + nr_pcnt = evsel->nr_members; + sizeof_bdl +=sizeof (double ) * (nr_pcnt -1 ); + } +if (symbol__annotate (sym, map,sizeof (struct browser_disasm_line )) <0 ) {ui__error ("%s" , ui_helpline__last_msg); goto out_free_offsets;
@@ -861,6 +907,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,if (browser.b.width < line_len) browser.b.width = line_len; bpos =disasm_line__browser (pos); + bpos->nr_pcnt = nr_pcnt; bpos->idx = browser.nr_entries++;if (pos->offset !=-1 ) { bpos->idx_asm = browser.nr_asm_entries++;
Signature · 1 line
1.7.11.7
Namhyung Kim
maintainerPATCH 12/12 perf annotate/gtk: Support event group view on GTK
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
Add support for event group view to GTK annotation browser.
--- tools/perf/ui/gtk/annotate.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
tools/perf/ui/gtk/annotate.c +16 -2
@@ -33,7 +33,7 @@ static int perf_gtk__get_percent(char *buf, size_t size, struct symbol *sym,return 0 ; symhist =annotation__histogram (symbol__annotation (sym), evidx); -if (!symhist->addr[dl->offset]) +if (!symbol_conf.event_group && !symhist->addr[dl->offset])return 0 ; percent =100.0 * symhist->addr[dl->offset] / symhist->sum;
@@ -119,10 +119,24 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,list_for_each_entry (pos, ¬es->src->source, node) {GtkTreeIter iter; +int ret =0 ;gtk_list_store_append (store, &iter); -if (perf_gtk__get_percent (s,sizeof (s), sym, pos, evsel->idx)) +if (perf_evsel__is_group_event (evsel)) { +for (i =0 ; i < evsel->nr_members; i++) { + ret +=perf_gtk__get_percent (s + ret, +sizeof (s) - ret, + sym, pos, + evsel->idx + i); + ret +=scnprintf (s + ret,sizeof (s) - ret," " ); + } + }else { + ret =perf_gtk__get_percent (s,sizeof (s), sym, pos, + evsel->idx); + } + +if (ret)gtk_list_store_set (store, &iter,ANN_COL__PERCENT , s,-1 );if (perf_gtk__get_offset (s,sizeof (s), sym, map, pos))gtk_list_store_set (store, &iter,ANN_COL__OFFSET , s,-1 );
Signature · 1 line
1.7.11.7
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf annotate/gtk: Support event group view on GTK
perf annotate/gtk: Support event group view on GTK
Commit-ID: d8d7cd93e6b5f42bd2ae77680b5dc27415ba7492 Gitweb: http://git.kernel.org/tip/d8d7cd93e6b5f42bd2ae77680b5dc27415ba7492 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 5 Mar 2013 14:53:32 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 15 Mar 2013 13:06:07 -0300
perf annotate/gtk: Support event group view on GTK
Add support for event group view to GTK annotation browser.
--- tools/perf/ui/gtk/annotate.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
tools/perf/ui/gtk/annotate.c +16 -2
@@ -33,7 +33,7 @@ static int perf_gtk__get_percent(char *buf, size_t size, struct symbol *sym,return 0 ; symhist =annotation__histogram (symbol__annotation (sym), evidx); -if (!symhist->addr[dl->offset]) +if (!symbol_conf.event_group && !symhist->addr[dl->offset])return 0 ; percent =100.0 * symhist->addr[dl->offset] / symhist->sum;
@@ -119,10 +119,24 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,list_for_each_entry (pos, ¬es->src->source, node) {GtkTreeIter iter; +int ret =0 ;gtk_list_store_append (store, &iter); -if (perf_gtk__get_percent (s,sizeof (s), sym, pos, evsel->idx)) +if (perf_evsel__is_group_event (evsel)) { +for (i =0 ; i < evsel->nr_members; i++) { + ret +=perf_gtk__get_percent (s + ret, +sizeof (s) - ret, + sym, pos, + evsel->idx + i); + ret +=scnprintf (s + ret,sizeof (s) - ret," " ); + } + }else { + ret =perf_gtk__get_percent (s,sizeof (s), sym, pos, + evsel->idx); + } + +if (ret)gtk_list_store_set (store, &iter,ANN_COL__PERCENT , s,-1 );if (perf_gtk__get_offset (s,sizeof (s), sym, map, pos))gtk_list_store_set (store, &iter,ANN_COL__OFFSET , s,-1 );
Em Tue, Mar 05, 2013 at 02:53:20PM +0900, Namhyung Kim escreveu:
Quoted 10 lines
This patchset implements event group view on perf annotate. It's basically a rebased version and major difference to prior version is the GTK annotation browser support.
Here goes an example:
$ perf annotate --group --stdiocrtstuff.c:0
8.08 2.40 5.29 : 387dc0aa50: mov %rdi,%rdx
I applied this series minus the TUI enabling one, as it is not working, so right now my perf/core has --group --stdio and --group --gtk working, please take a look at --group --tui.
I need to go thru this more thoroughly, as at least one thing caught my attention, in some cases ->nr_pcnt is used and in others evsel->nr_members, do we need both?
- Arnaldo
Namhyung Kim
maintainerHi Arnaldo,
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Tue, Mar 05, 2013 at 02:53:20PM +0900, Namhyung Kim escreveu:
Quoted 7 lines
This patchset implements event group view on perf annotate. It's basically a rebased version and major difference to prior version is the GTK annotation browser support.
Here goes an example:
$ perf annotate --group --stdio
Quoted 7 lines
Quoted 2 lines
crtstuff.c:0
8.08 2.40 5.29 : 387dc0aa50: mov %rdi,%rdxI applied this series minus the TUI enabling one, as it is not working, so right now my perf/core has --group --stdio and --group --gtk working, please take a look at --group --tui.
Thanks, I took a look at the TUI code and found some missing pieces and bugs. Those code were in the original version but seems to get lost during the cherry-picking and I tested wrong version. :(
Quoted 4 lines
I need to go thru this more thoroughly, as at least one thing caught my attention, in some cases ->nr_pcnt is used and in others
evsel->nr_members, do we need both?
Probably not. I was thought keeping an array and its length together is better. But it's rather a waste to save the same information to every date structure so I move it to the struct annotate_browser->nr_events.
For evsel->nr_members, current code sets it only for grouping is enabled so the individual events will have value of 0. Also it's not pass the evsel to every function need it. But if you think it should really be fixed that way I can make the change to pass and use evsel->nr_members.
Anyway, below is a fixed version that could survived my testing.
Quoted 1 line
From
9d2948c274c4958ebde866adb28951f44e0595ebMon Sep 17 00:00:00 2001
From: Namhyung Kim <[email protected]>
Date: Sat, 10 Nov 2012 01:21:02 +0900
Subject: [PATCH] perf annotate browser: Support event group view on TUI
Dynamically allocate browser_disasm_line according to a number of group members. This way we can handle multiple events in a general manner.
--- tools/perf/ui/browsers/annotate.c | 93 +++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 18 deletions(-)
tools/perf/ui/browsers/annotate.c +75 -18
@@ -17,6 +17,10 @@ struct browser_disasm_line {u32 idx;int idx_asm;int jump_sources; +/* +* actual length of this array is saved on the nr_events field +* of the struct annotate_browser +*/ double percent[1 ]; };
@@ -34,8 +38,9 @@ struct annotate_browser {struct ui_browser b;struct rb_root entries;struct rb_node *curr_hot; -struct disasm_line *selection; +struct disasm_line *selection;struct disasm_line **offsets; +int nr_events;u64 start;int nr_asm_entries;int nr_entries;
@@ -95,14 +100,24 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int (!current_entry || (browser->use_navkeypressed && !browser->navkeypressed)));int width = browser->width, printed; +int i, pcnt_width =7 * ab->nr_events; +double percent_max =0.0 ;char bf[256 ]; -if (dl->offset !=-1 && bdl->percent[0 ] !=0.0 ) { -ui_browser__set_percent_color (browser, bdl->percent[0 ], current_entry); -slsmg_printf ("%6.2f " , bdl->percent[0 ]); +for (i =0 ; i < ab->nr_events; i++) { +if (bdl->percent[i] > percent_max) + percent_max = bdl->percent[i]; + } + +if (dl->offset !=-1 && percent_max !=0.0 ) { +for (i =0 ; i < ab->nr_events; i++) { +ui_browser__set_percent_color (browser, bdl->percent[i], + current_entry); +slsmg_printf ("%6.2f " , bdl->percent[i]); + } }else {ui_browser__set_percent_color (browser,0 , current_entry); -slsmg_write_nstring (" " ,7 ); +slsmg_write_nstring (" " , pcnt_width); }SLsmg_write_char (' ' );
@@ -112,12 +127,12 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int width +=1 ;if (!*dl->line) -slsmg_write_nstring (" " , width -7 ); +slsmg_write_nstring (" " , width - pcnt_width);else if (dl->offset ==-1 ) { printed =scnprintf (bf,sizeof (bf),"%*s " , ab->addr_width," " );slsmg_write_nstring (bf, printed); -slsmg_write_nstring (dl->line, width - printed -6 ); +slsmg_write_nstring (dl->line, width - printed - pcnt_width +1 ); }else {u64 addr = dl->offset;int color =-1 ;
@@ -176,7 +191,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int }disasm_line__scnprintf (dl, bf,sizeof (bf), !annotate_browser__opts.use_offset); -slsmg_write_nstring (bf, width -10 - printed); +slsmg_write_nstring (bf, width - pcnt_width -3 - printed); }if (current_entry)
@@ -201,6 +216,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)unsigned int from, to;struct map_symbol *ms = ab->b.priv;struct symbol *sym = ms->sym; +u8 pcnt_width =7 ;/* PLT symbols contain external offsets */ if (strstr (sym->name,"@plt" ))
@@ -224,23 +240,44 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) to = (u64 )btarget->idx; } + pcnt_width *= ab->nr_events; +ui_browser__set_color (browser,HE_COLORSET_CODE ); -__ui_browser__line_arrow (browser,9 + ab->addr_width, from, to); +__ui_browser__line_arrow (browser, pcnt_width +2 + ab->addr_width, + from, to); }static unsigned int annotate_browser__refresh (struct ui_browser *browser) { + struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);int ret =ui_browser__list_head_refresh (browser); +int pcnt_width; + + pcnt_width =7 * ab->nr_events;if (annotate_browser__opts.jump_arrows)annotate_browser__draw_current_jump (browser);ui_browser__set_color (browser,HE_COLORSET_NORMAL ); -__ui_browser__vline (browser,7 ,0 , browser->height -1 ); +__ui_browser__vline (browser, pcnt_width,0 , browser->height -1 );return ret; } -static void disasm_rb_tree__insert (struct rb_root *root,struct browser_disasm_line *bdl) +static int disasm__cmp (struct browser_disasm_line *a, +struct browser_disasm_line *b,int nr_pcnt) +{ +int i; + +for (i =0 ; i < nr_pcnt; i++) { +if (a->percent[i] == b->percent[i]) +continue ; +return a->percent[i] < b->percent[i]; + } +return 0 ; +} + +static void disasm_rb_tree__insert (struct rb_root *root,struct browser_disasm_line *bdl, +int nr_events) {struct rb_node **p = &root->rb_node;struct rb_node *parent =NULL ;
@@ -249,7 +286,8 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct browser_disasm_lwhile (*p !=NULL ) { parent = *p; l = rb_entry(parent, struct browser_disasm_line, rb_node); -if (bdl->percent[0 ] < l->percent[0 ]) + +if (disasm__cmp (bdl, l, nr_events)) p = &(*p)->rb_left;else p = &(*p)->rb_right;
@@ -313,6 +351,8 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,list_for_each_entry (pos, ¬es->src->source, node) {struct browser_disasm_line *bpos =disasm_line__browser (pos);const char *path =NULL ; +double max_percent =0.0 ; +int i;if (pos->offset ==-1 ) {RB_CLEAR_NODE (&bpos->rb_node);
@@ -320,15 +360,24 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, } next =disasm__get_next_ip_line (¬es->src->source, pos); - bpos->percent[0 ] =disasm__calc_percent (notes, evsel->idx, - pos->offset, next ? next->offset : len, - &path); -if (bpos->percent[0 ] <0.01 ) { +for (i =0 ; i < browser->nr_events; i++) { + bpos->percent[i] =disasm__calc_percent (notes, + evsel->idx + i, + pos->offset, + next ? next->offset : len, + &path); + +if (max_percent < bpos->percent[i]) + max_percent = bpos->percent[i]; + } + +if (max_percent <0.01 ) {RB_CLEAR_NODE (&bpos->rb_node);continue ; } -disasm_rb_tree__insert (&browser->entries, bpos); +disasm_rb_tree__insert (&browser->entries, bpos, + browser->nr_events); }pthread_mutex_unlock (¬es->lock);
@@ -829,6 +878,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, }, };int ret =-1 ; +int nr_pcnt =1 ; +size_t sizeof_bdl =sizeof (struct browser_disasm_line );if (sym ==NULL )return -1 ;
@@ -844,7 +895,12 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,return -1 ; } -if (symbol__annotate (sym, map,sizeof (struct browser_disasm_line )) <0 ) { +if (perf_evsel__is_group_event (evsel)) { + nr_pcnt = evsel->nr_members; + sizeof_bdl +=sizeof (double ) * (nr_pcnt -1 ); + } + +if (symbol__annotate (sym, map, sizeof_bdl) <0 ) {ui__error ("%s" , ui_helpline__last_msg); goto out_free_offsets; }
@@ -882,6 +938,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, browser.addr_width = browser.target_width = browser.min_addr_width =hex_width (size); browser.max_addr_width =hex_width (sym->end); browser.jumps_width =width_jumps (browser.max_jump_sources); + browser.nr_events = nr_pcnt; browser.b.nr_entries = browser.nr_entries; browser.b.entries = ¬es->src->source, browser.b.width +=18 ;/* Percentage */
Signature · 1 line
1.7.11.7
Em Tue, Mar 12, 2013 at 12:21:27PM +0900, Namhyung Kim escreveu:
Quoted 5 lines · Arnaldo Carvalho de Melo
Quoted 3 lines
I need to go thru this more thoroughly, as at least one thing caught my attention, in some cases ->nr_pcnt is used and in others
evsel->nr_members, do we need both?
Quoted 8 lines
Probably not. I was thought keeping an array and its length together is better. But it's rather a waste to save the same information to every date structure so I move it to the struct
annotate_browser->nr_events.For
evsel->nr_members, current code sets it only for grouping is enabled so the individual events will have value of 0. Also it's not pass the evsel to every function need it. But if you think it should really be fixed that way I can make the change to pass and useevsel->nr_members.
This can be left for later, my point here is that we should try to avoid the various UIs from diverging too much, i.e. the code for --gtk, --stdio and --tui should be as close and using the same abstractions as possible.
Quoted 1 line
Anyway, below is a fixed version that could survived my testing.
indeed, works, compared the output of --stdio --group with --tui --group and it matches.
While looking at it I noticed that the stdio output wastes the initial columns, at some point we may want to make the hist_entry lines match the TUI ones, so that going back and forth on two xterm tabs shows no differences.
Anyway, thanks, applied!
- Arnaldo
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf annotate browser: Support event group view on TUI
In reply to Namhyung Kimperf annotate browser: Support event group view on TUI
Commit-ID: c7e7b6101361025fbea03833c6aee18e3d7bed34 Gitweb: http://git.kernel.org/tip/c7e7b6101361025fbea03833c6aee18e3d7bed34 Author: Namhyung Kim <[email protected]> AuthorDate: Sat, 10 Nov 2012 01:21:02 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 15 Mar 2013 13:06:07 -0300
perf annotate browser: Support event group view on TUI
Dynamically allocate browser_disasm_line according to a number of group members. This way we can handle multiple events in a general manner.
--- tools/perf/ui/browsers/annotate.c | 93 +++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 18 deletions(-)
tools/perf/ui/browsers/annotate.c +75 -18
@@ -17,6 +17,10 @@ struct browser_disasm_line {u32 idx;int idx_asm;int jump_sources; +/* +* actual length of this array is saved on the nr_events field +* of the struct annotate_browser +*/ double percent[1 ]; };
@@ -34,8 +38,9 @@ struct annotate_browser {struct ui_browser b;struct rb_root entries;struct rb_node *curr_hot; -struct disasm_line *selection; +struct disasm_line *selection;struct disasm_line **offsets; +int nr_events;u64 start;int nr_asm_entries;int nr_entries;
@@ -95,14 +100,24 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int (!current_entry || (browser->use_navkeypressed && !browser->navkeypressed)));int width = browser->width, printed; +int i, pcnt_width =7 * ab->nr_events; +double percent_max =0.0 ;char bf[256 ]; -if (dl->offset !=-1 && bdl->percent[0 ] !=0.0 ) { -ui_browser__set_percent_color (browser, bdl->percent[0 ], current_entry); -slsmg_printf ("%6.2f " , bdl->percent[0 ]); +for (i =0 ; i < ab->nr_events; i++) { +if (bdl->percent[i] > percent_max) + percent_max = bdl->percent[i]; + } + +if (dl->offset !=-1 && percent_max !=0.0 ) { +for (i =0 ; i < ab->nr_events; i++) { +ui_browser__set_percent_color (browser, bdl->percent[i], + current_entry); +slsmg_printf ("%6.2f " , bdl->percent[i]); + } }else {ui_browser__set_percent_color (browser,0 , current_entry); -slsmg_write_nstring (" " ,7 ); +slsmg_write_nstring (" " , pcnt_width); }SLsmg_write_char (' ' );
@@ -112,12 +127,12 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int width +=1 ;if (!*dl->line) -slsmg_write_nstring (" " , width -7 ); +slsmg_write_nstring (" " , width - pcnt_width);else if (dl->offset ==-1 ) { printed =scnprintf (bf,sizeof (bf),"%*s " , ab->addr_width," " );slsmg_write_nstring (bf, printed); -slsmg_write_nstring (dl->line, width - printed -6 ); +slsmg_write_nstring (dl->line, width - printed - pcnt_width +1 ); }else {u64 addr = dl->offset;int color =-1 ;
@@ -176,7 +191,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int }disasm_line__scnprintf (dl, bf,sizeof (bf), !annotate_browser__opts.use_offset); -slsmg_write_nstring (bf, width -10 - printed); +slsmg_write_nstring (bf, width - pcnt_width -3 - printed); }if (current_entry)
@@ -201,6 +216,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)unsigned int from, to;struct map_symbol *ms = ab->b.priv;struct symbol *sym = ms->sym; +u8 pcnt_width =7 ;/* PLT symbols contain external offsets */ if (strstr (sym->name,"@plt" ))
@@ -224,23 +240,44 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) to = (u64 )btarget->idx; } + pcnt_width *= ab->nr_events; +ui_browser__set_color (browser,HE_COLORSET_CODE ); -__ui_browser__line_arrow (browser,9 + ab->addr_width, from, to); +__ui_browser__line_arrow (browser, pcnt_width +2 + ab->addr_width, + from, to); }static unsigned int annotate_browser__refresh (struct ui_browser *browser) { + struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);int ret =ui_browser__list_head_refresh (browser); +int pcnt_width; + + pcnt_width =7 * ab->nr_events;if (annotate_browser__opts.jump_arrows)annotate_browser__draw_current_jump (browser);ui_browser__set_color (browser,HE_COLORSET_NORMAL ); -__ui_browser__vline (browser,7 ,0 , browser->height -1 ); +__ui_browser__vline (browser, pcnt_width,0 , browser->height -1 );return ret; } -static void disasm_rb_tree__insert (struct rb_root *root,struct browser_disasm_line *bdl) +static int disasm__cmp (struct browser_disasm_line *a, +struct browser_disasm_line *b,int nr_pcnt) +{ +int i; + +for (i =0 ; i < nr_pcnt; i++) { +if (a->percent[i] == b->percent[i]) +continue ; +return a->percent[i] < b->percent[i]; + } +return 0 ; +} + +static void disasm_rb_tree__insert (struct rb_root *root,struct browser_disasm_line *bdl, +int nr_events) {struct rb_node **p = &root->rb_node;struct rb_node *parent =NULL ;
@@ -249,7 +286,8 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct browser_disasm_lwhile (*p !=NULL ) { parent = *p; l = rb_entry(parent, struct browser_disasm_line, rb_node); -if (bdl->percent[0 ] < l->percent[0 ]) + +if (disasm__cmp (bdl, l, nr_events)) p = &(*p)->rb_left;else p = &(*p)->rb_right;
@@ -313,6 +351,8 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,list_for_each_entry (pos, ¬es->src->source, node) {struct browser_disasm_line *bpos =disasm_line__browser (pos);const char *path =NULL ; +double max_percent =0.0 ; +int i;if (pos->offset ==-1 ) {RB_CLEAR_NODE (&bpos->rb_node);
@@ -320,15 +360,24 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, } next =disasm__get_next_ip_line (¬es->src->source, pos); - bpos->percent[0 ] =disasm__calc_percent (notes, evsel->idx, - pos->offset, next ? next->offset : len, - &path); -if (bpos->percent[0 ] <0.01 ) { +for (i =0 ; i < browser->nr_events; i++) { + bpos->percent[i] =disasm__calc_percent (notes, + evsel->idx + i, + pos->offset, + next ? next->offset : len, + &path); + +if (max_percent < bpos->percent[i]) + max_percent = bpos->percent[i]; + } + +if (max_percent <0.01 ) {RB_CLEAR_NODE (&bpos->rb_node);continue ; } -disasm_rb_tree__insert (&browser->entries, bpos); +disasm_rb_tree__insert (&browser->entries, bpos, + browser->nr_events); }pthread_mutex_unlock (¬es->lock);
@@ -829,6 +878,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, }, };int ret =-1 ; +int nr_pcnt =1 ; +size_t sizeof_bdl =sizeof (struct browser_disasm_line );if (sym ==NULL )return -1 ;
@@ -844,7 +895,12 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,return -1 ; } -if (symbol__annotate (sym, map,sizeof (struct browser_disasm_line )) <0 ) { +if (perf_evsel__is_group_event (evsel)) { + nr_pcnt = evsel->nr_members; + sizeof_bdl +=sizeof (double ) * (nr_pcnt -1 ); + } + +if (symbol__annotate (sym, map, sizeof_bdl) <0 ) {ui__error ("%s" , ui_helpline__last_msg); goto out_free_offsets; }
@@ -882,6 +938,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, browser.addr_width = browser.target_width = browser.min_addr_width =hex_width (size); browser.max_addr_width =hex_width (sym->end); browser.jumps_width =width_jumps (browser.max_jump_sources); + browser.nr_events = nr_pcnt; browser.b.nr_entries = browser.nr_entries; browser.b.entries = ¬es->src->source, browser.b.width +=18 ;/* Percentage */