@@ -132,6 +132,7 @@ enum {
TRACECMD_FL_IGNORE_DATE = (1 << 0),
TRACECMD_FL_BUFFER_INSTANCE = (1 << 1),
TRACECMD_FL_IN_USECS = (1 << 2),
+ TRACECMD_FL_RAW_TS = (1 << 3),
};
struct tracecmd_ftrace {
@@ -1288,6 +1288,9 @@ static unsigned long long timestamp_calc(unsigned long long ts,
{
unsigned long long t = ts;
+ /* do not modify raw timestamps */
+ if (handle->flags & TRACECMD_FL_RAW_TS)
+ return ts;
/* Guest trace file, sync with host timestamps */
if (handle->host.sync_enable)
@@ -2603,7 +2606,8 @@ static int handle_options(struct tracecmd_input *handle)
* gtod. It is stored as ASCII with '0x'
* appended.
*/
- if (handle->flags & TRACECMD_FL_IGNORE_DATE)
+ if ((handle->flags & TRACECMD_FL_IGNORE_DATE) ||
+ (handle->flags & TRACECMD_FL_RAW_TS))
break;
offset = strtoll(buf, NULL, 0);
/* Convert from micro to nano */
@@ -2615,7 +2619,7 @@ static int handle_options(struct tracecmd_input *handle)
* Similar to date option, but just adds an
* offset to the timestamp.
*/
- if (handle->flags & TRACECMD_FL_IGNORE_DATE)
+ if (handle->flags & TRACECMD_FL_RAW_TS)
break;
offset = strtoll(buf, NULL, 0);
handle->ts_offset += offset;
@@ -2630,7 +2634,7 @@ static int handle_options(struct tracecmd_input *handle)
* long long array of size [count] of timestamp offsets.
* long long array of size [count] of timestamp scaling ratios.*
*/
- if (size < 16 || handle->flags & TRACECMD_FL_IGNORE_DATE)
+ if (size < 16 || (handle->flags & TRACECMD_FL_RAW_TS))
break;
handle->host.peer_trace_id = tep_read_number(handle->pevent,
buf, 8);
@@ -2709,7 +2713,7 @@ static int handle_options(struct tracecmd_input *handle)
trace_guest_load(handle, buf, size);
break;
case TRACECMD_OPTION_TSC2NSEC:
- if (size != 12)
+ if (size != 12 || (handle->flags & TRACECMD_FL_RAW_TS))
break;
handle->tsc_calc.mult = tep_read_number(handle->pevent,
buf, 4);
A new flag is added in the trace-cmd library for controlling events timestamp corrections while reading a trace file. If the flag is set, all timestamps are displayed as-is from the trace file. TRACECMD_FL_RAW_TS The flag can be modified with these APIs: tracecmd_set_flag() tracecmd_clear_flag() Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- lib/trace-cmd/include/private/trace-cmd-private.h | 1 + lib/trace-cmd/trace-input.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-)