Remote Debugging on Linux

Hi All

I am new to LLDB. I want to remotely debug some applications. Both the host and target OS is Linux.

I went through few discussions in this list regarding remote debugging but I am still unclear about how to do it.
I could figure out from the discussions that there are 2 ways to do remote debugging: lldb-platform and lldb-gdbserver

I don’t know which one of them is fully functional for Linux. I would highly appreciate some comments here.


The first way to do this is to use the lldb-platform to allow you to view and launch processes on the remote host.

On the remote machine launch lldb-server: lldb-server platform --listen=2000 --stay-alive

Then on your host machine: lldb
(lldb) platform select remote-linux
(lldb) platform connect connect://

Now you have a live connection to a platform server on the remote host so you can list existing processes:

(lldb) platform process list
(lldb) platform process attach --pid ...

Or you can launch:

(lldb) file /path/to/binary
(lldb) process launch -- arg1 arg2

The platform will launch a lldb-server to debug your programs on the other system.

The other is to just directly debug a process. In this case we don't go through the platform, we just start lldb-server on lldb-server gdbserver -- arg1 arg2

Then attach to it: lldb
(lldb) file /path/to/binary
(lldb) process connect connect://

Now you will be stopped at the program entry point and ready to debug a single process.

All of this is of course using the top of tree SVN sources. It will change a bit if you are using older sources.


It’s only really tested on x86_64->x86_64. We are bringing up x86_32 and arm32/64 now-ish, MIPS soon to follow.

Please let us know if you hit any problems!

Hi All

Thanks a lot for all the inputs.

@Greg: I could make it work using the lldb-platform. I had checked out source code of LLDB on Feb 16 and had built (Debug+Asserts) it on Fedora 20 system (x86_64). I will like to make few comments which are inlined.

@Vince: Are you building LLDB for x86_32 Linux ? I tried to build it (Debug build) for such a system and it fails during linking process because of lack of memory.
In order to bring up x86_32 support, are you following a different approach ? I read the thread initiated by you “Transitioning to Linux local debugging via lldb-gdbserver” . Are you using this approach?

Sorry, forgot to reply all last time. so there’s some duplicate.

I tried to build it (Debug build) for such a system and it fails during linking process because of lack of memory.

I ran into the same problem. Adding “-fuse-ld=gold -gsplit-dwarf” to your C{XX}FLAGS while configuring should resolve this issue. Caveat: you have to use gcc/gdb.

All of the instructions with lldb-platform and lldb-debugserver are now outdated since we merged the two binaries.

While running process connect command, I got the following error
“error: remote connections are not supported”



before launching LLDB.

This fixes the problem for me. I’m not sure if it’s worth the time to investigate why, since we’re eventually going to make that the default anyway.

We are focusing on cross compiling the 32bit LLDB server from x86_64. We will eventually need to compile the 32bit host binaries on Windows but we aren’t focused on 32 but Mac/Linux hosts. Please feel free to get this working.


Hi Chaoren

Thanks a lot for your reply. I tried building using the above C{XX}FLAGS. Now I am having trouble going past compiler-rt compilation.

make[5]: Entering directory /users/aggarwal/Work/LLVM/llvm/projects/compiler-rt' make[5]: Nothing to be done for clang_linux’.
make[5]: Leaving directory /users/aggarwal/Work/LLVM/llvm/projects/compiler-rt' llvm[4]: Copying runtime library linux/builtins-i386 to build dir cp: cannot stat '/users/aggarwal/Work/LLVM/build_llvm_32bit_new/tools/clang/runtime/compiler-rt/clang_linux/builtins-i386/libcompiler_rt.a': No such file or directory make[4]: *** [/users/aggarwal/Work/LLVM/build_llvm_32bit_new/Debug+Asserts/lib/clang/3.7.0/lib/linux/libclang_rt.builtins-i386.a] Error 1 rm /users/aggarwal/Work/LLVM/build_llvm_32bit_new/Debug+Asserts/lib/clang/3.7.0/lib/linux/.dir make[4]: Leaving directory /users/aggarwal/Work/LLVM/build_llvm_32bit_new/tools/clang/runtime/compiler-rt’
make[3]: *** [compiler-rt/.makeall] Error 2
make[3]: Leaving directory /users/aggarwal/Work/LLVM/build_llvm_32bit_new/tools/clang/runtime' make[2]: *** [all] Error 1 make[2]: Leaving directory /users/aggarwal/Work/LLVM/build_llvm_32bit_new/tools/clang’
make[1]: *** [clang/.makeall] Error 2
make[1]: Leaving directory `/users/aggarwal/Work/LLVM/build_llvm_32bit_new/tools’
make: *** [all] Error 1

Could you successfully build at your end when you had tried and do you have any comment regarding the above failure ?

Hi Vince

Do you mean that you are cross-compiling LLDB or are you cross-compiling only LLDB-server ?
Can you share with me the procedure to do it? I couldn’t find any documentation for it.

We don’t compile with compiler-rt in our tree yet.

I have only tried cross compiling lldb-server to 32bit. I’ve hit issues getting the host binaries to compile.