From: Alastair Bridgewater Date: Wed, 30 Nov 2011 15:32:40 +0000 (-0500) Subject: Improved undefined-function backtrace on x86oids. X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=f4f6c11c4a86c81767d919daf07671b467b3d829;p=sbcl.git Improved undefined-function backtrace on x86oids. * Instead of "bogus stack frame", present undefined function frames as "undefined function". * Implement this by checking specifically for escaped frames with the program counter within the range between the start of undefined_tramp and the start of whichever function follows it in $ARCH-assem.S. --- diff --git a/NEWS b/NEWS index e416553..8156f78 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,8 @@ changes relative to sbcl-1.0.54: * enhancement: the test runner now takes a --report-skipped-tests argument to report the individual tests skipped as well as the number of skipped tests. + * enhancement: undefined functions now appear in backtraces as ("undefined + function") instead of ("bogus stack frame") on x86oids. * optimization: the compiler is smarter about representation selection for floating point constants used in full calls. * optimization: the compiler no longer refuses to coerce large fixnums to diff --git a/src/code/debug-int.lisp b/src/code/debug-int.lisp index d5dd4c7..592c75f 100644 --- a/src/code/debug-int.lisp +++ b/src/code/debug-int.lisp @@ -866,7 +866,15 @@ (component-from-component-ptr component-ptr)))) (/noshow0 "got CODE") (when (null code) - (return (values code 0 context))) + ;; KLUDGE: Detect undefined functions by a range-check + ;; against the trampoline address and the following + ;; function in the runtime. + (if (< (foreign-symbol-address "undefined_tramp") + (sap-int (sb!vm:context-pc context)) + (foreign-symbol-address #!+x86 "closure_tramp" + #!+x86-64 "alloc_tramp")) + (return (values :undefined-function 0 context)) + (return (values code 0 context)))) (let* ((code-header-len (* (get-header-data code) sb!vm:n-word-bytes)) (pc-offset diff --git a/src/runtime/x86-64-assem.S b/src/runtime/x86-64-assem.S index 1fb7b00..34b9df5 100644 --- a/src/runtime/x86-64-assem.S +++ b/src/runtime/x86-64-assem.S @@ -275,6 +275,9 @@ GNAME(undefined_tramp): ret SIZE(GNAME(undefined_tramp)) +/* KLUDGE: FIND-ESCAPED-FRAME (SYS:SRC;CODE;DEBUG-INT.LISP) needs + * to know the name of the function immediately following the + * undefined-function trampoline. */ .text .align align_16byte,0x90 diff --git a/src/runtime/x86-assem.S b/src/runtime/x86-assem.S index d6dd52b..d04e194 100644 --- a/src/runtime/x86-assem.S +++ b/src/runtime/x86-assem.S @@ -347,6 +347,10 @@ GNAME(undefined_tramp): ret SIZE(GNAME(undefined_tramp)) +/* KLUDGE: FIND-ESCAPED-FRAME (SYS:SRC;CODE;DEBUG-INT.LISP) needs + * to know the name of the function immediately following the + * undefined-function trampoline. */ + /* * the closure trampoline */ diff --git a/tests/debug.impure.lisp b/tests/debug.impure.lisp index 3520c9a..b72317b 100644 --- a/tests/debug.impure.lisp +++ b/tests/debug.impure.lisp @@ -134,8 +134,7 @@ (defvar *undefined-function-frame* ;; bug 353 - '(#+(or x86 x86-64) "bogus stack frame" - #-(or x86 x86-64) "undefined function")) + '("undefined function")) ;;; Test for "undefined function" (undefined_tramp) working properly. ;;; Try it with and without tail call elimination, since they can have