public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Hannes Domani <ssbssa@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Don't close process handle provided by WaitForDebugEvent Date: Wed, 27 May 2020 17:44:39 +0000 (GMT) [thread overview] Message-ID: <20200527174439.94866386F468@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6479bf854a468c0270bb0fcdc9d0271cca3eb5b5 commit 6479bf854a468c0270bb0fcdc9d0271cca3eb5b5 Author: Hannes Domani <ssbssa@yahoo.de> Date: Mon May 25 00:18:25 2020 +0200 Don't close process handle provided by WaitForDebugEvent Only the process handle returned by OpenProcess or CreateProcess needs to be closed, the one provided by WaitForDebugEvent is closed automatically. gdbserver/ChangeLog: 2020-05-27 Hannes Domani <ssbssa@yahoo.de> * win32-low.cc (do_initial_child_stuff): Set open_process_used. (win32_clear_inferiors): Use open_process_used. (get_child_debug_event): Likewise. Diff: --- gdbserver/ChangeLog | 6 ++++++ gdbserver/win32-low.cc | 19 +++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog index 2b7fbb7c570..678689530fa 100644 --- a/gdbserver/ChangeLog +++ b/gdbserver/ChangeLog @@ -1,3 +1,9 @@ +2020-05-27 Hannes Domani <ssbssa@yahoo.de> + + * win32-low.cc (do_initial_child_stuff): Set open_process_used. + (win32_clear_inferiors): Use open_process_used. + (get_child_debug_event): Likewise. + 2020-05-25 Michael Weghorn <m.weghorn@posteo.de> PR gdbserver/25893 diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc index d5555a78fd2..a42fe25a220 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -88,6 +88,9 @@ static int soft_interrupt_requested = 0; by suspending all the threads. */ static int faked_breakpoint = 0; +/* True if current_process_handle needs to be closed. */ +static bool open_process_used = false; + #ifdef __x86_64__ bool wow64_process = false; #endif @@ -383,6 +386,7 @@ do_initial_child_stuff (HANDLE proch, DWORD pid, int attached) soft_interrupt_requested = 0; faked_breakpoint = 0; + open_process_used = true; memset (¤t_event, 0, sizeof (current_event)); @@ -859,8 +863,11 @@ windows_nat::handle_output_debug_string (struct target_waitstatus *ourstatus) static void win32_clear_inferiors (void) { - if (current_process_handle != NULL) - CloseHandle (current_process_handle); + if (open_process_used) + { + CloseHandle (current_process_handle); + open_process_used = false; + } for_each_thread (delete_thread_info); siginfo_er.ExceptionCode = 0; @@ -1513,6 +1520,12 @@ get_child_debug_event (DWORD *continue_status, (unsigned) current_event.dwThreadId)); CloseHandle (current_event.u.CreateProcessInfo.hFile); + if (open_process_used) + { + CloseHandle (current_process_handle); + open_process_used = false; + } + current_process_handle = current_event.u.CreateProcessInfo.hProcess; main_thread_id = current_event.dwThreadId; @@ -1560,8 +1573,6 @@ get_child_debug_event (DWORD *continue_status, } } child_continue (DBG_CONTINUE, desired_stop_thread_id); - CloseHandle (current_process_handle); - current_process_handle = NULL; break; case LOAD_DLL_DEBUG_EVENT:
reply other threads:[~2020-05-27 17:44 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200527174439.94866386F468@sourceware.org \ --to=ssbssa@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).