<div><font class="Apple-style-span" face="'courier new', monospace">Dear Steve and lldb-dev,</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">(starting a new thread to give a better, more appropriate, thread title)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">I've investigated a little bit more and I am coming to understand there is a big difference at the moment in how lldb initiates target processes in darwin vs linux (see the comparative ps output details below).  Perhaps it is more direct on linux in order to avoid having to port the debugserver?</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">Any insight into plans for lldb on linux would be appreciated.  I do see there are significant architectural differences at the moment, in that lldb on darwin goes through the debugserver process.  I wonder if that is intended as a temporary quick fix, or done with an eye to simplification.  e.g. I don't know, but perhaps it is much simpler to ptrace directly on linux than to use a separate process?  I'm pretty clueless here, and just starting to explore lldb on linux, so feel free to point me towards background threads or information I might wish to review.</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">Thanks everyone!</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br>
</font></div><div><font class="Apple-style-span" face="'courier new', monospace">cheers,<br>Jason</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br>
</font></div><div><font class="Apple-style-span" face="'courier new', monospace">details:</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">### On darwin, lldb starts a debugserver child process, and debugserver in turn starts a child process to contain the debug target a.out.</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace"> UID   PID  PPID</font></div><div><font class="Apple-style-span" face="'courier new', monospace">                                                   bash</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">                                                    |</font></div><div><font class="Apple-style-span" face="'courier new', monospace">                                                    V</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> 2086 42103 22537   0   0:00.07 ttyp0      0:00.16 ../lldb a.out</font></div><div><font class="Apple-style-span" face="'courier new', monospace">                                                    |</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">                                                    V</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> 2086 42104 42103   0   0:00.01 ??         0:00.02 /Users/jaten/pkg/llvm+lldb+ldc/llvm-2.8/tools/lldb/build/Debug/LLDB.framework/Versions/A/Resources/debugserver localhost:11358 --native-regs --setsid</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">                                                    |</font></div><div><font class="Apple-style-span" face="'courier new', monospace">                                                    V</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> 2086 42105 42104   0   0:00.00 ??         0:00.00 /Users/jaten/pkg/llvm+lldb+ldc/llvm-2.8/tools/lldb/build/Debug/test-lldb/a.out</font></div><div>
<font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">### On linux, at the moment, what I see in contrast is that lldb is the direct parent of the debug target (a.out here).</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">jaten     4532  0.0  0.3  25752  8160 pts/3    Ss   03:59   0:01              |       \_ /bin/bash --noediting -i</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">jaten    22645  0.6  0.8 148260 18256 pts/3    Sl+  11:57   0:00              |       |   \_ ./lldb test-lldb/a.out</font></div><div><font class="Apple-style-span" face="'courier new', monospace">jaten    22650  0.0  0.0  11728   960 pts/11   Ts+  11:58   0:00              |       |       \_ /home/jaten/pkg/latest-svn-llvm/llvm-build-r127600-with-lldb/Release+Debug+Profile+Asserts/bin/test-lldb/a.out</font></div>
<div><br></div><br><div class="gmail_quote">On Wed, Mar 16, 2011 at 9:40 AM, Jason E. Aten <span dir="ltr"><<a href="mailto:j.e.aten@gmail.com">j.e.aten@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><div><blockquote>On Mon, Mar 14, 2011 at 11:11 PM, Stephen Wilson <<a href="mailto:wilsons@start.ca" target="_blank">wilsons@start.ca</a>> wrote:<br>Well, in a nutshell you would need to implement something similar to<br>
what ProcessLinux::DoLaunch does, but in this case you want things to<br>
boil down to a ptrace(ATTACH) instead of a fork() + ptrace(TRACEME).<br>The basic sketch would be:<br>  - Define a new ProcessMonitor ctor that takes a pid as argument.<br>  - Define ProcessMonitor::Attach which does the actual ptrace magic.<br>

  - Write a another StartOperationThread method that takes a (new)<br>    AttachArgs struct as argument (could just contain the pid for now)<br>    and sets up the monitoring business in essentially the same way as<br>    the current launch-based code does.  Probably rename<br>

    OperationThread to LaunchOpThread or similar and write your own<br>    AttachOpThread analog.<br>It would certainly be nice to have that implemented.  I do not see<br>anything that would cause any complications off hand, and it should<br>

remain fairly isolated from all the other work that needs to happen wrt<br>linux support.</blockquote></div><div><br></div><div><br></div></div><div>Thanks Steve!  I scoped out the work a little bit, mostly by stepping through in the debuggers both the Xcode version and the current Linux version.  Btw it looks like the current version of lldb has been incremented (now r127600), which is very good news.</div>

<div><br></div><div>I note that the main contrast is this: the darwin built lldb uses the ProcessGDBRemote class, implemented in the "llvm/tools/lldb/source/Plugins/Process/gdb-remote" directory, rather than ProcessLinux.</div>

<div><br></div><div>The curious thing is: when I look through the gdb-remote code, there are only two lines that are #ifdef APPLE.  It seems fairly reusable.</div><div><br></div><div>My naive question then is, why not just reuse the ProcessGDBRemote code for Linux as well?   There's probably higher level design issues that I'm not familiar with, so anyone on lldb-dev should feel free to chime in here.  The second lazy inclination is to just port that code to linux if it must go in it's own directory.</div>

<div><br></div><div>Let me know what you think.  I'm probably asking silly questions, but I'm just trying to get my bearings. Please bear with me! :-)</div><div><br></div><div>Thanks,</div><div>Jason</div><div><br>

</div><div>p.s. the one thing that kept me from trying this directly was figuring out where in the Makefile system this got chosen, because by default on linux, the gdb-remote directory isn't built.  If anyone knows where this controlled, please point it out. Thank you!</div>

<br>
</blockquote></div><br><br>