[lldb-dev] lldb on linux -- immediate crash upon attaching to process
Jason E. Aten
j.e.aten at gmail.com
Wed Mar 16 07:40:35 PDT 2011
On Mon, Mar 14, 2011 at 11:11 PM, Stephen Wilson <wilsons at start.ca> wrote:
Well, in a nutshell you would need to implement something similar to
what ProcessLinux::DoLaunch does, but in this case you want things to
boil down to a ptrace(ATTACH) instead of a fork() + ptrace(TRACEME).
The basic sketch would be:
- Define a new ProcessMonitor ctor that takes a pid as argument.
- Define ProcessMonitor::Attach which does the actual ptrace magic.
- Write a another StartOperationThread method that takes a (new)
AttachArgs struct as argument (could just contain the pid for now)
and sets up the monitoring business in essentially the same way as
the current launch-based code does. Probably rename
OperationThread to LaunchOpThread or similar and write your own
AttachOpThread analog.
It would certainly be nice to have that implemented. I do not see
anything that would cause any complications off hand, and it should
remain fairly isolated from all the other work that needs to happen wrt
linux support.
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.
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.
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.
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.
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! :-)
Thanks,
Jason
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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20110316/dbcb81b1/attachment.html>
More information about the lldb-dev
mailing list