[armedbear-cvs] r13108 - trunk/abcl/src/org/armedbear/lisp

Mark Evenson mevenson at common-lisp.net
Tue Dec 28 21:00:23 UTC 2010


Author: mevenson
Date: Tue Dec 28 16:00:22 2010
New Revision: 13108

Log:
Fix strange backtrace growth as reported in ticket #114.

There may be other code paths through the error() routines that need
similar exceptions to omit their code paths as well.

Modified:
   trunk/abcl/src/org/armedbear/lisp/Lisp.java

Modified: trunk/abcl/src/org/armedbear/lisp/Lisp.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Lisp.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Lisp.java	Tue Dec 28 16:00:22 2010
@@ -331,6 +331,19 @@
       final LispThread thread = LispThread.currentThread();
       final StackTraceElement[] frames = thread.getJavaStackTrace();
 
+      // frames[0] java.lang.Thread.getStackTrace
+      // frames[1] org.armedbear.lisp.LispThread.getJavaStackTrace
+      // frames[2] org.armedbear.lisp.Lisp.pushJavaStackFrames
+
+      if (frames.length > 5
+        && frames[3].getClassName().equals("org.armedbear.lisp.Lisp")
+        && frames[3].getMethodName().equals("error")
+        && frames[4].getClassName().startsWith("org.armedbear.lisp.Lisp")
+        && frames[4].getMethodName().equals("eval")) {
+          // Error condition arising from within Lisp.eval(), so no
+          // Java stack frames should be visible to the consumer of the stack abstraction
+          return;
+      }
       // Search for last Primitive in the StackTrace; that was the
       // last entry point from Lisp.
       int last = frames.length - 1;
@@ -338,9 +351,8 @@
           if (frames[i].getClassName().startsWith("org.armedbear.lisp.Primitive"))
             last = i;
       }
-      // Do not include the first three frames:
-      //   Thread.getStackTrace, LispThread.getJavaStackTrace,
-      //   Lisp.pushJavaStackFrames.
+      // Do not include the first three frames which, as noted above, constitute
+      // the invocation of this method.
       while (last > 2) {
         thread.pushStackFrame(new JavaStackFrame(frames[last]));
         last--;




More information about the armedbear-cvs mailing list