<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 11, 2020, at 11:11 AM, Mike Mestnik <<a href="mailto:cheako+lists_llvm_org@mikemestnik.net" class="">cheako+lists_llvm_org@mikemestnik.net</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">On Mon, Nov 9, 2020 at 5:37 PM Greg Clayton <<a href="mailto:clayborg@gmail.com" class="">clayborg@gmail.com</a>> wrote:<br class=""><blockquote type="cite" class=""><br class=""><br class=""><br class=""><blockquote type="cite" class="">On Nov 4, 2020, at 1:28 PM, Mike Mestnik via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a>> wrote:<br class=""><br class="">I'm looking for support running lldb over ssh. I can forward the<br class="">originating connection, but the run command is attempting to use<br class="">random ports on localhost to attain another connection. This fails as<br class="">the localhost's are not the same.<br class=""></blockquote><br class="">When you say you want to run lldb over ssh, do you mean run "lldb-server"<br class=""></blockquote>Is there really an issue with saying these are both lldb? Seems like<br class="">my statements were unambiguous without noting a distinction.<br class=""><br class=""><blockquote type="cite" class="">remotely and then have a local LLDB connect to that lldb-server?<br class=""></blockquote>That's the usual way lldb is used remotely, so I don't really get that<br class="">lldb does not, in some cases, mean lldb-server.<br class=""></div></div></blockquote><div><br class=""></div>I am trying to figure out what exactly you would like to see happen here. There are many people that run ssh to open a terminal to another computer and run lldb on the command line on that remote machine, hence why I was trying to clarify what you are are asking for with regards to ssh. <br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""><blockquote type="cite" class="">You are looking to avoid "lldb-server" from having to bind to port 0 and then tell you which port it was actually bound to?<br class=""></blockquote>This is indeed a *feature* of lldb-server and not lldb, so I don't<br class="">really get your confusion when I claim lldb has a feature that's<br class="">entirely implemented with regard to lldb-server.<br class=""></div></div></blockquote><div><br class=""></div>Again, trying to understand exactly what you are asking for any not sure why the snippy answer.</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""></div><div class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><br class="">Is there a platform, preferably real time, for lldb support?<br class=""><br class=""></blockquote></blockquote>This is a really important question of mine! If we can only go back<br class="">and forth on email I'd like ppl to make a best effort to lessen the<br class="">effects this has. One tip I have, even for when ppl are chatting, is<br class="">to phrase questions in the form of an answer... Don't ask yes/no<br class="">questions or even questions with say less than 7 answers. Instead<br class="">provide bullet points of all the possible answers, one at a time.<br class="">There are many good reasons for everyone doing this, but here the most<br class="">relevant is to avoid round-trips that are expansive.</div></div></blockquote></div><div><br class=""></div><div>LLDB does have an IRC channel on the LLVM IRC chatbot named "lldb". Many LLDB developers do hang out on this chat and can provide some realtime answers for LLDB and lldb-server.</div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><div class=""><br class="">Can you answer your question twice? Once If I claim that "Yes" I do<br class="">plan on having lldb choose a port to listen on and have ssh forward<br class="">that port and again for if I answer "No".</div></div></blockquote></div><div><blockquote type="cite" class=""><div class=""><div class=""><br class="">I hope you can appreciate that having ssh forward a handful of ports<br class="">for a single service is not optimal. I'd actually do better by<br class="">writing another set of client-server applications that tunnel the IPC<br class="">over ssh... Something I'd only do if the program was closed source.<br class="">As lldb is not, the obvious path forward is to re-implement the lldb<br class="">IPC so it's more friendly to ssh.<br class=""></div></div></blockquote><div><br class=""></div>We are happy to help make remote debugging better and more friendly to ssh. We don't have a lot of ssh expertise in the LLDB core group of developers as far as I know, so if you have expertise here and can add ways for us to be better in that respect, we would love to see any patches. See more detailed solution suggestion below on where I think this would fit the best in LLDB.</div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">One might ask why ssh, the basic answer is I don't want to open<br class="">*another port on my remote host... Even if I did I'd still have the<br class="">same problem, a random port would fail to connect(this time because of<br class="">a firewall). The main answer is, without ssh, lldb is limited to<br class="">running on local or VPN networks. I'd rather use ssh than configure a<br class="">VPN for this one use case.<br class=""><br class="">* lldb doesn't sound like something one would want to host, even if<br class="">connections were blocked from everywhere "else."<br class=""><br class="">Now I'm attempting forward error correction by guessing where this<br class="">topic could lead. I would be willing to expand the network code to<br class="">include domain sockets, to replace the whole idea of using, IMHO<br class="">barbaric, port numbers. This work could potentially include direct<br class="">support for ssh. </blockquote></blockquote></div></div></blockquote><div><br class=""></div><div>lldb-server is not limited to port connections. LLDB has a plug-in mechanism for communications that is URL based. For example, if you are going to launch lldb-server on a remote system and specify a port number of 1234, you would connect to it with:</div><div><br class=""></div><div>(lldb) <span style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">process connect </span><a href="connect://remote.foo.com:1234" style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">connect://remote.foo.com:1234</a><div class=""><br class=""></div><div class="">"process connect" uses a communication plug-in that is specified by the URL for the first argument: "connect://". Each communication plug-in built into lldb and lldb-server registers a URL with the LLDB codebase so it can be easily found and used. "connect://" will get you a direct TCP connection using IPV4 of IPV6 depending on the rest of the URL. There isn't a valid URL for direct TCP connections so we made one up ("connect://"). </div><div class=""><br class=""></div><div class="">The reason I mention this is this is where I would envision any ssh support could easily be added to LLDB. So my theory would be we would add a new "ssh" communication plug-in, if that makes sense as I have no SSH experience other than using a lot of command line tools that can use it, and then when connecting to the remote via ssh we would end up using:</div><div class=""><br class=""></div><div class="">(lldb) process connect <a href="ssh://remote.foo.com%3Cargs%3E" class="">ssh://<args></a></div><div class=""><br class=""></div><div class="">where <args> is anything we need to make the connection, like "<a href="http://remote.foo.com" class="">remote.foo.com</a>". We would probably add a new option to lldb-server to specify it would use ssh as well when it was launched like:</div><div class=""><br class=""></div><div class="">remote$ <span style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">lldb-server gdbserver --ssh <ssh-args-if-needed> -- /bin/ls -lAF</span></div><div class=""><span style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class=""><br class=""></span></div><div class=""><span style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">Does that seam feasible? </span></div><div class=""><span style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class=""><br class=""></span></div></div><blockquote type="cite" class=""><div class=""><div class=""><blockquote type="cite" class=""><blockquote type="cite" class="">I understand that this would likely be a breaking<br class="">change, is there version negotiation?<br class=""></blockquote></blockquote></div></div></blockquote><div><br class=""></div></div><div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="white-space: pre-wrap;" class="">I don't think this needs to be a breaking change. For lldb-server, we just need a way to move packets over a communication layer, so we should be able to use our communication plug-ins to do this. </span></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="white-space: pre-wrap;" class=""><br class=""></span></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="white-space: pre-wrap;" class="">Another example of using different communication plug-ins is when lldb-server is running on the same machine as lldb: </span></span><span style="background-color: rgb(255, 255, 255);" class=""><span style="white-space: pre-wrap;" class="">lldb calls socketpair() and gets 2 socket file handles that are connected and dupes one of them into the lldb-server using posix_spawn attributes. When we actually spawn the process we send the file descriptor that it was duped to down as an argument: "--fd 12". So when lldb-server is starting up, it will parse the options, and discover it is just needs to use the specified file descriptor.</span></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="white-space: pre-wrap;" class=""><br class=""></span></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="white-space: pre-wrap;" class="">Greg Clayton</span></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="white-space: pre-wrap;" class=""><br class=""></span></span></div></div></body></html>