diff mbox series

[4/5] trace-cmd library: New API for modifyning the timestamp offset

Message ID 20210428122839.805296-5-tz.stoyanov@gmail.com (mailing list archive)
State Accepted
Commit deb38d95a289839a4fb5aab75cb789c4e27be39e
Headers show
Series [1/5] trace-cmd: Remove ts offset from tsc2nsec conversion | expand

Commit Message

Tzvetomir Stoyanov (VMware) April 28, 2021, 12:28 p.m. UTC
New API is introduced, it can be used to add value to the offset
which will be applied to the timestamps of all events from given
trace file:
 tracecmd_add_ts_offset()

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 include/trace-cmd/trace-cmd.h |  1 +
 lib/trace-cmd/trace-input.c   | 12 ++++++++++++
 2 files changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h
index 022720b0..7305487c 100644
--- a/include/trace-cmd/trace-cmd.h
+++ b/include/trace-cmd/trace-cmd.h
@@ -38,6 +38,7 @@  int tracecmd_get_guest_cpumap(struct tracecmd_input *handle,
 			      const char **name,
 			      int *vcpu_count, const int **cpu_pid);
 unsigned long long tracecmd_get_first_ts(struct tracecmd_input *handle);
+void tracecmd_add_ts_offset(struct tracecmd_input *handle, long long offset);
 int tracecmd_buffer_instances(struct tracecmd_input *handle);
 const char *tracecmd_buffer_instance_name(struct tracecmd_input *handle, int indx);
 struct tracecmd_input *tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx);
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 284f25e8..6adc8bfa 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -2291,6 +2291,18 @@  void tracecmd_set_ts_offset(struct tracecmd_input *handle,
 	handle->ts_offset = offset;
 }
 
+/**
+ * tracecmd_add_ts_offset - Add value to the offset which will be applied to the timestamps of all
+ *			    events from given trace file
+ * @handle: input handle to the trace.dat file
+ * @offset: value, that will be added to the offset
+ */
+void tracecmd_add_ts_offset(struct tracecmd_input *handle,
+			    long long offset)
+{
+	handle->ts_offset += offset;
+}
+
 void tracecmd_set_ts2secs(struct tracecmd_input *handle,
 			 unsigned long long hz)
 {