]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Support 'info proc files' on live FreeBSD processes.
authorJohn Baldwin <jhb@FreeBSD.org>
Tue, 18 Sep 2018 21:05:47 +0000 (14:05 -0700)
committerJohn Baldwin <jhb@FreeBSD.org>
Tue, 18 Sep 2018 21:05:47 +0000 (14:05 -0700)
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
gdb/fbsd-nat.c

index 7cd17a5dab84528871d46ae227e97c925c7b3b8a..88406c7bef7b9335e246b7a49d758321802bad37 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-18  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-18  John Baldwin  <jhb@FreeBSD.org>
 
        * fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
index 2b829bfc3b44d2efaa1cec706cc934420e2747a3..24e40e2406b80cec06c8435ae2ae0a6c6652e3b0 100644 (file)
@@ -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)
     {