From: Pedro Alves <alves.ped@gmail.com>
To: gdb-patches@sourceware.org, Eli Zaretskii <eliz@gnu.org>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>,
mark.kettenis@xs4all.nl, brobecker@adacore.com
Subject: Re: Code formatting [Re: [patch] s390*: watchpoints regression [repost]]
Date: Tue, 20 Dec 2011 14:29:00 -0000 [thread overview]
Message-ID: <201112201041.44282.alves.ped@gmail.com> (raw)
In-Reply-To: <83r501zrjw.fsf@gnu.org>
On Sunday 18 December 2011 18:02:43, Eli Zaretskii wrote:
> > Date: Sun, 18 Dec 2011 18:24:18 +0100
> > From: Jan Kratochvil <jan.kratochvil@redhat.com>
> > Cc: Mark Kettenis <mark.kettenis@xs4all.nl>, brobecker@adacore.com,
> > gdb-patches@sourceware.org, pedro@codesourcery.com
> >
> > You dropped the important part about "still going through the shell", that was
> > the surprising fact to note there.
> >
> > If you do not drop that shell part of the text the Pedro's text becomes
> > shorter, therefore more clear.
>
> Then don't drop it. I think I dropped it by mistake. Anyway, it was
> just an example of how to reword a comment to avoid the problem that
> started this thread.
Thanks. Here's what I checked in.
2011-12-20 Pedro Alves <alves.ped@gmail.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
* linux-nat.c (add_lwp): Don't call linux_nat_new_thread on the
first LWP.
* amd64-linux-nat.c (update_debug_registers_callback): Instantiate
`lwp->arch_private' if NULL.
(amd64_linux_prepare_to_resume): Do nothing if `lwp->arch_private'
is NULL.
* i386-linux-nat.c (update_debug_registers_callback): Instantiate
`lwp->arch_private' if NULL.
(i386_linux_prepare_to_resume): Do nothing if `lwp->arch_private'
is NULL.
---
gdb/amd64-linux-nat.c | 9 +++++++++
gdb/i386-linux-nat.c | 9 +++++++++
gdb/linux-nat.c | 10 +++++++++-
3 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index 288160b..865b971 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -343,6 +343,9 @@ amd64_linux_dr_get_status (void)
static int
update_debug_registers_callback (struct lwp_info *lwp, void *arg)
{
+ if (lwp->arch_private == NULL)
+ lwp->arch_private = XCNEW (struct arch_lwp_info);
+
/* The actual update is done later just before resuming the lwp, we
just mark that the registers need updating. */
lwp->arch_private->debug_registers_changed = 1;
@@ -386,6 +389,12 @@ amd64_linux_prepare_to_resume (struct lwp_info *lwp)
{
int clear_status = 0;
+ /* NULL means this is the main thread still going through the shell,
+ or, no watchpoint has been set yet. In that case, there's
+ nothing to do. */
+ if (lwp->arch_private == NULL)
+ return;
+
if (lwp->arch_private->debug_registers_changed)
{
struct i386_debug_reg_state *state = i386_debug_reg_state ();
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index 190979b..4527913 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -715,6 +715,9 @@ i386_linux_dr_get_status (void)
static int
update_debug_registers_callback (struct lwp_info *lwp, void *arg)
{
+ if (lwp->arch_private == NULL)
+ lwp->arch_private = XCNEW (struct arch_lwp_info);
+
/* The actual update is done later just before resuming the lwp, we
just mark that the registers need updating. */
lwp->arch_private->debug_registers_changed = 1;
@@ -758,6 +761,12 @@ i386_linux_prepare_to_resume (struct lwp_info *lwp)
{
int clear_status = 0;
+ /* NULL means this is the main thread still going through the shell,
+ or, no watchpoint has been set yet. In that case, there's
+ nothing to do. */
+ if (lwp->arch_private == NULL)
+ return;
+
if (lwp->arch_private->debug_registers_changed)
{
struct i386_debug_reg_state *state = i386_debug_reg_state ();
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 1cbfc44..e5f7c3e 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1151,7 +1151,15 @@ add_lwp (ptid_t ptid)
lp->next = lwp_list;
lwp_list = lp;
- if (linux_nat_new_thread != NULL)
+ /* Let the arch specific bits know about this new thread. Current
+ clients of this callback take the opportunity to install
+ watchpoints in the new thread. Don't do this for the first
+ thread though. If we're spawning a child ("run"), the thread
+ executes the shell wrapper first, and we shouldn't touch it until
+ it execs the program we want to debug. For "attach", it'd be
+ okay to call the callback, but it's not necessary, because
+ watchpoints can't yet have been inserted into the inferior. */
+ if (num_lwps (GET_PID (ptid)) > 1 && linux_nat_new_thread != NULL)
linux_nat_new_thread (lp);
return lp;
next prev parent reply other threads:[~2011-12-20 10:42 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-17 12:22 [obv] s390*: Fix build regression, remains execution regression Jan Kratochvil
2011-12-17 12:33 ` Pedro Alves
2011-12-17 19:37 ` [patch] s390*: watchpoints regression [Re: [obv] s390*: Fix build regression] Jan Kratochvil
2011-12-17 19:44 ` Pedro Alves
2011-12-17 19:45 ` Jan Kratochvil
2011-12-17 19:56 ` [patch] s390*: watchpoints regression [repost] Jan Kratochvil
2011-12-17 20:13 ` Pedro Alves
2011-12-17 20:35 ` Pedro Alves
2011-12-17 21:08 ` Jan Kratochvil
2011-12-18 6:37 ` Joel Brobecker
2011-12-18 10:11 ` Jan Kratochvil
2011-12-18 11:38 ` Joel Brobecker
2011-12-18 12:38 ` Code formatting [Re: [patch] s390*: watchpoints regression [repost]] Jan Kratochvil
2011-12-18 15:50 ` Mark Kettenis
2011-12-18 17:24 ` Eli Zaretskii
2011-12-18 17:57 ` Jan Kratochvil
2011-12-18 18:45 ` Eli Zaretskii
2011-12-20 14:29 ` Pedro Alves [this message]
2011-12-18 11:42 ` [patch] s390*: watchpoints regression [repost] Eli Zaretskii
2011-12-19 21:37 ` Ulrich Weigand
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=201112201041.44282.alves.ped@gmail.com \
--to=alves.ped@gmail.com \
--cc=brobecker@adacore.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=mark.kettenis@xs4all.nl \
/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