This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix problem on solaris with single stepping and signal handling


On Thu, Jan 25, 2007 at 10:37:54AM -0700, Fred Fish wrote:
> There is a problem on Solaris with signals that are being caught by
> gdb and not passed on to the inferior.  It can be reproduced as
> follows:
> 
> (1) Set a breakpoint and run the program until gdb stops at the
> breakpoint
> 
> (2) Send the stopped process a signal like SIGALRM
> 
> (3) Try to single step the stopped process
> 
> (4) The process either will remain at the breakpoint or run freely to
> the next breakpoint and/or exit.  I've seen both behaviors.
> 
> The problem is that gdb is unnecessarily setting a step resume
> breakpoint for signals that are not going to be passed to the
> inferior.  Then in a later pass through handle_inferior_event, the
> presence of this breakpoint, after the inferior has stepped off the
> breakpoint, allows the inferior to free run instead of stopping (for
> the free run case), which makes sense if you want it to run the signal
> handler and then break when it returns to the location of the step
> resume breakpoint.  What actually happens of course is that gdb simply
> steps off the breakpoint and then free runs the code it would have
> executed in the absence of the signal.

I'm worried that this is the wrong fix.  I might easily be wrong here
though, so take with a grain of salt.

You're avoiding inserting the step resume breakpoint in some case. 
This is an optimization, and not a bad idea.  But suppose we were going
to pass the signal to the inferior, but it was going to ignore it
(signal (SIGALRM, SIG_IGN)).  Wouldn't exactly the same bug
manifest that you're trying to fix?

Seems to me that we're confused because we've forcibly stepped past the
single step breakpoint and ended up on the other side of it instead of
on the first instruction of a signal handler.  We'd need to detect that
we didn't step into a signal handler, and treat it like hitting the
step resume breakpoint, perhaps.

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]