Remove linux_proc_pid_get_ns
authorGary Benson <gbenson@redhat.com>
Wed, 10 Jun 2015 13:28:43 +0000 (14:28 +0100)
committerGary Benson <gbenson@redhat.com>
Wed, 10 Jun 2015 13:28:43 +0000 (14:28 +0100)
This commit removes linux_proc_pid_get_ns, and updates its only
caller to use linux_ns_same instead.

gdb/ChangeLog:

* linux-thread-db.c (nat/linux-namespaces.h): New include.
(check_pid_namespace_match): Use linux_ns_same rather than
linux_proc_pid_get_ns to spot PID namespace mismatches.
* nat/linux-procfs.h (linux_proc_pid_get_ns): Remove.
* nat/linux-procfs.c (linux_proc_pid_get_ns): Likewise.

gdb/ChangeLog
gdb/linux-thread-db.c
gdb/nat/linux-procfs.c
gdb/nat/linux-procfs.h

index 42a5182f8f86c9e825a128641aff0066be40c751..d85e4e7c111f74c5327bc6a37b170ad57fda0420 100644 (file)
@@ -1,3 +1,11 @@
+2015-06-10  Gary Benson <gbenson@redhat.com>
+
+       * linux-thread-db.c (nat/linux-namespaces.h): New include.
+       (check_pid_namespace_match): Use linux_ns_same rather than
+       linux_proc_pid_get_ns to spot PID namespace mismatches.
+       * nat/linux-procfs.h (linux_proc_pid_get_ns): Remove.
+       * nat/linux-procfs.c (linux_proc_pid_get_ns): Likewise.
+
 2015-06-10  Gary Benson <gbenson@redhat.com>
 
        * configure.ac (AC_CHECK_FUNCS): Add setns.
index d6387d5d874ed6970dd7e5d32827f23fd6758d73..6177f3924c9953ae85cfbb35c75aebc0996b74e6 100644 (file)
@@ -42,9 +42,9 @@
 #include "nat/linux-osdata.h"
 #include "auto-load.h"
 #include "cli/cli-utils.h"
-
 #include <signal.h>
 #include <ctype.h>
+#include "nat/linux-namespaces.h"
 
 /* GNU/Linux libthread_db support.
 
@@ -1200,20 +1200,12 @@ check_pid_namespace_match (void)
         child's thread list, we'll mistakenly think it has no threads
         since the thread PID fields won't match the PID we give to
         libthread_db.  */
-      char *our_pid_ns = linux_proc_pid_get_ns (getpid (), "pid");
-      char *inferior_pid_ns = linux_proc_pid_get_ns (
-       ptid_get_pid (inferior_ptid), "pid");
-
-      if (our_pid_ns != NULL && inferior_pid_ns != NULL
-         && strcmp (our_pid_ns, inferior_pid_ns) != 0)
+      if (!linux_ns_same (ptid_get_pid (inferior_ptid), LINUX_NS_PID))
        {
          warning (_ ("Target and debugger are in different PID "
                      "namespaces; thread lists and other data are "
                      "likely unreliable"));
        }
-
-      xfree (our_pid_ns);
-      xfree (inferior_pid_ns);
     }
 }
 
index 44364c5fbbd01c570226739e5e2aba49051a4886..24bcb019a398f81e9a6c5ccf624147f97a05629e 100644 (file)
@@ -185,25 +185,6 @@ linux_proc_pid_is_zombie (pid_t pid)
   return linux_proc_pid_is_zombie_maybe_warn (pid, 1);
 }
 
-/* See linux-procfs.h declaration.  */
-
-char *
-linux_proc_pid_get_ns (pid_t pid, const char *ns)
-{
-  char buf[100];
-  char nsval[64];
-  int ret;
-  xsnprintf (buf, sizeof (buf), "/proc/%d/ns/%s", (int) pid, ns);
-  ret = readlink (buf, nsval, sizeof (nsval));
-  if (0 < ret && ret < sizeof (nsval))
-    {
-      nsval[ret] = '\0';
-      return xstrdup (nsval);
-    }
-
-  return NULL;
-}
-
 /* See linux-procfs.h.  */
 
 void
index fdbf3838135f790aab76a1cc11e4713f7e05bc21..f9cad39562c66bd92f275328b6192f15538ff30a 100644 (file)
@@ -54,12 +54,6 @@ extern int linux_proc_pid_is_zombie_nowarn (pid_t pid);
 
 extern int linux_proc_pid_is_gone (pid_t pid);
 
-/* Return an opaque string identifying PID's NS namespace or NULL if
- * the information is unavailable.  The returned string must be
- * released with xfree.  */
-
-extern char *linux_proc_pid_get_ns (pid_t pid, const char *ns);
-
 /* Callback function for linux_proc_attach_tgid_threads.  If the PTID
    thread is not yet known, try to attach to it and return true,
    otherwise return false.  */
This page took 0.03019 seconds and 4 git commands to generate.