public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* howto?  gdb --> AF_UNIX --> gdbserver
@ 2020-12-19 14:50 Rick van Rein
  2020-12-19 17:10 ` Martin Simmons
  0 siblings, 1 reply; 3+ messages in thread
From: Rick van Rein @ 2020-12-19 14:50 UTC (permalink / raw)
  To: gdb

Hello,

Our project uses a test program [0][1] that automatically runs and
connects test processes.  It would be useful to debug one or more of
these in their connected context.  The best match would be to use a
socket file name relative to the testdir, rather than a numeric port
shared with the entire host.

* I cannot figure out how to tell gdbserver to listen to a UNIX domain
socket at a given filename.  I would expect it to listen, like it does
for TCP sockets, but it complains that the name is missing.

* Using gdb with "target remote", the same thing seems to happen; it
seems to want a pre-existing UNIX domain socket.  This _is_ in line with
the TCP style of connecting.

* The automated tests might benefit from the reverse approach; try to
start gdbserver when it can connect to the UNIX domain socket of the
host, and if not continue with exec() to run the process without
debugger.  This is not how things seem to work, judging from the sparse
documentation.

* In all cases, both the syntax and available features are unclear and I
am confused after trying the things I can imagine; does a socket need a
prefix "unix:" or "unix::" or does it figure it all out?  An example
flow could be really useful...

The documentation about gdb and gdbserver is not really helping in
answering these questions.  May I suggest extending it?  Happy to
proof-read or, once understood, write some proze that would have helped me.


Thanks!
 -Rick


[0] https://gitlab.com/arpa2/kip/-/blob/initial/PYPELINE.MD
[1] https://gitlab.com/arpa2/kip/-/blob/initial/test/pypeline

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: howto?  gdb --> AF_UNIX --> gdbserver
  2020-12-19 14:50 howto? gdb --> AF_UNIX --> gdbserver Rick van Rein
@ 2020-12-19 17:10 ` Martin Simmons
  2020-12-22 10:15   ` Rick van Rein
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Simmons @ 2020-12-19 17:10 UTC (permalink / raw)
  To: Rick van Rein; +Cc: gdb

>>>>> On Sat, 19 Dec 2020 15:50:59 +0100, Rick van Rein via Gdb said:
> 
> Our project uses a test program [0][1] that automatically runs and
> connects test processes.  It would be useful to debug one or more of
> these in their connected context.  The best match would be to use a
> socket file name relative to the testdir, rather than a numeric port
> shared with the entire host.
> 
> * I cannot figure out how to tell gdbserver to listen to a UNIX domain
> socket at a given filename.  I would expect it to listen, like it does
> for TCP sockets, but it complains that the name is missing.

You can't do this with gdbserver itself, but you can wrap it with nc,
e.g.

rm $unix-domain-socket
nc -Ul -e "gdbserver --no-startup-with-shell stdio $program-to-debug" $unix-domain-socket


> * Using gdb with "target remote", the same thing seems to happen; it
> seems to want a pre-existing UNIX domain socket.  This _is_ in line with
> the TCP style of connecting.

Yes, if the argument to "target remote" is an existing UNIX domain
socket name then gdb will connect to it.

__Martin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: howto?  gdb --> AF_UNIX --> gdbserver
  2020-12-19 17:10 ` Martin Simmons
@ 2020-12-22 10:15   ` Rick van Rein
  0 siblings, 0 replies; 3+ messages in thread
From: Rick van Rein @ 2020-12-22 10:15 UTC (permalink / raw)
  To: Martin Simmons; +Cc: gdb

Hi Martin / GDB,

Turns out, I was quite right to complain about missing documentation.  I think it is useful if this would be fixed.

>> * I cannot figure out how to tell gdbserver to listen to a UNIX domain
>> socket at a given filename.  I would expect it to listen, like it does
>> for TCP sockets, but it complains that the name is missing.
>
> You can't do this with gdbserver itself, but you can wrap it with nc,
> e.g.
>
> rm $unix-domain-socket
> nc -Ul -e "gdbserver --no-startup-with-shell stdio $program-to-debug" $unix-domain-socket

Thanks, that really cleared up the problem.  You are using another flavour or netcat than the two I have :) but at least it is clear that gdbserver does not really align with gdb when it comes to UNIX domain sockets.  Surprising, but good to at least know.  I was really confused, especially because it is so surprising / unlogical.

This really is completely underdocumented, and that is a problem, I think.  The same goes for the --multi mode, which I worked out by trying, but it is not clear at all from the documentation.  I had to fiddle around to find out that it takes only one connection at a time, and so could not debug a couple of processes in parallel, in whatever way, as the --multi option might be interpreted.

>> * Using gdb with "target remote", the same thing seems to happen; it
>> seems to want a pre-existing UNIX domain socket.  This _is_ in line with
>> the TCP style of connecting.
>
> Yes, if the argument to "target remote" is an existing UNIX domain
> socket name then gdb will connect to it.

That makes sense on its own; because that it is what it does with TCP also.

-Rick

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-22 10:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-19 14:50 howto? gdb --> AF_UNIX --> gdbserver Rick van Rein
2020-12-19 17:10 ` Martin Simmons
2020-12-22 10:15   ` Rick van Rein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).