From: Simon Marchi <simark@simark.ca>
To: John Baldwin <jhb@FreeBSD.org>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/5] Assume KERN_PROC_PATHNAME is present on FreeBSD hosts.
Date: Mon, 20 Jul 2020 22:16:08 -0400 [thread overview]
Message-ID: <2dba9dc9-b814-99a8-4578-8a0c2938ea22@simark.ca> (raw)
In-Reply-To: <20200720173136.10514-3-jhb@FreeBSD.org>
On 2020-07-20 1:31 p.m., John Baldwin wrote:
> FreeBSD kernels have included this sysctl since 6.0 release. The most
> recent release without support is 5.5 which was released in May of
> 2006.
>
> gdb/ChangeLog:
>
> * fbsd-nat.c (fbsd_nat_target::pid_to_exec_file): Always use
> sysctl and remove procfs fallback.
> ---
> gdb/ChangeLog | 5 +++++
> gdb/fbsd-nat.c | 13 -------------
> 2 files changed, 5 insertions(+), 13 deletions(-)
>
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 687d9aede5..0339083f1a 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,8 @@
> +2020-07-20 John Baldwin <jhb@FreeBSD.org>
> +
> + * fbsd-nat.c (fbsd_nat_target::pid_to_exec_file): Always use
> + sysctl and remove procfs fallback.
> +
> 2020-07-20 John Baldwin <jhb@FreeBSD.org>
>
> * fbsd-nat.c: Assume PT_LWPINFO is always defined.
> diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
> index fc7136a97c..6193e0fbde 100644
> --- a/gdb/fbsd-nat.c
> +++ b/gdb/fbsd-nat.c
> @@ -53,11 +53,7 @@
> char *
> fbsd_nat_target::pid_to_exec_file (int pid)
> {
> - ssize_t len;
> static char buf[PATH_MAX];
> - char name[PATH_MAX];
> -
> -#ifdef KERN_PROC_PATHNAME
> size_t buflen;
> int mib[4];
>
> @@ -71,15 +67,6 @@ fbsd_nat_target::pid_to_exec_file (int pid)
> for processes without an associated executable such as kernel
> processes. */
> return buflen == 0 ? NULL : buf;
> -#endif
> -
> - xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
> - len = readlink (name, buf, PATH_MAX - 1);
> - if (len != -1)
> - {
> - buf[len] = '\0';
> - return buf;
> - }
>
> return NULL;
> }
> --
> 2.25.1
>
Note that the way the code is currently written allows the readlink method to be used
if the sysctl method fails at runtime. We probably don't care, but I thought I'd raise
it just in case.
Simon
next prev parent reply other threads:[~2020-07-21 2:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-20 17:31 [PATCH 0/5] Remove support for old " John Baldwin
2020-07-20 17:31 ` [PATCH 1/5] Assume that PT_LWPINFO is always defined on " John Baldwin
2020-07-20 17:31 ` [PATCH 2/5] Assume KERN_PROC_PATHNAME is present " John Baldwin
2020-07-21 2:16 ` Simon Marchi [this message]
2020-07-22 16:44 ` John Baldwin
2020-07-20 17:31 ` [PATCH 3/5] Assume FreeBSD hosts include support for fetching signal information John Baldwin
2020-07-20 17:31 ` [PATCH 4/5] Require kinfo_get_file and kinfo_get_vmmap for FreeBSD hosts John Baldwin
2020-07-20 17:31 ` [PATCH 5/5] Assume FreeBSD kernels always report exec events John Baldwin
2020-08-03 16:19 ` [PATCH 0/5] Remove support for old FreeBSD hosts John Baldwin
2020-09-10 12:24 ` Simon Marchi
2020-09-10 19:56 ` John Baldwin
2020-09-09 21:19 ` John Baldwin
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=2dba9dc9-b814-99a8-4578-8a0c2938ea22@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=jhb@FreeBSD.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).