From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Subject: [PATCH v3 6/8] Support 'info proc files' on live FreeBSD processes.
Date: Tue, 18 Sep 2018 18:55:00 -0000 [thread overview]
Message-ID: <20180918185444.89533-7-jhb@FreeBSD.org> (raw)
In-Reply-To: <20180918185444.89533-1-jhb@FreeBSD.org>
This walks the list of struct kinfo_file objects returned by a call to
kinfo_getfile outputting a description of each open file descriptor.
gdb/ChangeLog:
* fbsd-nat.c (fbsd_nat_target::info_proc): List open file
descriptors for IP_FILES and IP_ALL.
---
gdb/ChangeLog | 5 +++++
gdb/fbsd-nat.c | 32 +++++++++++++++++++++++++++++++-
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 146842bd29..0649464fba 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-09-17 John Baldwin <jhb@FreeBSD.org>
+
+ * fbsd-nat.c (fbsd_nat_target::info_proc): List open file
+ descriptors for IP_FILES and IP_ALL.
+
2018-09-17 John Baldwin <jhb@FreeBSD.org>
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 2b829bfc3b..24e40e2406 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -265,6 +265,9 @@ fbsd_nat_target::info_proc (const char *args, enum info_proc_what what)
bool do_cmdline = false;
bool do_cwd = false;
bool do_exe = false;
+#ifdef HAVE_KINFO_GETFILE
+ bool do_files = false;
+#endif
#ifdef HAVE_KINFO_GETVMMAP
bool do_mappings = false;
#endif
@@ -295,10 +298,18 @@ fbsd_nat_target::info_proc (const char *args, enum info_proc_what what)
case IP_CWD:
do_cwd = true;
break;
+#ifdef HAVE_KINFO_GETFILE
+ case IP_FILES:
+ do_files = true;
+ break;
+#endif
case IP_ALL:
do_cmdline = true;
do_cwd = true;
do_exe = true;
+#ifdef HAVE_KINFO_GETFILE
+ do_files = true;
+#endif
#ifdef HAVE_KINFO_GETVMMAP
do_mappings = true;
#endif
@@ -322,7 +333,7 @@ fbsd_nat_target::info_proc (const char *args, enum info_proc_what what)
printf_filtered (_("process %d\n"), pid);
#ifdef HAVE_KINFO_GETFILE
- if (do_cwd || do_exe)
+ if (do_cwd || do_exe || do_files)
fdtbl.reset (kinfo_getfile (pid, &nfd));
#endif
@@ -374,6 +385,25 @@ fbsd_nat_target::info_proc (const char *args, enum info_proc_what what)
else
warning (_("unable to fetch executable path name"));
}
+#ifdef HAVE_KINFO_GETFILE
+ if (do_files)
+ {
+ struct kinfo_file *kf = fdtbl.get ();
+
+ if (nfd > 0)
+ {
+ fbsd_info_proc_files_header ();
+ for (int i = 0; i < nfd; i++, kf++)
+ fbsd_info_proc_files_entry (kf->kf_type, kf->kf_fd, kf->kf_flags,
+ kf->kf_offset, kf->kf_vnode_type,
+ kf->kf_sock_domain, kf->kf_sock_type,
+ kf->kf_sock_protocol, &kf->kf_sa_local,
+ &kf->kf_sa_peer, kf->kf_path);
+ }
+ else
+ warning (_("unable to fetch list of open files"));
+ }
+#endif
#ifdef HAVE_KINFO_GETVMMAP
if (do_mappings)
{
--
2.18.0
next prev parent reply other threads:[~2018-09-18 18:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-18 18:55 [PATCH v3 0/8] Add a new 'info proc files' command John Baldwin
2018-09-18 18:55 ` John Baldwin [this message]
2018-09-18 18:55 ` [PATCH v3 3/8] Import gnulib's inet_ntop module John Baldwin
2018-09-18 18:55 ` [PATCH v3 1/8] Use KF_PATH to verify the size of a struct kinfo_file John Baldwin
2018-09-18 18:55 ` [PATCH v3 7/8] Document the 'info proc files' command John Baldwin
2018-09-18 19:16 ` Eli Zaretskii
2018-09-18 18:55 ` [PATCH v3 8/8] Make the "info proc" documentation more consistent John Baldwin
2018-09-18 19:16 ` Eli Zaretskii
2018-10-06 15:26 ` [PATCH] Update string expected from "help info proc" on gdb.base/info-proc.exp Sergio Durigan Junior
2018-10-08 15:55 ` John Baldwin
2018-09-18 18:55 ` [PATCH v3 2/8] Generate aclocal-m4-deps.mk more deterministically and portably John Baldwin
2018-09-18 20:27 ` Simon Marchi
2018-09-19 3:01 ` Sergio Durigan Junior
2018-09-18 19:04 ` [PATCH v3 4/8] Add a new 'info proc files' subcommand of 'info proc' John Baldwin
2018-09-18 19:04 ` [PATCH v3 5/8] Add support for 'info proc files' on FreeBSD core dumps 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=20180918185444.89533-7-jhb@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.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).