@@ -72,4 +72,6 @@ struct cpu_data_source {
int out_write_cpu_data(struct tracecmd_output *handle, int cpus,
struct cpu_data_source *data);
+int out_update_buffer_cpu_offset(struct tracecmd_output *handle, const char *name);
+
#endif /* _TRACE_CMD_LOCAL_H */
@@ -1853,8 +1853,7 @@ int tracecmd_append_cpu_data(struct tracecmd_output *handle,
return tracecmd_write_cpu_data(handle, cpus, cpu_data_files);
}
-int tracecmd_append_buffer_cpu_data(struct tracecmd_output *handle,
- const char *name, int cpus, char * const *cpu_data_files)
+__hidden int out_update_buffer_cpu_offset(struct tracecmd_output *handle, const char *name)
{
tsize_t b_offset;
tsize_t offset;
@@ -1883,6 +1882,14 @@ int tracecmd_append_buffer_cpu_data(struct tracecmd_output *handle,
tracecmd_warning("could not seek to %lld\n", offset);
return -1;
}
+ return 0;
+}
+
+int tracecmd_append_buffer_cpu_data(struct tracecmd_output *handle,
+ const char *name, int cpus, char * const *cpu_data_files)
+{
+ if (out_update_buffer_cpu_offset(handle, name))
+ return -1;
return tracecmd_write_cpu_data(handle, cpus, cpu_data_files);
}
Added a helper function, internal to the library, for updating CPU instance offset in the trace file. This allows to reuse the logic inside the library, will be used in the tracecmd_copy API. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- lib/trace-cmd/include/trace-cmd-local.h | 2 ++ lib/trace-cmd/trace-output.c | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-)