mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Daniel Jacobowitz <dan@debian.org>
Cc: Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Cagney <cagney@redhat.com>,
	Roland McGrath <roland@redhat.com>
Subject: Re: More trouble with i386 EFLAGS and ptrace
Date: Sun, 6 Mar 2005 12:03:22 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0503061155280.2304@ppc970.osdl.org> (raw)
In-Reply-To: <20050306193840.GA26114@nevyn.them.org>


On Sun, 6 Mar 2005, Daniel Jacobowitz wrote:
> 
> The reason this happens is that when the inferior hits a breakpoint, the
> first thing GDB will do is remove the breakpoint, single-step past it, and
> reinsert it.  So GDB does a PTRACE_SINGLESTEP, and the kernel invokes the
> signal handler (without single-step - good so far).

No, not good so far.

Yes, it cleared TF, but it saved eflags with TF set on-stack, even though 
the TF was due to a TIF_SINGLESTEP (and was thus "temporary", not a real 
flag). That's why you see the bogus SIGTRAP after returning from the 
signal handler.

Now, we actually get this _right_ if the signal is due to a single-step, 
because do_debug() will do:

                if (likely(tsk->ptrace & PT_DTRACE)) {
                        tsk->ptrace &= ~PT_DTRACE;
                        regs->eflags &= ~TF_MASK;
                }

but that's the only place we do that. So any _other_ signal won't do this, 
and we'll enter the signal handler without checking the PT_DTRACE flag to 
see if TF was a temporary thing from debugger rather than something the 
program actually did on its own.

I _think_ your test-case would work right if you just moved that code from
the special-case in do_debug(), and moved it to the top of
setup_sigcontext() instead. I've not tested it, though, and haven't really 
given it any "deep thought". Maybe somebody smarter can say "yeah, that's 
obviously the right thing to do" or "no, that won't work because.."

		Linus

  reply	other threads:[~2005-03-06 20:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-06 19:38 Daniel Jacobowitz
2005-03-06 20:03 ` Linus Torvalds [this message]
2005-03-06 21:14   ` Daniel Jacobowitz
2005-03-07  0:46     ` Linus Torvalds
2005-03-06 21:22   ` Roland McGrath
2005-03-06 22:13     ` Daniel Jacobowitz
     [not found]       ` <200503070316.j273Gb4G027048@magilla.sf.frob.com>
2005-03-07  4:49         ` Daniel Jacobowitz
2005-03-07 21:29           ` Roland McGrath
2005-03-09  0:12             ` Daniel Jacobowitz
2005-03-13  8:27               ` Roland McGrath
2005-03-13 20:06                 ` Daniel Jacobowitz
2005-03-07 19:13     ` Andi Kleen
2005-03-06 20:26 ` Daniel Jacobowitz
2005-03-14  4:06 Jesse Allen
2005-03-14  4:12 Jesse Allen

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=Pine.LNX.4.58.0503061155280.2304@ppc970.osdl.org \
    --to=torvalds@osdl.org \
    --cc=cagney@redhat.com \
    --cc=dan@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roland@redhat.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

all inboxes | Powered by JetHome®