From patchwork Thu Apr 16 19:23:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Turney X-Patchwork-Id: 6265 Received: (qmail 84608 invoked by alias); 16 Apr 2015 19:23:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 84546 invoked by uid 89); 16 Apr 2015 19:23:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 X-HELO: rgout06.bt.lon5.cpcloud.co.uk Received: from rgout06.bt.lon5.cpcloud.co.uk (HELO rgout06.bt.lon5.cpcloud.co.uk) (65.20.0.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Apr 2015 19:23:55 +0000 X-OWM-Source-IP: 31.51.207.104(GB) X-OWM-Env-Sender: jonturney@btinternet.com X-CTCH-RefID: str=0001.0A090205.55300C4A.00F3, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-Junkmail-Premium-Raw: score=27/50, refid=2.7.2:2015.3.30.162421:17:27.888, ip=31.51.207.104, rules=__HAS_FROM, __TO_MALFORMED_2, __TO_NO_NAME, __HAS_MSGID, __SANE_MSGID, __HAS_X_MAILER, __IN_REP_TO, __REFERENCES, __ANY_URI, __URI_NO_WWW, __URI_NO_PATH, __CP_NAME_BODY, BODY_SIZE_4000_4999, __MIME_TEXT_ONLY, RDNS_GENERIC_POOLED, __URI_NS, SXL_IP_DYNAMIC[104.207.51.31.fur], HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, RDNS_SUSP_GENERIC, RDNS_SUSP, BODY_SIZE_7000_LESS, REFERENCES X-CTCH-Spam: Unknown Received: from localhost.localdomain (31.51.207.104) by rgout06.bt.lon5.cpcloud.co.uk (8.6.122.06) (authenticated as jonturney@btinternet.com) id 5515161402614897; Thu, 16 Apr 2015 20:23:54 +0100 From: Jon Turney To: gdb-patches@sourceware.org Cc: Jon Turney Subject: [PATCH 2/5] windows-nat: Cleanups in get_windows_debug_event Date: Thu, 16 Apr 2015 20:23:26 +0100 Message-Id: <1429212209-20548-3-git-send-email-jon.turney@dronecode.org.uk> In-Reply-To: <1429212209-20548-1-git-send-email-jon.turney@dronecode.org.uk> References: <1429009382-21040-1-git-send-email-jon.turney@dronecode.org.uk> <1429212209-20548-1-git-send-email-jon.turney@dronecode.org.uk> gdb/ChangeLog: 2015-04-16 Jon Turney * windows-nat.c (get_windows_debug_event): Replace retval with thread_id throughout. Update stale comment. --- gdb/ChangeLog | 5 +++++ gdb/windows-nat.c | 30 +++++++++++++++--------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index dea4368..4b08d4d 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1307,8 +1307,8 @@ ctrl_c_handler (DWORD event_type) return TRUE; } -/* Get the next event from the child. Return 1 if the event requires - handling by WFI (or whatever). */ +/* Get the next event from the child. Returns a non-zero thread id if the event + requires handling by WFI (or whatever). */ static int get_windows_debug_event (struct target_ops *ops, int pid, struct target_waitstatus *ourstatus) @@ -1317,7 +1317,7 @@ get_windows_debug_event (struct target_ops *ops, DWORD continue_status, event_code; windows_thread_info *th; static windows_thread_info dummy_thread_info; - int retval = 0; + DWORD thread_id = 0; last_sig = GDB_SIGNAL_0; @@ -1348,14 +1348,14 @@ get_windows_debug_event (struct target_ops *ops, /* Kludge around a Windows bug where first event is a create thread event. Caused when attached process does not have a main thread. */ - retval = fake_create_process (); - if (retval) + thread_id = fake_create_process (); + if (thread_id) saw_create++; } break; } /* Record the existence of this thread. */ - retval = current_event.dwThreadId; + thread_id = current_event.dwThreadId; th = windows_add_thread (ptid_build (current_event.dwProcessId, 0, current_event.dwThreadId), current_event.u.CreateThread.hThread, @@ -1398,7 +1398,7 @@ get_windows_debug_event (struct target_ops *ops, current_event.dwThreadId), current_event.u.CreateProcessInfo.hThread, current_event.u.CreateProcessInfo.lpThreadLocalBase); - retval = current_event.dwThreadId; + thread_id = current_event.dwThreadId; break; case EXIT_PROCESS_DEBUG_EVENT: @@ -1417,7 +1417,7 @@ get_windows_debug_event (struct target_ops *ops, { ourstatus->kind = TARGET_WAITKIND_EXITED; ourstatus->value.integer = current_event.u.ExitProcess.dwExitCode; - retval = main_thread_id; + thread_id = main_thread_id; } break; @@ -1432,7 +1432,7 @@ get_windows_debug_event (struct target_ops *ops, catch_errors (handle_load_dll, NULL, (char *) "", RETURN_MASK_ALL); ourstatus->kind = TARGET_WAITKIND_LOADED; ourstatus->value.integer = 0; - retval = main_thread_id; + thread_id = main_thread_id; break; case UNLOAD_DLL_DEBUG_EVENT: @@ -1445,7 +1445,7 @@ get_windows_debug_event (struct target_ops *ops, catch_errors (handle_unload_dll, NULL, (char *) "", RETURN_MASK_ALL); ourstatus->kind = TARGET_WAITKIND_LOADED; ourstatus->value.integer = 0; - retval = main_thread_id; + thread_id = main_thread_id; break; case EXCEPTION_DEBUG_EVENT: @@ -1461,7 +1461,7 @@ get_windows_debug_event (struct target_ops *ops, continue_status = DBG_EXCEPTION_NOT_HANDLED; break; case 1: - retval = current_event.dwThreadId; + thread_id = current_event.dwThreadId; break; case -1: last_sig = 1; @@ -1477,7 +1477,7 @@ get_windows_debug_event (struct target_ops *ops, "OUTPUT_DEBUG_STRING_EVENT")); if (saw_create != 1) break; - retval = handle_output_debug_string (ourstatus); + thread_id = handle_output_debug_string (ourstatus); break; default: @@ -1491,7 +1491,7 @@ get_windows_debug_event (struct target_ops *ops, break; } - if (!retval || saw_create != 1) + if (!thread_id || saw_create != 1) { if (continue_status == -1) windows_resume (ops, minus_one_ptid, 0, 1); @@ -1501,14 +1501,14 @@ get_windows_debug_event (struct target_ops *ops, else { inferior_ptid = ptid_build (current_event.dwProcessId, 0, - retval); + thread_id); current_thread = th; if (!current_thread) current_thread = thread_rec (current_event.dwThreadId, TRUE); } out: - return retval; + return thread_id; } /* Wait for interesting events to occur in the target process. */