lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 25 Feb 2019 13:56:07 +0100
From:   Jiri Olsa <jolsa@...hat.com>
To:     Andi Kleen <andi@...stfloor.org>
Cc:     acme@...nel.org, linux-perf-users@...r.kernel.org,
        linux-kernel@...r.kernel.org, jolsa@...nel.org,
        namhyung@...nel.org, eranian@...gle.com,
        Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH 11/11] perf tools report: Implement browsing of
 individual samples

On Sun, Feb 24, 2019 at 07:37:22AM -0800, Andi Kleen wrote:

SNIP

> diff --git a/tools/perf/ui/browsers/res_sample.c b/tools/perf/ui/browsers/res_sample.c
> new file mode 100644
> index 000000000000..5b4807c29c2c
> --- /dev/null
> +++ b/tools/perf/ui/browsers/res_sample.c
> @@ -0,0 +1,74 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Display a menu with individual samples to browse with perf script */
> +#include "util.h"
> +#include "hist.h"
> +#include "evsel.h"
> +#include "hists.h"
> +#include "sort.h"
> +#include "time-utils.h"
> +
> +/* In ns. Could make configurable. */
> +#define CONTEXT_LEN 100000000
> +
> +int res_sample_browse(struct res_sample *res_samples, int num_res,
> +		      struct perf_evsel *evsel, enum rstype rstype)
> +{
> +	char **names;
> +	int i, n;
> +	int choice;
> +	char *cmd;
> +	char pbuf[256], tidbuf[32], cpubuf[32];
> +	const char *perf = perf_exe(pbuf, sizeof pbuf);
> +	char trange[128], tsample[64];
> +	struct res_sample *r;
> +	char extra_format[256];
> +
> +	/* For now since ui__popup_menu doesn't like lists that don't fit */
> +	num_res = max(min(SLtt_Screen_Rows - 4, num_res), 0);
> +
> +	names = calloc(num_res, sizeof(char *));
> +	if (!names)
> +		return -1;
> +	for (i = 0; i < num_res; i++) {
> +		char tbuf[64];
> +
> +		timestamp__scnprintf_nsec(res_samples[i].time, tbuf, sizeof tbuf);
> +		if (asprintf(&names[i], "%s: CPU %d tid %d", tbuf,
> +			     res_samples[i].cpu, res_samples[i].tid) < 0)
> +			return -1;

leaking names

jirka

> +	}
> +	choice = ui__popup_menu(num_res, names);
> +	for (i = 0; i < num_res; i++)
> +		free(names[i]);
> +	free(names);
> +
> +	if (choice < 0 || choice >= num_res)
> +		return -1;
> +	r = &res_samples[choice];
> +
> +	n = timestamp__scnprintf_nsec(r->time - CONTEXT_LEN, trange, sizeof trange);
> +	trange[n++] = ',';
> +	timestamp__scnprintf_nsec(r->time + CONTEXT_LEN, trange + n, sizeof trange - n);
> +
> +	timestamp__scnprintf_nsec(r->time, tsample, sizeof tsample);
> +
> +	attr_to_script(extra_format, &evsel->attr);
> +
> +	if (asprintf(&cmd, "%s script %s%s --time %s %s%s %s%s --ns %s %s | less +/%s",
> +		     perf,
> +		     input_name ? "-i " : "",
> +		     input_name ? input_name : "",
> +		     trange,
> +		     r->cpu ? "--cpu " : "",
> +		     r->cpu ? (sprintf(cpubuf, "%d", r->cpu), cpubuf) : "",
> +		     r->tid ? "--tid " : "",
> +		     r->tid ? (sprintf(tidbuf, "%d", r->tid), tidbuf) : "",
> +		     extra_format,
> +		     rstype == A_ASM ? "-F +insn --xed" :
> +		     rstype == A_SOURCE ? "-F +srcline,+srccode" : "",
> +		     tsample) < 0)
> +		return -1;
> +	run_script(cmd);
> +	free(cmd);
> +	return 0;
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ