Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: "Ulrich Weigand" <uweigand@de.ibm.com>
Subject: Re: [commit] Re: [rfc][1/2] Signal delivery + software single-step is broken
Date: Wed, 27 Apr 2011 18:15:00 -0000	[thread overview]
Message-ID: <201104271915.05190.pedro@codesourcery.com> (raw)
In-Reply-To: <201104271717.p3RHHPEL005251@d06av02.portsmouth.uk.ibm.com>

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


  reply	other threads:[~2011-04-27 18:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-19 16:43 Ulrich Weigand
2011-04-27 17:17 ` [commit] " Ulrich Weigand
2011-04-27 18:15   ` Pedro Alves [this message]
2011-04-27 19:12     ` Ulrich Weigand
2011-04-27 19:44       ` Pedro Alves
2011-04-28  8:55         ` [patch] " Ulrich Weigand
2011-04-28 12:01           ` Pedro Alves
2011-04-28 15:18             ` [patch v2] " Ulrich Weigand
2011-04-28 15:46               ` Pedro Alves
2011-04-28 16:04                 ` Ulrich Weigand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201104271915.05190.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=uweigand@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox