aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung.kim@lge.com>2013-02-07 04:02:10 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-02-14 12:59:28 -0500
commit237522378604a2e26e19a8b11a70171eaf98c6c5 (patch)
treed44b55dfa50786238ae69553a4e077543b0cbd58 /tools/perf
parent7a60ba948267336d77a48a3539f98151f9dcfba6 (diff)
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. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Andi Kleen <andi@firstfloor.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Pekka Enberg <penberg@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1360227734-375-4-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/ui/gtk/annotate.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c
index 1ce89f2558fa..2fe056b0096c 100644
--- a/tools/perf/ui/gtk/annotate.c
+++ b/tools/perf/ui/gtk/annotate.c
@@ -60,6 +60,30 @@ static int perf_gtk__get_offset(char *buf, size_t size, struct symbol *sym,
60 return scnprintf(buf, size, "%"PRIx64, start + dl->offset); 60 return scnprintf(buf, size, "%"PRIx64, start + dl->offset);
61} 61}
62 62
63static 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
63static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym, 87static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
64 struct map *map, int evidx, 88 struct map *map, int evidx,
65 struct hist_browser_timer *hbt __maybe_unused) 89 struct hist_browser_timer *hbt __maybe_unused)
@@ -93,8 +117,7 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
93 117
94 for (i = 0; i < MAX_ANN_COLS; i++) { 118 for (i = 0; i < MAX_ANN_COLS; i++) {
95 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), 119 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
96 -1, col_names[i], renderer, 120 -1, col_names[i], renderer, "markup",
97 i == ANN_COL__PERCENT ? "markup" : "text",
98 i, NULL); 121 i, NULL);
99 } 122 }
100 123
@@ -110,7 +133,8 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
110 gtk_list_store_set(store, &iter, ANN_COL__PERCENT, s, -1); 133 gtk_list_store_set(store, &iter, ANN_COL__PERCENT, s, -1);
111 if (perf_gtk__get_offset(s, sizeof(s), sym, map, pos)) 134 if (perf_gtk__get_offset(s, sizeof(s), sym, map, pos))
112 gtk_list_store_set(store, &iter, ANN_COL__OFFSET, s, -1); 135 gtk_list_store_set(store, &iter, ANN_COL__OFFSET, s, -1);
113 gtk_list_store_set(store, &iter, ANN_COL__LINE, pos->line, -1); 136 if (perf_gtk__get_line(s, sizeof(s), pos))
137 gtk_list_store_set(store, &iter, ANN_COL__LINE, s, -1);
114 } 138 }
115 139
116 gtk_container_add(GTK_CONTAINER(window), view); 140 gtk_container_add(GTK_CONTAINER(window), view);