This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2] Improve ptrace-error detection on Linux targets
On Monday, August 26 2019, Christian Biesinger wrote:
> On Mon, Aug 26, 2019 at 1:32 PM Sergio Durigan Junior
> <sergiodj@redhat.com> wrote:
>> @@ -30,11 +32,70 @@
>> of 0 means there are no supported features. */
>> static int supported_ptrace_options = -1;
>>
>> -/* Find all possible reasons we could fail to attach PID and return these
>> - as a string. An empty string is returned if we didn't find any reason. */
>> +typedef int (*selinux_ftype) (const char *);
>> +
>> +/* Helper function which checks if ptrace is probably restricted
>> + (i.e., if ERR is either EACCES or EPERM), and returns a string with
>> + possible workarounds. */
>> +
>> +static std::string
>> +linux_ptrace_restricted_fail_reason (int err)
>> +{
>> + if (err != EACCES && err != EPERM)
>> + {
>> + /* It just makes sense to perform the checks below if errno was
>> + either EACCES or EPERM. */
>> + return {};
>> + }
>> +
>> + std::string ret;
>> + gdb_dlhandle_up handle = gdb_dlopen ("libselinux.so", true);
>
> I would dlopen libselinux.so.1 instead so that this works even without
> the -dev package.
Ah, right, I forgot about this. I fixed it in my local copy, thanks for
pointing it out.
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/