Re: [PATCH 1/3] perf, tools, report: Handle samples without time

From: Jiri Olsa
Date: Tue Mar 12 2019 - 07:14:29 EST


On Mon, Mar 11, 2019 at 08:52:22PM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
>
> When a sample doesn't have a time stamp (e.g. from --no-time),
> show the beginning of the trace for res samples instead of generating
> an impossible time range that errors out.
>
> Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>

Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx>

thanks,
jirka

> ---
> tools/perf/ui/browsers/res_sample.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/ui/browsers/res_sample.c b/tools/perf/ui/browsers/res_sample.c
> index c0dd73176d42..c450a3536f10 100644
> --- a/tools/perf/ui/browsers/res_sample.c
> +++ b/tools/perf/ui/browsers/res_sample.c
> @@ -60,7 +60,9 @@ int res_sample_browse(struct res_sample *res_samples, int num_res,
> return -1;
> r = &res_samples[choice];
>
> - n = timestamp__scnprintf_nsec(r->time - context_len, trange, sizeof trange);
> + n = timestamp__scnprintf_nsec(r->time > context_len ?
> + r->time - context_len : r->time,
> + trange, sizeof trange);
> trange[n++] = ',';
> timestamp__scnprintf_nsec(r->time + context_len, trange + n, sizeof trange - n);
>
> --
> 2.20.1
>