Issue 4708 - [profile][cov] expose rt.trace and rt.cover api's
Summary: [profile][cov] expose rt.trace and rt.cover api's
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: Sean Kelly
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-22 00:27 UTC by Brad Roberts
Modified: 2024-12-07 13:31 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Brad Roberts 2010-08-22 00:27:21 UTC
The dmd test suite has a few tests that run -profile and -cov.  Right now, those all output to the same filename with no non-hacky way of getting to those apis.

They're extern(C)'ed, so they can be forced with repeating the extern declaration where needed, but that's awfully ugly.

Food for thought.. could the defaults be better?  What's the definition of better?

Right now, both default to the current directory.  Trace defaults to 'trace.log' and 'trace.def'.  Cover defaults to sourcefile.lst, if I read the code correctly.

Maybe this would be a good place for some env vars to influence the two?
Comment 1 Brad Roberts 2010-08-22 00:51:04 UTC
Merely adding the calls to set the trace log files is enough to cause the files to be created, even without -cov.  This is due to the calls being enough to drag in the module and it's shared this/~this are invoked.

Also, for a simple test case, no trace results other than the file headers are being produced:

module hello;

extern(C)
{
    int printf(const char*, ...);
    int trace_setlogfilename(string name);
    int trace_setdeffilename(string name);
}

void showargs(char[][] args)
{
    printf("hello world\n");
    printf("args.length = %d\n", args.length);
    for (int i = 0; i < args.length; i++)
        printf("args[%d] = '%s'\n", i, cast(char *)args[i]);
}

int main(char[][] args)
{
    trace_setlogfilename("test_results/runnable/hello-profile.d.trace.log");
    trace_setdeffilename("test_results/runnable/hello-profile.d.trace.def");

    showargs(args);

    return 0;
}

Results in:
::::::::::::::
test_results/runnable/hello-profile.d.out
::::::::::::::
../src/dmd -Irunnable -cov -od./test_results/runnable -of./test_results/runnable/hello-profile runnable/hello-profile.d
./test_results/runnable/hello-profile
hello world
args.length = 1
args[0] = './test_results/runnable/hello-profile'

::::::::::::::
test_results/runnable/hello-profile.d.trace.def
::::::::::::::

FUNCTIONS
::::::::::::::
test_results/runnable/hello-profile.d.trace.log
::::::::::::::

======== Timer Is 3579545 Ticks/Sec, Times are in Microsecs ========

  Num          Tree        Func        Per
  Calls        Time        Time        Call
Comment 2 Brad Roberts 2010-08-22 00:56:34 UTC
Ok.. ignore most of #1, I should have been using -profile instead of -cov.  Of course, that just further outlines the problems caused by having the two result files generated with just the column headers merely by setting the destination file names.  Compiling with -profile and running the sample code below produces the two files as expected:

::::::::::::::
test_results/runnable/hello-profile.d.trace.def
::::::::::::::

FUNCTIONS
        _Dmain
        _D5hello8showargsFAAaZv
::::::::::::::
test_results/runnable/hello-profile.d.trace.log
::::::::::::::
------------------
            1   _Dmain
_D5hello8showargsFAAaZv 1       141436  141436
------------------
_Dmain  0       142088  652
            1   _D5hello8showargsFAAaZv

======== Timer Is 3579545 Ticks/Sec, Times are in Microsecs ========

  Num          Tree        Func        Per
  Calls        Time        Time        Call

      1       39512       39512       39512     _D5hello8showargsFAAaZv
      1       39694         182         182     _Dmain
Comment 3 dlangBugzillaToGithub 2024-12-07 13:31:08 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17229

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB