|
@@ -2768,6 +2768,18 @@ int perf_session__read_header(struct perf_session *session)
|
|
|
if (perf_file_header__read(&f_header, header, fd) < 0)
|
|
|
return -EINVAL;
|
|
|
|
|
|
+ /*
|
|
|
+ * Sanity check that perf.data was written cleanly; data size is
|
|
|
+ * initialized to 0 and updated only if the on_exit function is run.
|
|
|
+ * If data size is still 0 then the file contains only partial
|
|
|
+ * information. Just warn user and process it as much as it can.
|
|
|
+ */
|
|
|
+ if (f_header.data.size == 0) {
|
|
|
+ pr_warning("WARNING: The %s file's data size field is 0 which is unexpected.\n"
|
|
|
+ "Was the 'perf record' command properly terminated?\n",
|
|
|
+ session->filename);
|
|
|
+ }
|
|
|
+
|
|
|
nr_attrs = f_header.attrs.size / f_header.attr_size;
|
|
|
lseek(fd, f_header.attrs.offset, SEEK_SET);
|
|
|
|