public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [patch] gdbserver assert error on arm platform
@ 2023-05-11  6:20 zhiyong.yan
  2023-05-11 21:04 ` Kevin Buettner
  2023-06-19  1:50 ` Yan, Zhiyong
  0 siblings, 2 replies; 6+ messages in thread
From: zhiyong.yan @ 2023-05-11  6:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: tom, zhiyong.yan

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [patch] gdbserver assert error on arm platform
  2023-05-11  6:20 [PATCH] [patch] gdbserver assert error on arm platform zhiyong.yan
@ 2023-05-11 21:04 ` Kevin Buettner
  2023-06-19  1:50 ` Yan, Zhiyong
  1 sibling, 0 replies; 6+ messages in thread
From: Kevin Buettner @ 2023-05-11 21:04 UTC (permalink / raw)
  To: zhiyong.yan; +Cc: gdb-patches, tom

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
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] [patch] gdbserver assert error on arm platform
  2023-05-11  6:20 [PATCH] [patch] gdbserver assert error on arm platform zhiyong.yan
  2023-05-11 21:04 ` Kevin Buettner
@ 2023-06-19  1:50 ` Yan, Zhiyong
  2023-06-20  7:35   ` Bruno Larsen
  1 sibling, 1 reply; 6+ messages in thread
From: Yan, Zhiyong @ 2023-06-19  1:50 UTC (permalink / raw)
  To: gdb-patches; +Cc: tom

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [patch] gdbserver assert error on arm platform
  2023-06-19  1:50 ` Yan, Zhiyong
@ 2023-06-20  7:35   ` Bruno Larsen
  2023-06-20  8:08     ` Yan, Zhiyong
  0 siblings, 1 reply; 6+ messages in thread
From: Bruno Larsen @ 2023-06-20  7:35 UTC (permalink / raw)
  To: Yan, Zhiyong, gdb-patches; +Cc: tom

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
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] [patch] gdbserver assert error on arm platform
  2023-06-20  7:35   ` Bruno Larsen
@ 2023-06-20  8:08     ` Yan, Zhiyong
  2023-06-22  1:44       ` Kevin Buettner
  0 siblings, 1 reply; 6+ messages in thread
From: Yan, Zhiyong @ 2023-06-20  8:08 UTC (permalink / raw)
  To: Bruno Larsen, gdb-patches; +Cc: tom

[-- Attachment #1: Type: text/plain, Size: 3721 bytes --]

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
>


[-- Attachment #2: gdbserver-test-app.tar --]
[-- Type: application/x-tar, Size: 10240 bytes --]

[-- Attachment #3: gdbx2 --]
[-- Type: application/octet-stream, Size: 356 bytes --]

# gdbserver --once --attach :1234 $(pgrep eqptCntrl)

set pagination off

#target remote 128.224.176.94:1234
target remote 128.224.178.123:1234

#set logging file pr29742-host.log
#set logging enabled

#set debug remote 1
#set debug remote-packet-max-chars unlimited

handle SIG32 nostop noprint
handle SIGSTOP nostop noprint

b lpudated.c:92

c
n
n
n
n
n

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [patch] gdbserver assert error on arm platform
  2023-06-20  8:08     ` Yan, Zhiyong
@ 2023-06-22  1:44       ` Kevin Buettner
  0 siblings, 0 replies; 6+ messages in thread
From: Kevin Buettner @ 2023-06-22  1:44 UTC (permalink / raw)
  To: Yan, Zhiyong; +Cc: gdb-patches, Bruno Larsen, tom

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
> >  
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-06-22  1:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-11  6:20 [PATCH] [patch] gdbserver assert error on arm platform zhiyong.yan
2023-05-11 21:04 ` Kevin Buettner
2023-06-19  1:50 ` Yan, Zhiyong
2023-06-20  7:35   ` Bruno Larsen
2023-06-20  8:08     ` Yan, Zhiyong
2023-06-22  1:44       ` Kevin Buettner

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).