From patchwork Thu Apr 30 12:05:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 6499 Received: (qmail 79356 invoked by alias); 30 Apr 2015 12:05:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 79329 invoked by uid 89); 30 Apr 2015 12:05:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 30 Apr 2015 12:05:50 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 5CF0CA12D1; Thu, 30 Apr 2015 12:05:49 +0000 (UTC) Received: from blade.nx (ovpn-116-76.ams2.redhat.com [10.36.116.76]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3UC5mhV016223; Thu, 30 Apr 2015 08:05:48 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id A257E263E7B; Thu, 30 Apr 2015 13:05:47 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Cc: Eli Zaretskii , Pedro Alves , Doug Evans , =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Subject: [PATCH 3/9 v2] Remove linux_proc_pid_get_ns Date: Thu, 30 Apr 2015 13:05:36 +0100 Message-Id: <1430395542-16017-4-git-send-email-gbenson@redhat.com> In-Reply-To: <1429186791-6867-1-git-send-email-gbenson@redhat.com> References: <1429186791-6867-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes 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 | 8 ++++++++ gdb/linux-thread-db.c | 12 ++---------- gdb/nat/linux-procfs.c | 19 ------------------- gdb/nat/linux-procfs.h | 6 ------ 4 files changed, 10 insertions(+), 35 deletions(-) diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 886d8ac..c4ada7a 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -42,9 +42,9 @@ #include "nat/linux-osdata.h" #include "auto-load.h" #include "cli/cli-utils.h" - #include #include +#include "nat/linux-namespaces.h" /* GNU/Linux libthread_db support. @@ -1211,20 +1211,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); } } diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c index 44364c5..24bcb01 100644 --- a/gdb/nat/linux-procfs.c +++ b/gdb/nat/linux-procfs.c @@ -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 diff --git a/gdb/nat/linux-procfs.h b/gdb/nat/linux-procfs.h index fdbf383..f9cad39 100644 --- a/gdb/nat/linux-procfs.h +++ b/gdb/nat/linux-procfs.h @@ -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. */