Author: ptw
Date: 2007-10-31 12:36:00 -0700 (Wed, 31 Oct 2007)
New Revision: 7065

Modified:
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/debugger/LzBacktrace.lzs
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/debugger/LzDebug.lzs
   
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/debugger/platform/dhtml/kernel.js
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
Log:
Change 20071031-ptw-w by [EMAIL PROTECTED] on 2007-10-31 15:21:33 EDT
    in /Users/ptw/OpenLaszlo/jujube
    for http://svn.openlaszlo.org/openlaszlo/branches/wafflecone

Summary: Merge Debug.bugReport to cranberry

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:
    Merged r6484 and r6520 from trunk

Tests:
    Inspection



Modified: 
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/debugger/LzBacktrace.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/debugger/LzBacktrace.lzs     
2007-10-31 18:39:25 UTC (rev 7064)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/debugger/LzBacktrace.lzs     
2007-10-31 19:36:00 UTC (rev 7065)
@@ -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/wafflecone/WEB-INF/lps/lfc/debugger/LzDebug.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/debugger/LzDebug.lzs 
2007-10-31 18:39:25 UTC (rev 7064)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/debugger/LzDebug.lzs 
2007-10-31 19:36:00 UTC (rev 7065)
@@ -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,95 @@
   */
 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");
+      // Thus copy/paste will not get the 'hotlink' markup
+      Debug.inspect(obj);
+      Debug.format("\n");
+    }
+  }
+  Debug.format("\n---END OF BUG REPORT---\n");
 }
 
 
-

Modified: 
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/debugger/platform/dhtml/kernel.js
===================================================================
--- 
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/debugger/platform/dhtml/kernel.js
    2007-10-31 18:39:25 UTC (rev 7064)
+++ 
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/debugger/platform/dhtml/kernel.js
    2007-10-31 19:36:00 UTC (rev 7065)
@@ -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/wafflecone/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LaszloCanvas.lzs       
2007-10-31 18:39:25 UTC (rev 7064)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LaszloCanvas.lzs       
2007-10-31 19:36:00 UTC (rev 7065)
@@ -568,7 +568,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

Reply via email to