Karthik Chennupati
Karthik Chennupati

Reputation: 365

Eclipse C/C++ lldb debugger setup macOS Catalina

I've been using Eclipse for a while now for java development and it is seamless. I considered using eclipse for C development also. I installed C/C++ IDE CDT 9.9 addon from the marketplace. I now can create a Makefile project and develop code. But, I'm not able to debug code. After some research, I understood that the native debugger CDT is integrated with, GDB is no longer shipped with macOS. So, at this point, I understood that I have two solutions:

  1. Install GDB and everything works normally.
  2. Install LLDB addon for Eclipse available at the marketplace and everything works normally.

I went on installing LLDB addon for Eclipse and when tried to debug, it showed me:

Eclipse debugger error message

I checked it in the terminal and I found out that lldb is available and lldb-mi is not available. I googled it and found lldb-mi. To install lldb-mi as shown on the Github page, I needed to install CMake. When I try to generate build files for lldb-mi using CMake, it showed me:

CMake lldb-mi error message

After seeing this message, I thought I may need to install LLVM. I googled and found two ways:

  1. Install from Homebrew
  2. Compile and build from source code and install from it

I chose to go and compile the source code and install it. I downloaded llvm-9.0.0.src and generated build as instructed here. It took almost 2 hours and gave this error:

enter image description here

Now, as I understand it, I just generated build files(Makefiles) and compiled the LLVM source code. It's 19GB in size now. Should I go ahead and install it? or have I misinterpreted anything and did anything wrong?

As @Tsyvarev pointed out, using sudo, llvm got installed successfully. Now, lldb-mi needs to be installed. When I go back and cmake ., it's showing me this error:

Karthiks-MacBook-Pro:lldb-mi-master karthik$ sudo cmake .
-- Found LLVM 9.0.0
-- Using LLVMConfig.cmake in: /usr/local/lib/cmake/llvm
-- Building with -fPIC
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
lib_lldb
linked by target "lldb-mi" in directory /Users/karthik/Downloads/lldb-mi-master/src

-- Configuring incomplete, errors occurred!
See also "/Users/karthik/Downloads/lldb-mi-master/CMakeFiles/CMakeOutput.log".

As @squareskittles pointed, I understood that lldb-mi requires lib_lldb for cmake to generate build files. I did:

$git clone https://github.com/lldb-tools/lldb-mi
$cd lldb-mi
$mkdir build
$cmake -DCMAKE_PREFIX_PATH=path/to/llvm/root/tree -S . -B build/

CMake should generate all the build files into lldb-mi/build/. It is successful. $cd build $make make should compile the code. It produced: enter image description here

Karthiks-MacBook-Pro:lldb-mi karthik$ cd build
Karthiks-MacBook-Pro:build karthik$ make
[  1%] Building CXX object src/CMakeFiles/lldb-mi.dir/MICmdArgValListBase.cpp.o
In file included from /Users/karthik/buildspace/lldb-mi/src/MICmdArgValListBase.cpp:10:
/Users/karthik/buildspace/lldb-mi/src/MICmdArgValListBase.h:40:69: error: a space is required between consecutive right
  angle brackets (use '> >')
: public CMICmdArgValBaseTemplate<std::vector<CMICmdArgValBase *>> {
                                                                ^~
                                                                > >
1 error generated.
make[2]: *** [src/CMakeFiles/lldb-mi.dir/MICmdArgValListBase.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/lldb-mi.dir/all] Error 2
make: *** [all] Error 2
Karthiks-MacBook-Pro:build karthik$ 

I put space between those > >, but there are still a lot of errors in the code. I presume there are errors in the lldb-mi repository itself.

Can anyone tell me what I should be doing now?

Thanks in advance!

Upvotes: 2

Views: 3583

Answers (1)

phreaz
phreaz

Reputation: 31

The lldb-mi not longer present from Xcode 11.x, but lldb and LLDB.Framework already included in the Xcode. Use the lldb-mi that comes bundled with previous versions of XCode( 10.x) , the location is ‘Xcode.app/Contents/Developer/usr/bin/lldb-mi’, copy it to the same location of current version XCode.

And, in Eclipse, change the lldb command location.

Fine!

Upvotes: 3

Related Questions