@@ -4466,34 +4466,37 @@ tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx)
new_handle->flags |= TRACECMD_FL_BUFFER_INSTANCE;
new_handle->pid_maps = NULL;
+ if (!HAS_SECTIONS(handle)) {
+ /* Save where we currently are */
+ offset = lseek64(handle->fd, 0, SEEK_CUR);
- /* Save where we currently are */
- offset = lseek64(handle->fd, 0, SEEK_CUR);
-
- ret = lseek64(handle->fd, buffer->offset, SEEK_SET);
- if (ret < 0) {
- tracecmd_warning("could not seek to buffer %s offset %ld\n",
- buffer->name, buffer->offset);
- goto error;
- }
-
- /*
- * read_options_type() is called right after the CPU count so update
- * file state accordingly.
- */
- new_handle->file_state = TRACECMD_FILE_CPU_COUNT;
- ret = read_options_type(new_handle);
- if (!ret)
- ret = read_cpu_data(new_handle);
- if (ret < 0) {
- tracecmd_warning("failed to read sub buffer %s\n", buffer->name);
- goto error;
- }
+ ret = lseek64(handle->fd, buffer->offset, SEEK_SET);
+ if (ret == (off64_t)-1) {
+ tracecmd_warning("could not seek to buffer %s offset %ld\n",
+ buffer->name, buffer->offset);
+ goto error;
+ }
+ /*
+ * read_options_type() is called right after the CPU count so update
+ * file state accordingly.
+ */
+ new_handle->file_state = TRACECMD_FILE_CPU_COUNT;
+ ret = read_options_type(new_handle);
+ if (!ret)
+ ret = read_cpu_data(new_handle);
- ret = lseek64(handle->fd, offset, SEEK_SET);
- if (ret < 0) {
- tracecmd_warning("could not seek to back to offset %ld\n", offset);
- goto error;
+ if (ret < 0) {
+ tracecmd_warning("failed to read sub buffer %s\n", buffer->name);
+ goto error;
+ }
+ ret = lseek64(handle->fd, offset, SEEK_SET);
+ if (ret < 0) {
+ tracecmd_warning("could not seek to back to offset %ld\n", offset);
+ goto error;
+ }
+ } else {
+ if (init_buffer_cpu_data(new_handle, buffer) < 0)
+ goto error;
}
return new_handle;
CPU data initialization is different for trace files version 6 and 7. When a new input handler to trace buffer is created, initialize the CPU data according to the file version. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- lib/trace-cmd/trace-input.c | 55 +++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 26 deletions(-)