Index: /branches/watchpoints/level-1/x86-trap-support.lisp
===================================================================
--- /branches/watchpoints/level-1/x86-trap-support.lisp	(revision 12903)
+++ /branches/watchpoints/level-1/x86-trap-support.lisp	(revision 12904)
@@ -387,5 +387,6 @@
 ;;; may not be meaningful.
 (defcallback xcmain (:address xp :address xcf :int signal :long code :long addr :long other :int)
-  (let* ((frame-ptr (macptr->fixnum xcf)))
+  (let* ((frame-ptr (macptr->fixnum xcf))
+	 (skip 0))
     (cond ((zerop signal)               ;thread interrupt
            (cmain))
@@ -436,13 +437,19 @@
 			 (%get-object a 0))))
 		(let ((object (%int-to-object other)))
-		  (restart-case (%error (make-condition
-					 'write-to-watched-object
-					 :address addr
-					 :object object)
-					nil frame-ptr)
-		    (unwatch ()
-		      :report (lambda (s)
-				(format s "Unwatch ~s and perform the write." object))
-		      (unwatch object))))))))
+		  (multiple-value-bind (insn insn-length)
+		      (x86-faulting-instruction xp)
+		    (restart-case (%error (make-condition
+					   'write-to-watched-object
+					   :instruction insn
+					   :address addr
+					   :object object)
+					  nil frame-ptr)
+		      (ignore ()
+			:report "Ignore this write."
+			(setq skip insn-length))
+		      (unwatch ()
+			:report (lambda (s)
+				  (format s "Unwatch ~s and perform the write." object))
+			(unwatch object)))))))))
           ((= signal #+win32-target 10 #-win32-target #$SIGBUS)
            (if (= code -1)
@@ -454,4 +461,17 @@
                                      :write-p (not (zerop code)))
                      ()
-                     frame-ptr)))))
-  0)
+                     frame-ptr))))
+    skip))
+
+(defun x86-faulting-instruction (xp)
+  (let* ((code-bytes (make-array 15 :element-type '(unsigned-byte 8)))
+         (pc (indexed-gpr-macptr xp rip-register-offset)))
+    (dotimes (i (length code-bytes))
+      (setf (aref code-bytes i) (%get-unsigned-byte pc i)))
+    (let* ((ds (make-x86-disassembly-state
+                :mode-64 #+x8664-target t #+x8632-target nil
+                :code-vector code-bytes
+                :code-pointer 0))
+           (insn (x86-disassemble-instruction ds nil))
+           (len (- (x86-ds-code-pointer ds) (x86-ds-insn-start ds))))
+      (values insn len))))
