Re: [RFC] Proposal for ptrace improvements

From: Denys Vlasenko
Date: Tue Mar 01 2011 - 18:51:50 EST


On Tue, Mar 1, 2011 at 7:34 PM, Tejun Heo <tj@xxxxxxxxxx> wrote:
> On Tue, Mar 01, 2011 at 06:21:49PM +0100, Denys Vlasenko wrote:
>> > gdb can do whatever it wants to do but I don't think the above needs
>> > fixing.  In the first case, the user is explicitly telling gdb to
>> > continue the tracee, so it continues as it always has.
>>
>> It does not look like that to me.
>>
>> User attached to some process. User might be unaware that
>> the process is currently stopped (imagine a group of processes
>> which use SIGSTOP/SIGCONT in their normal interactions).
>>
>> User peeked some state, and then wants to let process
>> continue whatever process was doing, but remain in the debugger.
>>
>> What user did not know is that "whatever process was doing" =
>> "being stopped by SIGSTOP, waiting to be woken up".
>> Therefore, if "continue" makes process run, it does not
>> return process to whatever process was doing.
>>
>> > In the latter
>> > case, the debugging session is over.  The tracee now should do
>> > whatever it's supposed to do.
>>
>> It should do that in both cases.
>
> Maybe it should, maybe not, but that's mostly irrelevant because the
> described behavior is the current behavior.

This is not a good argument. We are in this discussion exactly because
there are cases of current behavior in strace and gdb which are clearly
wrong and which we want to change. Therefore, "it's the current
behavior" does not automatically mean it is desired behavior.

> There is no
> continue-if-not-job-control-stopped operation and we shouldn't change
> that beneath gdb

I feel that "continue" is meant to be such operation. Currently
it is not merely because ptrace is buggy.

There is already continue-no-matter-what command in gdb:

(gdb) signal SIGCONT

> because otherwise not only the behavior changes
> unexpectedly

"strace no longer breaks ^Z" is also an unexpected
change in behavior. This doesn't mean we should avoid it,
right?

Bottom line is: I am not trying to shoot your proposal down.
It looks good to me.

I am only discussing it in more detail from the userspace API
POV and from "what changes will be needed in strace and gdb?"
and "what improvements in strace and gdb are becoming possible
with this proposal, and how exactly to implement them there?"
POVs.

--
vda
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/