Re: [PATCH 2/7] trace-cmd: Added new option in trace.dat file for negative time offsets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 21, 2019 at 11:08 AM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> On Wed, 16 Jan 2019 21:18:33 +0200
> Tzvetomir Stoyanov <tstoyanov@xxxxxxxxxx> wrote:
>
> > diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
> > index b628570..de15d4b 100644
> > --- a/lib/trace-cmd/trace-input.c
> > +++ b/lib/trace-cmd/trace-input.c
> > @@ -2151,6 +2151,7 @@ static int handle_options(struct tracecmd_input *handle)
> >                       handle->ts_offset += offset;
> >                       break;
> >               case TRACECMD_OPTION_OFFSET:
> > +             case TRACECMD_OPTION_OFFSET_N:
> >                       /*
> >                        * Similar to date option, but just adds an
> >                        * offset to the timestamp.
> > @@ -2158,7 +2159,11 @@ static int handle_options(struct tracecmd_input *handle)
> >                       if (handle->flags & TRACECMD_FL_IGNORE_DATE)
> >                               break;
> >                       offset = strtoll(buf, NULL, 0);
> > -                     handle->ts_offset += offset;
> > +                     if (option == TRACECMD_OPTION_OFFSET_N) {
>
> Instead of adding a new option, couldn't we just make option a "long
> long" and save a negative number in the trace.dat file? strtoll()
> should be able to handle it.

Yes,  we can make in long long, but this will break the backward compatibility.
The old versions of  trace-cmd will get confused, as they will cast it
to unsigned.
That's why I added a new option, in this way old trace-cmd versions
will not read the
negative offset at all.

>
> -- Steve
>
>
> > +                             if (handle->ts_offset > offset)
> > +                                     handle->ts_offset -= offset;
> > +                     } else
> > +                             handle->ts_offset += offset;
> >                       break;
> >               case TRACECMD_OPTION_CPUSTAT:
> >                       buf[size-1] = '\n';



-- 

Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux