Re: [PATCH 1/1] ptrace: Get tracer PID without reliance on the proc FS

From: Roman Kisel
Date: Wed Sep 11 2024 - 16:25:20 EST




On 9/11/2024 12:53 PM, Oleg Nesterov wrote:
Roman,

I can only repeat that we can't understand each other. Quite possibly my bad.


Oleg,

I'll re-read the whole thread to see where I can improve.
Didn't mean to cause the undue burden for you. My apologies, will make a
note to myself to be crisper and more concise at the very least.

On 09/11, Roman Kisel wrote:

On 09/11, Oleg Nesterov wrote:

On 09/10, Roman Kisel wrote:

On 09/09, Oleg wrote:


Yet another thing in this discussion I can't understand... sorry, I tried.
You do not need to teach, say, gdb to recognize this pattern. You can just do

$ gdb -ex 'b please_insert_the_breakpoint_here' ...

Nevermind, as I have already said you can safely ignore me. I still do not
see any "real" use-case for breakpoint_if_debugging(), but I guess that is
due to my ignorance and lack of imagination.

I've started this so let me butt in and take up the gaunlet.

Lambda's would be the most prominent example to me[1]. The toolchain
doesn't give them the user-accesible type and the name as it does for
the functions.

And?

You wanted an example of '"real" use-case for breakpoint_if_debugging()':

Then why does your email explain that c++ lambdas don't have a good name?
Why doesi it mention lambdas at all?


I was making the point that setting a breakpoint on the lambda is quite
laborious, and instead one can put "breakpoint_if_debugging()" inside
of it.

Nevermind, as I have already said you can safely ignore me. I still do not
see any "real" use-case for breakpoint_if_debugging(), but I guess that is
due to my ignorance and lack of imagination.

I have provided them, and illustrated how it is tiresome to set the breakpoint
in the debugger in these cases so can add a call to breakpoint_if_debugging()
to these places instead.

Instead of what??? Instead of

#define breakpoint_if_debugging() \
asm volatile ("call please_insert_the_breakpoint_here" : ASM_CALL_CONSTRAINT);

plus -ex 'b please_insert_the_breakpoint_here'???

If you say that this is ugly I won't even argue. But instead of what?

Roman, I am leaving this thread, sorry. But let me try to summarize.
Your patch was buggy and you seem to agree. Feel free to send V2 and I will
be happy to review it correctness-wise. But:

- please keep Eric/Linus cc'ed

- please try to make your changelog more convincing. And in particular,
please explain why !!current->ptrace is not enough and this feature
needs the tracer's pid.

If possible, please provide a clear/simple/artificial/whatever example
of the (pseudo)code which can justify this feature.

Oleg,

I owe you a great deal of gratitude for giving my arguments a chance! I
won't reply more to this thread, too. Will use the relevant points
from the list you kindly provided where that applies when posting
to LKML in the future.

Oleg.

--
Thank you,
Roman