Skip to contentSkip to conversation

perf annotate: Add support for GTK+ annotation browser (v2)

PATCH In review Namhyung Kim 3 participants 17 messages Feb 7, 2013 – Feb 15, 2013 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

cover perf annotate: Add support for GTK+ annotation browser (v2)

Hi,

This patchset adds support to GTK+ annotation browser. For now only the most frequently sampled symbol per evsel will be shown. IOW it shows the hottest symbol per event by default and you can change it by giving the --symbol option or an argument.

The patch 4 and 5 are somewhat independent so that they can be merged separately.

You can also get it from my perf/annotate-gtk-v2 branch on

git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

Any comments are welcome, thanks,
Namhyung

v2 changes:
* patch 1 and 2 in the previous patchset are merged already
* squash the last (add --gtk option) patch into the patch 1 (Arnaldo)
* make --gtk option does not fallback to stdio for a piped stdout (Borislav)

Namhyung Kim (7):
perf ui/gtk: Implement basic GTK2 annotation browser perf gtk/annotate: Support multiple event annotation perf gtk/annotate: Show source lines with gray color perf buildid-cache: Add --update option
perf annotate: Fix warning message on a missing vmlinux perf gtk/annotate: Fail early if it can't annotate perf annotate: Make it to be able to skip unannotatable symbols

 tools/perf/Documentation/perf-annotate.txt      |   4 +-
 tools/perf/Documentation/perf-buildid-cache.txt |   4 +
 tools/perf/Makefile                             |   1 +
 tools/perf/builtin-annotate.c                   |  27 ++-
 tools/perf/builtin-buildid-cache.c              |  50 +++++-
 tools/perf/ui/gtk/annotate.c                    | 229 ++++++++++++++++++++++++
 tools/perf/ui/gtk/gtk.h                         |   1 +
 tools/perf/ui/setup.c                           |   2 +-
 tools/perf/util/annotate.c                      |   2 +-
 tools/perf/util/annotate.h                      |  24 +++
 10 files changed, 338 insertions(+), 6 deletions(-)
 create mode 100644 tools/perf/ui/gtk/annotate.c
Signature · 1 line
1.7.11.7
author maintainer
#1 lore raw

PATCH 1/7 perf ui/gtk: Implement basic GTK2 annotation browser

Basic implementation of perf annotate on GTK2. Currently only shows first symbol. Add a new --gtk option to use it.

Cc Borislav Petkov <[email protected]>
Cc Pekka Enberg <[email protected]>
---
 tools/perf/Documentation/perf-annotate.txt |   4 +-
 tools/perf/Makefile                        |   1 +
 tools/perf/builtin-annotate.c              |  10 +-
 tools/perf/ui/gtk/annotate.c               | 185 +++++++++++++++++++++++++++++
 tools/perf/ui/setup.c                      |   2 +-
 tools/perf/util/annotate.h                 |  20 ++++
 6 files changed, 218 insertions(+), 4 deletions(-)
 create mode 100644 tools/perf/ui/gtk/annotate.c
tools/perf/Documentation/perf-annotate.txt +3 -1
index c8ffd9fd5c6a..e5e1d06efc37 100644
@@ -61,11 +61,13 @@ OPTIONS
 
 --stdio:: Use the stdio interface.
 
---tui:: Use the TUI interface Use of --tui requires a tty, if one is not
+--tui:: Use the TUI interface. Use of --tui requires a tty, if one is not
 	present, as when piping to other commands, the stdio interface is
 	used. This interfaces starts by centering on the line with more
 	samples, TAB/UNTAB cycles through the lines with more samples.
 
+--gtk:: Use the GTK interface.
+
 -C::
 --cpu:: Only report samples for the list of CPUs provided. Multiple CPUs can
 	be provided as a comma-separated list with no space: 0,1. Ranges of
tools/perf/Makefile +1 -0
index a158309a65ef..1c8df6f9c4d9 100644
@@ -698,6 +698,7 @@ ifndef NO_GTK2
 		LIB_OBJS += $(OUTPUT)ui/gtk/util.o
 		LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o
 		LIB_OBJS += $(OUTPUT)ui/gtk/progress.o
+		LIB_OBJS += $(OUTPUT)ui/gtk/annotate.o
 	endif
 endif
 
tools/perf/builtin-annotate.c +8 -2
index 95a2ad3f043e..9d758c9611a5 100644
@@ -34,7 +34,7 @@
 
 struct perf_annotate {
 	struct perf_tool tool;
-	bool	   force, use_tui, use_stdio;
+	bool	   force, use_tui, use_stdio, use_gtk;
 	bool	   full_paths;
 	bool	   print_line;
 	const char *sym_hist_filter;
@@ -138,7 +138,10 @@ find_next:
 			continue;
 		}
 
-		if (use_browser > 0) {
+		if (use_browser == 2) {
+			hist_entry__gtk_annotate(he, evidx, NULL);
+			return;
+		} else if (use_browser == 1) {
 			key = hist_entry__tui_annotate(he, evidx, NULL);
 			switch (key) {
 			case K_RIGHT:
@@ -270,6 +273,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "be more verbose (show symbol address, etc)"),
 	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
 		    "dump raw trace in ASCII"),
+	OPT_BOOLEAN(0, "gtk", &annotate.use_gtk, "Use the GTK interface"),
 	OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"),
 	OPT_BOOLEAN(0, "stdio", &annotate.use_stdio, "Use the stdio interface"),
 	OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
@@ -300,6 +304,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 		use_browser = 0;
 	else if (annotate.use_tui)
 		use_browser = 1;
+	else if (annotate.use_gtk)
+		use_browser = 2;
 
 	setup_browser(true);
 
tools/perf/ui/gtk/annotate.c new file +185 -0

185 lines not on this page · raw message

tools/perf/ui/setup.c +1 -1
index 166f13df3134..ae6a789cb0f6 100644
@@ -8,7 +8,7 @@ pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
 
 void setup_browser(bool fallback_to_pager)
 {
-	if (!isatty(1) || dump_trace)
+	if (use_browser < 2 && (!isatty(1) || dump_trace))
 		use_browser = 0;
 
 	/* default to TUI */
tools/perf/util/annotate.h +20 -0
index 8eec94358a4a..a8ccbda4aeb7 100644
@@ -6,6 +6,7 @@
 #include "types.h"
 #include "symbol.h"
 #include "hist.h"
+#include "sort.h"
 #include <linux/list.h>
 #include <linux/rbtree.h>
 #include <pthread.h>
@@ -154,6 +155,25 @@ static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused,
 }
 #endif
 
+#ifdef GTK2_SUPPORT
+int symbol__gtk_annotate(struct symbol *sym, struct map *map, int evidx,
+			 struct hist_browser_timer *hbt);
+
+static inline int hist_entry__gtk_annotate(struct hist_entry *he, int evidx,
+					   struct hist_browser_timer *hbt)
+{
+	return symbol__gtk_annotate(he->ms.sym, he->ms.map, evidx, hbt);
+}
+#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)
+{
+	return 0;
+}
+#endif
+
 extern const char	*disassembler_style;
 
 #endif	/* __PERF_ANNOTATE_H */
Signature · 1 line
1.7.11.7
author maintainer
#2 lore raw

[tip:perf/core] perf ui/gtk: Implement basic GTK2 annotation browser

Commit-ID:  2b676bf068916046151277f27113f80828e33001
Gitweb:     http://git.kernel.org/tip/2b676bf068916046151277f27113f80828e33001
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 7 Feb 2013 18:02:08 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 14 Feb 2013 14:59:27 -0300

perf ui/gtk: Implement basic GTK2 annotation browser

Basic implementation of perf annotate on GTK2. Currently only shows first symbol. Add a new --gtk option to use it.

---
 tools/perf/Documentation/perf-annotate.txt |   4 +-
 tools/perf/Makefile                        |   1 +
 tools/perf/builtin-annotate.c              |  10 +-
 tools/perf/ui/gtk/annotate.c               | 185 +++++++++++++++++++++++++++++
 tools/perf/ui/setup.c                      |   2 +-
 tools/perf/util/annotate.h                 |  20 ++++
 6 files changed, 218 insertions(+), 4 deletions(-)
tools/perf/Documentation/perf-annotate.txt +3 -1
index c8ffd9f..e5e1d06 100644
@@ -61,11 +61,13 @@ OPTIONS
 
 --stdio:: Use the stdio interface.
 
---tui:: Use the TUI interface Use of --tui requires a tty, if one is not
+--tui:: Use the TUI interface. Use of --tui requires a tty, if one is not
 	present, as when piping to other commands, the stdio interface is
 	used. This interfaces starts by centering on the line with more
 	samples, TAB/UNTAB cycles through the lines with more samples.
 
+--gtk:: Use the GTK interface.
+
 -C::
 --cpu:: Only report samples for the list of CPUs provided. Multiple CPUs can
 	be provided as a comma-separated list with no space: 0,1. Ranges of
tools/perf/Makefile +1 -0
index a158309..1c8df6f 100644
@@ -698,6 +698,7 @@ ifndef NO_GTK2
 		LIB_OBJS += $(OUTPUT)ui/gtk/util.o
 		LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o
 		LIB_OBJS += $(OUTPUT)ui/gtk/progress.o
+		LIB_OBJS += $(OUTPUT)ui/gtk/annotate.o
 	endif
 endif
 
tools/perf/builtin-annotate.c +8 -2
index 95a2ad3..9d758c9 100644
@@ -34,7 +34,7 @@
 
 struct perf_annotate {
 	struct perf_tool tool;
-	bool	   force, use_tui, use_stdio;
+	bool	   force, use_tui, use_stdio, use_gtk;
 	bool	   full_paths;
 	bool	   print_line;
 	const char *sym_hist_filter;
@@ -138,7 +138,10 @@ find_next:
 			continue;
 		}
 
-		if (use_browser > 0) {
+		if (use_browser == 2) {
+			hist_entry__gtk_annotate(he, evidx, NULL);
+			return;
+		} else if (use_browser == 1) {
 			key = hist_entry__tui_annotate(he, evidx, NULL);
 			switch (key) {
 			case K_RIGHT:
@@ -270,6 +273,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "be more verbose (show symbol address, etc)"),
 	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
 		    "dump raw trace in ASCII"),
+	OPT_BOOLEAN(0, "gtk", &annotate.use_gtk, "Use the GTK interface"),
 	OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"),
 	OPT_BOOLEAN(0, "stdio", &annotate.use_stdio, "Use the stdio interface"),
 	OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
@@ -300,6 +304,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 		use_browser = 0;
 	else if (annotate.use_tui)
 		use_browser = 1;
+	else if (annotate.use_gtk)
+		use_browser = 2;
 
 	setup_browser(true);
 
tools/perf/ui/gtk/annotate.c new file +185 -0

185 lines not on this page · raw message

tools/perf/ui/setup.c +1 -1
index 166f13d..ae6a789 100644
@@ -8,7 +8,7 @@ pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
 
 void setup_browser(bool fallback_to_pager)
 {
-	if (!isatty(1) || dump_trace)
+	if (use_browser < 2 && (!isatty(1) || dump_trace))
 		use_browser = 0;
 
 	/* default to TUI */
tools/perf/util/annotate.h +20 -0
index 8eec943..a8ccbda 100644
@@ -6,6 +6,7 @@
 #include "types.h"
 #include "symbol.h"
 #include "hist.h"
+#include "sort.h"
 #include <linux/list.h>
 #include <linux/rbtree.h>
 #include <pthread.h>
@@ -154,6 +155,25 @@ static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused,
 }
 #endif
 
+#ifdef GTK2_SUPPORT
+int symbol__gtk_annotate(struct symbol *sym, struct map *map, int evidx,
+			 struct hist_browser_timer *hbt);
+
+static inline int hist_entry__gtk_annotate(struct hist_entry *he, int evidx,
+					   struct hist_browser_timer *hbt)
+{
+	return symbol__gtk_annotate(he->ms.sym, he->ms.map, evidx, hbt);
+}
+#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)
+{
+	return 0;
+}
+#endif
+
 extern const char	*disassembler_style;
 
 #endif	/* __PERF_ANNOTATE_H */
author maintainer
#3 lore raw

PATCH 2/7 perf gtk/annotate: Support multiple event annotation

In reply to Namhyung Kim

From: Namhyung Kim <[email protected]>

Show multiple annotation result for each evsel. Each result represents the most frquently sampled symbol/function for the evsel and it will be shown in a tab window.

For this add a reference to main container (notebook) to the pgctx. At the first call to annotate browser, hist_entry__find_annotations() will setup a new browser, and next calls will add new tabs to the browser. But it requires final perf_gtk__show_annotations() to start processing GUI events.

Cc Borislav Petkov <[email protected]>
Cc Pekka Enberg <[email protected]>
---
 tools/perf/builtin-annotate.c |  4 +++
 tools/perf/ui/gtk/annotate.c  | 74 +++++++++++++++++++++++++++----------------
 tools/perf/ui/gtk/gtk.h       |  1 +
 tools/perf/util/annotate.h    |  4 +++
 4 files changed, 56 insertions(+), 27 deletions(-)
tools/perf/builtin-annotate.c +4 -0
index 9d758c9611a5..68e3a16abd3d 100644
@@ -227,6 +227,10 @@ static int __cmd_annotate(struct perf_annotate *ann)
 		ui__error("The %s file has no samples!\n", session->filename);
 		goto out_delete;
 	}
+
+	if (use_browser == 2)
+		perf_gtk__show_annotations();
+
 out_delete:
 	/*
 	 * Speed up the exit process, for large files this can
tools/perf/ui/gtk/annotate.c +47 -27

102 lines not on this page · raw message

tools/perf/ui/gtk/gtk.h +1 -0
index 5d3693754828..3d96785ef155 100644
@@ -10,6 +10,7 @@
 
 struct perf_gtk_context {
 	GtkWidget *main_window;
+	GtkWidget *notebook;
 
 #ifdef HAVE_GTK_INFO_BAR
 	GtkWidget *info_bar;
tools/perf/util/annotate.h +4 -0
index a8ccbda4aeb7..c422440fe611 100644
@@ -164,6 +164,8 @@ static inline int hist_entry__gtk_annotate(struct hist_entry *he, int evidx,
 {
 	return symbol__gtk_annotate(he->ms.sym, he->ms.map, evidx, 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,
@@ -172,6 +174,8 @@ static inline int hist_entry__gtk_annotate(struct hist_entry *he __maybe_unused,
 {
 	return 0;
 }
+
+static inline void perf_gtk__show_annotations(void) {}
 #endif
 
 extern const char	*disassembler_style;
Signature · 1 line
1.7.11.7
#4 lore raw

[tip:perf/core] perf gtk/annotate: Support multiple event annotation

Commit-ID:  7a60ba948267336d77a48a3539f98151f9dcfba6
Gitweb:     http://git.kernel.org/tip/7a60ba948267336d77a48a3539f98151f9dcfba6
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 7 Feb 2013 18:02:09 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 14 Feb 2013 14:59:28 -0300

perf gtk/annotate: Support multiple event annotation

Show multiple annotation result for each evsel. Each result represents the most frquently sampled symbol/function for the evsel and it will be shown in a tab window.

For this add a reference to main container (notebook) to the pgctx. At the first call to annotate browser, hist_entry__find_annotations() will setup a new browser, and next calls will add new tabs to the browser. But it requires final perf_gtk__show_annotations() to start processing GUI events.

---
 tools/perf/builtin-annotate.c |  4 +++
 tools/perf/ui/gtk/annotate.c  | 74 +++++++++++++++++++++++++++----------------
 tools/perf/ui/gtk/gtk.h       |  1 +
 tools/perf/util/annotate.h    |  4 +++
 4 files changed, 56 insertions(+), 27 deletions(-)
tools/perf/builtin-annotate.c +4 -0
index 9d758c9..68e3a16 100644
@@ -227,6 +227,10 @@ static int __cmd_annotate(struct perf_annotate *ann)
 		ui__error("The %s file has no samples!\n", session->filename);
 		goto out_delete;
 	}
+
+	if (use_browser == 2)
+		perf_gtk__show_annotations();
+
 out_delete:
 	/*
 	 * Speed up the exit process, for large files this can
tools/perf/ui/gtk/annotate.c +47 -27

102 lines not on this page · raw message

tools/perf/ui/gtk/gtk.h +1 -0
index 5d36937..3d96785 100644
@@ -10,6 +10,7 @@
 
 struct perf_gtk_context {
 	GtkWidget *main_window;
+	GtkWidget *notebook;
 
 #ifdef HAVE_GTK_INFO_BAR
 	GtkWidget *info_bar;
tools/perf/util/annotate.h +4 -0
index a8ccbda..c422440 100644
@@ -164,6 +164,8 @@ static inline int hist_entry__gtk_annotate(struct hist_entry *he, int evidx,
 {
 	return symbol__gtk_annotate(he->ms.sym, he->ms.map, evidx, 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,
@@ -172,6 +174,8 @@ static inline int hist_entry__gtk_annotate(struct hist_entry *he __maybe_unused,
 {
 	return 0;
 }
+
+static inline void perf_gtk__show_annotations(void) {}
 #endif
 
 extern const char	*disassembler_style;
author maintainer
#5 lore raw

PATCH 3/7 perf gtk/annotate: Show source lines with gray color

In reply to Namhyung Kim

From: Namhyung Kim <[email protected]>

In order to differentiate source lines from asm line, print them with gray color. To do this, it needs to be escaped since sometimes it contains "<" and/or ">" characters so that it should not be considered as a markup tags. Use glib's g_markup_escape_text() for this.

Cc Borislav Petkov <[email protected]>
Cc Pekka Enberg <[email protected]>
---
 tools/perf/ui/gtk/annotate.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)
tools/perf/ui/gtk/annotate.c +27 -3
index 1ce89f2558fa..2fe056b0096c 100644
@@ -60,6 +60,30 @@ static int perf_gtk__get_offset(char *buf, size_t size, struct symbol *sym,
 	return scnprintf(buf, size, "%"PRIx64, start + dl->offset);
 }
 
+static int perf_gtk__get_line(char *buf, size_t size, struct disasm_line *dl)
+{
+	int ret = 0;
+	char *line = g_markup_escape_text(dl->line, -1);
+	const char *markup = "<span fgcolor='gray'>";
+
+	strcpy(buf, "");
+
+	if (!line)
+		return 0;
+
+	if (dl->offset != (s64) -1)
+		markup = NULL;
+
+	if (markup)
+		ret += scnprintf(buf, size, "%s", markup);
+	ret += scnprintf(buf + ret, size - ret, "%s", line);
+	if (markup)
+		ret += scnprintf(buf + ret, size - ret, "</span>");
+
+	g_free(line);
+	return ret;
+}
+
 static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
 				struct map *map, int evidx,
 				struct hist_browser_timer *hbt __maybe_unused)
@@ -93,8 +117,7 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
 
 	for (i = 0; i < MAX_ANN_COLS; i++) {
 		gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
-					-1, col_names[i], renderer,
-					i == ANN_COL__PERCENT ? "markup" : "text",
+					-1, col_names[i], renderer, "markup",
 					i, NULL);
 	}
 
@@ -110,7 +133,8 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
 			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);
-		gtk_list_store_set(store, &iter, ANN_COL__LINE, pos->line, -1);
+		if (perf_gtk__get_line(s, sizeof(s), pos))
+			gtk_list_store_set(store, &iter, ANN_COL__LINE, s, -1);
 	}
 
 	gtk_container_add(GTK_CONTAINER(window), view);
Signature · 1 line
1.7.11.7
#6 lore raw

[tip:perf/core] perf gtk/annotate: Show source lines with gray color

Commit-ID:  237522378604a2e26e19a8b11a70171eaf98c6c5
Gitweb:     http://git.kernel.org/tip/237522378604a2e26e19a8b11a70171eaf98c6c5
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 7 Feb 2013 18:02:10 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 14 Feb 2013 14:59:28 -0300

perf gtk/annotate: Show source lines with gray color

In order to differentiate source lines from asm line, print them with gray color. To do this, it needs to be escaped since sometimes it contains "<" and/or ">" characters so that it should not be considered as a markup tags. Use glib's g_markup_escape_text() for this.

---
 tools/perf/ui/gtk/annotate.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)
tools/perf/ui/gtk/annotate.c +27 -3
index 1ce89f2..2fe056b 100644
@@ -60,6 +60,30 @@ static int perf_gtk__get_offset(char *buf, size_t size, struct symbol *sym,
 	return scnprintf(buf, size, "%"PRIx64, start + dl->offset);
 }
 
+static int perf_gtk__get_line(char *buf, size_t size, struct disasm_line *dl)
+{
+	int ret = 0;
+	char *line = g_markup_escape_text(dl->line, -1);
+	const char *markup = "<span fgcolor='gray'>";
+
+	strcpy(buf, "");
+
+	if (!line)
+		return 0;
+
+	if (dl->offset != (s64) -1)
+		markup = NULL;
+
+	if (markup)
+		ret += scnprintf(buf, size, "%s", markup);
+	ret += scnprintf(buf + ret, size - ret, "%s", line);
+	if (markup)
+		ret += scnprintf(buf + ret, size - ret, "</span>");
+
+	g_free(line);
+	return ret;
+}
+
 static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
 				struct map *map, int evidx,
 				struct hist_browser_timer *hbt __maybe_unused)
@@ -93,8 +117,7 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
 
 	for (i = 0; i < MAX_ANN_COLS; i++) {
 		gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
-					-1, col_names[i], renderer,
-					i == ANN_COL__PERCENT ? "markup" : "text",
+					-1, col_names[i], renderer, "markup",
 					i, NULL);
 	}
 
@@ -110,7 +133,8 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
 			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);
-		gtk_list_store_set(store, &iter, ANN_COL__LINE, pos->line, -1);
+		if (perf_gtk__get_line(s, sizeof(s), pos))
+			gtk_list_store_set(store, &iter, ANN_COL__LINE, s, -1);
 	}
 
 	gtk_container_add(GTK_CONTAINER(window), view);
author maintainer
#7 lore raw

PATCH 4/7 perf buildid-cache: Add --update option

In reply to Namhyung Kim

From: Namhyung Kim <[email protected]>

When adding vmlinux file to build-id cache, it'd be fail since kallsyms dso with a same build-id was already added by perf record. So one needs to remove the kallsyms first to add vmlinux into the cache. Add --update option for doing it at once.

---
 tools/perf/Documentation/perf-buildid-cache.txt |  4 ++
 tools/perf/builtin-buildid-cache.c              | 50 ++++++++++++++++++++++++-
 2 files changed, 53 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-buildid-cache.txt +4 -0
index 8e798baae0fd..e9a8349a7172 100644
@@ -27,6 +27,10 @@ OPTIONS
 -M::
 --missing=:: 
 	List missing build ids in the cache for the specified file.
+-u::
+--update::
+	Update specified file of the cache. It can be used to update kallsyms
+	kernel dso to vmlinux in order to support annotation.
 -v::
 --verbose::
 	Be more verbose.
tools/perf/builtin-buildid-cache.c +49 -1

73 lines not on this page · raw message

Signature · 1 line
1.7.11.7
#8 lore raw

[tip:perf/core] perf buildid-cache: Add --update option

Commit-ID:  eeb49845425375481f14c0e5721f88242642e88e
Gitweb:     http://git.kernel.org/tip/eeb49845425375481f14c0e5721f88242642e88e
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 7 Feb 2013 18:02:11 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 14 Feb 2013 14:59:27 -0300

perf buildid-cache: Add --update option

When adding vmlinux file to build-id cache, it'd be fail since kallsyms dso with a same build-id was already added by perf record.

So one needs to remove the kallsyms first to add vmlinux into the cache. Add --update option for doing it at once.

---
 tools/perf/Documentation/perf-buildid-cache.txt |  4 ++
 tools/perf/builtin-buildid-cache.c              | 50 ++++++++++++++++++++++++-
 2 files changed, 53 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-buildid-cache.txt +4 -0
index 8e798ba..e9a8349 100644
@@ -27,6 +27,10 @@ OPTIONS
 -M::
 --missing=:: 
 	List missing build ids in the cache for the specified file.
+-u::
+--update::
+	Update specified file of the cache. It can be used to update kallsyms
+	kernel dso to vmlinux in order to support annotation.
 -v::
 --verbose::
 	Be more verbose.
tools/perf/builtin-buildid-cache.c +49 -1

73 lines not on this page · raw message

author maintainer
#9 lore raw

PATCH 5/7 perf annotate: Fix warning message on a missing vmlinux

In reply to Namhyung Kim

From: Namhyung Kim <[email protected]>

When perf annotate runs with no vmlinux file it cannot annotate kernel symbols because the kallsyms only provides symbol addresses. So it recommends to run perf buildid-cache to install proper vmlinux image.

But running perf buildid-cache -av vmlinux as the message gives me a following error:

  $ perf buildid-cache -av /home/namhyung/build/kernel/vmlinux
  Couldn't add v: No such file or directory

Since the -a option receives a parameter, 'v' should not be after the option.

In addition -a option is not work for this case since the build-id cache already has a kallsyms with same build-id so it'll fail with EEXIST. Use recently added -u (--update) option for it.

---
 tools/perf/util/annotate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.c +1 -1
index 07aaeea60000..d33fe937e6f1 100644
@@ -809,7 +809,7 @@ fallback:
 		pr_err("Can't annotate %s:\n\n"
 		       "No vmlinux file%s\nwas found in the path.\n\n"
 		       "Please use:\n\n"
-		       "  perf buildid-cache -av vmlinux\n\n"
+		       "  perf buildid-cache -vu vmlinux\n\n"
 		       "or:\n\n"
 		       "  --vmlinux vmlinux\n",
 		       sym->name, build_id_msg ?: "");
Signature · 1 line
1.7.11.7
#10 lore raw

[tip:perf/core] perf annotate: Fix warning message on a missing vmlinux

Commit-ID:  e3a34029c635b7dee06e51d99441578b96c7d463
Gitweb:     http://git.kernel.org/tip/e3a34029c635b7dee06e51d99441578b96c7d463
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 7 Feb 2013 18:02:12 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 14 Feb 2013 14:59:27 -0300

perf annotate: Fix warning message on a missing vmlinux

When perf annotate runs with no vmlinux file it cannot annotate kernel symbols because the kallsyms only provides symbol addresses. So it recommends to run perf buildid-cache to install proper vmlinux image.

But running perf buildid-cache -av vmlinux as the message gives me a following error:

  $ perf buildid-cache -av /home/namhyung/build/kernel/vmlinux
  Couldn't add v: No such file or directory

Since the -a option receives a parameter, 'v' should not be after the option.

In addition -a option is not work for this case since the build-id cache already has a kallsyms with same build-id so it'll fail with EEXIST. Use recently added -u (--update) option for it.

---
 tools/perf/util/annotate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.c +1 -1
index 07aaeea..d33fe93 100644
@@ -809,7 +809,7 @@ fallback:
 		pr_err("Can't annotate %s:\n\n"
 		       "No vmlinux file%s\nwas found in the path.\n\n"
 		       "Please use:\n\n"
-		       "  perf buildid-cache -av vmlinux\n\n"
+		       "  perf buildid-cache -vu vmlinux\n\n"
 		       "or:\n\n"
 		       "  --vmlinux vmlinux\n",
 		       sym->name, build_id_msg ?: "");
author maintainer
#11 lore raw

PATCH 6/7 perf gtk/annotate: Fail early if it can't annotate

In reply to Namhyung Kim

From: Namhyung Kim <[email protected]>

Don't need to setup a browser window if annotate cannot work.

---
 tools/perf/ui/gtk/annotate.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
tools/perf/ui/gtk/annotate.c +8 -8
index 2fe056b0096c..7d8dc581a545 100644
@@ -97,14 +97,6 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
 	int i;
 	char s[512];
 
-	if (map->dso->annotate_warned)
-		return -1;
-
-	if (symbol__annotate(sym, map, 0) < 0) {
-		ui__error("%s", ui_helpline__current);
-		return -1;
-	}
-
 	notes = symbol__annotation(sym);
 
 	for (i = 0; i < MAX_ANN_COLS; i++) {
@@ -155,6 +147,14 @@ int symbol__gtk_annotate(struct symbol *sym, struct map *map, int evidx,
 	GtkWidget *scrolled_window;
 	GtkWidget *tab_label;
 
+	if (map->dso->annotate_warned)
+		return -1;
+
+	if (symbol__annotate(sym, map, 0) < 0) {
+		ui__error("%s", ui_helpline__current);
+		return -1;
+	}
+
 	if (perf_gtk__is_active_context(pgctx)) {
 		window = pgctx->main_window;
 		notebook = pgctx->notebook;
Signature · 1 line
1.7.11.7
#12 lore raw

[tip:perf/core] perf gtk/annotate: Fail early if it can' t annotate

Commit-ID:  c0e79be74907b4654b622601692e1a27fd1dbeb3
Gitweb:     http://git.kernel.org/tip/c0e79be74907b4654b622601692e1a27fd1dbeb3
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 7 Feb 2013 18:02:13 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 14 Feb 2013 14:59:28 -0300

perf gtk/annotate: Fail early if it can't annotate

Don't need to setup a browser window if annotate cannot work.

---
 tools/perf/ui/gtk/annotate.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
tools/perf/ui/gtk/annotate.c +8 -8
index 2fe056b..7d8dc58 100644
@@ -97,14 +97,6 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
 	int i;
 	char s[512];
 
-	if (map->dso->annotate_warned)
-		return -1;
-
-	if (symbol__annotate(sym, map, 0) < 0) {
-		ui__error("%s", ui_helpline__current);
-		return -1;
-	}
-
 	notes = symbol__annotation(sym);
 
 	for (i = 0; i < MAX_ANN_COLS; i++) {
@@ -155,6 +147,14 @@ int symbol__gtk_annotate(struct symbol *sym, struct map *map, int evidx,
 	GtkWidget *scrolled_window;
 	GtkWidget *tab_label;
 
+	if (map->dso->annotate_warned)
+		return -1;
+
+	if (symbol__annotate(sym, map, 0) < 0) {
+		ui__error("%s", ui_helpline__current);
+		return -1;
+	}
+
 	if (perf_gtk__is_active_context(pgctx)) {
 		window = pgctx->main_window;
 		notebook = pgctx->notebook;
author maintainer
#13 lore raw

PATCH 7/7 perf annotate: Make it to be able to skip unannotatable symbols

In reply to Namhyung Kim

From: Namhyung Kim <[email protected]>

Add --skip-missing option for skipping symbols that cannot be used for annotation. It's the case of kernel symbols that user doesn't have a vmlinux image file.

---
 tools/perf/builtin-annotate.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
tools/perf/builtin-annotate.c +15 -2
index 68e3a16abd3d..2e6961ea3184 100644
@@ -37,6 +37,7 @@ struct perf_annotate {
 	bool	   force, use_tui, use_stdio, use_gtk;
 	bool	   full_paths;
 	bool	   print_line;
+	bool	   skip_missing;
 	const char *sym_hist_filter;
 	const char *cpu_list;
 	DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
@@ -139,11 +140,21 @@ find_next:
 		}
 
 		if (use_browser == 2) {
-			hist_entry__gtk_annotate(he, evidx, NULL);
-			return;
+			int ret;
+
+			ret = hist_entry__gtk_annotate(he, evidx, 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);
 			switch (key) {
+			case -1:
+				if (!ann->skip_missing)
+					return;
+				/* fall through */
 			case K_RIGHT:
 				next = rb_next(nd);
 				break;
@@ -288,6 +299,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "print matching source lines (may be slow)"),
 	OPT_BOOLEAN('P', "full-paths", &annotate.full_paths,
 		    "Don't shorten the displayed pathnames"),
+	OPT_BOOLEAN(0, "skip-missing", &annotate.skip_missing,
+		    "Skip symbols that cannot be annotated"),
 	OPT_STRING('C', "cpu", &annotate.cpu_list, "cpu", "list of cpus to profile"),
 	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
 		   "Look for files with symbols relative to this directory"),
Signature · 1 line
1.7.11.7
#14 lore raw

Re: [PATCH 7/7] perf annotate: Make it to be able to skip unannotatable symbols

Em Thu, Feb 07, 2013 at 06:02:14PM +0900, Namhyung Kim escreveu:

Quoted 9 lines

From: Namhyung Kim <[email protected]>

Add --skip-missing option for skipping symbols that cannot be used for annotation. It's the case of kernel symbols that user doesn't have a vmlinux image file.

---
 tools/perf/builtin-annotate.c | 17 +++++++++++++++--

You forgot to add the entry in the man page...

- Arnaldo

author maintainer
#15 lore raw

Re: [PATCH 7/7] perf annotate: Make it to be able to skip unannotatable symbols

Hi Arnaldo,

Quoted 7 lines · Arnaldo Carvalho de Melo

Em Thu, Feb 07, 2013 at 06:02:14PM +0900, Namhyung Kim escreveu:

Quoted 6 lines

From: Namhyung Kim <[email protected]>

Add --skip-missing option for skipping symbols that cannot be used for annotation. It's the case of kernel symbols that user doesn't have a vmlinux image file.

Quoted 5 lines
Quoted 3 lines
---
 tools/perf/builtin-annotate.c | 17 +++++++++++++++--

You forgot to add the entry in the man page...

Arghh... resending..

---------------------8<-----------------------

Quoted 1 line

From 797a62666d6098aaeda816279fa9181473762dc6 Mon Sep 17 00:00:00 2001

From: Namhyung Kim <[email protected]>
Date: Thu, 7 Feb 2013 17:37:03 +0900
Subject: [PATCH v2 7/7] perf annotate: Make it to be able to skip unannotatable
symbols

Add --skip-missing option for skipping symbols that cannot be used for annotation. It's the case of kernel symbols that user doesn't have a vmlinux image file.

---
 tools/perf/Documentation/perf-annotate.txt |  3 +++
 tools/perf/builtin-annotate.c              | 17 +++++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-annotate.txt +3 -0
index e5e1d06efc37..5ad07ef417f0 100644
@@ -90,6 +90,9 @@ OPTIONS
 --objdump=<path>::
         Path to objdump binary.
 
+--skip-missing::
+	Skip symbols that cannot be annotated.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-report[1]
tools/perf/builtin-annotate.c +15 -2
index 68e3a16abd3d..2e6961ea3184 100644
@@ -37,6 +37,7 @@ struct perf_annotate {
 	bool	   force, use_tui, use_stdio, use_gtk;
 	bool	   full_paths;
 	bool	   print_line;
+	bool	   skip_missing;
 	const char *sym_hist_filter;
 	const char *cpu_list;
 	DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
@@ -139,11 +140,21 @@ find_next:
 		}
 
 		if (use_browser == 2) {
-			hist_entry__gtk_annotate(he, evidx, NULL);
-			return;
+			int ret;
+
+			ret = hist_entry__gtk_annotate(he, evidx, 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);
 			switch (key) {
+			case -1:
+				if (!ann->skip_missing)
+					return;
+				/* fall through */
 			case K_RIGHT:
 				next = rb_next(nd);
 				break;
@@ -288,6 +299,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "print matching source lines (may be slow)"),
 	OPT_BOOLEAN('P', "full-paths", &annotate.full_paths,
 		    "Don't shorten the displayed pathnames"),
+	OPT_BOOLEAN(0, "skip-missing", &annotate.skip_missing,
+		    "Skip symbols that cannot be annotated"),
 	OPT_STRING('C', "cpu", &annotate.cpu_list, "cpu", "list of cpus to profile"),
 	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
 		   "Look for files with symbols relative to this directory"),
Signature · 1 line
1.7.11.7
#16 lore raw

[tip:perf/core] perf annotate: Make it to be able to skip unannotatable symbols

In reply to Namhyung Kim
Commit-ID:  18c9e5c567e1bc475edc67dca3680ecd2562dc5c
Gitweb:     http://git.kernel.org/tip/18c9e5c567e1bc475edc67dca3680ecd2562dc5c
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 7 Feb 2013 18:02:14 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 14 Feb 2013 14:59:28 -0300

perf annotate: Make it to be able to skip unannotatable symbols

Add --skip-missing option for skipping symbols that cannot be used for annotation. It's the case of kernel symbols that user doesn't have a vmlinux image file.

---
 tools/perf/Documentation/perf-annotate.txt |  3 +++
 tools/perf/builtin-annotate.c              | 17 +++++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-annotate.txt +3 -0
index e5e1d06..5ad07ef 100644
@@ -90,6 +90,9 @@ OPTIONS
 --objdump=<path>::
         Path to objdump binary.
 
+--skip-missing::
+	Skip symbols that cannot be annotated.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-report[1]
tools/perf/builtin-annotate.c +15 -2
index 68e3a16..2e6961e 100644
@@ -37,6 +37,7 @@ struct perf_annotate {
 	bool	   force, use_tui, use_stdio, use_gtk;
 	bool	   full_paths;
 	bool	   print_line;
+	bool	   skip_missing;
 	const char *sym_hist_filter;
 	const char *cpu_list;
 	DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
@@ -139,11 +140,21 @@ find_next:
 		}
 
 		if (use_browser == 2) {
-			hist_entry__gtk_annotate(he, evidx, NULL);
-			return;
+			int ret;
+
+			ret = hist_entry__gtk_annotate(he, evidx, 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);
 			switch (key) {
+			case -1:
+				if (!ann->skip_missing)
+					return;
+				/* fall through */
 			case K_RIGHT:
 				next = rb_next(nd);
 				break;
@@ -288,6 +299,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "print matching source lines (may be slow)"),
 	OPT_BOOLEAN('P', "full-paths", &annotate.full_paths,
 		    "Don't shorten the displayed pathnames"),
+	OPT_BOOLEAN(0, "skip-missing", &annotate.skip_missing,
+		    "Skip symbols that cannot be annotated"),
 	OPT_STRING('C', "cpu", &annotate.cpu_list, "cpu", "list of cpus to profile"),
 	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
 		   "Look for files with symbols relative to this directory"),