Message ID | 86vapqp6j6.fsf@gmail.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 14922 invoked by alias); 27 Apr 2017 09:02:44 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 14905 invoked by uid 89); 27 Apr 2017 09:02:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2278, wondering X-HELO: mail-wm0-f42.google.com Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Apr 2017 09:02:42 +0000 Received: by mail-wm0-f42.google.com with SMTP id m123so11835313wma.0 for <gdb-patches@sourceware.org>; Thu, 27 Apr 2017 02:02:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=M3oaaetjtFfMSttb1r+ypLhtSCtXlIDB/0eyEPxvwr8=; b=NFuzEuDFjJn6vjZu30TJEJVKissLI13ovF3I8w+NAVKlT4+5HZFGtgsdcOKD0APxsf 4kcq084p8vSg3DSIPOnCS7kG3cOT3nNg5RaKZSYBmOwYo90oeYjFUyugZ26EEvON8XL2 Q25XpH4Vj8A9vrnoI7b7P+4y/kY7OBI9JrUNuWsoInJ0/HKtXSh7XjeZdxZY5kZvbep+ b6/KZx5f7CU9HCF6LGHBvraud1hypIcgaSpfwgBAEJj/TMdrWPF944aVjWGKz8AmKAh+ Mlp5CSM7wVBk9wBbGyyf89BbQtnpa73VvERZT6cBL8ijMEILUeo/EIHY6Pb2MeB0t6HC 2Oxw== X-Gm-Message-State: AN3rC/5IxVFEb6jB+vyRLnJkPyEC7qCmn/JlWMJ7JOsh1O7awuFiFajw E5utYEcsKrTTmjLU X-Received: by 10.28.99.70 with SMTP id x67mr1293317wmb.42.1493283761832; Thu, 27 Apr 2017 02:02:41 -0700 (PDT) Received: from E107787-LIN ([194.214.185.158]) by smtp.gmail.com with ESMTPSA id f189sm5474789wmf.34.2017.04.27.02.02.40 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 27 Apr 2017 02:02:41 -0700 (PDT) From: Yao Qi <qiyaoltc@gmail.com> To: RAJESH DASARI <raajeshdasari@gmail.com> Cc: gdb-patches@sourceware.org Subject: Re: Reg : gdb crash is seen while attaching a process to gdb. References: <CAPXMrf8TH66vZtp+9riDpDR4fBizip5-LQtZ9+1nSfVaywTLxg@mail.gmail.com> <CAH=s-PPcmOkY-yPuGsDbE0L=Q=SC9qjw9afTZnHfRE_oMPTzVA@mail.gmail.com> <728178DD-B9FD-4695-A7FF-F13B829DFD2E@gmail.com> <864lyfp0b7.fsf@gmail.com> <CAPXMrf9sjaQ4DUF+2guOYNE2FGRsM7RCcnRxZZ6VT28xLu40ZA@mail.gmail.com> <CAPXMrf_+cHn9sjFY-yXy==cNoGS98cSmcV+R9TVLbeExru+NWQ@mail.gmail.com> Date: Thu, 27 Apr 2017 10:02:37 +0100 In-Reply-To: <CAPXMrf_+cHn9sjFY-yXy==cNoGS98cSmcV+R9TVLbeExru+NWQ@mail.gmail.com> (RAJESH DASARI's message of "Thu, 27 Apr 2017 11:42:59 +0530") Message-ID: <86vapqp6j6.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes |
Commit Message
Yao Qi
April 27, 2017, 9:02 a.m. UTC
RAJESH DASARI <raajeshdasari@gmail.com> writes: [Move it to gdb-patches@sourceware.org] > Could someone please provide comments. > > diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c > index 9d22773..68641f8 100644 > --- a/gdb/mips-linux-nat.c > +++ b/gdb/mips-linux-nat.c > @@ -634,9 +634,20 @@ mips_linux_new_thread (struct lwp_info *lp) > &watch_readback_valid, 0)) > return; > > + long r; > + r= ptrace (PTRACE_SET_WATCH_REGS, tid, &watch_mirror, NULL); > tid = ptid_get_lwp (lp->ptid); > - if (ptrace (PTRACE_SET_WATCH_REGS, tid, &watch_mirror, NULL) == -1) > - perror_with_name (_("Couldn't write debug register")); > + if ( r == -1L && errno == ESRCH ) > + { > + /* sleep for a while to eliminate race condition on update to kernel > + * task structure with the process state (STOP state of thread). > + */ > + usleep(10000); > + if ( ptrace (PTRACE_SET_WATCH_REGS, tid, &watch_mirror, NULL) == -1 ) > + { > + perror_with_name (_("Couldn't write debug register")); > + } > + } > } I am wondering why mips_linux_read_watch_registers (ptrace (PTRACE_GET_WATCH_REGS) is successful but ptrace (PTRACE_SET_WATCH_REGS) fails here. Looks they may use different lwpids. Does the patch work for you?
Comments
Hi , Yes it worked for me. Thanks, Rajesh Dasari. On Thu, Apr 27, 2017 at 2:32 PM, Yao Qi <qiyaoltc@gmail.com> wrote: > RAJESH DASARI <raajeshdasari@gmail.com> writes: > > [Move it to gdb-patches@sourceware.org] > >> Could someone please provide comments. >> >> diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c >> index 9d22773..68641f8 100644 >> --- a/gdb/mips-linux-nat.c >> +++ b/gdb/mips-linux-nat.c >> @@ -634,9 +634,20 @@ mips_linux_new_thread (struct lwp_info *lp) >> &watch_readback_valid, 0)) >> return; >> >> + long r; >> + r= ptrace (PTRACE_SET_WATCH_REGS, tid, &watch_mirror, NULL); >> tid = ptid_get_lwp (lp->ptid); >> - if (ptrace (PTRACE_SET_WATCH_REGS, tid, &watch_mirror, NULL) == -1) >> - perror_with_name (_("Couldn't write debug register")); >> + if ( r == -1L && errno == ESRCH ) >> + { >> + /* sleep for a while to eliminate race condition on update to kernel >> + * task structure with the process state (STOP state of thread). >> + */ >> + usleep(10000); >> + if ( ptrace (PTRACE_SET_WATCH_REGS, tid, &watch_mirror, NULL) == -1 ) >> + { >> + perror_with_name (_("Couldn't write debug register")); >> + } >> + } >> } > > I am wondering why mips_linux_read_watch_registers > (ptrace (PTRACE_GET_WATCH_REGS) is successful but > ptrace (PTRACE_SET_WATCH_REGS) fails here. Looks they may use different > lwpids. Does the patch work for you? > > -- > Yao (齐尧) > > From dc9b626b826b26431772271c9d9a3ee343d8a1e8 Mon Sep 17 00:00:00 2001 > From: Yao Qi <yao.qi@linaro.org> > Date: Thu, 27 Apr 2017 09:59:40 +0100 > Subject: [PATCH] Use lwpid from lwp_info instead of inferior_ptid > > gdb: > > 2017-04-27 Yao Qi <yao.qi@linaro.org> > > * mips-linux-nat.c (mips_linux_new_thread): Get lwpid from > lwp_info instead of getting from inferior_ptid. > > diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c > index 9596b49..c5c18fd 100644 > --- a/gdb/mips-linux-nat.c > +++ b/gdb/mips-linux-nat.c > @@ -624,14 +624,13 @@ write_watchpoint_regs (void) > static void > mips_linux_new_thread (struct lwp_info *lp) > { > - int tid; > + long tid = ptid_get_lwp (lp->ptid); > > - if (!mips_linux_read_watch_registers (ptid_get_lwp (inferior_ptid), > + if (!mips_linux_read_watch_registers (tid, > &watch_readback, > &watch_readback_valid, 0)) > return; > > - tid = ptid_get_lwp (lp->ptid); > if (ptrace (PTRACE_SET_WATCH_REGS, tid, &watch_mirror, NULL) == -1) > perror_with_name (_("Couldn't write debug register")); > }
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c index 9596b49..c5c18fd 100644 --- a/gdb/mips-linux-nat.c +++ b/gdb/mips-linux-nat.c @@ -624,14 +624,13 @@ write_watchpoint_regs (void) static void mips_linux_new_thread (struct lwp_info *lp) { - int tid; + long tid = ptid_get_lwp (lp->ptid); - if (!mips_linux_read_watch_registers (ptid_get_lwp (inferior_ptid), + if (!mips_linux_read_watch_registers (tid, &watch_readback, &watch_readback_valid, 0)) return; - tid = ptid_get_lwp (lp->ptid); if (ptrace (PTRACE_SET_WATCH_REGS, tid, &watch_mirror, NULL) == -1) perror_with_name (_("Couldn't write debug register")); }