Revision: 10669
Author: cromwell...@google.com
Date: Thu Sep 22 22:25:49 2011
Log: Edited wiki page SourceMaps through web user interface.
http://code.google.com/p/google-web-toolkit/source/detail?r=10669
Modified:
/wiki/SourceMaps.wiki
=======================================
--- /wiki/SourceMaps.wiki Thu Sep 22 22:21:16 2011
+++ /wiki/SourceMaps.wiki Thu Sep 22 22:25:49 2011
@@ -22,13 +22,13 @@
= Source Maps =
-Unlike GWT's current Symbol Map support, SourceMaps not only record a
mapping from Java identifier to obfuscated Javascript identifier,
SourceMaps record a complete mapping of Javascript source ranges to Java
source ranges. Every (line, column) - (ending line, ending column) span
with the compiled script has a unique mapping to a Java file name and line
number. Thus, if the browser could tell us, for each method on the stack,
the exact column and line number, we could perfectly map this to the
original Java source.
+Unlike GWT's current Symbol Map support, SourceMaps not only record a
mapping from Java identifier to obfuscated Javascript identifier,
SourceMaps record a complete mapping of Javascript source ranges to Java
source ranges. Every (line, column) - (ending line, ending column) span
within the compiled script has a unique mapping to a Java file name and
line number. Thus, if the browser could tell us, for each method on the
stack, the exact column and line number, we could perfectly map this to the
original Java source.
= Enter Chrome / V8 =
Unfortunately, most browsers don't supply line and column information. In
fact, most don't even supply line numbers. The Chrome browser features an
Error.stack property on stack traces which not only includes a full
Javascript stack trace, but provides column number and line number
information within the script for each frame on the stack. Firefox is
promising full support for this soon
([https://wiki.mozilla.org/DevTools/Features/SourceMap])
-There's just one catch: GWT code fragments are loaded in many different
ways. Some are loaded as src URLs using <iframe> or <script> tags., and
some are loaded by using XHR and the equivalent of JS eval(). However,
whenever a script comes from an eval() or via dynamic <script>.text
injection, it loses origination information, and since it doesn't have a
filename to associate with itself, it also stops yielding line, column
information.
+There's just one catch: GWT code fragments are loaded in many different
ways. Some are loaded as src URLs using <iframe> or <script> tags, and some
are loaded by using XHR and the equivalent of JS eval(). However, whenever
a script comes from an eval() or via dynamic script.text injection, it
loses origination information, and since it doesn't have a filename to
associate with itself, it also stops yielding line, column information.
The workaround is to use a *magic* comment in the JS that allows
overriding of the source location.
[http://blog.getfirebug.com/2009/08/11/give-your-eval-a-name-with-sourceurl/]
@@ -42,7 +42,7 @@
{{{StackTraceCreator}}} has been modified for Chrome to analyze the
{{{Error.stack}}} property of an exception, and encode column and line
number information in each StackTraceElement. Since the Java
StackTraceElement class only includes a field for line numbers, the line
and column information are encoded in a single 32-bit number.
-On the server, {{{StackTraceDeobfuscator}}} is modified to look first try
regular symbol maps as a fallback. Then, using the stack trace from Chrome
in the form {{{filename.js:linenumber}}}, it looks for the appropriate
source map (if filename is a number, or initial fragment), and refines the
{{{StackTraceElement}}} information based on information from the SourceMap.
+On the server, {{{StackTraceDeobfuscator}}} is modified to first try
regular symbol maps as a fallback. Then, using the stack trace from Chrome
in the form {{{filename.js:linenumber}}}, it looks for the appropriate
source map (if filename is a number, or initial fragment), and refines the
{{{StackTraceElement}}} information based on information from the SourceMap.
= Turning on SourceMaps =
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors