[Lldb-commits] [PATCH] D106226: [lldb] Improve error message when "lldb attach" fails

APOORV SACHAN via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 6 13:37:45 PDT 2021


apoos-maximus added a comment.

Hi, 
@DavidSpickett, @teemperor, @rupprecht

After our previous discussions, I have modified the patch.
Now :-

1. OS is detected in Target::Attach(), and reason for failure is analyzed accordingly.
2. ptrace_scope related error message is only emitted after checking :-
  - If /proc/sys/kernel/yama/ptrace_scope file exists
  - If it Exists weather it's value is non-zero.
  - If Either don't satisfy user is asked try again as the root user, as only possibly left (//I think..//) is that user is trying to debug a process, owned by the root user. In which case setting ptrace_policy to zero alone will not help.
3. Changed the Error Message to be more informative, and unique compared to gdb. I went with the kernel.org documentation as it's more generic to all linux OS es.

I have tested the above code by trying to debug a process on `localhost`, and also by debugging a remote process. It's works as expected.
I am yet to build this on  a windows machine, and test. As I don't own a Mac machine I'll need help from someone who does.
Only the Os detection scenario needs to be tested here, when attach fails i.e. process hasn't stopped.

Although this approach seems to work I am yet to implement the error-code approach suggested by @teemperor, I  have a few questions regarding the same :-

1. Will we have to introduce new Error Code particulary for the ptrace_conditon?
2. This logic will reside in Process::Attach() ?
3. Since Error code needs to be propagated from lldb-server to lldb, how are the two interacting (//I meant code wise ...//) :
  - In case of debugging a remote process : does local lldb, control the remote lldb through lldb-server ? have I understood it right ?
  - In this case lldb/lldb-server will have to get cross-compiled shipped to the remote host and than tested using the same lldb on localhost.
4. How are new Error Codes Introduced into the system ? And how are their behaviours modified, like `error.AsCString()`




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106226



More information about the lldb-commits mailing list