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.
"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"
(#.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
"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"))
(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"))
(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.
;;;
(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