Building a debugger for a high-level language on top of a low-level
recording is unexplored territory but it's definitely possible and it would
have some nice features. However, you can't get much leverage from any
existing debugging support built into a VM.

We could build some JS debugging support on top of rr like this:
1) Add support to extract JS program state from a stopped Firefox process,
by reading memory and register contents. Basically, completely passive
stack walking and value/heap inspection. There are two sub-approaches that
can be mixed and matched here:
* Duplicating some functionality of the JS engine into the debugging layer
so it can run outside the stopped Firefox process.
* Add a way to interpret JS engine machine code *as if* it was running in
the context of the stopped process. Side effects (e.g. memory writes) would
be buffered temporarily and thrown away once we've got the results we need.
Basically, this would let us support running user code for debugging
purposes during an rr replay.
2) Add support for JS breakpoints. Map a JS breakpoint to a conditional
breakpoint in the interpreter C++ code, or one (or more) locations in
compiled code. This mapping may be possible just by inspecting VM state, or
we may need to monitor VM execution (e.g. compilation) to maintain this
mapping during replay. I think if we can accept some heuristics and
approximations here, it could work OK. E.g., just setting breakpoints at
the beginning of non-inlined functions and at loop heads would go quite a
long way.

That's makeshift. Ultimately you want to take a completely different
approach to debugging both JS and C++, e.g. by building something like
Chronicle + Chronomancer on top of rr. But, baby steps.

Rob
-- 
Jtehsauts  tshaei dS,o n" Wohfy  Mdaon  yhoaus  eanuttehrotraiitny  eovni
le atrhtohu gthot sf oirng iyvoeu rs ihnesa.r"t sS?o  Whhei csha iids  teoa
stiheer :p atroa lsyazye,d  'mYaonu,r  "sGients  uapr,e  tfaokreg iyvoeunr,
'm aotr  atnod  sgaoy ,h o'mGee.t"  uTph eann dt hwea lmka'n?  gBoutt  uIp
waanndt  wyeonut  thoo mken.o w
_______________________________________________
dev-platform mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to