Message ID | 20230511062001.2745878-1-zhiyong.yan@windriver.com |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D78B385414C for <patchwork@sourceware.org>; Thu, 11 May 2023 06:20:18 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mx0b-0064b401.pphosted.com (mx0b-0064b401.pphosted.com [205.220.178.238]) by sourceware.org (Postfix) with ESMTPS id 134833856970 for <gdb-patches@sourceware.org>; Thu, 11 May 2023 06:20:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 134833856970 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=windriver.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=windriver.com Received: from pps.filterd (m0250812.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34B5g7YD015453; Thu, 11 May 2023 06:20:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=PPS06212021; bh=Vi/GCVik4U4rLhoQh4SkgIFWOrrfPbDN5fkiZuBl3fc=; b=NDHK//Fapt75k8iBT9ere3e99M6K5OvRMAo7gfW9EN0ZMuvO8V90aox04NiQw7aCom9z l6pOg3lkAVaJK699qjsHqXQCqg0rrTGlQwVrqgiXFzYrGzXEw25rrVmxrOaA5FVo9Cy8 7y6Ey+S0bHysKZnx9YIKkTYLfPC8dY5P9emnnfkVbC0PfuVAPbTL392w2hfdCiyPqFCd VwrFxHT3EZ4I1JBxBnlt/Fc/M8lB+0WTm3XMXPjYE/y8gXVYDqQrGD3uejiC0T80AUcO KqlzOEjCZ0CLkFFlNJSDx731xBz5RPp0jHdAyi8UWn1oSp+LFCDopBsw/1NigqlPPWso kQ== Received: from ala-exchng01.corp.ad.wrs.com (unknown-82-252.windriver.com [147.11.82.252]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3qf8b92cmu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Thu, 11 May 2023 06:20:04 +0000 Received: from ALA-EXCHNG02.corp.ad.wrs.com (147.11.82.254) by ala-exchng01.corp.ad.wrs.com (147.11.82.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 10 May 2023 23:20:02 -0700 Received: from pek-lpd-ccm6.wrs.com (147.11.1.11) by ALA-EXCHNG02.corp.ad.wrs.com (147.11.82.254) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Wed, 10 May 2023 23:20:01 -0700 From: <zhiyong.yan@windriver.com> To: <gdb-patches@sourceware.org> CC: <tom@tromey.com>, <zhiyong.yan@windriver.com> Subject: [PATCH] [patch] gdbserver assert error on arm platform Date: Thu, 11 May 2023 14:20:01 +0800 Message-ID: <20230511062001.2745878-1-zhiyong.yan@windriver.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Proofpoint-GUID: vqVHaBjYmT4s34HT7p3itX-VryfUMRvf X-Proofpoint-ORIG-GUID: vqVHaBjYmT4s34HT7p3itX-VryfUMRvf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-10_04,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 impostorscore=0 clxscore=1011 lowpriorityscore=0 mlxlogscore=826 adultscore=0 spamscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305110053 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
gdbserver assert error on arm platform
|
|
Commit Message
Yan, Zhiyong
May 11, 2023, 6:20 a.m. UTC
From: Zhiyong Yan <zhiyong.yan@windriver.com> Bugzilla 30387 has given the steps of producing this issue on arm platform. Gdb should not assume pending threads always generate “a non-gdbserver trap event”, a “Signal 17” event could happen. Now that resume_stopped_resumed_lwps() -> may_hw_step() assumes that the break point must already exist, resume_one_thread() should ensure the software breaking point is installed although the thread is pending. LINK: https://sourceware.org/bugzilla/show_bug.cgi?id=30387 Signed-off-by: Zhiyong Yan zhiyong.yan@windriver.com --- gdbserver/linux-low.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
Comments
I have some formatting nits as well as a request for a test case. See below... On Thu, 11 May 2023 14:20:01 +0800 <zhiyong.yan@windriver.com> wrote: > From: Zhiyong Yan <zhiyong.yan@windriver.com> > > Bugzilla 30387 has given the steps of producing this issue on arm platform. > Gdb should not assume pending threads always generate ___a non-gdbserver trap event___, a ___Signal 17___ event could happen. > Now that resume_stopped_resumed_lwps() -> may_hw_step() assumes that the break point must already exist, resume_one_thread() should ensure the software breaking point is installed although the thread is pending. In addition to the provided patch, could you also add a test case? > > LINK: https://sourceware.org/bugzilla/show_bug.cgi?id=30387 s/LINK/Bug/ > > Signed-off-by: Zhiyong Yan zhiyong.yan@windriver.com > --- > gdbserver/linux-low.cc | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc > index e6a39202a98..543daf66376 100644 > --- a/gdbserver/linux-low.cc > +++ b/gdbserver/linux-low.cc > @@ -4670,8 +4670,16 @@ linux_process_target::resume_one_thread (thread_info *thread, > > proceed_one_lwp (thread, NULL); > } > - else > - threads_debug_printf ("leaving LWP %ld stopped", lwpid_of (thread)); > + else{ > + threads_debug_printf ("leaving LWP %ld stopped", lwpid_of (thread)); > + if(thread->last_resume_kind == resume_step){ Missing space before left paren and after right paren. > + /* > + * If resume_step is required by GDB, install single-step breakpoint. > + */ Format the above comment as: /* If resume_step is required by GDB, install single-step breakpoint. */ If you want to use a block comment, don't prefix each line with a '*'. Also, the trailing '*/' should be placed at the end of the last line in the block comment. Likewise for the leading '/*'. > + if (supports_software_single_step()) Missing space before '()'. > + install_software_single_step_breakpoints (lwp); > + } > + } > > thread->last_status.set_ignore (); > lwp->resume = NULL; > -- > 2.25.1 >
Hi, Did this patch get a chance of review ? Thanks! Zhiyong -----Original Message----- From: zhiyong.yan@windriver.com <zhiyong.yan@windriver.com> Sent: Thursday, May 11, 2023 2:20 PM To: gdb-patches@sourceware.org Cc: tom@tromey.com; Yan, Zhiyong <Zhiyong.Yan@windriver.com> Subject: [PATCH] [patch] gdbserver assert error on arm platform From: Zhiyong Yan <zhiyong.yan@windriver.com> Bugzilla 30387 has given the steps of producing this issue on arm platform. Gdb should not assume pending threads always generate “a non-gdbserver trap event”, a “Signal 17” event could happen. Now that resume_stopped_resumed_lwps() -> may_hw_step() assumes that the break point must already exist, resume_one_thread() should ensure the software breaking point is installed although the thread is pending. LINK: https://sourceware.org/bugzilla/show_bug.cgi?id=30387 Signed-off-by: Zhiyong Yan zhiyong.yan@windriver.com --- gdbserver/linux-low.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index e6a39202a98..543daf66376 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -4670,8 +4670,16 @@ linux_process_target::resume_one_thread (thread_info *thread, proceed_one_lwp (thread, NULL); } - else - threads_debug_printf ("leaving LWP %ld stopped", lwpid_of (thread)); + else{ + threads_debug_printf ("leaving LWP %ld stopped", lwpid_of (thread)); + if(thread->last_resume_kind == resume_step){ + /* + * If resume_step is required by GDB, install single-step breakpoint. + */ + if (supports_software_single_step()) + install_software_single_step_breakpoints (lwp); + } + } thread->last_status.set_ignore (); lwp->resume = NULL; -- 2.25.1
Hi Zhiyong, Kevin has posted a review back in may 11th: https://inbox.sourceware.org/gdb-patches/20230511140407.0a0977fb@f37-zws-nv/
Hi Bruno, The test case is attached into https://sourceware.org/bugzilla/show_bug.cgi?id=30387. Please look for "Luis Machado 2023-05-02 14:17:40 UTC" in Bugzilla comments, you can see Luis already produced this issue. I copy Produce step below, test app and gdb script can be found in the attachment. Produce step (This issue can only be produced on arm platform): (1) tar xvf gdbserver-test-app.tar on a host which can do arm-cross compile. (2) In osm.service, modify ExecStart path according to your running environment. (3) make (4) Please refer to "make install", install osm systemd service on target board. [On target board] systemctl daemon-reload systemctl start osm gdbserver --debug --debug-format=all --remote-debug --event-loop-debug --once --attach :1234 $(pgrep osm) [On pc host] your-arm-gdb ./osm(this is test app build out as above) -x ~/gdbx2 gdbx2 can be found in the attachment, please modify target-remote pointing to your target board's gdbserver in gdbx2. When gdb executes gdbx2, gdbserver will assert on target board. -----Original Message----- From: Bruno Larsen <blarsen@redhat.com> Sent: Tuesday, June 20, 2023 3:36 PM To: Yan, Zhiyong <Zhiyong.Yan@windriver.com>; gdb-patches@sourceware.org Cc: tom@tromey.com Subject: Re: [PATCH] [patch] gdbserver assert error on arm platform CAUTION: This email comes from a non Wind River email account! Do not click links or open attachments unless you recognize the sender and know the content is safe. Hi Zhiyong, Kevin has posted a review back in may 11th: https://inbox.sourceware.org/gdb-patches/20230511140407.0a0977fb@f37-zws-nv/ -- Cheers, Bruno On 19/06/2023 03:50, Yan, Zhiyong wrote: > Hi, > Did this patch get a chance of review ? > > Thanks! > Zhiyong > > > > -----Original Message----- > From: zhiyong.yan@windriver.com <zhiyong.yan@windriver.com> > Sent: Thursday, May 11, 2023 2:20 PM > To: gdb-patches@sourceware.org > Cc: tom@tromey.com; Yan, Zhiyong <Zhiyong.Yan@windriver.com> > Subject: [PATCH] [patch] gdbserver assert error on arm platform > > From: Zhiyong Yan <zhiyong.yan@windriver.com> > > Bugzilla 30387 has given the steps of producing this issue on arm platform. > Gdb should not assume pending threads always generate “a non-gdbserver trap event”, a “Signal 17” event could happen. > Now that resume_stopped_resumed_lwps() -> may_hw_step() assumes that the break point must already exist, resume_one_thread() should ensure the software breaking point is installed although the thread is pending. > > LINK: https://sourceware.org/bugzilla/show_bug.cgi?id=30387 > > Signed-off-by: Zhiyong Yan zhiyong.yan@windriver.com > --- > gdbserver/linux-low.cc | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index e6a39202a98..543daf66376 100644 > --- a/gdbserver/linux-low.cc > +++ b/gdbserver/linux-low.cc > @@ -4670,8 +4670,16 @@ linux_process_target::resume_one_thread (thread_info *thread, > > proceed_one_lwp (thread, NULL); > } > - else > - threads_debug_printf ("leaving LWP %ld stopped", lwpid_of (thread)); > + else{ > + threads_debug_printf ("leaving LWP %ld stopped", lwpid_of (thread)); > + if(thread->last_resume_kind == resume_step){ > + /* > + * If resume_step is required by GDB, install single-step breakpoint. > + */ > + if (supports_software_single_step()) > + install_software_single_step_breakpoints (lwp); > + } > + } > > thread->last_status.set_ignore (); > lwp->resume = NULL; > -- > 2.25.1 >
Hi Zhiyong, If possible, it'd be nice if you could write a test case which would run when a developer does "make check" (with suitable RUNTESTFLAGS and --target_board settings). I'd guess that you'd put your new .exp file and source file into gdb/testsuite/gdb.server. If you look around in that directory (and perhaps in some of the other testing directories too) you might find something similar upon which to base your new test. I know from experience that it's sometimes a hassle to write these test cases, but they're extremely useful in the long term because regression testing will show if/when the bug (or some other) crops up again. Here are a couple of links which might help you to rework your existing test into a test case for GDB: Testing GDB: https://sourceware.org/gdb/wiki/TestingGDB GDB Testcase Cookbook: https://sourceware.org/gdb/wiki/GDBTestcaseCookbook Please also note that I commented on some formatting nits. Please address those too. If you're wondering about GDB's coding conventions, please see: https://sourceware.org/gdb/wiki/ContributionChecklist#Properly_Formatted_Changes Kevin On Tue, 20 Jun 2023 08:08:52 +0000 "Yan, Zhiyong" <Zhiyong.Yan@windriver.com> wrote: > Hi Bruno, > The test case is attached into https://sourceware.org/bugzilla/show_bug.cgi?id=30387. Please look for "Luis Machado 2023-05-02 14:17:40 UTC" in Bugzilla comments, you can see Luis already produced this issue. > I copy Produce step below, test app and gdb script can be found in the attachment. > > Produce step (This issue can only be produced on arm platform): > > (1) tar xvf gdbserver-test-app.tar on a host which can do arm-cross compile. > (2) In osm.service, modify ExecStart path according to your running environment. > (3) make > (4) Please refer to "make install", install osm systemd service on target board. > > [On target board] > systemctl daemon-reload > systemctl start osm > gdbserver --debug --debug-format=all --remote-debug --event-loop-debug --once --attach :1234 $(pgrep osm) > > [On pc host] > your-arm-gdb ./osm(this is test app build out as above) -x ~/gdbx2 > > gdbx2 can be found in the attachment, please modify target-remote pointing to your target board's gdbserver in gdbx2. > > When gdb executes gdbx2, gdbserver will assert on target board. > > > -----Original Message----- > From: Bruno Larsen <blarsen@redhat.com> > Sent: Tuesday, June 20, 2023 3:36 PM > To: Yan, Zhiyong <Zhiyong.Yan@windriver.com>; gdb-patches@sourceware.org > Cc: tom@tromey.com > Subject: Re: [PATCH] [patch] gdbserver assert error on arm platform > > CAUTION: This email comes from a non Wind River email account! > Do not click links or open attachments unless you recognize the sender and know the content is safe. > > Hi Zhiyong, > > Kevin has posted a review back in may 11th: > https://inbox.sourceware.org/gdb-patches/20230511140407.0a0977fb@f37-zws-nv/ > > -- > Cheers, > Bruno > > On 19/06/2023 03:50, Yan, Zhiyong wrote: > > Hi, > > Did this patch get a chance of review ? > > > > Thanks! > > Zhiyong > > > > > > > > -----Original Message----- > > From: zhiyong.yan@windriver.com <zhiyong.yan@windriver.com> > > Sent: Thursday, May 11, 2023 2:20 PM > > To: gdb-patches@sourceware.org > > Cc: tom@tromey.com; Yan, Zhiyong <Zhiyong.Yan@windriver.com> > > Subject: [PATCH] [patch] gdbserver assert error on arm platform > > > > From: Zhiyong Yan <zhiyong.yan@windriver.com> > > > > Bugzilla 30387 has given the steps of producing this issue on arm platform. > > Gdb should not assume pending threads always generate ___a non-gdbserver trap event___, a ___Signal 17___ event could happen. > > Now that resume_stopped_resumed_lwps() -> may_hw_step() assumes that the break point must already exist, resume_one_thread() should ensure the software breaking point is installed although the thread is pending. > > > > LINK: https://sourceware.org/bugzilla/show_bug.cgi?id=30387 > > > > Signed-off-by: Zhiyong Yan zhiyong.yan@windriver.com > > --- > > gdbserver/linux-low.cc | 12 ++++++++++-- > > 1 file changed, 10 insertions(+), 2 deletions(-) > > > > diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index e6a39202a98..543daf66376 100644 > > --- a/gdbserver/linux-low.cc > > +++ b/gdbserver/linux-low.cc > > @@ -4670,8 +4670,16 @@ linux_process_target::resume_one_thread (thread_info *thread, > > > > proceed_one_lwp (thread, NULL); > > } > > - else > > - threads_debug_printf ("leaving LWP %ld stopped", lwpid_of (thread)); > > + else{ > > + threads_debug_printf ("leaving LWP %ld stopped", lwpid_of (thread)); > > + if(thread->last_resume_kind == resume_step){ > > + /* > > + * If resume_step is required by GDB, install single-step breakpoint. > > + */ > > + if (supports_software_single_step()) > > + install_software_single_step_breakpoints (lwp); > > + } > > + } > > > > thread->last_status.set_ignore (); > > lwp->resume = NULL; > > -- > > 2.25.1 > > >
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index e6a39202a98..543daf66376 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -4670,8 +4670,16 @@ linux_process_target::resume_one_thread (thread_info *thread, proceed_one_lwp (thread, NULL); } - else - threads_debug_printf ("leaving LWP %ld stopped", lwpid_of (thread)); + else{ + threads_debug_printf ("leaving LWP %ld stopped", lwpid_of (thread)); + if(thread->last_resume_kind == resume_step){ + /* + * If resume_step is required by GDB, install single-step breakpoint. + */ + if (supports_software_single_step()) + install_software_single_step_breakpoints (lwp); + } + } thread->last_status.set_ignore (); lwp->resume = NULL;