From: Cedric Le Goater <clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
To: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: Linux Containers
<containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>,
Linux Kernel Mailing List
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: debugging threaded apps running under a clone(CLONE_NEWPID)
Date: Tue, 24 Feb 2009 10:51:16 +0100 [thread overview]
Message-ID: <49A3C314.6010806@fr.ibm.com> (raw)
In-Reply-To: <20090223182153.GD13151-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Serge E. Hallyn wrote:
> Quoting Cedric Le Goater (clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org):
>> Hello !
>>
>> to debug threaded apps, gdb uses a special libthread_db which seeks in the
>> symbols of the exec the list of running threads. This list contains the glibc
>> 'struct pthread' descriptor with pids and tids which values are relative
>> to the namespace in which the threads were created.
>>
>> unless you run gdb in the same pid namespace, gdb will not see any thread
>> in the debugged app. this is frustrating for some scenarios and some
>> support from the kernel would be needed to address this issue. Here
>> are some ideas :
>>
>> . enter a pid namespace. hard.
>>
>> . expose the pid numbers of a task in its pid namespaces, through some
>> ways like /proc/self/stat or /proc/self/pids and modify gdb to make
>> the conversion.
>>
>> How would you do it ?
>
> perhaps a /proc/$$/vpid which prints out
> task_pid_nr_ns(tsk, current->nsproxy->pidns)
yes something like below, which prints out too much values.
> then each thread opens an fd for /proc/self/vpid and passes it
> over an af_unix socket to the parent gdb, which then reads it
> to get the pid in its own ns?
if we suppose that gdb is running in a parent namespace, i'd fix
the libthread_db to convert the pids of the threads in the child
namespace to the pids of the threads in the parent namespace using
the new /proc file. this can be done with LD_PRELOAD but gdb also
offers a framework to load operations interacting with threads.
This needs more studies, specially on the gdb side, but I think we
will need a way to convert pid values between parent and child
namespace if we don't want to change the all the thread support in
gdb.
C.
Signed-off-by: Cedric Le Goater <clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
---
fs/proc/base.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
Index: 2.6.27-mcr.git/fs/proc/base.c
===================================================================
--- 2.6.27-mcr.git.orig/fs/proc/base.c
+++ 2.6.27-mcr.git/fs/proc/base.c
@@ -2444,6 +2444,23 @@ static int proc_tgid_io_accounting(struc
}
#endif /* CONFIG_TASK_IO_ACCOUNTING */
+static int proc_pid_vpids(struct task_struct *task, char *buffer)
+{
+ struct pid_namespace *pid_ns = task->nsproxy->pid_ns;
+
+ return sprintf(buffer, "%6d %6d %6d %6d %6d %6d %6d %6d %6d %6d\n",
+ task_pid_nr_ns(task, pid_ns), // pid
+ task_pid_nr(task),
+ task_tgid_nr_ns(task, pid_ns), // tgid
+ task_tgid_nr(task),
+ task_tgid_nr_ns(task->real_parent, pid_ns), // ppid
+ task_tgid_nr(task->real_parent),
+ task_pgrp_nr_ns(task, pid_ns), // pgid
+ task_pgrp_nr(task),
+ task_session_nr_ns(task, pid_ns), // sid
+ task_session_nr(task));
+}
+
/*
* Thread groups
*/
@@ -2519,6 +2536,7 @@ static const struct pid_entry tgid_base_
#ifdef CONFIG_TASK_IO_ACCOUNTING
INF("io", S_IRUGO, tgid_io_accounting),
#endif
+ INF("vpids", S_IRUGO, pid_vpids),
};
static int proc_tgid_base_readdir(struct file * filp,
@@ -2854,6 +2872,7 @@ static const struct pid_entry tid_base_s
#ifdef CONFIG_TASK_IO_ACCOUNTING
INF("io", S_IRUGO, tid_io_accounting),
#endif
+ INF("vpids", S_IRUGO, pid_vpids),
};
static int proc_tid_base_readdir(struct file * filp,
WARNING: multiple messages have this Message-ID (diff)
From: Cedric Le Goater <clg@fr.ibm.com>
To: "Serge E. Hallyn" <serue@us.ibm.com>
Cc: Linux Containers <containers@lists.osdl.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: debugging threaded apps running under a clone(CLONE_NEWPID)
Date: Tue, 24 Feb 2009 10:51:16 +0100 [thread overview]
Message-ID: <49A3C314.6010806@fr.ibm.com> (raw)
In-Reply-To: <20090223182153.GD13151@us.ibm.com>
Serge E. Hallyn wrote:
> Quoting Cedric Le Goater (clg@fr.ibm.com):
>> Hello !
>>
>> to debug threaded apps, gdb uses a special libthread_db which seeks in the
>> symbols of the exec the list of running threads. This list contains the glibc
>> 'struct pthread' descriptor with pids and tids which values are relative
>> to the namespace in which the threads were created.
>>
>> unless you run gdb in the same pid namespace, gdb will not see any thread
>> in the debugged app. this is frustrating for some scenarios and some
>> support from the kernel would be needed to address this issue. Here
>> are some ideas :
>>
>> . enter a pid namespace. hard.
>>
>> . expose the pid numbers of a task in its pid namespaces, through some
>> ways like /proc/self/stat or /proc/self/pids and modify gdb to make
>> the conversion.
>>
>> How would you do it ?
>
> perhaps a /proc/$$/vpid which prints out
> task_pid_nr_ns(tsk, current->nsproxy->pidns)
yes something like below, which prints out too much values.
> then each thread opens an fd for /proc/self/vpid and passes it
> over an af_unix socket to the parent gdb, which then reads it
> to get the pid in its own ns?
if we suppose that gdb is running in a parent namespace, i'd fix
the libthread_db to convert the pids of the threads in the child
namespace to the pids of the threads in the parent namespace using
the new /proc file. this can be done with LD_PRELOAD but gdb also
offers a framework to load operations interacting with threads.
This needs more studies, specially on the gdb side, but I think we
will need a way to convert pid values between parent and child
namespace if we don't want to change the all the thread support in
gdb.
C.
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
---
fs/proc/base.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
Index: 2.6.27-mcr.git/fs/proc/base.c
===================================================================
--- 2.6.27-mcr.git.orig/fs/proc/base.c
+++ 2.6.27-mcr.git/fs/proc/base.c
@@ -2444,6 +2444,23 @@ static int proc_tgid_io_accounting(struc
}
#endif /* CONFIG_TASK_IO_ACCOUNTING */
+static int proc_pid_vpids(struct task_struct *task, char *buffer)
+{
+ struct pid_namespace *pid_ns = task->nsproxy->pid_ns;
+
+ return sprintf(buffer, "%6d %6d %6d %6d %6d %6d %6d %6d %6d %6d\n",
+ task_pid_nr_ns(task, pid_ns), // pid
+ task_pid_nr(task),
+ task_tgid_nr_ns(task, pid_ns), // tgid
+ task_tgid_nr(task),
+ task_tgid_nr_ns(task->real_parent, pid_ns), // ppid
+ task_tgid_nr(task->real_parent),
+ task_pgrp_nr_ns(task, pid_ns), // pgid
+ task_pgrp_nr(task),
+ task_session_nr_ns(task, pid_ns), // sid
+ task_session_nr(task));
+}
+
/*
* Thread groups
*/
@@ -2519,6 +2536,7 @@ static const struct pid_entry tgid_base_
#ifdef CONFIG_TASK_IO_ACCOUNTING
INF("io", S_IRUGO, tgid_io_accounting),
#endif
+ INF("vpids", S_IRUGO, pid_vpids),
};
static int proc_tgid_base_readdir(struct file * filp,
@@ -2854,6 +2872,7 @@ static const struct pid_entry tid_base_s
#ifdef CONFIG_TASK_IO_ACCOUNTING
INF("io", S_IRUGO, tid_io_accounting),
#endif
+ INF("vpids", S_IRUGO, pid_vpids),
};
static int proc_tid_base_readdir(struct file * filp,
next prev parent reply other threads:[~2009-02-24 9:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-20 16:56 debugging threaded apps running under a clone(CLONE_NEWPID) Cedric Le Goater
2009-02-23 18:21 ` Serge E. Hallyn
[not found] ` <20090223182153.GD13151-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-02-24 9:51 ` Cedric Le Goater [this message]
2009-02-24 9:51 ` Cedric Le Goater
2009-02-24 11:28 ` Greg Kurz
2009-02-24 12:09 ` Cedric Le Goater
2009-02-24 14:52 ` Serge E. Hallyn
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=49A3C314.6010806@fr.ibm.com \
--to=clg-nmtc/0zbporqt0dzr+alfa@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.