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: [commit] Re: [rfc][1/2] Signal delivery + software single-step is broken


On Wednesday 27 April 2011 18:17:25, Ulrich Weigand wrote:
> +  /* Stepping over a breakpoint while at the same time delivering a signal
> +     has a problem: we cannot use displaced stepping, but we also cannot
> +     use software single-stepping, because we do not know where execution
> +     will continue if a signal handler is installed.
> +
> +     On the other hand, if there is a signal handler we'd have to step
> +     over it anyway.  So what we do instead is to install a step-resume
> +     handler at the current address right away, deliver the signal without
> +     stepping, and once we arrive back at the step-resume breakpoint, step
> +     once more over the original breakpoint we wanted to step over.  */
> +  if (oneproc && tp->suspend.stop_signal != TARGET_SIGNAL_0
> +      && execution_direction != EXEC_REVERSE)
> +    {
> +      insert_step_resume_breakpoint_at_frame (get_current_frame ());
> +      tp->step_after_step_resume_breakpoint = 1;
> +      oneproc = 0;
> +    }

This unfortunately somewhat breaks hardware-step archs:

(the below is a simple program that writes to 0, and has a
SIGSEGV handler installed)

Program received signal SIGSEGV, Segmentation fault.
0x00000000004008ca in main2 () at siginfo.c:104
104       *(int *)p = 0;
(gdb) b
Breakpoint 1 at 0x4008ca: file siginfo.c, line 104.
(gdb) si

Program received signal SIGTRAP, Trace/breakpoint trap.
handler (sig=0, info=0xffffefbd5a360000, context=0xffffffffb4400000) at siginfo.c:69
69      {
(gdb) 

Same with debug output (next, step or stepi, same thing):

(gdb) set debug infrun 1
(gdb) s
infrun: clear_proceed_status_thread (Thread 0x7ffff7fd5700 (LWP 18800))
infrun: proceed (addr=0xffffffffffffffff, signal=144, step=1)
infrun: inserting step-resume breakpoint at 0x4008ca
infrun: resume (step=1, signal=11), trap_expected=0
infrun: wait_for_inferior (treat_exec_as_sigtrap=0)
infrun: target_wait (-1, status) =
infrun:   18800 [Thread 0x7ffff7fd5700 (LWP 18800)],
infrun:   status->kind = stopped, signal = SIGTRAP
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x4007a7
infrun: random signal 5

Program received signal SIGTRAP, Trace/breakpoint trap.
infrun: stop_stepping
handler (sig=0, info=0xffffefbd5a360000, context=0xffffffffb4400000) at siginfo.c:69
69      {
(gdb) 

We'd previously step into the installed handler without
that spurious SIGTRAP:

Program received signal SIGSEGV, Segmentation fault.
infrun: stop_stepping
0x00000000004008ca in main2 () at siginfo.c:104
104       *(int *)p = 0;
(gdb) b
Breakpoint 2 at 0x4008ca: file siginfo.c, line 104.
(gdb) s
infrun: clear_proceed_status_thread (Thread 0x7ffff7fd5700 (LWP 18970))
infrun: proceed (addr=0xffffffffffffffff, signal=144, step=1)
infrun: resume (step=1, signal=11), trap_expected=1
infrun: wait_for_inferior (treat_exec_as_sigtrap=0)
infrun: target_wait (-1, status) =
infrun:   18970 [Thread 0x7ffff7fd5700 (LWP 18970)],
infrun:   status->kind = stopped, signal = SIGTRAP
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x4007a7
infrun: stepped to a different line
infrun: stop_stepping
handler (sig=32767, info=0xffffffffbe600000, context=0x7ffff7bb8b40) at siginfo.c:69
69      {
(gdb) 


-- 
Pedro Alves


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