From: Pedro Alves <palves@redhat.com>
To: jon@ringle.org, gdb-patches@sourceware.org
Cc: Jon Ringle <jringle@gridpoint.com>
Subject: Re: [PATCH v2] gdbserver: linux_low: elf_64_file_p cache results
Date: Thu, 24 Aug 2017 09:27:00 -0000 [thread overview]
Message-ID: <402cb282-9cd1-2725-f6de-ec5f9eb15e0d@redhat.com> (raw)
In-Reply-To: <1503549910-24770-1-git-send-email-jon@ringle.org>
Hi Jon,
On 08/24/2017 05:45 AM, jon@ringle.org wrote:
> The problem lied in the fact that the function elf_64_file_p() (call on
> line 7184), was returning -1 because it could not open the file (with errno
> set to EACCESS). This was because the inferior's code was dropping root
> privileges and no longer was able to read the file.
I feel like I'm missing something. If it's the inferior that
is dropping privileges, how can that affect gdbserver? It's gdbserver
that opens the file, not the inferior.
It'd be nice to have a testcase for this. Would it be possible to come
up with a small reproducer?
> This patch implements a cache per file in the elf_64_file_p() function so
> that it remembers the results of a previous query for the same filename.
>
> Since it seems that c++ is now accepted in gdb, the cache was implemented
> using std::map
Doesn't look correct, since it assumes that the 64-bit-ness
of "/proc/PID/exe" stays constant for the lifetime of gdbserver,
which is certainly false. With "gdbserver --multi", a single gdbserver can
stay around debugging multiple processes for an undeterminate amount of time.
After the current process PID exits, nothing prevents the kernel from
reusing PID for another process.
Also, we need to clear the cache when the inferior process execs,
since a 32-bit process can well exec a 64-bit process, and vice-versa.
If caching is the right approach, then it seems to me that it'd be
much simpler/efficient to make it a new 'bool is_elf64;' field of
struct process_info_private.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2017-08-24 9:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-24 4:45 jon
2017-08-24 9:27 ` Pedro Alves [this message]
2017-08-24 14:15 ` Jon Ringle
2017-08-24 14:42 ` Pedro Alves
2017-08-24 14:53 ` Pedro Alves
2017-08-24 15:00 ` Jon Ringle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=402cb282-9cd1-2725-f6de-ec5f9eb15e0d@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=jon@ringle.org \
--cc=jringle@gridpoint.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox