title: How to log execution trace of JavaScript programs from engine?
body: <p>I'm trying to write a tool to extract dependencies between JavaScript functions. There's <a href="http://jsanalyse.codeplex.com/" rel="nofollow noreferrer">JSAnalyse</a>, but it uses static analysis and it is incomplete.
  I've try metaprogramming, overwriting all functions to log the execution trace. Something like that:</p>
  
  <pre><code>originalFunction = function () {
      //generate stack trace
       return originalFunction.apply(this, arguments);
  };
  </code></pre>
  
  <p>But it has some problems and doesn't look like a good solution.
  I've try <a href="https://www.eecs.berkeley.edu/~gongliang13/jalangi_ff/" rel="nofollow noreferrer">Jalangi</a>, but it doesn't help.</p>
  
  <p>I think the best solution is changing a JavaScript engine (like Rhino or V8) or debugger to intercept the functions calls and <a href="https://stackoverflow.com/questions/17752422/trace-the-execution-of-all-javascript-in-a-web-app">log a trace</a> with name and location (file and line) of the caller function.
  How can I log this dynamic information? How can I log an execution trace of JavaScript programs not changing the source code of the program?</p>