On 6/20/17 1:53 PM, Benjamin Smedberg wrote:
> Is there a way to have automation call DumpJSStack() on assertion (before
> crashing)
You could hack a DumpJSStack() call into the nsDebug machinery, basically.
> Would it be safe to call DumpJSStack() explicitly from the place where I'm
> firing this assertion, or are there potential issues with locking or the JS
> engine internals that would make this a bad idea? (And would that output
> show up in the automation logs?)
Calling DumpJSStack is generally safe, I believe, as long as you know
that you're on the main thread or a DOM worker thread. It'll crash on
you on other threads.
Given that you're dealing with shutdown, you need to make sue your call
happens before nsContentUtils::Shutdown, but hopefully that's the case
anyway if you know you're running JS.
One possible failure mode of DumpJSStack is that it will print nothing
if we're conceptually not running JS (e.g. have an AutoNoJSAPI on the
stack). You could work around that if you end up hitting it by
replacing the nsContentUtils::GetCurrentJSContextForThread() call in
xpc_DumpJSStack with mozilla::dom::danger::GetJSContext.
-Boris