aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2011-05-27 16:28:44 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-06-02 12:29:14 -0400
commit610723f24eeb842025178a6722fa9108c4e157b6 (patch)
treee184c3b2242ba9b9da065221d4673603dd9d8e86
parent787bef174f055343c69a9639e6e05a564980ed4c (diff)
perf script: Make printing of dso a separate field option
The 'sym' option displays both the function name and the DSO it comes from. Split the display of the dso into a separate option. This allows display of the ip address and symbol without the dso, thus shortening line lengths - and decluttering the output a bit. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/1306528124-25861-3-git-send-email-dsahern@gmail.com Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/Documentation/perf-script.txt2
-rw-r--r--tools/perf/builtin-script.c17
-rw-r--r--tools/perf/util/session.c13
-rw-r--r--tools/perf/util/session.h2
4 files changed, 24 insertions, 10 deletions
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index 67a4e5cbc88..1e744c2391d 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -115,7 +115,7 @@ OPTIONS
115-f:: 115-f::
116--fields:: 116--fields::
117 Comma separated list of fields to print. Options are: 117 Comma separated list of fields to print. Options are:
118 comm, tid, pid, time, cpu, event, trace, ip, sym. Field 118 comm, tid, pid, time, cpu, event, trace, ip, sym, dso. Field
119 list can be prepended with the type, trace, sw or hw, 119 list can be prepended with the type, trace, sw or hw,
120 to indicate to which event type the field list applies. 120 to indicate to which event type the field list applies.
121 e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace 121 e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 0852db2ea15..a8bd00f2e55 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -32,6 +32,7 @@ enum perf_output_field {
32 PERF_OUTPUT_TRACE = 1U << 6, 32 PERF_OUTPUT_TRACE = 1U << 6,
33 PERF_OUTPUT_IP = 1U << 7, 33 PERF_OUTPUT_IP = 1U << 7,
34 PERF_OUTPUT_SYM = 1U << 8, 34 PERF_OUTPUT_SYM = 1U << 8,
35 PERF_OUTPUT_DSO = 1U << 9,
35}; 36};
36 37
37struct output_option { 38struct output_option {
@@ -47,6 +48,7 @@ struct output_option {
47 {.str = "trace", .field = PERF_OUTPUT_TRACE}, 48 {.str = "trace", .field = PERF_OUTPUT_TRACE},
48 {.str = "ip", .field = PERF_OUTPUT_IP}, 49 {.str = "ip", .field = PERF_OUTPUT_IP},
49 {.str = "sym", .field = PERF_OUTPUT_SYM}, 50 {.str = "sym", .field = PERF_OUTPUT_SYM},
51 {.str = "dso", .field = PERF_OUTPUT_DSO},
50}; 52};
51 53
52/* default set to maintain compatibility with current format */ 54/* default set to maintain compatibility with current format */
@@ -63,7 +65,7 @@ static struct {
63 .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID | 65 .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
64 PERF_OUTPUT_CPU | PERF_OUTPUT_TIME | 66 PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
65 PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP | 67 PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
66 PERF_OUTPUT_SYM, 68 PERF_OUTPUT_SYM | PERF_OUTPUT_DSO,
67 69
68 .invalid_fields = PERF_OUTPUT_TRACE, 70 .invalid_fields = PERF_OUTPUT_TRACE,
69 }, 71 },
@@ -74,7 +76,7 @@ static struct {
74 .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID | 76 .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
75 PERF_OUTPUT_CPU | PERF_OUTPUT_TIME | 77 PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
76 PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP | 78 PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
77 PERF_OUTPUT_SYM, 79 PERF_OUTPUT_SYM | PERF_OUTPUT_DSO,
78 80
79 .invalid_fields = PERF_OUTPUT_TRACE, 81 .invalid_fields = PERF_OUTPUT_TRACE,
80 }, 82 },
@@ -93,7 +95,7 @@ static struct {
93 .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID | 95 .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
94 PERF_OUTPUT_CPU | PERF_OUTPUT_TIME | 96 PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
95 PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP | 97 PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
96 PERF_OUTPUT_SYM, 98 PERF_OUTPUT_SYM | PERF_OUTPUT_DSO,
97 99
98 .invalid_fields = PERF_OUTPUT_TRACE, 100 .invalid_fields = PERF_OUTPUT_TRACE,
99 }, 101 },
@@ -176,6 +178,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
176 "No addresses to convert to symbols.\n"); 178 "No addresses to convert to symbols.\n");
177 return -EINVAL; 179 return -EINVAL;
178 } 180 }
181 if (PRINT_FIELD(DSO) && !PRINT_FIELD(IP)) {
182 pr_err("Display of DSO requested but IP is not selected.\n"
183 "No addresses to convert to dso.\n");
184 return -EINVAL;
185 }
179 186
180 if ((PRINT_FIELD(PID) || PRINT_FIELD(TID)) && 187 if ((PRINT_FIELD(PID) || PRINT_FIELD(TID)) &&
181 perf_event_attr__check_stype(attr, PERF_SAMPLE_TID, "TID", 188 perf_event_attr__check_stype(attr, PERF_SAMPLE_TID, "TID",
@@ -304,7 +311,7 @@ static void process_event(union perf_event *event __unused,
304 else 311 else
305 printf("\n"); 312 printf("\n");
306 perf_session__print_ip(event, sample, session, 313 perf_session__print_ip(event, sample, session,
307 PRINT_FIELD(SYM)); 314 PRINT_FIELD(SYM), PRINT_FIELD(DSO));
308 } 315 }
309 316
310 printf("\n"); 317 printf("\n");
@@ -996,7 +1003,7 @@ static const struct option options[] = {
996 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", 1003 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
997 "Look for files with symbols relative to this directory"), 1004 "Look for files with symbols relative to this directory"),
998 OPT_CALLBACK('f', "fields", NULL, "str", 1005 OPT_CALLBACK('f', "fields", NULL, "str",
999 "comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym", 1006 "comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso",
1000 parse_output_fields), 1007 parse_output_fields),
1001 1008
1002 OPT_END() 1009 OPT_END()
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index ad33650cdd4..0dd41829926 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1205,7 +1205,7 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
1205void perf_session__print_ip(union perf_event *event, 1205void perf_session__print_ip(union perf_event *event,
1206 struct perf_sample *sample, 1206 struct perf_sample *sample,
1207 struct perf_session *session, 1207 struct perf_session *session,
1208 int print_sym) 1208 int print_sym, int print_dso)
1209{ 1209{
1210 struct addr_location al; 1210 struct addr_location al;
1211 const char *symname, *dsoname; 1211 const char *symname, *dsoname;
@@ -1241,12 +1241,15 @@ void perf_session__print_ip(union perf_event *event,
1241 else 1241 else
1242 symname = ""; 1242 symname = "";
1243 1243
1244 printf(" %s", symname);
1245 }
1246 if (print_dso) {
1244 if (node->map && node->map->dso && node->map->dso->name) 1247 if (node->map && node->map->dso && node->map->dso->name)
1245 dsoname = node->map->dso->name; 1248 dsoname = node->map->dso->name;
1246 else 1249 else
1247 dsoname = ""; 1250 dsoname = "";
1248 1251
1249 printf(" %s (%s)", symname, dsoname); 1252 printf(" (%s)", dsoname);
1250 } 1253 }
1251 printf("\n"); 1254 printf("\n");
1252 1255
@@ -1261,12 +1264,16 @@ void perf_session__print_ip(union perf_event *event,
1261 else 1264 else
1262 symname = ""; 1265 symname = "";
1263 1266
1267 printf(" %s", symname);
1268 }
1269
1270 if (print_dso) {
1264 if (al.map && al.map->dso && al.map->dso->name) 1271 if (al.map && al.map->dso && al.map->dso->name)
1265 dsoname = al.map->dso->name; 1272 dsoname = al.map->dso->name;
1266 else 1273 else
1267 dsoname = ""; 1274 dsoname = "";
1268 1275
1269 printf(" %s (%s)", symname, dsoname); 1276 printf(" (%s)", dsoname);
1270 } 1277 }
1271 } 1278 }
1272} 1279}
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index d76af0f975d..de4178d7bb7 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -170,6 +170,6 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
170void perf_session__print_ip(union perf_event *event, 170void perf_session__print_ip(union perf_event *event,
171 struct perf_sample *sample, 171 struct perf_sample *sample,
172 struct perf_session *session, 172 struct perf_session *session,
173 int print_sym); 173 int print_sym, int print_dso);
174 174
175#endif /* __PERF_SESSION_H */ 175#endif /* __PERF_SESSION_H */