diff options
author | Ingo Molnar <mingo@kernel.org> | 2013-02-15 10:38:33 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-02-15 10:38:33 -0500 |
commit | 6a71e69f78fbcb453f4444a8288ea8b7cdc7cea4 (patch) | |
tree | 9d4dd00367eeb909edf4c1a30e2e8178efb9dc5a /tools | |
parent | a3d4fd7a2d81604fedfa270d29c824b8d3380c2e (diff) | |
parent | 02e176af92f3e2e9ec3a48792036566af2dcd534 (diff) |
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
* Fix cleanup in case of kzalloc failure, from Daniel Baluta.
* Limit unwind support to x86 archs, fix from Jiri Olsa.
* Initial GTK+ annotate browser, from Namhyung Kim.
* Fix build with bison 2.3 and older, from Vinson Lee.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Documentation/perf-annotate.txt | 7 | ||||
-rw-r--r-- | tools/perf/Documentation/perf-buildid-cache.txt | 4 | ||||
-rw-r--r-- | tools/perf/Makefile | 10 | ||||
-rw-r--r-- | tools/perf/builtin-annotate.c | 27 | ||||
-rw-r--r-- | tools/perf/builtin-buildid-cache.c | 50 | ||||
-rw-r--r-- | tools/perf/ui/gtk/annotate.c | 229 | ||||
-rw-r--r-- | tools/perf/ui/gtk/gtk.h | 1 | ||||
-rw-r--r-- | tools/perf/ui/setup.c | 2 | ||||
-rw-r--r-- | tools/perf/util/annotate.c | 2 | ||||
-rw-r--r-- | tools/perf/util/annotate.h | 24 | ||||
-rw-r--r-- | tools/perf/util/parse-events.y | 1 | ||||
-rw-r--r-- | tools/perf/util/pmu.y | 1 |
12 files changed, 348 insertions, 10 deletions
diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt index c8ffd9fd5c6a..5ad07ef417f0 100644 --- a/tools/perf/Documentation/perf-annotate.txt +++ b/tools/perf/Documentation/perf-annotate.txt | |||
@@ -61,11 +61,13 @@ OPTIONS | |||
61 | 61 | ||
62 | --stdio:: Use the stdio interface. | 62 | --stdio:: Use the stdio interface. |
63 | 63 | ||
64 | --tui:: Use the TUI interface Use of --tui requires a tty, if one is not | 64 | --tui:: Use the TUI interface. Use of --tui requires a tty, if one is not |
65 | present, as when piping to other commands, the stdio interface is | 65 | present, as when piping to other commands, the stdio interface is |
66 | used. This interfaces starts by centering on the line with more | 66 | used. This interfaces starts by centering on the line with more |
67 | samples, TAB/UNTAB cycles through the lines with more samples. | 67 | samples, TAB/UNTAB cycles through the lines with more samples. |
68 | 68 | ||
69 | --gtk:: Use the GTK interface. | ||
70 | |||
69 | -C:: | 71 | -C:: |
70 | --cpu:: Only report samples for the list of CPUs provided. Multiple CPUs can | 72 | --cpu:: Only report samples for the list of CPUs provided. Multiple CPUs can |
71 | be provided as a comma-separated list with no space: 0,1. Ranges of | 73 | be provided as a comma-separated list with no space: 0,1. Ranges of |
@@ -88,6 +90,9 @@ OPTIONS | |||
88 | --objdump=<path>:: | 90 | --objdump=<path>:: |
89 | Path to objdump binary. | 91 | Path to objdump binary. |
90 | 92 | ||
93 | --skip-missing:: | ||
94 | Skip symbols that cannot be annotated. | ||
95 | |||
91 | SEE ALSO | 96 | SEE ALSO |
92 | -------- | 97 | -------- |
93 | linkperf:perf-record[1], linkperf:perf-report[1] | 98 | linkperf:perf-record[1], linkperf:perf-report[1] |
diff --git a/tools/perf/Documentation/perf-buildid-cache.txt b/tools/perf/Documentation/perf-buildid-cache.txt index 8e798baae0fd..e9a8349a7172 100644 --- a/tools/perf/Documentation/perf-buildid-cache.txt +++ b/tools/perf/Documentation/perf-buildid-cache.txt | |||
@@ -27,6 +27,10 @@ OPTIONS | |||
27 | -M:: | 27 | -M:: |
28 | --missing=:: | 28 | --missing=:: |
29 | List missing build ids in the cache for the specified file. | 29 | List missing build ids in the cache for the specified file. |
30 | -u:: | ||
31 | --update:: | ||
32 | Update specified file of the cache. It can be used to update kallsyms | ||
33 | kernel dso to vmlinux in order to support annotation. | ||
30 | -v:: | 34 | -v:: |
31 | --verbose:: | 35 | --verbose:: |
32 | Be more verbose. | 36 | Be more verbose. |
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index a158309a65ef..a2108ca1cc17 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -296,13 +296,13 @@ $(OUTPUT)util/parse-events-flex.c: util/parse-events.l $(OUTPUT)util/parse-event | |||
296 | $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c | 296 | $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c |
297 | 297 | ||
298 | $(OUTPUT)util/parse-events-bison.c: util/parse-events.y | 298 | $(OUTPUT)util/parse-events-bison.c: util/parse-events.y |
299 | $(QUIET_BISON)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $(OUTPUT)util/parse-events-bison.c | 299 | $(QUIET_BISON)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $(OUTPUT)util/parse-events-bison.c -p parse_events_ |
300 | 300 | ||
301 | $(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c | 301 | $(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c |
302 | $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/pmu-flex.h -t util/pmu.l > $(OUTPUT)util/pmu-flex.c | 302 | $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/pmu-flex.h -t util/pmu.l > $(OUTPUT)util/pmu-flex.c |
303 | 303 | ||
304 | $(OUTPUT)util/pmu-bison.c: util/pmu.y | 304 | $(OUTPUT)util/pmu-bison.c: util/pmu.y |
305 | $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c | 305 | $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c -p perf_pmu_ |
306 | 306 | ||
307 | $(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c | 307 | $(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c |
308 | $(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c | 308 | $(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c |
@@ -581,6 +581,11 @@ else | |||
581 | endif # SOURCE_LIBELF | 581 | endif # SOURCE_LIBELF |
582 | endif # NO_LIBELF | 582 | endif # NO_LIBELF |
583 | 583 | ||
584 | # There's only x86 (both 32 and 64) support for CFI unwind so far | ||
585 | ifneq ($(ARCH),x86) | ||
586 | NO_LIBUNWIND := 1 | ||
587 | endif | ||
588 | |||
584 | ifndef NO_LIBUNWIND | 589 | ifndef NO_LIBUNWIND |
585 | # for linking with debug library, run like: | 590 | # for linking with debug library, run like: |
586 | # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ | 591 | # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ |
@@ -698,6 +703,7 @@ ifndef NO_GTK2 | |||
698 | LIB_OBJS += $(OUTPUT)ui/gtk/util.o | 703 | LIB_OBJS += $(OUTPUT)ui/gtk/util.o |
699 | LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o | 704 | LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o |
700 | LIB_OBJS += $(OUTPUT)ui/gtk/progress.o | 705 | LIB_OBJS += $(OUTPUT)ui/gtk/progress.o |
706 | LIB_OBJS += $(OUTPUT)ui/gtk/annotate.o | ||
701 | endif | 707 | endif |
702 | endif | 708 | endif |
703 | 709 | ||
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 95a2ad3f043e..2e6961ea3184 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -34,9 +34,10 @@ | |||
34 | 34 | ||
35 | struct perf_annotate { | 35 | struct perf_annotate { |
36 | struct perf_tool tool; | 36 | struct perf_tool tool; |
37 | bool force, use_tui, use_stdio; | 37 | bool force, use_tui, use_stdio, use_gtk; |
38 | bool full_paths; | 38 | bool full_paths; |
39 | bool print_line; | 39 | bool print_line; |
40 | bool skip_missing; | ||
40 | const char *sym_hist_filter; | 41 | const char *sym_hist_filter; |
41 | const char *cpu_list; | 42 | const char *cpu_list; |
42 | DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); | 43 | DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); |
@@ -138,9 +139,22 @@ find_next: | |||
138 | continue; | 139 | continue; |
139 | } | 140 | } |
140 | 141 | ||
141 | if (use_browser > 0) { | 142 | if (use_browser == 2) { |
143 | int ret; | ||
144 | |||
145 | ret = hist_entry__gtk_annotate(he, evidx, NULL); | ||
146 | if (!ret || !ann->skip_missing) | ||
147 | return; | ||
148 | |||
149 | /* skip missing symbols */ | ||
150 | nd = rb_next(nd); | ||
151 | } else if (use_browser == 1) { | ||
142 | key = hist_entry__tui_annotate(he, evidx, NULL); | 152 | key = hist_entry__tui_annotate(he, evidx, NULL); |
143 | switch (key) { | 153 | switch (key) { |
154 | case -1: | ||
155 | if (!ann->skip_missing) | ||
156 | return; | ||
157 | /* fall through */ | ||
144 | case K_RIGHT: | 158 | case K_RIGHT: |
145 | next = rb_next(nd); | 159 | next = rb_next(nd); |
146 | break; | 160 | break; |
@@ -224,6 +238,10 @@ static int __cmd_annotate(struct perf_annotate *ann) | |||
224 | ui__error("The %s file has no samples!\n", session->filename); | 238 | ui__error("The %s file has no samples!\n", session->filename); |
225 | goto out_delete; | 239 | goto out_delete; |
226 | } | 240 | } |
241 | |||
242 | if (use_browser == 2) | ||
243 | perf_gtk__show_annotations(); | ||
244 | |||
227 | out_delete: | 245 | out_delete: |
228 | /* | 246 | /* |
229 | * Speed up the exit process, for large files this can | 247 | * Speed up the exit process, for large files this can |
@@ -270,6 +288,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) | |||
270 | "be more verbose (show symbol address, etc)"), | 288 | "be more verbose (show symbol address, etc)"), |
271 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | 289 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |
272 | "dump raw trace in ASCII"), | 290 | "dump raw trace in ASCII"), |
291 | OPT_BOOLEAN(0, "gtk", &annotate.use_gtk, "Use the GTK interface"), | ||
273 | OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"), | 292 | OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"), |
274 | OPT_BOOLEAN(0, "stdio", &annotate.use_stdio, "Use the stdio interface"), | 293 | OPT_BOOLEAN(0, "stdio", &annotate.use_stdio, "Use the stdio interface"), |
275 | OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, | 294 | OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, |
@@ -280,6 +299,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) | |||
280 | "print matching source lines (may be slow)"), | 299 | "print matching source lines (may be slow)"), |
281 | OPT_BOOLEAN('P', "full-paths", &annotate.full_paths, | 300 | OPT_BOOLEAN('P', "full-paths", &annotate.full_paths, |
282 | "Don't shorten the displayed pathnames"), | 301 | "Don't shorten the displayed pathnames"), |
302 | OPT_BOOLEAN(0, "skip-missing", &annotate.skip_missing, | ||
303 | "Skip symbols that cannot be annotated"), | ||
283 | OPT_STRING('C', "cpu", &annotate.cpu_list, "cpu", "list of cpus to profile"), | 304 | OPT_STRING('C', "cpu", &annotate.cpu_list, "cpu", "list of cpus to profile"), |
284 | OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", | 305 | OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", |
285 | "Look for files with symbols relative to this directory"), | 306 | "Look for files with symbols relative to this directory"), |
@@ -300,6 +321,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) | |||
300 | use_browser = 0; | 321 | use_browser = 0; |
301 | else if (annotate.use_tui) | 322 | else if (annotate.use_tui) |
302 | use_browser = 1; | 323 | use_browser = 1; |
324 | else if (annotate.use_gtk) | ||
325 | use_browser = 2; | ||
303 | 326 | ||
304 | setup_browser(true); | 327 | setup_browser(true); |
305 | 328 | ||
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index a336014e0286..c96c8fa38243 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c | |||
@@ -93,6 +93,32 @@ static int build_id_cache__fprintf_missing(const char *filename, bool force, FIL | |||
93 | return 0; | 93 | return 0; |
94 | } | 94 | } |
95 | 95 | ||
96 | static int build_id_cache__update_file(const char *filename, | ||
97 | const char *debugdir) | ||
98 | { | ||
99 | u8 build_id[BUILD_ID_SIZE]; | ||
100 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; | ||
101 | |||
102 | int err; | ||
103 | |||
104 | if (filename__read_build_id(filename, &build_id, sizeof(build_id)) < 0) { | ||
105 | pr_debug("Couldn't read a build-id in %s\n", filename); | ||
106 | return -1; | ||
107 | } | ||
108 | |||
109 | build_id__sprintf(build_id, sizeof(build_id), sbuild_id); | ||
110 | err = build_id_cache__remove_s(sbuild_id, debugdir); | ||
111 | if (!err) { | ||
112 | err = build_id_cache__add_s(sbuild_id, debugdir, filename, | ||
113 | false, false); | ||
114 | } | ||
115 | if (verbose) | ||
116 | pr_info("Updating %s %s: %s\n", sbuild_id, filename, | ||
117 | err ? "FAIL" : "Ok"); | ||
118 | |||
119 | return err; | ||
120 | } | ||
121 | |||
96 | int cmd_buildid_cache(int argc, const char **argv, | 122 | int cmd_buildid_cache(int argc, const char **argv, |
97 | const char *prefix __maybe_unused) | 123 | const char *prefix __maybe_unused) |
98 | { | 124 | { |
@@ -103,7 +129,9 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
103 | char debugdir[PATH_MAX]; | 129 | char debugdir[PATH_MAX]; |
104 | char const *add_name_list_str = NULL, | 130 | char const *add_name_list_str = NULL, |
105 | *remove_name_list_str = NULL, | 131 | *remove_name_list_str = NULL, |
106 | *missing_filename = NULL; | 132 | *missing_filename = NULL, |
133 | *update_name_list_str = NULL; | ||
134 | |||
107 | const struct option buildid_cache_options[] = { | 135 | const struct option buildid_cache_options[] = { |
108 | OPT_STRING('a', "add", &add_name_list_str, | 136 | OPT_STRING('a', "add", &add_name_list_str, |
109 | "file list", "file(s) to add"), | 137 | "file list", "file(s) to add"), |
@@ -112,6 +140,8 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
112 | OPT_STRING('M', "missing", &missing_filename, "file", | 140 | OPT_STRING('M', "missing", &missing_filename, "file", |
113 | "to find missing build ids in the cache"), | 141 | "to find missing build ids in the cache"), |
114 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), | 142 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), |
143 | OPT_STRING('u', "update", &update_name_list_str, "file list", | ||
144 | "file(s) to update"), | ||
115 | OPT_INCR('v', "verbose", &verbose, "be more verbose"), | 145 | OPT_INCR('v', "verbose", &verbose, "be more verbose"), |
116 | OPT_END() | 146 | OPT_END() |
117 | }; | 147 | }; |
@@ -169,5 +199,23 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
169 | if (missing_filename) | 199 | if (missing_filename) |
170 | ret = build_id_cache__fprintf_missing(missing_filename, force, stdout); | 200 | ret = build_id_cache__fprintf_missing(missing_filename, force, stdout); |
171 | 201 | ||
202 | if (update_name_list_str) { | ||
203 | list = strlist__new(true, update_name_list_str); | ||
204 | if (list) { | ||
205 | strlist__for_each(pos, list) | ||
206 | if (build_id_cache__update_file(pos->s, debugdir)) { | ||
207 | if (errno == ENOENT) { | ||
208 | pr_debug("%s wasn't in the cache\n", | ||
209 | pos->s); | ||
210 | continue; | ||
211 | } | ||
212 | pr_warning("Couldn't update %s: %s\n", | ||
213 | pos->s, strerror(errno)); | ||
214 | } | ||
215 | |||
216 | strlist__delete(list); | ||
217 | } | ||
218 | } | ||
219 | |||
172 | return ret; | 220 | return ret; |
173 | } | 221 | } |
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c new file mode 100644 index 000000000000..7d8dc581a545 --- /dev/null +++ b/tools/perf/ui/gtk/annotate.c | |||
@@ -0,0 +1,229 @@ | |||
1 | #include "gtk.h" | ||
2 | #include "util/debug.h" | ||
3 | #include "util/annotate.h" | ||
4 | #include "ui/helpline.h" | ||
5 | |||
6 | |||
7 | enum { | ||
8 | ANN_COL__PERCENT, | ||
9 | ANN_COL__OFFSET, | ||
10 | ANN_COL__LINE, | ||
11 | |||
12 | MAX_ANN_COLS | ||
13 | }; | ||
14 | |||
15 | static const char *const col_names[] = { | ||
16 | "Overhead", | ||
17 | "Offset", | ||
18 | "Line" | ||
19 | }; | ||
20 | |||
21 | static int perf_gtk__get_percent(char *buf, size_t size, struct symbol *sym, | ||
22 | struct disasm_line *dl, int evidx) | ||
23 | { | ||
24 | struct sym_hist *symhist; | ||
25 | double percent = 0.0; | ||
26 | const char *markup; | ||
27 | int ret = 0; | ||
28 | |||
29 | strcpy(buf, ""); | ||
30 | |||
31 | if (dl->offset == (s64) -1) | ||
32 | return 0; | ||
33 | |||
34 | symhist = annotation__histogram(symbol__annotation(sym), evidx); | ||
35 | if (!symhist->addr[dl->offset]) | ||
36 | return 0; | ||
37 | |||
38 | percent = 100.0 * symhist->addr[dl->offset] / symhist->sum; | ||
39 | |||
40 | markup = perf_gtk__get_percent_color(percent); | ||
41 | if (markup) | ||
42 | ret += scnprintf(buf, size, "%s", markup); | ||
43 | ret += scnprintf(buf + ret, size - ret, "%6.2f%%", percent); | ||
44 | if (markup) | ||
45 | ret += scnprintf(buf + ret, size - ret, "</span>"); | ||
46 | |||
47 | return ret; | ||
48 | } | ||
49 | |||
50 | static int perf_gtk__get_offset(char *buf, size_t size, struct symbol *sym, | ||
51 | struct map *map, struct disasm_line *dl) | ||
52 | { | ||
53 | u64 start = map__rip_2objdump(map, sym->start); | ||
54 | |||
55 | strcpy(buf, ""); | ||
56 | |||
57 | if (dl->offset == (s64) -1) | ||
58 | return 0; | ||
59 | |||
60 | return scnprintf(buf, size, "%"PRIx64, start + dl->offset); | ||
61 | } | ||
62 | |||
63 | static int perf_gtk__get_line(char *buf, size_t size, struct disasm_line *dl) | ||
64 | { | ||
65 | int ret = 0; | ||
66 | char *line = g_markup_escape_text(dl->line, -1); | ||
67 | const char *markup = "<span fgcolor='gray'>"; | ||
68 | |||
69 | strcpy(buf, ""); | ||
70 | |||
71 | if (!line) | ||
72 | return 0; | ||
73 | |||
74 | if (dl->offset != (s64) -1) | ||
75 | markup = NULL; | ||
76 | |||
77 | if (markup) | ||
78 | ret += scnprintf(buf, size, "%s", markup); | ||
79 | ret += scnprintf(buf + ret, size - ret, "%s", line); | ||
80 | if (markup) | ||
81 | ret += scnprintf(buf + ret, size - ret, "</span>"); | ||
82 | |||
83 | g_free(line); | ||
84 | return ret; | ||
85 | } | ||
86 | |||
87 | static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym, | ||
88 | struct map *map, int evidx, | ||
89 | struct hist_browser_timer *hbt __maybe_unused) | ||
90 | { | ||
91 | struct disasm_line *pos, *n; | ||
92 | struct annotation *notes; | ||
93 | GType col_types[MAX_ANN_COLS]; | ||
94 | GtkCellRenderer *renderer; | ||
95 | GtkListStore *store; | ||
96 | GtkWidget *view; | ||
97 | int i; | ||
98 | char s[512]; | ||
99 | |||
100 | notes = symbol__annotation(sym); | ||
101 | |||
102 | for (i = 0; i < MAX_ANN_COLS; i++) { | ||
103 | col_types[i] = G_TYPE_STRING; | ||
104 | } | ||
105 | store = gtk_list_store_newv(MAX_ANN_COLS, col_types); | ||
106 | |||
107 | view = gtk_tree_view_new(); | ||
108 | renderer = gtk_cell_renderer_text_new(); | ||
109 | |||
110 | for (i = 0; i < MAX_ANN_COLS; i++) { | ||
111 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), | ||
112 | -1, col_names[i], renderer, "markup", | ||
113 | i, NULL); | ||
114 | } | ||
115 | |||
116 | gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store)); | ||
117 | g_object_unref(GTK_TREE_MODEL(store)); | ||
118 | |||
119 | list_for_each_entry(pos, ¬es->src->source, node) { | ||
120 | GtkTreeIter iter; | ||
121 | |||
122 | gtk_list_store_append(store, &iter); | ||
123 | |||
124 | if (perf_gtk__get_percent(s, sizeof(s), sym, pos, evidx)) | ||
125 | gtk_list_store_set(store, &iter, ANN_COL__PERCENT, s, -1); | ||
126 | if (perf_gtk__get_offset(s, sizeof(s), sym, map, pos)) | ||
127 | gtk_list_store_set(store, &iter, ANN_COL__OFFSET, s, -1); | ||
128 | if (perf_gtk__get_line(s, sizeof(s), pos)) | ||
129 | gtk_list_store_set(store, &iter, ANN_COL__LINE, s, -1); | ||
130 | } | ||
131 | |||
132 | gtk_container_add(GTK_CONTAINER(window), view); | ||
133 | |||
134 | list_for_each_entry_safe(pos, n, ¬es->src->source, node) { | ||
135 | list_del(&pos->node); | ||
136 | disasm_line__free(pos); | ||
137 | } | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | int symbol__gtk_annotate(struct symbol *sym, struct map *map, int evidx, | ||
143 | struct hist_browser_timer *hbt) | ||
144 | { | ||
145 | GtkWidget *window; | ||
146 | GtkWidget *notebook; | ||
147 | GtkWidget *scrolled_window; | ||
148 | GtkWidget *tab_label; | ||
149 | |||
150 | if (map->dso->annotate_warned) | ||
151 | return -1; | ||
152 | |||
153 | if (symbol__annotate(sym, map, 0) < 0) { | ||
154 | ui__error("%s", ui_helpline__current); | ||
155 | return -1; | ||
156 | } | ||
157 | |||
158 | if (perf_gtk__is_active_context(pgctx)) { | ||
159 | window = pgctx->main_window; | ||
160 | notebook = pgctx->notebook; | ||
161 | } else { | ||
162 | GtkWidget *vbox; | ||
163 | GtkWidget *infobar; | ||
164 | GtkWidget *statbar; | ||
165 | |||
166 | signal(SIGSEGV, perf_gtk__signal); | ||
167 | signal(SIGFPE, perf_gtk__signal); | ||
168 | signal(SIGINT, perf_gtk__signal); | ||
169 | signal(SIGQUIT, perf_gtk__signal); | ||
170 | signal(SIGTERM, perf_gtk__signal); | ||
171 | |||
172 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | ||
173 | gtk_window_set_title(GTK_WINDOW(window), "perf annotate"); | ||
174 | |||
175 | g_signal_connect(window, "delete_event", gtk_main_quit, NULL); | ||
176 | |||
177 | pgctx = perf_gtk__activate_context(window); | ||
178 | if (!pgctx) | ||
179 | return -1; | ||
180 | |||
181 | vbox = gtk_vbox_new(FALSE, 0); | ||
182 | notebook = gtk_notebook_new(); | ||
183 | pgctx->notebook = notebook; | ||
184 | |||
185 | gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); | ||
186 | |||
187 | infobar = perf_gtk__setup_info_bar(); | ||
188 | if (infobar) { | ||
189 | gtk_box_pack_start(GTK_BOX(vbox), infobar, | ||
190 | FALSE, FALSE, 0); | ||
191 | } | ||
192 | |||
193 | statbar = perf_gtk__setup_statusbar(); | ||
194 | gtk_box_pack_start(GTK_BOX(vbox), statbar, FALSE, FALSE, 0); | ||
195 | |||
196 | gtk_container_add(GTK_CONTAINER(window), vbox); | ||
197 | } | ||
198 | |||
199 | scrolled_window = gtk_scrolled_window_new(NULL, NULL); | ||
200 | tab_label = gtk_label_new(sym->name); | ||
201 | |||
202 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), | ||
203 | GTK_POLICY_AUTOMATIC, | ||
204 | GTK_POLICY_AUTOMATIC); | ||
205 | |||
206 | gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled_window, | ||
207 | tab_label); | ||
208 | |||
209 | perf_gtk__annotate_symbol(scrolled_window, sym, map, evidx, hbt); | ||
210 | return 0; | ||
211 | } | ||
212 | |||
213 | void perf_gtk__show_annotations(void) | ||
214 | { | ||
215 | GtkWidget *window; | ||
216 | |||
217 | if (!perf_gtk__is_active_context(pgctx)) | ||
218 | return; | ||
219 | |||
220 | window = pgctx->main_window; | ||
221 | gtk_widget_show_all(window); | ||
222 | |||
223 | perf_gtk__resize_window(window); | ||
224 | gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); | ||
225 | |||
226 | gtk_main(); | ||
227 | |||
228 | perf_gtk__deactivate_context(&pgctx); | ||
229 | } | ||
diff --git a/tools/perf/ui/gtk/gtk.h b/tools/perf/ui/gtk/gtk.h index 5d3693754828..3d96785ef155 100644 --- a/tools/perf/ui/gtk/gtk.h +++ b/tools/perf/ui/gtk/gtk.h | |||
@@ -10,6 +10,7 @@ | |||
10 | 10 | ||
11 | struct perf_gtk_context { | 11 | struct perf_gtk_context { |
12 | GtkWidget *main_window; | 12 | GtkWidget *main_window; |
13 | GtkWidget *notebook; | ||
13 | 14 | ||
14 | #ifdef HAVE_GTK_INFO_BAR | 15 | #ifdef HAVE_GTK_INFO_BAR |
15 | GtkWidget *info_bar; | 16 | GtkWidget *info_bar; |
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c index 166f13df3134..ae6a789cb0f6 100644 --- a/tools/perf/ui/setup.c +++ b/tools/perf/ui/setup.c | |||
@@ -8,7 +8,7 @@ pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; | |||
8 | 8 | ||
9 | void setup_browser(bool fallback_to_pager) | 9 | void setup_browser(bool fallback_to_pager) |
10 | { | 10 | { |
11 | if (!isatty(1) || dump_trace) | 11 | if (use_browser < 2 && (!isatty(1) || dump_trace)) |
12 | use_browser = 0; | 12 | use_browser = 0; |
13 | 13 | ||
14 | /* default to TUI */ | 14 | /* default to TUI */ |
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 07aaeea60000..d33fe937e6f1 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -809,7 +809,7 @@ fallback: | |||
809 | pr_err("Can't annotate %s:\n\n" | 809 | pr_err("Can't annotate %s:\n\n" |
810 | "No vmlinux file%s\nwas found in the path.\n\n" | 810 | "No vmlinux file%s\nwas found in the path.\n\n" |
811 | "Please use:\n\n" | 811 | "Please use:\n\n" |
812 | " perf buildid-cache -av vmlinux\n\n" | 812 | " perf buildid-cache -vu vmlinux\n\n" |
813 | "or:\n\n" | 813 | "or:\n\n" |
814 | " --vmlinux vmlinux\n", | 814 | " --vmlinux vmlinux\n", |
815 | sym->name, build_id_msg ?: ""); | 815 | sym->name, build_id_msg ?: ""); |
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 8eec94358a4a..c422440fe611 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h | |||
@@ -6,6 +6,7 @@ | |||
6 | #include "types.h" | 6 | #include "types.h" |
7 | #include "symbol.h" | 7 | #include "symbol.h" |
8 | #include "hist.h" | 8 | #include "hist.h" |
9 | #include "sort.h" | ||
9 | #include <linux/list.h> | 10 | #include <linux/list.h> |
10 | #include <linux/rbtree.h> | 11 | #include <linux/rbtree.h> |
11 | #include <pthread.h> | 12 | #include <pthread.h> |
@@ -154,6 +155,29 @@ static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused, | |||
154 | } | 155 | } |
155 | #endif | 156 | #endif |
156 | 157 | ||
158 | #ifdef GTK2_SUPPORT | ||
159 | int symbol__gtk_annotate(struct symbol *sym, struct map *map, int evidx, | ||
160 | struct hist_browser_timer *hbt); | ||
161 | |||
162 | static inline int hist_entry__gtk_annotate(struct hist_entry *he, int evidx, | ||
163 | struct hist_browser_timer *hbt) | ||
164 | { | ||
165 | return symbol__gtk_annotate(he->ms.sym, he->ms.map, evidx, hbt); | ||
166 | } | ||
167 | |||
168 | void perf_gtk__show_annotations(void); | ||
169 | #else | ||
170 | static inline int hist_entry__gtk_annotate(struct hist_entry *he __maybe_unused, | ||
171 | int evidx __maybe_unused, | ||
172 | struct hist_browser_timer *hbt | ||
173 | __maybe_unused) | ||
174 | { | ||
175 | return 0; | ||
176 | } | ||
177 | |||
178 | static inline void perf_gtk__show_annotations(void) {} | ||
179 | #endif | ||
180 | |||
157 | extern const char *disassembler_style; | 181 | extern const char *disassembler_style; |
158 | 182 | ||
159 | #endif /* __PERF_ANNOTATE_H */ | 183 | #endif /* __PERF_ANNOTATE_H */ |
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index 4de2fdca98c8..afc44c18dfe1 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y | |||
@@ -1,5 +1,4 @@ | |||
1 | %pure-parser | 1 | %pure-parser |
2 | %name-prefix "parse_events_" | ||
3 | %parse-param {void *_data} | 2 | %parse-param {void *_data} |
4 | %parse-param {void *scanner} | 3 | %parse-param {void *scanner} |
5 | %lex-param {void* scanner} | 4 | %lex-param {void* scanner} |
diff --git a/tools/perf/util/pmu.y b/tools/perf/util/pmu.y index ec898047ebb9..bfd7e8509869 100644 --- a/tools/perf/util/pmu.y +++ b/tools/perf/util/pmu.y | |||
@@ -1,5 +1,4 @@ | |||
1 | 1 | ||
2 | %name-prefix "perf_pmu_" | ||
3 | %parse-param {struct list_head *format} | 2 | %parse-param {struct list_head *format} |
4 | %parse-param {char *name} | 3 | %parse-param {char *name} |
5 | 4 | ||