Bug 4708 – [profile][cov] expose rt.trace and rt.cover api's

Status
NEW
Severity
enhancement
Priority
P4
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-08-22T00:27:21Z
Last change time
2024-12-07T13:31:08Z
Assigned to
Sean Kelly
Creator
Brad Roberts
Moved to GitHub: dmd#17229 →

Comments

Comment #0 by braddr — 2010-08-22T00:27:21Z
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 by braddr — 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
Comment #2 by braddr — 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
Comment #3 by robert.schadek — 2024-12-07T13:31:08Z
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