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 0/7] GNU/Linux mount namespace support


Thanks a lot for the patches!

I've got a small feature request. If the process inside the mount namespace is
running on a chroot I believe it won't work (I couldn't test it because the
patches don't work for me[1]).

The reason I want this feature is that rkt[2] runs several apps in a container,
each one on its own chroot and I'd like to debug programs running there.

Maybe you could detect if it's runinng on a chroot by reading /proc/$PID/root,
comparing it to / and, if they're different, use the former to get the binary.
What do you think about it?

Thanks again.
Cheers.

[1]: Context from an IRC conversation with gbenson: My gdb is multi-threaded and
multi-threaded programs can't change mount namespaces, he is already working on
a fix.

[2]: https://github.com/coreos/rkt

On 04/16/2015 02:19 PM, Gary Benson wrote:
> Hi all,
> 
> This series allows GDB and gdbserver on GNU/Linux systems to attach
> to processes in mount namespaces other than the debugger's own when
> invoked with the appropriate permissions.  This allows an application
> running in a container to be debugged by running GDB or gdbserver on
> the host, or by running GDB or gdbserver from within another container
> that shares the host's PID namespace.
> 
> This series builds on the 'Do not require "file" commands for remote
> targets' series that is currently under review:
> 
>   https://sourceware.org/ml/gdb-patches/2015-04/msg00015.html
> 
> It also requires the 'Do not manipulate "target:" filenames as local
> paths' patch to function correctly:
> 
>   https://sourceware.org/ml/gdb-patches/2015-04/msg00547.html
> 
> A tree with the latest versions of all these patches applied is
> available here:
> 
>   https://github.com/gbenson/binutils-gdb/tree/namespaces
> 
> The patches in this series are as follows:
> 
>  - Patch 1 (Move make_cleanup_close to common code) is a minor
>    refactoring required for patch 3.
> 
>  - Patch 2 (Introduce target_fileio_set_fs) adds target-layer
>    support for systems where different processes can have different
>    views of the filesystem.  The new function target_fileio_set_fs
>    sets the context in which target_filesystem_is_local and the
>    other target_fileio_* functions operate, and can be called to
>    select the filesystem of a specific inferior or the filesystem
>    of the debugger (GDB or gdbserver).  The default implementation
>    of target_fileio_set_fs does nothing, which means that targets
>    where inferiors and the debugger share the same filesystem will
>    work without modification.
> 
>  - Patch 3 (Introduce nat/linux-namespaces.[ch]) introduces some
>    shared code that GDB and gdbserver can use to query and enter
>    Linux namespaces.
> 
>  - GDB contained a small amount of namespace-aware code used to
>    display a warning.  Patch 4 (Remove linux_proc_pid_get_ns)
>    replaces the querying part of this code with a call to the
>    new code introduced by patch 3.
> 
>  - Patch 5 (Implement multiple-filesystem support for Linux targets)
>    does exactly what it says on the tin.  With this patch you can
>    attach to processes in containers using the native Linux target
>    using, e.g., "gdb -p PID".
> 
>  - Patch 6 (Implement multiple-filesystem support for remote targets)
>    adds remote protocol support for remote targets where different
>    processes can have different views of the filesystem.  A new
>    vFile:setfs packet is introduced that passes the context set using
>    target_fileio_set_fs to the remote target.  Caching is used to
>    avoid sending unnecessary vFile:setfs packets.
> 
>  - Patch 7 (Implement vFile:setfs in gdbserver) implements the
>    vFile:setfs packet in gdbserver.  Currently only GNU/Linux systems
>    support this; gdbserver on other systems will return empty
>    responses in reply to vFile:setfs packets.
> 
> Built and regtested on RHEL 6.6 x86_64.
> 
> Ok to commit?
> 
> Thanks,
> Gary
> 
> --
> http://gbenson.net/
> 

-- 

Iago LÃpez Galeiras
Software developer @ Endocode AG
iago@endocode.com

------
Endocode AG, Johannisstrasse 20, 10117 Berlin
info@endocode.com | www.endocode.com

Vorstandsvorsitzender: Mirko Boehm
VorstÃnde: Dr. Karl Beecher, Chris KÃhl, Sebastian Sucker
Aufsichtsratsvorsitzende: Jennifer Beecher

Registergericht: Amtsgericht Charlottenburg - HRB 150748 B


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