aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.c
diff options
context:
space:
mode:
authorDavid Ahern <daahern@cisco.com>2011-03-10 00:23:27 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-03-14 16:06:50 -0400
commitc0230b2bfbd16e42d937c34aed99e5d6493eb5e4 (patch)
tree352cbe720b4b0bbe65c302c4a3977e21ba722a78 /tools/perf/util/session.c
parent745f43e3433a7939bd9c351c8106e0c1db2044c6 (diff)
perf script: Add support for dumping symbols
Add option to dump symbols found in events. e.g., perf script -f comm,pid,tid,time,trace,sym swapper 0/0 537.037184: prev_comm=swapper prev_pid=0 prev_prio=120... ffffffff81030350 perf_trace_sched_switch ([kernel.kallsyms]) ffffffff81382ac5 schedule ([kernel.kallsyms]) ffffffff8100134a cpu_idle ([kernel.kallsyms]) ffffffff81370b39 rest_init ([kernel.kallsyms]) ffffffff81696c23 start_kernel ([kernel.kallsyms].init.text) ffffffff816962af x86_64_start_reservations ([kernel.kallsyms].init.text) ffffffff816963b9 x86_64_start_kernel ([kernel.kallsyms].init.text) sshd 1675/1675 537.037309: prev_comm=sshd prev_pid=1675 prev_prio=120... ffffffff81030350 perf_trace_sched_switch ([kernel.kallsyms]) ffffffff81382ac5 schedule ([kernel.kallsyms]) ffffffff813837aa schedule_hrtimeout_range_clock ([kernel.kallsyms]) ffffffff81383886 schedule_hrtimeout_range ([kernel.kallsyms]) ffffffff8110c4f9 poll_schedule_timeout ([kernel.kallsyms]) ffffffff8110cd20 do_select ([kernel.kallsyms]) ffffffff8110ced8 core_sys_select ([kernel.kallsyms]) ffffffff8110d00d sys_select ([kernel.kallsyms]) ffffffff81002bc2 system_call ([kernel.kallsyms]) 7f1647e56e93 __GI_select (/lib64/libc-2.12.90.so) netstat 1692/1692 537.038664: prev_comm=netstat prev_pid=1692 prev_prio=... ffffffff81030350 perf_trace_sched_switch ([kernel.kallsyms]) ffffffff81382ac5 schedule ([kernel.kallsyms]) ffffffff81002c3a sysret_careful ([kernel.kallsyms]) 7f7a6cd1b210 __GI___libc_read (/lib64/libc-2.12.90.so) Acked-by: Frederic Weisbecker <fweisbec@gmail.com> 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> LKML-Reference: <1299734608-5223-6-git-send-email-daahern@cisco.com> Signed-off-by: David Ahern <daahern@cisco.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r--tools/perf/util/session.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index f26639fa0fb3..c68cf40764f9 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1134,3 +1134,64 @@ size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp)
1134 1134
1135 return ret; 1135 return ret;
1136} 1136}
1137
1138void perf_session__print_symbols(union perf_event *event,
1139 struct perf_sample *sample,
1140 struct perf_session *session)
1141{
1142 struct addr_location al;
1143 const char *symname, *dsoname;
1144 struct callchain_cursor *cursor = &session->callchain_cursor;
1145 struct callchain_cursor_node *node;
1146
1147 if (perf_event__preprocess_sample(event, session, &al, sample,
1148 NULL) < 0) {
1149 error("problem processing %d event, skipping it.\n",
1150 event->header.type);
1151 return;
1152 }
1153
1154 if (symbol_conf.use_callchain && sample->callchain) {
1155
1156 if (perf_session__resolve_callchain(session, al.thread,
1157 sample->callchain, NULL) != 0) {
1158 if (verbose)
1159 error("Failed to resolve callchain. Skipping\n");
1160 return;
1161 }
1162 callchain_cursor_commit(cursor);
1163
1164 while (1) {
1165 node = callchain_cursor_current(cursor);
1166 if (!node)
1167 break;
1168
1169 if (node->sym && node->sym->name)
1170 symname = node->sym->name;
1171 else
1172 symname = "";
1173
1174 if (node->map && node->map->dso && node->map->dso->name)
1175 dsoname = node->map->dso->name;
1176 else
1177 dsoname = "";
1178
1179 printf("\t%16" PRIx64 " %s (%s)\n", node->ip, symname, dsoname);
1180
1181 callchain_cursor_advance(cursor);
1182 }
1183
1184 } else {
1185 if (al.sym && al.sym->name)
1186 symname = al.sym->name;
1187 else
1188 symname = "";
1189
1190 if (al.map && al.map->dso && al.map->dso->name)
1191 dsoname = al.map->dso->name;
1192 else
1193 dsoname = "";
1194
1195 printf("%16" PRIx64 " %s (%s)", al.addr, symname, dsoname);
1196 }
1197}