aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-report.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-08-16 14:56:37 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-16 17:06:44 -0400
commit0d3a5c885971de1e3124d85bfadf818abac9ba12 (patch)
treeeb1a76270a7e749609ff9627838f1d9eb6571bd4 /tools/perf/builtin-report.c
parent0f25bfc8d8b31a4ac8e4ff6cbc3911fb7092a4a7 (diff)
perf tools: Librarize sample type and attr finding from headers
Librarize the sample type and attr fetching from perf data file headers so that we can also use it from perf trace. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Mike Galbraith <efault@gmx.de> LKML-Reference: <1250448997-30715-1-git-send-email-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r--tools/perf/builtin-report.c44
1 files changed, 6 insertions, 38 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 05d52ff4c33d..c6326deb1636 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -70,6 +70,8 @@ static int cwdlen;
70static struct rb_root threads; 70static struct rb_root threads;
71static struct thread *last_match; 71static struct thread *last_match;
72 72
73static struct perf_header *header;
74
73static 75static
74struct callchain_param callchain_param = { 76struct callchain_param callchain_param = {
75 .mode = CHAIN_GRAPH_REL, 77 .mode = CHAIN_GRAPH_REL,
@@ -1319,29 +1321,12 @@ static void trace_event(event_t *event)
1319 dump_printf(".\n"); 1321 dump_printf(".\n");
1320} 1322}
1321 1323
1322static struct perf_header *header;
1323
1324static struct perf_counter_attr *perf_header__find_attr(u64 id)
1325{
1326 int i;
1327
1328 for (i = 0; i < header->attrs; i++) {
1329 struct perf_header_attr *attr = header->attr[i];
1330 int j;
1331
1332 for (j = 0; j < attr->ids; j++) {
1333 if (attr->id[j] == id)
1334 return &attr->attr;
1335 }
1336 }
1337
1338 return NULL;
1339}
1340
1341static int 1324static int
1342process_read_event(event_t *event, unsigned long offset, unsigned long head) 1325process_read_event(event_t *event, unsigned long offset, unsigned long head)
1343{ 1326{
1344 struct perf_counter_attr *attr = perf_header__find_attr(event->read.id); 1327 struct perf_counter_attr *attr;
1328
1329 attr = perf_header__find_attr(event->read.id, header);
1345 1330
1346 if (show_threads) { 1331 if (show_threads) {
1347 const char *name = attr ? __event_name(attr->type, attr->config) 1332 const char *name = attr ? __event_name(attr->type, attr->config)
@@ -1405,23 +1390,6 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
1405 return 0; 1390 return 0;
1406} 1391}
1407 1392
1408static u64 perf_header__sample_type(void)
1409{
1410 u64 type = 0;
1411 int i;
1412
1413 for (i = 0; i < header->attrs; i++) {
1414 struct perf_header_attr *attr = header->attr[i];
1415
1416 if (!type)
1417 type = attr->attr.sample_type;
1418 else if (type != attr->attr.sample_type)
1419 die("non matching sample_type");
1420 }
1421
1422 return type;
1423}
1424
1425static int __cmd_report(void) 1393static int __cmd_report(void)
1426{ 1394{
1427 int ret, rc = EXIT_FAILURE; 1395 int ret, rc = EXIT_FAILURE;
@@ -1460,7 +1428,7 @@ static int __cmd_report(void)
1460 header = perf_header__read(input); 1428 header = perf_header__read(input);
1461 head = header->data_offset; 1429 head = header->data_offset;
1462 1430
1463 sample_type = perf_header__sample_type(); 1431 sample_type = perf_header__sample_type(header);
1464 1432
1465 if (!(sample_type & PERF_SAMPLE_CALLCHAIN)) { 1433 if (!(sample_type & PERF_SAMPLE_CALLCHAIN)) {
1466 if (sort__has_parent) { 1434 if (sort__has_parent) {