<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">lldb-server can be launched in two ways:<div class="">1 - platform connection mode</div><div class="">2 - debug a single process mode</div><div class=""><br class=""></div><div class="">LLDB has two ways to connect to a remote process:</div><div class="">1 - you launch the GDB server yourself and attach to it</div><div class="">2 - you launch lldb-server in platform mode, connect to the platform, and then just debug like you normally would on a local machine.</div><div class=""><br class=""></div><div class="">When you launch the GDB server yourself as mentioned in step 1 above, you can do:</div><div class=""><br class=""></div><div class=""><a href="http://remote.foo.com" class="">remote.foo.com</a>% lldb-server gdbserver 1234 -- /bin/ls -lAF</div><div class=""><br class=""></div><div class="">Then attach to it yourself:</div><div class=""><br class=""></div><div class=""><a href="http://local.foo.com" class="">local.foo.com</a>% lldb</div><div class="">(lldb) process connect <a href="connect://remote.foo.com:1234" class="">connect://remote.foo.com:1234</a></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">When you want an lldb-server to do the work of startup on the GDB server for you:</div><div class=""><br class=""></div><div class=""><a href="http://remote.foo.com" class="">remote.foo.com</a>% lldb-server platform --server --listen 1234</div><div class=""><br class=""></div><div class="">Then you select the remote platform and connect to it with LLDB:</div><div class=""><br class=""></div><div class=""><a href="http://local.foo.com" class="">local.foo.com</a>% lldb</div>(lldb) platform select remote-macosx <br class="">  Platform: remote-macosx<br class=""> Connected: no<br class=""><div class="">(lldb) platform connect <a href="connect://localhost:1234" class="">connect://localhost:1234</a><br class="">  Platform: remote-macosx<br class="">    Triple: x86_64-apple-macosx<br class="">OS Version: 10.12.6 (16G1036)<br class="">    Kernel: Darwin Kernel Version 16.7.0: Wed Oct  4 00:17:00 PDT 2017; root:xnu-3789.71.6~1/RELEASE_X86_64<br class="">  Hostname: gclayton-pro<br class=""> Connected: yes<br class="">WorkingDir: /Users/gclayton<br class=""></div><div class=""><br class=""></div><div class="">Now LLDB has a "platform" connection to the remote machine that can start up the GDB server for you. Also note that the platform states what its working directory is (which defaults to the directory it was launched in).</div><div class=""><br class=""></div><div class="">If you want to launch a locally built executable on the remote side, now you can do:</div><div class=""><br class=""></div><div class="">(lldb) file a.out</div><div class="">(lldb) run</div><div class=""><br class=""></div><div class="">This will cause LLDB to create a target with the "a.out" executable that you cross built. Then you "run" and this will cause LLDB to upload "a.out" to the platform's current working directory only if the file has changed. The platform connection allows us to transfer files, but also allows us to get the MD5 checksum of the file on the other end in the current working directory and only upload the file if it has changed. If you don't want the "a.out" executable to be uploaded to the current platform working directory you can do to specify where the executable will be uploaded to:</div><div class=""><br class=""></div><div class=""><div class="">(lldb) file /local/path/to/a.out</div><div class=""># Get the lldb.SBModule for "/local/path/to/a.out" in the local variable named "m":</div><div class="">(lldb) script m = lldb.target.module['a.out']</div><div class=""># Set the platform path for the executable to "/bin/a.out":</div><div class="">(lldb) script m.<span style="font-size: 11px;" class="">SetPlatformFileSpec("/bin/a.out")</span></div><div class="">(lldb) run</div></div><div class=""><br class=""></div><div class="">Now when you run your program, the program will be uploaded to "/bin/a.out" instead of the the current working directory of the platform.</div><div class=""><br class=""></div><div class="">You can also change the platform working directory if you are connected to the platform</div><div class=""><br class=""></div><div class="">(lldb) platform settings -w /tmp</div><div class=""><br class=""></div><div class="">And you can verify it worked using "platform status":</div><div class=""><br class=""></div><div class="">(lldb) platform status<br class="">  Platform: remote-macosx<br class="">    Triple: x86_64-apple-macosx<br class="">OS Version: 10.12.6 (16G1036)<br class="">    Kernel: Darwin Kernel Version 16.7.0: Wed Oct  4 00:17:00 PDT 2017; root:xnu-3789.71.6~1/RELEASE_X86_64<br class="">  Hostname: gclayton-pro<br class=""> Connected: yes<br class="">WorkingDir: /private/tmp<br class=""><br class=""></div><div class=""><br class=""></div><div class="">If you want to attach to a remote process, you can list the processes if you are connected:</div><div class=""><br class=""></div><div class="">(lldb) platform process list</div><div class="">223 matching processes were found on "remote-macosx"<br class="">PID    PARENT USER       TRIPLE                   NAME<br class="">====== ====== ========== ======================== ============================<br class="">68881  96266  (null)     x86_64-apple-macosx      lldb-server<br class="">68639  90652             x86_64-apple-macosx      lldb<br class="">67830  1                 x86_64-apple-macosx      helpd<br class="">67737  1                 x86_64-apple-macosx      com.apple.iCloudHelper<br class=""><br class=""></div><div class="">...</div><div class=""><br class=""></div><div class="">Then attach:</div><div class=""><br class=""></div><div class="">(lldb) attach 68639</div><div class=""><br class=""></div><div class="">Let me know if you have any questions.</div><div class=""><br class=""></div><div class="">Greg Clayton</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On Nov 28, 2017, at 9:29 AM, Adrian Prantl via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">I would recommend asking this on the lldb mailing list instead.</div><div class=""><br class=""></div><div class="">-- adrian<br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Nov 26, 2017, at 8:30 AM, Lior Halphon via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">

<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class="">

<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 15px; line-height: inherit; vertical-align: baseline; clear: both; color: rgb(36, 39, 41);" class="">
I'm trying to remotely launch and debug a new process with <code style="margin: 0px; padding: 1px 5px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant-caps: inherit; line-height: inherit; vertical-align: baseline; background-color: rgb(239, 240, 241); white-space: pre-wrap;" class="">lldb</code> without
 much success.</p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 15px; line-height: inherit; vertical-align: baseline; clear: both; color: rgb(36, 39, 41);" class="">
Attaching to an already launched process works well by running these commands:</p>
<pre style="margin-top: 0px; margin-bottom: 1em; padding: 5px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; line-height: inherit; vertical-align: baseline; width: auto; max-height: 600px; overflow: auto; background-color: rgb(239, 240, 241); word-wrap: normal; color: rgb(36, 39, 41);" class=""><code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-style: inherit; font-variant-caps: inherit; line-height: inherit; vertical-align: baseline; white-space: inherit;" class="">process connect <url>
process attach -P gdb-remote --pid <pid>
</code></pre><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 15px; line-height: inherit; vertical-align: baseline; clear: both; color: rgb(36, 39, 41);" class="">
But if I want <code style="margin: 0px; padding: 1px 5px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant-caps: inherit; line-height: inherit; vertical-align: baseline; background-color: rgb(239, 240, 241); white-space: pre-wrap;" class="">debugserver</code> to
 launch the executable by itself I'm running into troubles. Especially, I have no clue what arguments should I pass to <code style="margin: 0px; padding: 1px 5px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant-caps: inherit; line-height: inherit; vertical-align: baseline; background-color: rgb(239, 240, 241); white-space: pre-wrap;" class="">target
 create</code>.</p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 15px; line-height: inherit; vertical-align: baseline; clear: both; color: rgb(36, 39, 41);" class="">
According to <a href="https://lldb.llvm.org/remote.html" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant-caps: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 119, 204); text-decoration: none; cursor: pointer;" class="">this
 page</a> LLDB "will transparently take care of [..] downloading the executable in order to be able to debug", yet <code style="margin: 0px; padding: 1px 5px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant-caps: inherit; line-height: inherit; vertical-align: baseline; background-color: rgb(239, 240, 241); white-space: pre-wrap;" class="">target
 create</code> seem to always require a local file. If I specify the remote file via <code style="margin: 0px; padding: 1px 5px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant-caps: inherit; line-height: inherit; vertical-align: baseline; background-color: rgb(239, 240, 241); white-space: pre-wrap;" class="">-r</code> I
 get either <code style="margin: 0px; padding: 1px 5px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant-caps: inherit; line-height: inherit; vertical-align: baseline; background-color: rgb(239, 240, 241); white-space: pre-wrap;" class="">unable
 to open target file</code> or <code style="margin: 0px; padding: 1px 5px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant-caps: inherit; line-height: inherit; vertical-align: baseline; background-color: rgb(239, 240, 241); white-space: pre-wrap;" class="">remote
 --> local transfer without local path is not implemented yet</code> errors. If I set the target to a local file (such as a local copy of the remote's loader executable) without using <code style="margin: 0px; padding: 1px 5px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant-caps: inherit; line-height: inherit; vertical-align: baseline; background-color: rgb(239, 240, 241); white-space: pre-wrap;" class="">-r</code>,
 then attempt to run <code style="margin: 0px; padding: 1px 5px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant-caps: inherit; line-height: inherit; vertical-align: baseline; background-color: rgb(239, 240, 241); white-space: pre-wrap;" class="">process
 launch -p gdb-remote -s <remote path></code> LLDB will attempt running the local path on the remote machine and fail.</p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 15px; line-height: inherit; vertical-align: baseline; clear: both; color: rgb(36, 39, 41);" class="">
What are the correct commands I need to use in order to launch a remote process?</p>
</div>

_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class=""></div></blockquote></div><br class=""></div></div>
_______________________________________________<br class="">lldb-dev mailing list<br class=""><a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev<br class=""></div></blockquote></div><br class=""></div></body></html>