[jsc-dev] How to preload JS scripts into the Web Inspector Debugger without evaluating them?
Alexander Karaberov
alexander.karaberov at gmail.com
Fri Jul 6 14:25:42 PDT 2018
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/jsc-dev/attachments/20180706/aa9d8a94/attachment.html>
More information about the jsc-dev
mailing list