I'm embedding javascript in my app using spidermonkey and I have a function called reportError
that receives a JSErrorReport.
It seems simple to grab the current line of the error, but is it possible to get the entire call path to display a full backtrace?
It's not doable through JSErrorReport. Instead, you have to look at the debugger APIS. Find header jsdbgapi.h. It has a list of hook functions that will be invoked if you are running with debug enabled(JS_SetDebugMode(cx, true)). Inside those hook functions you could simply call js_DumpBacktrace to get the full stack. Note that js_DumpBacktrace would not work if you do not enable debugging first. In debug mode, you could do way more than printing the stack. It's actually possible to get the function context and alls its arguments and local vars.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With