0.8.13.10: I don't think we're in lisp-land anymore...

* Display foreign function names in backtraces on platforms
              with dladdr. Essentially a port of Helmut Eller's patch
              for CMUCL. Works fine on x86 and Sparc at least.
           * Clean up some spurious sb-alien package prefixes from
              foreign.lisp while at it.
This commit is contained in:
Nikodemus Siivola 2004-07-29 11:29:52 +00:00
parent e29e584efd
commit bcb7a9c9d1
5 changed files with 49 additions and 12 deletions

3
NEWS
View file

@ -1,4 +1,7 @@
changes in sbcl-0.8.14 relative to sbcl-0.8.13:
* new feature: on platforms where "dladdr" is available foreign
function names now appear in backtraces. (based on Helmut Eller's
work for CMUCL)
* bug fix: backtraces involving undefined functions or assembly
routines are more informative. (thanks to Brian Downing)
* bug fix: mutually referent alien structures now work correctly.

View file

@ -1792,6 +1792,7 @@ SB-KERNEL) have been undone, but probably more remain."
"ENABLE-INTERRUPT" "ENUMERATION"
"FD-STREAM-FD" "FD-STREAM-P"
"FOREIGN-SYMBOL-ADDRESS" "FOREIGN-SYMBOL-ADDRESS-AS-INTEGER"
"FOREIGN-SYMBOL-IN-ADDRESS"
"GET-PAGE-SIZE" "GET-SYSTEM-INFO"
"IGNORE-INTERRUPT"
"INT-SAP" "INVALIDATE-DESCRIPTOR" "IO-TIMEOUT"

View file

@ -780,6 +780,12 @@
(#.lra-save-offset
(setf (sap-ref-sap pointer (- (* (1+ stack-slot) 4))) value))))))
(defun foreign-function-debug-name (sap)
(multiple-value-bind (name file base offset) (foreign-symbol-in-address sap)
(if name
(format nil "foreign function: ~A [~A: #x~X + #x~X]" name file base offset)
(format nil "foreign function: #x~X" (sap-int sap)))))
;;; This returns a frame for the one existing in time immediately
;;; prior to the frame referenced by current-fp. This is current-fp's
;;; caller or the next frame down the control stack. If there is no
@ -826,7 +832,7 @@
"undefined function"))
(:foreign-function
(make-bogus-debug-fun
(format nil "foreign function call land:")))
(foreign-function-debug-name (int-sap (get-lisp-obj-address lra)))))
((nil)
(make-bogus-debug-fun
"bogus stack frame"))
@ -871,9 +877,7 @@
(make-bogus-debug-fun
"undefined function"))
(:foreign-function
(make-bogus-debug-fun
(format nil "foreign function call land: ra=#x~X"
(sap-int ra))))
(make-bogus-debug-fun (foreign-function-debug-name ra)))
((nil)
(make-bogus-debug-fun
"bogus stack frame"))

View file

@ -67,13 +67,14 @@
(push (lambda () (setq *handles-from-dlopen* nil))
*after-save-initializations*)
(sb-alien:define-alien-routine dlopen system-area-pointer
(file sb-alien:c-string) (mode sb-alien:int))
(sb-alien:define-alien-routine dlsym system-area-pointer
(lib system-area-pointer)
(name sb-alien:c-string))
(sb-alien:define-alien-routine dlerror sb-alien:c-string)
(define-alien-routine dlopen system-area-pointer
(file c-string) (mode int))
(define-alien-routine dlsym system-area-pointer
(lib system-area-pointer) (name c-string))
(define-alien-routine dlerror c-string)
;;; Ensure that we've opened our own binary so we can dynamically resolve
;;; symbols in the C runtime.
;;;
@ -135,4 +136,32 @@
(unless (zerop possible-result)
(return possible-result)))))
(defun foreign-symbol-in-address (sap)
(declare (ignore sap)))
(when (ignore-errors (foreign-symbol-address "dladdr"))
(setf (symbol-function 'foreign-symbol-in-address)
;; KLUDGE: This COMPILE trick is to avoid trying to
;; compile a reference to dladdr on platforms without it.
(compile nil
'(lambda (sap)
(let ((addr (sap-int sap)))
(with-alien ((info
(struct dl-info
(filename c-string)
(base unsigned)
(symbol c-string)
(symbol-address unsigned)))
(dladdr
(function unsigned
unsigned (* (struct dl-info)))
:extern "dladdr"))
(let ((err (alien-funcall dladdr addr (addr info))))
(if (zerop err)
nil
(values (slot info 'symbol)
(slot info 'filename)
addr
(- addr (slot info 'symbol-address)))))))))))
)) ; PROGN, MACROLET

View file

@ -17,4 +17,4 @@
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
"0.8.13.9"
"0.8.13.10"