From: "Pedro Alves (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io>
To: Tom Tromey <tromey@sourceware.org>, gdb-patches@sourceware.org
Cc: Joel Brobecker <brobecker@adacore.com>,
Luis Machado <luis.machado@linaro.org>
Subject: [review v2] Handle pending stops from the Windows kernel
Date: Fri, 29 Nov 2019 19:08:00 -0000 [thread overview]
Message-ID: <20191129190806.818ED20AF6@gnutoolchain-gerrit.osci.io> (raw)
In-Reply-To: <gerrit.1572371871000.I5d0dd64c3d2d8220b534d3e02aeaa6f6815264ab@gnutoolchain-gerrit.osci.io>
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<char> 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 <tromey@sourceware.org>
Gerrit-Reviewer: Joel Brobecker <brobecker@adacore.com>
Gerrit-Reviewer: Luis Machado <luis.machado@linaro.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Comment-Date: Fri, 29 Nov 2019 19:08:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
prev parent reply other threads:[~2019-11-29 19:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-29 18:05 [review] " Tom Tromey (Code Review)
2019-11-04 14:40 ` Luis Machado (Code Review)
2019-11-14 20:27 ` Pedro Alves
2019-11-19 14:20 ` Tom Tromey
2019-11-19 17:22 ` Pedro Alves
2019-11-26 17:08 ` Tom Tromey
2019-11-19 1:01 ` Joel Brobecker (Code Review)
2019-11-26 17:16 ` [review v2] " Tom Tromey (Code Review)
2019-11-29 19:08 ` Pedro Alves (Code Review) [this message]
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=20191129190806.818ED20AF6@gnutoolchain-gerrit.osci.io \
--to=gerrit@gnutoolchain-gerrit.osci.io \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=gnutoolchain-gerrit@osci.io \
--cc=luis.machado@linaro.org \
--cc=tromey@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: link
Be 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).