Suggest running gdbserver for a PID in container

Message ID 20160315220750.GA24570@host1.jankratochvil.net
State New, archived
Headers

Commit Message

Jan Kratochvil March 15, 2016, 10:07 p.m. UTC
  Hi,

currently
	gdb -p <pid from a container>
will print:
	warning: Target and debugger are in different PID namespaces; thread lists and other data are likely unreliable

BTW it is a bit lost in all the other messages.  Full screen output is in:
	https://sourceware.org/bugzilla/show_bug.cgi?id=19828

It correctly states the problem but it does not say how to solve it.

Is at least this little suggestion OK?

Originally I wanted to suggest also the Docker "-p 1234:1234" parameter but
I see the containers are more general topic than just Docker (even LxC etc.).

According to Gary future GDBs should be able to work even without gdbserver.
But currently gdbserver is still required.


Thanks,
Jan
gdb/ChangeLog
2016-03-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* linux-thread-db.c (check_pid_namespace_match): Extend the message.
  

Comments

Daniel Colascione March 15, 2016, 10:10 p.m. UTC | #1
On 03/15/2016 03:07 PM, Jan Kratochvil wrote:
> Hi,
> 
> currently
> 	gdb -p <pid from a container>
> will print:
> 	warning: Target and debugger are in different PID namespaces; thread lists and other data are likely unreliable
> 
> BTW it is a bit lost in all the other messages.  Full screen output is in:
> 	https://sourceware.org/bugzilla/show_bug.cgi?id=19828
> 
> It correctly states the problem but it does not say how to solve it.

We (FB) just treat the container as an entirely separate machine and
debug processes inside it using gdbserver.
  
Pedro Alves March 17, 2016, 11:13 a.m. UTC | #2
On 03/15/2016 10:07 PM, Jan Kratochvil wrote:
> Hi,
>
> currently
> 	gdb -p <pid from a container>
> will print:
> 	warning: Target and debugger are in different PID namespaces; thread lists and other data are likely unreliable
>
> BTW it is a bit lost in all the other messages.  Full screen output is in:
> 	https://sourceware.org/bugzilla/show_bug.cgi?id=19828
>
> It correctly states the problem but it does not say how to solve it.
>
> Is at least this little suggestion OK?

OK.

> Originally I wanted to suggest also the Docker "-p 1234:1234" parameter but
> I see the containers are more general topic than just Docker (even LxC etc.).
>
> According to Gary future GDBs should be able to work even without gdbserver.
> But currently gdbserver is still required.

Yes, when/if Infinity notes are accepted in glibc.

Thanks,
Pedro Alves
  
Jan Kratochvil March 17, 2016, 5:19 p.m. UTC | #3
On Thu, 17 Mar 2016 12:13:45 +0100, Pedro Alves wrote:
> On 03/15/2016 10:07 PM, Jan Kratochvil wrote:
> > Is at least this little suggestion OK?
> 
> OK.

Checked in:
	708bf0a14b10d801a600759f3ef6d272978ae854


Thanks,
Jan
  

Patch

diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 1eb457d..21166bf 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -1020,7 +1020,8 @@  check_pid_namespace_match (void)
 	{
 	  warning (_ ("Target and debugger are in different PID "
 		      "namespaces; thread lists and other data are "
-		      "likely unreliable"));
+		      "likely unreliable.  "
+		      "Connect to gdbserver inside the container."));
 	}
     }
 }