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]
Message-ID: <20171003104426.GE13755@krava>
Date:   Tue, 3 Oct 2017 12:44:26 +0200
From:   Jiri Olsa <jolsa@...hat.com>
To:     yuzhoujian <ufo19890607@...il.com>
Cc:     peterz@...radead.org, mingo@...hat.com,
        alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
        dsahern@...il.com, namhyung@...nel.org, milian.wolff@...b.com,
        arnaldo.melo@...il.com, yuzhoujian@...ichuxing.com,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 4/4] Make all print functions receive the fp argument,
 and opens a dump file in process_event.

On Tue, Sep 26, 2017 at 02:53:17PM +0800, yuzhoujian wrote:

SNIP

> -	fprint_sample_start(sample, thread, evsel, stdout);
> +	/* the dump file name is <ORIGINAL PERF DATA FILE NAME>-script-dump-<EVENT NAME>.txt */
> +	evname = perf_evsel__name(evsel);
> +	if (script->tool.per_event_dump) {
> +		if (asprintf(&filename, "%s%s%s%s", file_name, "-script-dump-", evname, ".txt") < 0)
> +			filename = NULL;
> +		fp = fopen(filename, "a+");
> +		if (!fp)
> +			return;
> +		free(filename);
> +	}
> +	fprint_sample_start(sample, thread, evsel, fp);
>  

SNIP

>  
>  	if (PRINT_FIELD(PHYS_ADDR))
> -		fprintf(stdout, "%16" PRIx64, sample->phys_addr);
> -	fprintf(stdout, "\n");
> +		fprintf(fp, "%16" PRIx64, sample->phys_addr);
> +	fprintf(fp, "\n");
> +	if (script->tool.per_event_dump)
> +		fclose(fp);

so you open and close the file for each sample.. I think
we should store the FILE* in perf_evsel::priv

open it at the first time sample/event is processed
and close at the end of the perf script

jirka

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ