+;;; This is not a WITH-TEST :FAILS-ON PPC DARWIN since there are
+;;; suspicions that the breakpoint trace might corrupt the whole image
+;;; on that platform.
+(with-test (:name (trace :encapsulate nil)
+ :fails-on '(or (and :ppc (not :linux)) :sparc :mips)
+ :broken-on '(or :darwin :sunos))
+ (let ((out (with-output-to-string (*trace-output*)
+ (trace trace-this :encapsulate nil)
+ (assert (eq 'ok (trace-this)))
+ (untrace))))
+ (assert (search "TRACE-THIS" out))
+ (assert (search "returned OK" out))))
+
+(with-test (:name (trace-recursive :encapsulate nil)
+ :fails-on '(or (and :ppc (not :linux)) :sparc :mips :sunos)
+ :broken-on '(or :darwin (and :x86 :sunos)))
+ (let ((out (with-output-to-string (*trace-output*)
+ (trace trace-fact :encapsulate nil)
+ (assert (= 120 (trace-fact 5)))
+ (untrace))))
+ (assert (search "TRACE-FACT" out))
+ (assert (search "returned 1" out))
+ (assert (search "returned 120" out))))
+
+(defun trace-and-fmakunbound-this (x)
+ x)
+
+(with-test (:name :bug-667657)
+ (trace trace-and-fmakunbound-this)
+ (fmakunbound 'trace-and-fmakunbound-this)
+ (untrace)
+ (assert (not (trace))))
+
+(with-test (:name :bug-414)
+ (handler-bind ((warning #'error))
+ (load (compile-file "bug-414.lisp"))
+ (disassemble 'bug-414)))
+
+(with-test (:name :bug-310175 :fails-on '(not :stack-allocatable-lists))
+ ;; KLUDGE: Not all DX-enabled platforms DX CONS, and the compiler
+ ;; transforms two-arg-LIST* (and one-arg-LIST) to CONS. Therefore,
+ ;; use two-arg-LIST, which should get through to VOP LIST, and thus
+ ;; stack-allocate on a predictable set of machines.
+ (let ((dx-arg (list t t)))
+ (declare (dynamic-extent dx-arg))
+ (flet ((dx-arg-backtrace (x)
+ (declare (optimize (debug 2)))
+ (prog1 (sb-debug:backtrace-as-list 10)
+ (assert (sb-debug::stack-allocated-p x)))))
+ (declare (notinline dx-arg-backtrace))
+ (assert (member-if (lambda (frame)
+ (and (consp frame)
+ (consp (car frame))
+ (equal '(flet dx-arg-backtrace :in) (butlast (car frame)))
+ (notany #'sb-debug::stack-allocated-p (cdr frame))))
+ (dx-arg-backtrace dx-arg))))))
+
+(with-test (:name :bug-795245)
+ (assert
+ (eq :ok
+ (catch 'done
+ (handler-bind
+ ((error (lambda (e)
+ (declare (ignore e))
+ (handler-case
+ (sb-debug:backtrace 100 (make-broadcast-stream))
+ (error ()
+ (throw 'done :error))
+ (:no-error ()
+ (throw 'done :ok))))))
+ (apply '/= nil 1 2 nil))))))