New APIs added to get trace cpustats, uname, version strings, and cpu file sizes. const char *tracecmd_get_cpustats(struct tracecmd_input *handle); const char *tracecmd_get_uname(struct tracecmd_input *handle); const char *tracecmd_get_version(struct tracecmd_input *handle); unsigned long long tracecmd_get_cpu_file_size(struct tracecmd_input *handle, int cpu); Signed-off-by: Michael Sartain <mikesart@xxxxxxxxxxxx> --- .../include/private/trace-cmd-private.h | 5 ++ lib/trace-cmd/trace-input.c | 63 +++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h index c58b09e..6e2af31 100644 --- a/lib/trace-cmd/include/private/trace-cmd-private.h +++ b/lib/trace-cmd/include/private/trace-cmd-private.h @@ -90,6 +90,11 @@ bool tracecmd_get_quiet(struct tracecmd_output *handle); void tracecmd_set_out_clock(struct tracecmd_output *handle, const char *clock); const char *tracecmd_get_trace_clock(struct tracecmd_input *handle); +const char *tracecmd_get_cpustats(struct tracecmd_input *handle); +const char *tracecmd_get_uname(struct tracecmd_input *handle); +const char *tracecmd_get_version(struct tracecmd_input *handle); +off64_t tracecmd_get_cpu_file_size(struct tracecmd_input *handle, int cpu); + static inline int tracecmd_host_bigendian(void) { unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 }; diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c index ac57bc4..c55adcd 100644 --- a/lib/trace-cmd/trace-input.c +++ b/lib/trace-cmd/trace-input.c @@ -4088,6 +4088,69 @@ const char *tracecmd_get_trace_clock(struct tracecmd_input *handle) return handle->trace_clock; } +/** + * tracecmd_get_cpustats - return the saved cpu stats + * @handle: input handle for the trace.dat file + * + * Provides a method to extract the cpu stats saved in @handle. + * + * Returns a string of the cpu stats that was saved in the trace.dat file. + * The string should not be freed, as it points to the internal + * structure data. + */ +const char *tracecmd_get_cpustats(struct tracecmd_input *handle) +{ + return handle->cpustats; +} + +/** + * tracecmd_get_uname - return the saved name and kernel information + * @handle: input handle for the trace.dat file + * + * Provides a method to extract the system information saved in @handle. + * + * Returns a string of the system information that was saved in the + * trace.dat file. + * The string should not be freed, as it points to the internal + * structure data. + */ +const char *tracecmd_get_uname(struct tracecmd_input *handle) +{ + return handle->uname; +} + +/** + * tracecmd_get_version - return the saved version information + * @handle: input handle for the trace.dat file + * + * Provides a method to extract the version string saved in @handle. + * + * Returns a string of the version that was saved in the trace.dat file. + * The string should not be freed, as it points to the internal + * structure data. + */ +const char *tracecmd_get_version(struct tracecmd_input *handle) +{ + return handle->version; +} + +/** + * tracecmd_get_cpu_file_size - return the saved cpu file size + * @handle: input handle for the trace.dat file + * @cpu: cpu index + * + * Provides a method to extract the cpu file size saved in @handle. + * + * Returns the cpu file size saved in trace.dat file or (off64_t)-1 for + * invalid cpu index. + */ +off64_t tracecmd_get_cpu_file_size(struct tracecmd_input *handle, int cpu) +{ + if (cpu < 0 || cpu >= handle->cpus) + return (off64_t)-1; + return handle->cpu_data[cpu].file_size; +} + /** * tracecmd_get_show_data_func - return the show data func * @handle: input handle for the trace.dat file -- 2.33.0