teemperor added a comment.

Congrats on getting started on your first patch! I improving this error message 
really seems like a good idea.

From what I can see the error message here is identical to GDB's which is a 
different project with an incompatible license. No idea if this is large enough 
of a copy to bring us into the realm of copyright (not a lawyer), but I think 
formulating our own (maybe even better?) error message would anyway be a good 
idea. What about something along those lines:

  error: attach failed: <Whatever error we already would return here> (This 
line is just the normal LLDB attach error)
  Note that attaching might have failed due to the ptrace_scope security policy
  which restricts debuggers from attaching to other processes. See
  the ptrace_scope documentation for more information:
    https://www.kernel.org/doc/Documentation/security/Yama.txt
  The current ptrace_scope policy can be found here:
    /proc/sys/kernel/yama/ptrace_scope

(Not sure how I feel about linking to some internet URL, but I couldn't find 
any man page for Yama/ptrace_scope)

Also I wonder how we could make sure we emit this diagnostic in cases where the 
ptrace_scope is actually the reason for the failed attach. The proper way to 
check this seems to be checking the `errno` after we call `ptrace` and then 
propagate the error all the way back to `lldb` from `lldb-server`. From the 
`lldb` side I don't think we have any way of knowing why the attach actually 
failed so we would emit this error speculatively which doesn't seem ideal. It 
still sounds like a better solution than having just this generic error message 
that doesn't help anyone, so I think David's suggestion + a FIXME is maybe a 
good compromise here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106226/new/

https://reviews.llvm.org/D106226

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to