Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
allow to configure file names for profile reports
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinNowak committed Aug 29, 2015
1 parent e6510d0 commit 91a669b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
22 changes: 22 additions & 0 deletions src/core/runtime.d
Expand Up @@ -351,6 +351,28 @@ extern (C) void dmd_coverDestPath(string path);
*/
extern (C) void dmd_coverSetMerge(bool flag);

/**
* Set the output file name for profile reports (-profile switch).
* An empty name will set the output to stdout.
*
* Params:
* name = file name
* Note:
* This is a dmd specific setting.
*/
extern (C) void trace_setlogfilename(string name);

/**
* Set the output file name for the optimized profile linker DEF file (-profile switch).
* An empty name will set the output to stdout.
*
* Params:
* name = file name
* Note:
* This is a dmd specific setting.
*/
extern (C) void trace_setdeffilename(string name);

/**
* Set the output file name for memory profile reports (-profile=gc switch).
* An empty name will set the output to stdout.
Expand Down
12 changes: 6 additions & 6 deletions src/rt/trace.d
Expand Up @@ -92,10 +92,9 @@ __gshared
// 0 success
// !=0 failure

int trace_setlogfilename(string name)
void trace_setlogfilename(string name)
{
trace_logfilename = name;
return 0;
}

////////////////////////////////////////
Expand All @@ -105,10 +104,9 @@ int trace_setlogfilename(string name)
// 0 success
// !=0 failure

int trace_setdeffilename(string name)
void trace_setdeffilename(string name)
{
trace_deffilename = name;
return 0;
}

////////////////////////////////////////
Expand Down Expand Up @@ -478,7 +476,8 @@ shared static ~this()
trace_merge(&groot);

// Report results
FILE* fplog = fopen(trace_logfilename.ptr, "w");
FILE* fplog = trace_logfilename.length == 0 ? stdout :
fopen(trace_logfilename.ptr, "w");
if (fplog)
{
auto nsymbols = trace_report(fplog, groot);
Expand All @@ -498,7 +497,8 @@ shared static ~this()
fprintf(stderr, "cannot write '%s'", trace_logfilename.ptr);

// Output function link order
FILE* fpdef = fopen(trace_deffilename.ptr,"w");
FILE* fpdef = trace_deffilename.length == 0 ? stdout :
fopen(trace_deffilename.ptr, "w");
if (fpdef)
{
fprintf(fpdef,"\nFUNCTIONS\n");
Expand Down

0 comments on commit 91a669b

Please sign in to comment.