From patchwork Tue Nov 26 17:11:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 36238 Received: (qmail 3898 invoked by alias); 26 Nov 2019 17:31:55 -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 3857 invoked by uid 89); 26 Nov 2019 17:31:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Nov 2019 17:31:53 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 00ADF208B6; Tue, 26 Nov 2019 12:11:52 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id A1F8B20A81; Tue, 26 Nov 2019 12:11:31 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 7F64928173; Tue, 26 Nov 2019 12:11:31 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Tue, 26 Nov 2019 12:11:28 -0500 From: "Tom Tromey (Code Review)" To: Luis Machado , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [review v2] Change type of argument to windows-nat.c:thread_rec X-Gerrit-Change-Id: I06acddba162573bd5f0d2f6f5b36f16a0b652916 X-Gerrit-Change-Number: 413 X-Gerrit-ChangeURL: X-Gerrit-Commit: 6ee0fa267c69d999dc11ae6726be1288f1457b09 In-Reply-To: References: Reply-To: tromey@sourceware.org, luis.machado@linaro.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20191126171131.7F64928173@gnutoolchain-gerrit.osci.io> Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/413 ...................................................................... Change type of argument to windows-nat.c:thread_rec windows-nat.c:thread_rec accepts an integer parameter whose interpretation depends on whether it is less than, equal to, or greater than zero. I found this confusing at times, so this patch replaces it with an enum instead. gdb/ChangeLog 2019-11-26 Tom Tromey * windows-nat.c (enum thread_disposition_type): New. (thread_rec): Replace "get_context" parameter with "disposition"; change type. (windows_add_thread, windows_nat_target::fetch_registers) (windows_nat_target::store_registers, handle_exception) (windows_nat_target::resume, get_windows_debug_event) (windows_nat_target::get_tib_address) (windows_nat_target::thread_name) (windows_nat_target::thread_alive): Update. Change-Id: I06acddba162573bd5f0d2f6f5b36f16a0b652916 --- M gdb/ChangeLog M gdb/windows-nat.c 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6862a12..14cb238 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,17 @@ 2019-11-26 Tom Tromey + * windows-nat.c (enum thread_disposition_type): New. + (thread_rec): Replace "get_context" parameter with "disposition"; + change type. + (windows_add_thread, windows_nat_target::fetch_registers) + (windows_nat_target::store_registers, handle_exception) + (windows_nat_target::resume, get_windows_debug_event) + (windows_nat_target::get_tib_address) + (windows_nat_target::thread_name) + (windows_nat_target::thread_alive): Update. + +2019-11-26 Tom Tromey + * windows-nat.c (thread_rec): Use windows_thread_info::suspend. (windows_continue): Use windows_continue::resume. * nat/windows-nat.h (struct windows_thread_info) tid == id) { - if (!th->suspended && get_context) + if (!th->suspended) { - if (get_context > 0 && id != current_event.dwThreadId) - th->suspend (); - else if (get_context < 0) - th->suspended = -1; - th->reload_context = true; + switch (disposition) + { + case DONT_INVALIDATE_CONTEXT: + /* Nothing. */ + break; + case INVALIDATE_CONTEXT: + if (id != current_event.dwThreadId) + th->suspend (); + th->reload_context = true; + break; + case DONT_SUSPEND: + th->reload_context = true; + th->suspended = -1; + break; + } } return th; } @@ -406,7 +428,7 @@ id = ptid.lwp (); - if ((th = thread_rec (id, FALSE))) + if ((th = thread_rec (id, DONT_INVALIDATE_CONTEXT))) return th; th = new windows_thread_info (id, h, (CORE_ADDR) (uintptr_t) tlb); @@ -546,7 +568,7 @@ windows_nat_target::fetch_registers (struct regcache *regcache, int r) { DWORD tid = regcache->ptid ().lwp (); - windows_thread_info *th = thread_rec (tid, TRUE); + windows_thread_info *th = thread_rec (tid, INVALIDATE_CONTEXT); /* Check if TH exists. Windows sometimes uses a non-existent thread id in its events. */ @@ -616,7 +638,7 @@ windows_nat_target::store_registers (struct regcache *regcache, int r) { DWORD tid = regcache->ptid ().lwp (); - windows_thread_info *th = thread_rec (tid, TRUE); + windows_thread_info *th = thread_rec (tid, INVALIDATE_CONTEXT); /* Check if TH exists. Windows sometimes uses a non-existent thread id in its events. */ @@ -1114,7 +1136,7 @@ ourstatus->kind = TARGET_WAITKIND_STOPPED; /* Record the context of the current thread. */ - thread_rec (current_event.dwThreadId, -1); + thread_rec (current_event.dwThreadId, DONT_SUSPEND); switch (code) { @@ -1230,7 +1252,7 @@ if (named_thread_id == (DWORD) -1) named_thread_id = current_event.dwThreadId; - named_thread = thread_rec (named_thread_id, 0); + named_thread = thread_rec (named_thread_id, DONT_INVALIDATE_CONTEXT); if (named_thread != NULL) { int thread_name_len; @@ -1402,7 +1424,7 @@ ptid.pid (), (unsigned) ptid.lwp (), step, sig)); /* Get context for currently selected thread. */ - th = thread_rec (inferior_ptid.lwp (), FALSE); + th = thread_rec (inferior_ptid.lwp (), DONT_INVALIDATE_CONTEXT); if (th) { if (step) @@ -1656,7 +1678,7 @@ inferior_ptid = ptid_t (current_event.dwProcessId, thread_id, 0); current_thread = th; if (!current_thread) - current_thread = thread_rec (thread_id, TRUE); + current_thread = thread_rec (thread_id, INVALIDATE_CONTEXT); } out: @@ -2957,7 +2979,7 @@ { windows_thread_info *th; - th = thread_rec (ptid.lwp (), 0); + th = thread_rec (ptid.lwp (), DONT_INVALIDATE_CONTEXT); if (th == NULL) return false; @@ -2978,7 +3000,7 @@ const char * windows_nat_target::thread_name (struct thread_info *thr) { - return thread_rec (thr->ptid.lwp (), 0)->name.get (); + return thread_rec (thr->ptid.lwp (), DONT_INVALIDATE_CONTEXT)->name.get (); } @@ -3141,7 +3163,8 @@ gdb_assert (ptid.lwp () != 0); tid = ptid.lwp (); - return WaitForSingleObject (thread_rec (tid, FALSE)->h, 0) != WAIT_OBJECT_0; + return (WaitForSingleObject (thread_rec (tid, DONT_INVALIDATE_CONTEXT)->h, 0) + != WAIT_OBJECT_0); } void