Correctly attach the debugger to a running VM.

Fixed #1001639.