Updates:
        Status: Fixed
        Owner: [email protected]

Comment #1 on issue 2005 by [email protected]: Ability to track and display the number times each line of code executed
http://code.google.com/p/v8/issues/detail?id=2005

The existing debugger API can be easily extended to perform such a task. I wrote and attached a simple javascript wrapper that accomplishes this. However, this is far slower than instrumenting the javascript code since the instrumentation code is compiled as well, whereas using the debugger interrupts the execution at every single step.

Start the script using
$ ./d8 --expose-debug-as debug lineprofile.js -e "profile('test.js')"

The output should be

line   1 [     0 ]: function f(n) {
line   2 [    15 ]:   if (n < 2) return 1;
line   3 [    14 ]:   return f(n-1) + f(n-2);
line   4 [     8 ]: }
line   5 [     1 ]: f(5);

Note that line 3 is counted twice when being executed, once when f(n-1) is evaluated and once when f(n-2) is evaluated.

Feel free to extend this script.

Attachments:
        lineprofile.js  3.0 KB
        test.js  73 bytes

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to