Announce attach should be earlier (submit separately)

If GDB ever hangs in the loop before the actual detach, it's nice to
say:

While working on the previous patch, I noticed:

 (gdb) detach
 [windows events] continue_one_thread: continuing 0x24c4, debug_registers_changed=0, ContextFlags=0xc810001f
 [windows events] continue_one_thread: trap flag for 0x24c4, trap=0
 [windows events] continue_one_thread: continuing 0x22dc, debug_registers_changed=0, ContextFlags=0xd010001f
 [windows events] continue_one_thread: trap flag for 0x22dc, trap=0
 [windows events] continue_one_thread: continuing 0x208c, debug_registers_changed=0, ContextFlags=0x0
 [windows events] continue_one_thread: continuing 0x264c, debug_registers_changed=0, ContextFlags=0x0
 [windows events] break_out_process_thread: got unrelated event, code 1
 [windows events] windows_continue: windows_continue -> continue_last_debug_event
 [windows events] continue_last_debug_event: ContinueDebugEvent (cpid=11400, ctid=0x24c4, DBG_CONTINUE)
 [windows events] break_out_process_thread: got CREATE_THREAD_DEBUG_EVENT for break thread
 [windows events] windows_continue: windows_continue -> continue_last_debug_event
 [windows events] continue_last_debug_event: ContinueDebugEvent (cpid=11400, ctid=0x19fc, DBG_CONTINUE)
 Detaching from program: /home/alves/rocm/gdb/build-cygwin-testsuite/outputs/gdb.base/watchpoint-hw-attach/watchpoint-hw-attach, process 11400
 [Inferior 1 (process 11400) detached]
 [windows events] close: inferior_ptid=0

Note the "Detaching from program" message only appears after we've
done a lot of things, including looping looking for an event.  If that
ever hangs, we never see the "Detaching" message.  That doesn't seem
very consistent.  This commit moves the target_announce_detach call
earlier, before we actually detach.

We now get:

 (gdb) detach
 Detaching from program: /home/alves/rocm/gdb/build-cygwin-testsuite/outputs/gdb.base/watchpoint-hw-attach/watchpoint-hw-attach, process 11544
 [windows events] continue_one_thread: continuing 0x3554, debug_registers_changed=0, ContextFlags=0xc810001f
 [windows events] continue_one_thread: trap flag for 0x3554, trap=0
 [windows events] continue_one_thread: continuing 0x4320, debug_registers_changed=0, ContextFlags=0xd010001f
 [windows events] continue_one_thread: trap flag for 0x4320, trap=0
 [windows events] continue_one_thread: continuing 0x3944, debug_registers_changed=0, ContextFlags=0xd010001f
 [windows events] continue_one_thread: trap flag for 0x3944, trap=0
 [windows events] continue_one_thread: continuing 0x1710, debug_registers_changed=0, ContextFlags=0x0
 [windows events] break_out_process_thread: got unrelated event, code 1
 [windows events] windows_continue: windows_continue -> continue_last_debug_event
 [windows events] continue_last_debug_event: ContinueDebugEvent (cpid=11544, ctid=0x3554, DBG_CONTINUE)
 [windows events] break_out_process_thread: got CREATE_THREAD_DEBUG_EVENT for break thread
 [windows events] windows_continue: windows_continue -> continue_last_debug_event
 [windows events] continue_last_debug_event: ContinueDebugEvent (cpid=11544, ctid=0x438c, DBG_CONTINUE)
 [Inferior 1 (process 11544) detached]
 [windows events] close: inferior_ptid=0

Change-Id: I5c3b90cd8cb8755480c2e2b6e23e34fb9043e47e
1 file changed