diff options
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r-- | tools/perf/builtin-report.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 7a6577bf9a41..37b26ecb0d0b 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -1366,11 +1366,13 @@ process_event(event_t *event, unsigned long offset, unsigned long head) | |||
1366 | return 0; | 1366 | return 0; |
1367 | } | 1367 | } |
1368 | 1368 | ||
1369 | static struct perf_file_header file_header; | ||
1370 | |||
1369 | static int __cmd_report(void) | 1371 | static int __cmd_report(void) |
1370 | { | 1372 | { |
1371 | int ret, rc = EXIT_FAILURE; | 1373 | int ret, rc = EXIT_FAILURE; |
1372 | unsigned long offset = 0; | 1374 | unsigned long offset = 0; |
1373 | unsigned long head = 0; | 1375 | unsigned long head = sizeof(file_header); |
1374 | struct stat stat; | 1376 | struct stat stat; |
1375 | event_t *event; | 1377 | event_t *event; |
1376 | uint32_t size; | 1378 | uint32_t size; |
@@ -1398,6 +1400,14 @@ static int __cmd_report(void) | |||
1398 | exit(0); | 1400 | exit(0); |
1399 | } | 1401 | } |
1400 | 1402 | ||
1403 | read(input, &file_header, sizeof(file_header)); | ||
1404 | |||
1405 | if (sort__has_parent && | ||
1406 | !(file_header.sample_type & PERF_SAMPLE_CALLCHAIN)) { | ||
1407 | fprintf(stderr, "selected --sort parent, but no callchain data\n"); | ||
1408 | exit(-1); | ||
1409 | } | ||
1410 | |||
1401 | if (load_kernel() < 0) { | 1411 | if (load_kernel() < 0) { |
1402 | perror("failed to load kernel symbols"); | 1412 | perror("failed to load kernel symbols"); |
1403 | return EXIT_FAILURE; | 1413 | return EXIT_FAILURE; |
@@ -1469,9 +1479,13 @@ more: | |||
1469 | 1479 | ||
1470 | head += size; | 1480 | head += size; |
1471 | 1481 | ||
1482 | if (offset + head >= sizeof(file_header) + file_header.data_size) | ||
1483 | goto done; | ||
1484 | |||
1472 | if (offset + head < stat.st_size) | 1485 | if (offset + head < stat.st_size) |
1473 | goto more; | 1486 | goto more; |
1474 | 1487 | ||
1488 | done: | ||
1475 | rc = EXIT_SUCCESS; | 1489 | rc = EXIT_SUCCESS; |
1476 | close(input); | 1490 | close(input); |
1477 | 1491 | ||