This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 2/9 v2] Introduce nat/linux-namespaces.[ch]
- From: Gary Benson <gbenson at redhat dot com>
- To: Alban Crequy <alban at endocode dot com>
- Cc: gdb-patches at sourceware dot org, Eli Zaretskii <eliz at gnu dot org>, Pedro Alves <palves at redhat dot com>, Doug Evans <dje at google dot com>, Iago López Galeiras <iago at endocode dot com>
- Date: Thu, 7 May 2015 11:38:53 +0100
- Subject: Re: [PATCH 2/9 v2] Introduce nat/linux-namespaces.[ch]
- Authentication-results: sourceware.org; auth=none
- References: <1429186791-6867-1-git-send-email-gbenson at redhat dot com> <1430395542-16017-3-git-send-email-gbenson at redhat dot com> <20150501000739 dot 740 dot 47967 at domU-12-31-39-0A-A0-4F> <20150501092817 dot GA28105 at blade dot nx> <CALdWxcuP1crzx7rTFbVcOtgn5abxxHn31kq2s+v9LmPK=buwqQ at mail dot gmail dot com> <20150501202948 dot GA11582 at blade dot nx>
Gary Benson wrote:
> Alban Crequy wrote:
> > On Fri, May 1, 2015 at 11:28 AM, Gary Benson <gbenson@redhat.com> wrote:
> > > Alban Crequy wrote:
> > > > On Thu, Apr 30, 2015 at 2:05 PM, Gary Benson <gbenson@redhat.com> wrote:
> > > The scenario I'm targeting is that you have an application you
> > > want to debug running in a container. You don't want to run GDB
> > > as root on the container host, so you start a second container
> > > with just the privileges you need and run GDB from there.
> >
> > How do you get the pid of the process to give as a parameter to
> > "gdb -p" if gdb is running in a different pid namespace than the
> > process to debug?
>
> It's the PID on the host, I've just been finding them with ps. I'm
> not sure how well that'd work if you had hundreds or thousands of
> containers running though... It'd be nice to have a command like ps
> but that was limited to one container and that listed both inner and
> outer PIDs [snip]
FWIW the command I was looking for is "docker top":
bash-4.2# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
615386bf33ac rhel7:0 "bash" 11 minutes ago Up 11 minutes rhel7
bash-4.2# docker top 615386bf33ac
UID PID PPID C STIME TTY TIME CMD
root 2209 939 0 11:18 pts/1 00:00:00 bash
root 2595 939 0 11:23 ? 00:00:00 nsenter-exec --nspid 2209 -- gdb -p 1
root 2596 2595 0 11:23 ? 00:00:00 gdb -p 1
root 2653 939 0 11:24 pts/4 00:00:00 nsenter-exec --nspid 2209 --console /dev/pts/4 -- bash
root 2654 2653 0 11:24 pts/4 00:00:00 bash
root 2674 2654 0 11:26 pts/4 00:00:01 /usr/bin/python /usr/bin/debuginfo-install gdb-7.6.1-64.el7.x86_64
root 2675 2674 7 11:26 pts/4 00:00:22 /usr/bin/python /usr/libexec/urlgrabber-ext-down
root 2676 2674 1 11:26 pts/4 00:00:03 /usr/bin/python /usr/libexec/urlgrabber-ext-down
Cheers,
Gary
--
http://gbenson.net/