From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76093 invoked by alias); 29 Nov 2019 19:08:13 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 76080 invoked by uid 89); 29 Nov 2019 19:08:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=sk:stopped, ptid 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; Fri, 29 Nov 2019 19:08:11 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id DB0AD203C1; Fri, 29 Nov 2019 14:08:08 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 9FAA020277; Fri, 29 Nov 2019 14:08:06 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 818ED20AF6; Fri, 29 Nov 2019 14:08:06 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Fri, 29 Nov 2019 19:08:00 -0000 From: "Pedro Alves (Code Review)" To: Tom Tromey , gdb-patches@sourceware.org Cc: Joel Brobecker , Luis Machado Auto-Submitted: auto-generated X-Gerrit-MessageType: comment Subject: [review v2] Handle pending stops from the Windows kernel X-Gerrit-Change-Id: I5d0dd64c3d2d8220b534d3e02aeaa6f6815264ab X-Gerrit-Change-Number: 414 X-Gerrit-ChangeURL: X-Gerrit-Commit: 804c23872b255f1efa53fa64cfe5067b1c3653f1 In-Reply-To: References: X-Gerrit-Comment-Date: Fri, 29 Nov 2019 14:08:06 -0500 Reply-To: gnutoolchain-gerrit@osci.io MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Content-Type: text/plain; charset=UTF-8 Message-Id: <20191129190806.818ED20AF6@gnutoolchain-gerrit.osci.io> X-SW-Source: 2019-11/txt/msg01146.txt.bz2 Pedro Alves has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/414 ...................................................................... Patch Set 2: Code-Review+2 (2 comments) Minor nit below. Otherwise this version LGTM. | --- gdb/nat/windows-nat.h | +++ gdb/nat/windows-nat.h | @@ -64,15 +64,19 @@ #endif | CONTEXT context {}; | | /* Whether debug registers changed since we last set CONTEXT back to | the thread. */ | bool debug_registers_changed = false; | | /* Nonzero if CONTEXT is invalidated and must be re-read from the | inferior thread. */ | bool reload_context = false; | | + /* True if this thread is currently stopped at a breakpoint. This | + is used to offset the PC when needed. */ | + bool stopped_at_breakpoint = false; PS2, Line 76: I think it would be better if this said "stopped at a software breakpoint", and the field was called stopped_at_sw_breakpoint (for example). This is because you won't do the offsetting with hardware breakpoints. | + | /* The name of the thread, allocated by xmalloc. */ | gdb::unique_xmalloc_ptr name; | }; | | #endif | --- gdb/windows-nat.c | +++ gdb/windows-nat.c | @@ -556,16 +610,37 @@ windows_fetch_one_register (struct regcache *regcache, | { | /* GDB treats segment registers as 32bit registers, but they are | in fact only 16 bits long. Make sure we do not read extra | bits from our source buffer. */ | long l = *((long *) context_offset) & 0xffff; | regcache->raw_supply (r, (char *) &l); | } | else | - regcache->raw_supply (r, context_offset); | + { | + if (th->stopped_at_breakpoint && r == gdbarch_pc_regnum (gdbarch)) | + { | + int size = register_size (gdbarch, r); | + if (size == 4) | + { | + uint32_t value; | + memcpy (&value, context_offset, size); | + value -= gdbarch_decr_pc_after_break (gdbarch); | + memcpy (context_offset, &value, size); | + } | + else | + { | + gdb_assert (size == 8); | + uint64_t value; | + memcpy (&value, context_offset, size); | + value -= gdbarch_decr_pc_after_break (gdbarch); | + memcpy (context_offset, &value, size); | + } | + } PS2, Line 637: Clever to do this here. | + regcache->raw_supply (r, context_offset); | + } | } | | void | windows_nat_target::fetch_registers (struct regcache *regcache, int r) | { | DWORD tid = regcache->ptid ().lwp (); | windows_thread_info *th = thread_rec (tid, INVALIDATE_CONTEXT); -- Gerrit-Project: binutils-gdb Gerrit-Branch: master Gerrit-Change-Id: I5d0dd64c3d2d8220b534d3e02aeaa6f6815264ab Gerrit-Change-Number: 414 Gerrit-PatchSet: 2 Gerrit-Owner: Tom Tromey Gerrit-Reviewer: Joel Brobecker Gerrit-Reviewer: Luis Machado Gerrit-Reviewer: Pedro Alves Gerrit-Comment-Date: Fri, 29 Nov 2019 19:08:06 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment