public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paulo Marques <pmarques@grupopie.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [SOLVED] Trap flag handling change in 2.6.10-bk5 broke Kylix debugger
Date: Fri, 17 Feb 2006 14:45:56 +0000	[thread overview]
Message-ID: <43F5E1A4.7060502@grupopie.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0602161127040.916@g5.osdl.org>

Linus Torvalds wrote:
> On Thu, 16 Feb 2006, Paulo Marques wrote:
> [...]
>>I did a workaround in the interposer (remembering that a single step was
>>requested so that it sets the trap flag on the next call to ptrace) and the
>>debugger actually works, but I would prefer to do it better.
> 
> Ok. It does seem like the debugger is using the TF bit in the debuggee to 
> "remember" whether it was single-stepping or not.
> 
> Which is pretty insane.

It sure is :P

>>BTW, is there a good way to do the "test_tsk_thread_flag(child,
>>TIF_SINGLESTEP)" from user space?
> 
> Not really. Except you should just remember that you asked for 
> single-stepping. That, together with the status return on the wait (which 
> tells you why the process stopped - the single-step could have been 
> aborted because of a real fault), should be plenty good enough, and sounds 
> like the natural way to do this.

I think I can do a better interposer, then. I can interpose both the 
ptrace and the wait functions so that I can keep an internal "is being 
single stepped" state for each process being ptrace'd.

> Relying on the TF bit, which is under the control of the debugged 
> application itself, is kind of hokey.

If I understand this correctly, if the kernel had some other way of 
producing a single step (a new flag on newer processors, a timer 
interrupt going on after one cycle, whatever) it might not even set the 
trap flag at all, and still execute perfectly well the ptrace syscalls, 
with all the expected signals being generated, etc.

So this is very much implementation dependent, and the application 
should not rely on internal kernel mechanisms like that...

> So your patch isn't too intrusive, which is nice. The thing that _isn't_ 
> nice about it is that it means that the debugger cannot actually set the 
> TF bit "for real" on the process it is debugging, and it cannot really ask 
> for what the state of the TF bit is (because it will be overshadowed by 
> the debugger single-stepping).

The patch wasn't meant to be used like that. It was just to show what 
was needed to make the debugger happy.

At the very least, the patch needs a lot more comments and a quarantine 
on -mm before it can be used on mainline.

> So I like your patch because it re-instates old (admittedly broken) 
> behaviour without breaking the _internal_ kernel logic (just the "external 
> interface"). And while the old behaviour _was_ broken, being backwards 
> compatible is damn important.
>
> That said, I'd be a lot happier if we could just fix Kylix instead ;(

The interposer is the closest thing we have to "fixing kylix". I think 
most kylix users will be perfectly happy with the interposer and we 
really don't need to change the kernel. They are already used to work 
around problems that arise from the total staleness of the project.

I'll try to send a few posts to Kylix forums with the interposer thing 
and see how well it is accepted.

 From what I've heard, Borland is selling its languages, including 
Delphi and Kylix, so maybe the company that buys it will be more willing 
to properly maintain kylix in the future :)

-- 
Paulo Marques - www.grupopie.com

Pointy-Haired Boss: I don't see anything that could stand in our way.
            Dilbert: Sanity? Reality? The laws of physics?

      reply	other threads:[~2006-02-17 14:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-14 20:21 Trap flag handling change in 2.6.10-bk5 broke Kylix debugger Paulo Marques
2006-02-14 20:52 ` Linus Torvalds
2006-02-15 17:43   ` Paulo Marques
2006-02-16 12:07     ` [SOLVED] " Paulo Marques
2006-02-16 19:34       ` Linus Torvalds
2006-02-17 14:45         ` Paulo Marques [this message]

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=43F5E1A4.7060502@grupopie.com \
    --to=pmarques@grupopie.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /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