Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA Darwin]: handle simultaneous signal posting and single-stepping
@ 2009-07-07  8:52 Tristan Gingold
  2009-07-07  9:45 ` Mark Kettenis
  0 siblings, 1 reply; 3+ messages in thread
From: Tristan Gingold @ 2009-07-07  8:52 UTC (permalink / raw)
  To: gdb-patches

Hi,

in some cases (when a signal was received when the execution was  
stopped on a breakpoint), gdb resumes the
inferior with both step=1 and signal != 0.  This case wasn't handled  
correctly by darwin-nat (as the native
API isn't able to do that).

This patch fixes the issue by first single-stepping and keeping in  
mind that a signal has to be posted.

This patch fixes about 10 regressions (that resulted in timeout).

Tristan.

2009-07-07  Tristan Gingold  <gingold@adacore.com>

	* darwin-nat.c (darwin_resume_thread): Handle simultaneous single-step
	and signal.
	* darwin-nat.h (struct private_thread_info): Add signal_to_send field.
	Improve comment.


Index: darwin-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/darwin-nat.c,v
retrieving revision 1.13
diff -u -p -r1.13 darwin-nat.c
--- darwin-nat.c	22 Jun 2009 08:24:29 -0000	1.13
+++ darwin-nat.c	7 Jul 2009 08:50:45 -0000
@@ -640,6 +640,19 @@ darwin_resume_thread (struct inferior *i
      (3, _("darwin_resume_thread: state=%d, thread=0x%x, step=%d  
nsignal=%d\n"),
       thread->msg_state, thread->gdb_port, step, nsignal);

+  if (step && nsignal)
+    {
+      /* We can't handle this in one step.  The expected behaviour is  
single
+         step first and then post the signal.  */
+      thread->signal_to_send = nsignal;
+      nsignal = 0;
+    }
+  else if (thread->signal_to_send && !step)
+    {
+      nsignal = thread->signal_to_send;
+      thread->signal_to_send = 0;
+    }
+
    switch (thread->msg_state)
      {
      case DARWIN_MESSAGE:
Index: darwin-nat.h
===================================================================
RCS file: /cvs/src/src/gdb/darwin-nat.h,v
retrieving revision 1.3
diff -u -p -r1.3 darwin-nat.h
--- darwin-nat.h	19 Jun 2009 14:30:30 -0000	1.3
+++ darwin-nat.h	7 Jul 2009 08:50:45 -0000
@@ -80,9 +80,13 @@ struct private_thread_info
    /* True if this thread is single-stepped.  */
    unsigned char single_step;

-  /* True if a signal was manually sent to the thread.  */
+  /* True if a signal was manually sent to the thread.  In this case,  
we don't
+     report that a signal was posted.  */
    unsigned char signaled;

+  /* Signal to be sent.  Used to handle simultaneous step and  
signal.  */
+  unsigned char signal_to_send;
+
    /* The last exception received.  */
    struct darwin_exception_msg event;
  };


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

* Re: [RFA Darwin]: handle simultaneous signal posting and single-stepping
  2009-07-07  8:52 [RFA Darwin]: handle simultaneous signal posting and single-stepping Tristan Gingold
@ 2009-07-07  9:45 ` Mark Kettenis
  2009-07-07 10:42   ` Tristan Gingold
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2009-07-07  9:45 UTC (permalink / raw)
  To: gingold; +Cc: gdb-patches

> From: Tristan Gingold <gingold@adacore.com>
> Date: Tue, 7 Jul 2009 10:52:15 +0200
> 
> Hi,
> 
> in some cases (when a signal was received when the execution was  
> stopped on a breakpoint), gdb resumes the
> inferior with both step=1 and signal != 0.  This case wasn't handled  
> correctly by darwin-nat (as the native
> API isn't able to do that).
> 
> This patch fixes the issue by first single-stepping and keeping in  
> mind that a signal has to be posted.

I'm not sure that single-stepping before sending the signal is right.
This means we'll execute an instruction (which potentially affects the
way signals are handled) before the program actually sees the signal.

I think a better way to do this is to continue with a signal while
keeping the breakpoints inserted, and deal with hitting the breakpoint
again in the appropriate way.

Also, I think this needs to be handled in the generic code.  I'm
facing the same problem on OpenBSD.

> 2009-07-07  Tristan Gingold  <gingold@adacore.com>
> 
> 	* darwin-nat.c (darwin_resume_thread): Handle simultaneous single-step
> 	and signal.
> 	* darwin-nat.h (struct private_thread_info): Add signal_to_send field.
> 	Improve comment.
> 
> 
> Index: darwin-nat.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/darwin-nat.c,v
> retrieving revision 1.13
> diff -u -p -r1.13 darwin-nat.c
> --- darwin-nat.c	22 Jun 2009 08:24:29 -0000	1.13
> +++ darwin-nat.c	7 Jul 2009 08:50:45 -0000
> @@ -640,6 +640,19 @@ darwin_resume_thread (struct inferior *i
>       (3, _("darwin_resume_thread: state=%d, thread=0x%x, step=%d  
> nsignal=%d\n"),
>        thread->msg_state, thread->gdb_port, step, nsignal);
> 
> +  if (step && nsignal)
> +    {
> +      /* We can't handle this in one step.  The expected behaviour is  
> single
> +         step first and then post the signal.  */
> +      thread->signal_to_send = nsignal;
> +      nsignal = 0;
> +    }
> +  else if (thread->signal_to_send && !step)
> +    {
> +      nsignal = thread->signal_to_send;
> +      thread->signal_to_send = 0;
> +    }
> +
>     switch (thread->msg_state)
>       {
>       case DARWIN_MESSAGE:
> Index: darwin-nat.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/darwin-nat.h,v
> retrieving revision 1.3
> diff -u -p -r1.3 darwin-nat.h
> --- darwin-nat.h	19 Jun 2009 14:30:30 -0000	1.3
> +++ darwin-nat.h	7 Jul 2009 08:50:45 -0000
> @@ -80,9 +80,13 @@ struct private_thread_info
>     /* True if this thread is single-stepped.  */
>     unsigned char single_step;
> 
> -  /* True if a signal was manually sent to the thread.  */
> +  /* True if a signal was manually sent to the thread.  In this case,  
> we don't
> +     report that a signal was posted.  */
>     unsigned char signaled;
> 
> +  /* Signal to be sent.  Used to handle simultaneous step and  
> signal.  */
> +  unsigned char signal_to_send;
> +
>     /* The last exception received.  */
>     struct darwin_exception_msg event;
>   };
> 
> 


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

* Re: [RFA Darwin]: handle simultaneous signal posting and single-stepping
  2009-07-07  9:45 ` Mark Kettenis
@ 2009-07-07 10:42   ` Tristan Gingold
  0 siblings, 0 replies; 3+ messages in thread
From: Tristan Gingold @ 2009-07-07 10:42 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches


On Jul 7, 2009, at 11:43 AM, Mark Kettenis wrote:
>>
>> This patch fixes the issue by first single-stepping and keeping in
>> mind that a signal has to be posted.
>
> I'm not sure that single-stepping before sending the signal is right.
> This means we'll execute an instruction (which potentially affects the
> way signals are handled) before the program actually sees the signal.
>
> I think a better way to do this is to continue with a signal while
> keeping the breakpoints inserted, and deal with hitting the breakpoint
> again in the appropriate way.

Doesn't this change the gdb behaviour ?  I have no strong opinion on  
this but this is
generally a concern.

> Also, I think this needs to be handled in the generic code.  I'm
> facing the same problem on OpenBSD.

Interesting.  So I have to work on infrun.c...

Thanks for the comment,
Tristan.


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

end of thread, other threads:[~2009-07-07 10:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-07  8:52 [RFA Darwin]: handle simultaneous signal posting and single-stepping Tristan Gingold
2009-07-07  9:45 ` Mark Kettenis
2009-07-07 10:42   ` Tristan Gingold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox