1

I'm trying to write a tool to extract dependencies between JavaScript functions. There's JSAnalyse, but it uses static analysis and it is incomplete. I've try metaprogramming, overwriting all functions to log the execution trace. Something like that:

originalFunction = function () {
    //generate stack trace
     return originalFunction.apply(this, arguments);
};

But it has some problems and doesn't look like a good solution. I've try Jalangi, but it doesn't help.

I think the best solution is changing a JavaScript engine (like Rhino or V8) or debugger to intercept the functions calls and log a trace 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?

Community
  • 1
  • 1
Tamara
  • 11
  • 2
  • Jalangi seems promising. Why doesn't it help? If there aren't any builds of browsers which facilitate this sort of logging, modifying a browser codebase to do it is probably a pretty time consuming undertaking. It should be possible, but the biggest problem is it isn't clear to me how much time you will burn attempting something like that. Would take me a few weeks. You'll need to work out how to build the browser from src, and then dig in and wade through its source code to boot. Anyways, I suggest adding more details about what you have tried, and where you're stuck – Steven Lu Sep 08 '14 at 22:28
  • Poking at it from another direction -- it's not really reasonable to expect to figure crap like this out without being able to play with the source. Like, management has got to at least give you some reasonable sounding reason to justify this. It's quite like bringing a car with its engine blown up to a mechanic, and then telling him that he can't open the hood or use a lift... One more thing. You should explain better what you mean by "dependencies". Are you trying to visualize what functions call what other functions? Usually for this i just use some pen and paper and reason it out. – Steven Lu Sep 08 '14 at 22:35
  • Jalangi changes the code of the application in browser. But the application looses the format and behavior. And yes, I mean 'dependencies' what functions call other functions. I have to automate it. – Tamara Sep 08 '14 at 22:55

0 Answers0