summaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-report.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r--tools/perf/builtin-report.c16
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)
return 0;
}
+static struct perf_file_header file_header;
+
static int __cmd_report(void)
{
int ret, rc = EXIT_FAILURE;
unsigned long offset = 0;
- unsigned long head = 0;
+ unsigned long head = sizeof(file_header);
struct stat stat;
event_t *event;
uint32_t size;
@@ -1398,6 +1400,14 @@ static int __cmd_report(void)
exit(0);
}
+ read(input, &file_header, sizeof(file_header));
+
+ if (sort__has_parent &&
+ !(file_header.sample_type & PERF_SAMPLE_CALLCHAIN)) {
+ fprintf(stderr, "selected --sort parent, but no callchain data\n");
+ exit(-1);
+ }
+
if (load_kernel() < 0) {
perror("failed to load kernel symbols");
return EXIT_FAILURE;
@@ -1469,9 +1479,13 @@ more:
head += size;
+ if (offset + head >= sizeof(file_header) + file_header.data_size)
+ goto done;
+
if (offset + head < stat.st_size)
goto more;
+done:
rc = EXIT_SUCCESS;
close(input);