[jsc-dev] How to preload JS scripts into the Web Inspector Debugger without evaluating them?
Saam barati
sbarati at apple.com
Fri Jul 13 11:41:36 PDT 2018
+ Some folks that work on the web inspector
Hi Alexander,
I don’t know of a way to accomplish this without at least parsing the scripts. Is the goal here just to be able to view all the sources of your scripts? I believe the reason the inspector needs to actually have the scripts evaluated is once you see the scripts in the inspector, you’re able to set breakpoints and such. This would not be doable without evaluating the scripts.
Perhaps there is a way to design these scripts so they don’t actually do any work (like call other functions that may not yet be set up) when you evaluate them. Perhaps they can just expose a single function that can be called to actually make them start doing work?
- Saam
> On Jul 6, 2018, at 2:25 PM, Alexander Karaberov <alexander.karaberov at gmail.com> wrote:
>
> Hello jsc-dev folks,
>
> I’m currently struggling with one issue. Long story short: let's say I have a big JSON file with 400+ different JS scripts which is stored in the iOS app's local db. When I run a dev/simulator build of the app and open Safari --> Develop --> Debugger I want to see all of these scripts under Sources tab handy without actually evaluating them, otherwise debugging process becomes a bit cumbersome. Also our app is used by a lot of JavaScript developers who develop custom scripts for it, normally they use a simulator + Safari Debugger and they also want to see all the scripts at once. From my understanding for the JS script to be visible in the Debugger --> Sources tab it has be evaluated first. And indeed if I call JSEvaluateScript() in a for-loop for all the 400+ scripts stored in the file it works and I can see all of them in the Debugger. The problem with this approach is that it causes an avalanche of different side-effects, exceptions thrown and so forth, because some scripts call another ones, some scripts are not ready yet to be called (some of the libs or modules were not loaded for instance), some are not intended for execution at the given moment at all and etc. So I have to come up with a different solution and make Inspector's Debugger aware of all the JS scripts at once without executing all of them. In the best case scenario I want something akin to (roughly) JSInspectorLoad(script) which I will call for all the scripts in the file. I tried to call JSCheckScriptSyntax() in a loop in the same way, but it didn’t work. It finds and reports errors but nonetheless in the Debugger I see only those scripts which have already been evaluated. I checked JavaScriptCore code and it seems that all the interesting logic related to Debugger/Inspector resides somewhere inside of profiledEvaluate() function namely either in the CodeProfiling profile(source) or vm.interpreter->executeProgram(). All those calls are private and unfortunately unavailable via the scarce JavaScriptCore public API. My next silly idea is to somehow get pointers to proper functions via the dlsym() and then call them, but I don’t even know where to start with this. Modifying and rebuilding my own version of JavaScriptCore together with its dependencies (bmalloc, WTF) and shipping all these (potentially broken) things with the app is definitely not an option for me.
> I will highly appreciate if someone suggests a different approach to preload scripts to the Debugger without evaluating them. Maybe I'm missing something and there is actually a way to do this, because I really need this feature. Thank you very much in advance!
>
> Kind Regards,
> Alexander
>
> _______________________________________________
> jsc-dev mailing list
> jsc-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/jsc-dev
More information about the jsc-dev
mailing list