lkml.org 
[lkml]   [2017]   [Oct]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2017-10-03 12:45    [W:0.038 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site