This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/9 v2] Introduce nat/linux-namespaces.[ch]


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]