@@ -446,19 +446,72 @@ static void dump_section_header(int fd, enum dump_items v, unsigned short *flags
*flags = fl;
}
-static void dump_option_buffer(int fd, int size)
+static void dump_option_buffer(int fd, unsigned short option, int size)
{
+ unsigned long long total_size = 0;
+ unsigned long long data_size;
+ unsigned long long current;
unsigned long long offset;
+ unsigned short flags;
+ char clock[DUMP_SIZE];
+ char name[DUMP_SIZE];
+ int cpus = 0;
+ int id;
+ int i;
if (size < 8)
die("broken buffer option with size %d", size);
if (read_file_number(fd, &offset, 8))
die("cannot read the offset of the buffer option");
+ if (read_file_string(fd, name, DUMP_SIZE))
+ die("cannot read the name of the buffer option");
+ if (file_version < FILE_VERSION_SECTIONS) {
+ do_print(OPTIONS|FLYRECORD, "\t\t[Option BUFFER, %d bytes]\n", size);
+ do_print(OPTIONS|FLYRECORD, "%lld [offset]\n", offset);
+ do_print(OPTIONS|FLYRECORD, "\"%s\" [name]\n", name);
+ return;
+ }
+
+ current = lseek64(fd, 0, SEEK_CUR);
+ if (lseek64(fd, offset, SEEK_SET) == (off_t)-1)
+ die("cannot goto buffer offset %lld", offset);
+
+ dump_section_header(fd, FLYRECORD, &flags);
+
+ if (lseek64(fd, current, SEEK_SET) == (off_t)-1)
+ die("cannot go back to buffer option");
+
+ do_print(OPTIONS|FLYRECORD, "\t\t[Option BUFFER, %d bytes]\n", size);
+ do_print(OPTIONS|FLYRECORD, "%lld [offset]\n", offset);
+ do_print(OPTIONS|FLYRECORD, "\"%s\" [name]\n", name);
+
+ if (read_file_string(fd, clock, DUMP_SIZE))
+ die("cannot read clock of the buffer option");
+ do_print(OPTIONS|FLYRECORD, "\"%s\" [clock]\n", clock);
+ if (option == TRACECMD_OPTION_BUFFER) {
+ if (read_file_number(fd, &cpus, 4))
+ die("cannot read the cpu count of the buffer option");
+
+ do_print(OPTIONS|FLYRECORD, "%d [CPUs]:\n", cpus);
+ for (i = 0; i < cpus; i++) {
+ if (read_file_number(fd, &id, 4))
+ die("cannot read the id of cpu %d from the buffer option", i);
+ if (read_file_number(fd, &offset, 8))
+ die("cannot read the offset of cpu %d from the buffer option", i);
+ if (read_file_number(fd, &data_size, 8))
+ die("cannot read the data size of cpu %d from the buffer option", i);
+ total_size += data_size;
+ do_print(OPTIONS|FLYRECORD, " %d %lld\t%lld\t[id, data offset and size]\n",
+ id, offset, data_size);
+ }
+ do_print(SUMMARY, "\t\[buffer \"%s\", \"%s\" clock, "
+ "%d cpus, %lld bytes flyrecord data]\n",
+ name, clock, cpus, total_size);
+ } else {
+ do_print(SUMMARY, "\t\[buffer \"%s\", \"%s\" clock, latency data]\n", name, clock);
+ }
- do_print(OPTIONS, "\t\t[Option BUFFER, %d bytes]\n", size);
- do_print(OPTIONS, "%lld [offset]\n", offset);
- read_dump_string(fd, size - 8, OPTIONS);
}
static void dump_option_int(int fd, int size, char *desc)
@@ -665,7 +718,8 @@ static int dump_options_read(int fd)
dump_option_string(fd, size, "CPUSTAT");
break;
case TRACECMD_OPTION_BUFFER:
- dump_option_buffer(fd, size);
+ case TRACECMD_OPTION_BUFFER_TEXT:
+ dump_option_buffer(fd, option, size);
break;
case TRACECMD_OPTION_TRACECLOCK:
do_print(OPTIONS, "\t\t[Option TRACECLOCK, %d bytes]\n", size);
In trace file version 7 the BUFFER option is extended to hold a trace metadata, related to the recorded instance. Also, a new BUFFER_TEXT option is added for latency trace data. Implemented logic for reading and printing these extended options. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- tracecmd/trace-dump.c | 64 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 5 deletions(-)