We are trying to send uncaught GWT exceptions (we are using GWT 2.5 rc1) to our server for logging and debugging purposes. We want to deobfuscate the exception stack traces, otherwise it would be pretty much useless.
After some investigations, I found 7 Tips for Exception Handling in GWT and WebModeExceptions that contained valuable information.
So we created a GWT UncaughtExceptionHandler that uses a custom RPC service to transfer the exceptions with their stack traces. That works fine.
As described in WebModeExceptions deobfuscation section, we enabled stacktrace emulation with this in our GWT module :
<set-property name="compiler.stackMode" value="emulated" />
<set-configuration-property name="compiler.emulatedStack.recordLineNumbers"
value="true" />
Now our stacktraces look like this :
com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot call method 'pp' of null
Unknown.aT(Unknown Source:174)
Unknown.AVa(Unknown Source:501)
Unknown.YF(Unknown Source:29)
Unknown.Lqb(Unknown Source:138)
...
It seems ok to me because it contains the obfuscated method name and the line number which seems to be what is needed as described in WebModeExceptions deobfuscation section.
Then we compile our GWT modules with the -extra parameter to get the symbolmaps.
Our custom log service uses the symbolMaps directory to invoke com.google.gwt.logging.server.StackTraceDeobfuscator. We use X-GWT-Permutation http header to invoke the deobfuscator. I stepped in the deobfuscate method to make sure it could load the symbol map. It could. I validated that the symbolMap file name used was matching the *.cache.js file name of the GWT module. It does match.
So basically, the service does this:
// Create the deobfuscator
String dir = getSymbolMapsDirPath();
StackTraceDeobfuscator deobfuscator = new StackTraceDeobfuscator(dir);
// request is the HttpServletRequest
String strongName = request.getHeader(RpcRequestBuilder.STRONG_NAME_HEADER);
// Deobfuscate the stack trace
exception.setStackTrace(
deobfuscator.deobfuscateStackTrace(exception.getStackTrace(), strongName));
// Log the exception
logger.severe("Uncaught GWT exception", exception);
The end result is that the stack traces don't get deobfuscated. Sometimes, some lines would get deobufscated with the wrong class and method name but nothing more. When looking at the symbolMap file, the actual symbols in the stack trace don't match to any of the symbols in the symbolMap file.
Any idea what we are doing wrong here?
EDIT: I tried RemoteLoggingServiceImpl and I get the same results.
After further investigation it seems that the new GWT compiler option -XenableClosureCompiler
that we were using generates code that is not outputting stack traces that uses the symbol maps generated by the compiler. After removing that option, the stack traces can be deobfuscated successfully.
As a side note, the compiler and GWT module options required to enabled stack trace deobfuscation (the ones described in my question and removing the closure compiler option) make our final js files twice as big as before.
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