Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[profile][cov] expose rt.trace and rt.cover api's #17229

Open
dlangBugzillaToGithub opened this issue Aug 22, 2010 · 2 comments
Open

[profile][cov] expose rt.trace and rt.cover api's #17229

dlangBugzillaToGithub opened this issue Aug 22, 2010 · 2 comments
Labels
Druntime Specific to druntime Feature:coverage Specific to coverage P4 Severity:Enhancement

Comments

@dlangBugzillaToGithub
Copy link

Brad Roberts (@braddr) reported this on 2010-08-22T00:27:21Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=4708

Description

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?
@dlangBugzillaToGithub
Copy link
Author

braddr commented on 2010-08-22T00:51:04Z

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

@dlangBugzillaToGithub
Copy link
Author

braddr commented on 2010-08-22T00:56:34Z

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

@thewilsonator thewilsonator added Severity:Enhancement Druntime Specific to druntime Feature:coverage Specific to coverage and removed enhancement labels Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Druntime Specific to druntime Feature:coverage Specific to coverage P4 Severity:Enhancement
Projects
None yet
Development

No branches or pull requests

2 participants