From: Pedro Alves Date: Wed, 3 Apr 2024 21:14:51 +0000 (+0100) Subject: Announce attach should be earlier (submit separately) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fusers%2Fpalves%2Fwindows-non-stop-v2-plus;p=thirdparty%2Fbinutils-gdb.git 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 --- diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index afc01eec7d1..5ee85736f06 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -3061,6 +3061,8 @@ windows_nat_target::continue_status_for_event_detaching void windows_nat_target::detach (inferior *inf, int from_tty) { + target_announce_detach (from_tty); + DWORD continue_status = DBG_CONTINUE; /* For any thread the core hasn't resumed, call prepare_resume with @@ -3176,8 +3178,6 @@ windows_nat_target::detach (inferior *inf, int from_tty) throw_winerror_with_name (msg.c_str (), *err); } - target_announce_detach (from_tty); - x86_cleanup_dregs (); switch_to_no_thread (); detach_inferior (inf);