Author: ptw
Date: 2007-09-14 17:07:43 -0700 (Fri, 14 Sep 2007)
New Revision: 6484
Modified:
openlaszlo/branches/legals/WEB-INF/lps/lfc/debugger/LzBacktrace.lzs
openlaszlo/branches/legals/WEB-INF/lps/lfc/debugger/LzDebug.lzs
openlaszlo/branches/legals/WEB-INF/lps/lfc/debugger/platform/dhtml/kernel.js
openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
Log:
Change 20070913-ptw-P by [EMAIL PROTECTED] on 2007-09-13 08:34:45 EDT
in /Users/ptw/OpenLaszlo/legals-test
for http://svn.openlaszlo.org/openlaszlo/branches/legals
Summary: Add Debug.bugReport
New Features:
The `bugReport` method of the Debugger can be used to create a
report suitable for copy/pasting into a bug report.
Bugs Fixed:
LPP-4719 'Provide a way to output relevant debug info to copy/paste into mail'
Technical Reviewer: ben (Message-Id: <[EMAIL PROTECTED]>)
QA Reviewer: frisco (pending)
Doc Reviewer: jsundman (Message-Id: <[EMAIL PROTECTED]>)
Documentation:
The `bugReport` method of the Debugger can be used to create a
report suitable for copy/pasting into a bug report. To use it,
enable backtraces and debugging, then inspect the error message
that you believe reveals a bug, then invoke `Debug.bugReport()` in
the debugger. Copy and paste the output of that call into your
bug report.
Details:
LzDebug: Move environment from platform to here. Add bugReport
that outputs versionInfo, the backtrace from the last inspected
error, and inspects all the `this` objects in the backtrace.
LzBacktrace: Add an interface to map over the frames of a backtrace.
LaszloCanvas: Fix a type-oh in versionInfoString
Tests:
Invoking Debug.bugReport after inspecting an assertion failure in
smokecheck yields the following output:
lzx> Debug.bugReport()
Please copy the following information into your bug report:
---START OF BUG REPORT---
LPS VERSION INFORMATION:
URL:
http://dueling-banjos.local:8080/legals-test/test/smoke/simple.lzx?lzt=swf&debug=true&lzr=swf7&lzbacktrace=true
Version: 4.0.x.0
Release: Latest
Build: 6483 /Users/ptw/OpenLaszlo/legals-test
Date: 2007-09-14T19:59:36-0400
Target: swf7
Runtime: 9.45
ERROR MESSAGE: ERROR @lzunit-test.lzl#609: undefined object does not have a
property '[]'
ERROR BACKTRACE:
testUndefinedErrors @lzunit-test.lzl#606
this: ?\194?\171lz.IntentionalErrors#137| IntentionalErrors?\194?\187
runTest @lzunit/lzunit.lzx#668
this: ?\194?\171lz.IntentionalErrors#137| IntentionalErrors?\194?\187
arg 0: 'testUndefinedErrors'
run @lzunit/lzunit.lzx#632
this: ?\194?\171lz.IntentionalErrors#137| IntentionalErrors?\194?\187
arg 0: ?\194?\171TestResult#142| Tests: 448 Failures: 0 Errors:
0?\194?\187
arg 1: 'testUndefinedErrors'
runNextTest @lzunit/lzunit.lzx#1148
this: ?\194?\171TestSuite#145| TestSuite?\194?\187
arg 0: 2942
execute @lfc/events/LaszloEvents.lzs#95
this: ?\194?\171LzDelegate#148| TestSuite.runNextTest()?\194?\187
arg 0: 2942
removeCallIdleDelegates @lfc/services/LzIdle.lzs#67
this: ?\194?\171LzIdleClass#151| LzIdle?\194?\187
arg 0: 2942
sendEvent @lfc/events/LaszloEvents.lzs#437
this: ?\194?\171LzEvent#154| LzIdle.onidle?\194?\187
arg 0: 2942
__idleupdate @lfc/services/LzIdle.lzs#103
this: ?\194?\171MovieClip#157| global?\194?\187
arg 0: 2942
kernel/LzIdleKernel.lzs#29/16 @lfc/kernel/LzIdleKernel.lzs#32
this: ?\194?\171undefined?\194?\187
OBJECT DETAILS:
?\194?\171lz.IntentionalErrors#137| IntentionalErrors?\194?\187 {
_dbg_filename: 'simple.lzx'
_dbg_lineno: 16
_instanceAttrs: <a
href="asfunction:_root.$modules.lz.Debug.displayObj,161"><font
color="#0000ff">{..., _dbg_lineno: 16, _dbg_filename: simple.lzx}</font></a>
_instanceChildren: null
addedToParent: true
constructor: <a
href="asfunction:_root.$modules.lz.Debug.displayObj,162"><font
color="#0000ff">lz.IntentionalErrors</font></a>
debugWrite: false
devnull: ?\194?\171undefined?\194?\187
expectedError: null
expectedErrors: 1
immediateparent: <a
href="asfunction:_root.$modules.lz.Debug.displayObj,145"><font
color="#0000ff">TestSuite</font></a>
isinited: true
mask: <a href="asfunction:_root.$modules.lz.Debug.displayObj,163"><font
color="#0000ff">This is the canvas</font></a>
name: 'IntentionalErrors'
nodeLevel: 2
parent: <a href="asfunction:_root.$modules.lz.Debug.displayObj,145"><font
color="#0000ff">TestSuite</font></a>
resourceheight: 0
resourcewidth: 0
result: <a href="asfunction:_root.$modules.lz.Debug.displayObj,142"><font
color="#0000ff">Tests: 448 Failures: 0 Errors: 0</font></a>
sprite: <a href="asfunction:_root.$modules.lz.Debug.displayObj,164"><font
color="#0000ff">LzSprite for IntentionalErrors name: IntentionalErrors
</font></a>
}
[...]
---END OF BUG REPORT---
lzx>
Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/debugger/LzBacktrace.lzs
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/debugger/LzBacktrace.lzs
2007-09-14 21:45:55 UTC (rev 6483)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/debugger/LzBacktrace.lzs
2007-09-15 00:07:43 UTC (rev 6484)
@@ -149,6 +149,21 @@
}
/**
+ * Map over a backtraces frames
+ * @param fn:Function the function to call on each frame
+ * @param limit:Maximum number of frames to map
+ *
+ * @access private
+ */
+LzBacktrace.prototype.map = function(fn, limit) {
+ if (! (fn instanceof Function)) { return; }
+ if (! limit) { limit = this.length; }
+ for (var i = this.length - 1; (i >= 0) && (limit > 0); i--, limit--) {
+ fn(this[i]);
+ }
+}
+
+/**
* Convert a backtrace to a string
* @param printer:Function the function to print the backtrace
* functions with. Defaults to Debug.__String
Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/debugger/LzDebug.lzs
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/debugger/LzDebug.lzs
2007-09-14 21:45:55 UTC (rev 6483)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/debugger/LzDebug.lzs
2007-09-15 00:07:43 UTC (rev 6484)
@@ -73,6 +73,12 @@
*/
Debug.showInternalProperties = false;
+/** Any amendments to the environment for debug evaluator, initially
+ * just _, __, and ___. Could put things like write, format, inspect.
+ * @access private
+ */
+Debug.environment = {};
+
/**
* Display version info
*/
@@ -366,7 +372,92 @@
*/
Debug.ObjectForID = function (id) {
return this.id_to_object_table[id];
+};
+
+/**
+ * Format information about an error suitably for reporting a bug
+ *
+ * This method can be used to create a report suitable for
+ * copy/pasting into a bug report. To use it, enable backtraces and
+ * debugging, inspect the error message that you believe reveals a
+ * bug, then invoke `Debug.bugReport()` in the debugger. Copy and
+ * paste the output of that call into your bug report.
+ *
+ * @param error: An error message or ID. Defaults to the last error
+ * that was inspected.
+ * @param Boolean verbose: If true, each frame
+ * argument in the backtrace will be inspected. Defaults to the value
+ * of Debug.showInternalProperties.
+ *
+ * @note By inspecting an error message (by clicking on it), the error
+ * message will be assigned to the Debug environment variable `_`.
+ * Thus to enable a verbose report (which will detail all arguments of
+ * each frame, as opposed to just the `this` argument), invoke as
+ * `Debug.bugReport(_, true)`.
+ */
+Debug.bugReport = function (error, verbose) {
+ // Default values
+ switch (arguments.length) {
+ case 0:
+ with (global) {
+ with (this.environment) {
+ error = _;
+ }
+ }
+ case 1:
+ verbose = this.showInternalProperties;
+ }
+ if (typeof(error) == 'number') {
+ error = this.ObjectForID(error);
+ }
+ if (! (error instanceof LzSourceMessage)) {
+ Debug.error("You must provide an error to report. Please inspect an error
message and try again.")
+ return;
+ }
+ if (! (('backtrace' in error) && (error.backtrace instanceof LzBacktrace))) {
+ Debug.error("Backtraces must be on to report a bug. Please enable
backtracing and try again.");
+ return;
+ }
+ var inspected = [];
+ function inspect (obj, verbose) {
+ var id = verbose && Debug.IDForObject(obj);
+ if (id && (! (id in inspected))) {
+ inspected[id] = obj;
+ }
+ return obj;
+ }
+
+ Debug.format("Please copy the following information into your bug
report:\n\n---START OF BUG REPORT---\n\nLPS VERSION INFORMATION:\n");
+ Debug.versionInfo();
+ Debug.format("\nERROR MESSAGE: %s", error);
+ Debug.format("\nERROR BACKTRACE:");
+ error.backtrace.map(
+ function (frame) {
+ Debug.format("\n%w", frame);
+ Debug.format("\n this: %#w", inspect(frame['this'], true));
+ var args = frame.arguments;
+ for (var i = 0; i < args.length; i++) {
+ Debug.format("\n arg %2d: %#w", i, inspect(args[i], verbose));
+ }
+ });
+ if (inspected.length > 0) {
+ Debug.format("\n\nOBJECT DETAILS:");
+ var keys = [];
+ // Present the object's in ID-order so they are easier to find.
+ for (var id in inspected) {
+ keys.push(id);
+ }
+ keys.sort(function (a, b) {
+ var al = parseInt(a);
+ var bl = parseInt(b);
+ return (al > bl) - (al < bl);
+ });
+ for (var i = 0; i < keys.length; i++) {
+ var obj = inspected[keys[i]];
+ Debug.format("\n%s\n", Debug.inspectInternal(obj));
+ }
+ }
+ Debug.format("\n---END OF BUG REPORT---\n");
}
-
Modified:
openlaszlo/branches/legals/WEB-INF/lps/lfc/debugger/platform/dhtml/kernel.js
===================================================================
---
openlaszlo/branches/legals/WEB-INF/lps/lfc/debugger/platform/dhtml/kernel.js
2007-09-14 21:45:55 UTC (rev 6483)
+++
openlaszlo/branches/legals/WEB-INF/lps/lfc/debugger/platform/dhtml/kernel.js
2007-09-15 00:07:43 UTC (rev 6484)
@@ -191,12 +191,6 @@
this.displayResult(this.inspect(obj));
}
-/** Any amendments to the environment for debug evaluator, initially
- * just _, __, and ___. Could put things like write, format, inspect.
- * @access private
- */
-Debug.environment = {};
-
/**
* @access private
*/
Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
2007-09-14 21:45:55 UTC (rev 6483)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
2007-09-15 00:07:43 UTC (rev 6484)
@@ -586,7 +586,7 @@
'Build: ' + canvas.lpsbuild + '\n' +
'Date: ' + canvas.lpsbuilddate + '\n' +
'Target: ' + canvas.runtime + '\n' +
- 'Runtime:' + LzBrowser.getVersion() + '\n');
+ 'Runtime: ' + LzBrowser.getVersion() + '\n');
}
/**
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins