[lldb-dev] lldb on linux -- immediate crash upon attaching to process

Stephen Wilson wilsons at start.ca
Mon Mar 14 21:11:02 PDT 2011

On Mon, Mar 14, 2011 at 09:54:50PM -0500, Jason E. Aten wrote:
> I'm trying lldb on linux x86_64.  Upon attaching to any process with "pro
> attach --pid XXX", I get
> an immediate core dump via referencing an invalid mutex.

Heh, ya.  Attach is simply not implemented.  Until it is, I would
suggest "don't do that" :)

> I know linux is a new platform for lldb, and I've just recently started
> exploring lldb on linux so
> so please forgive me if this is already a well known issue. (Is there a bug
> database to search?).

We have only the most basic infrastructure on linux.  There is still a
significant amount of work that needs to be done before LLDB even begins
to approach "usable" on that platform.

> In case it helps, I attach a debugging log with strack trace and a small
> test case to make it
> easy to reproduce. This was running on Ubuntu 10.04, with the latest lldb
> (svn r127570), and
> llvm and clang at svn r124349, as Steve Wilson kindly indicated was
> necessary for lldb to build.
> lldb was built with this configuration.
>  $ /home/jaten/pkg/latest-svn-llvm/llvm/configure --enable-optimized
> --enable-debug-runtime --enable-debug-symbols --enable-profiling
> --enable-jit --enable-doxygen --enable-pic --enable-shared
> --enable-assertions --enable-targets=x86_64 REQUIRES_RTTI=1
> Let me know if I can be of further assistance in tracking this down. If it's
> a known problem and
> somebody can sketch a solution, I may be able to implement it.

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.


More information about the lldb-dev mailing list