4

I have followed the instructions for updating my GDB for use with Eigen3. However, the CLion IDE is unable to load the contents of eigen matrices in the debug panel.

What should be a quick validation and debug process of results is turning into a time consuming manual print process (or worse: running gdb in interactive mode in cygwin's terminal).

There must be a way to enable eigen to be used with clion's debugger?

Chris
  • 28,822
  • 27
  • 83
  • 158

2 Answers2

5

There is quite a simple way @Chris and anyone else looking for a solution using GDB, CLion, I tested it on ubuntu but it should work on any system.

enter image description here enter image description here

Part of the solution is already in the eigen repository, just needs a bit of tweaking.

Eigen printers

What I changed is the python module import logic:

  1. Save printers.py to a newly created printers directory under any directory of your choosing, lets say /any_full_path/printers
  2. make sure you create and empty __init__.py
  3. Create a ~/.gdbinit in your home directory
  4. Copy paste the slightly changed(from the original repo) script below
python
import sys
sys.path.insert(0, '/any_full_path/printers')
from printers import register_eigen_printers
register_eigen_printers(None)
end

Feel free to ask for more screenshots or other clarification, caus that should work simply like a charm.

flatronka
  • 1,061
  • 25
  • 51
0

I've managed to make lldb work in CLion using this project on windows: https://github.com/fantaosha/LLDB-Eigen-Pretty-Printer

You need to create .lldbinit in your home directory and add similar line:

command script import "C:\Users\user.lldb-eigen-data-formatter\LLDB_Eigen_Pretty_Printer.py" (ofc this folder and file needs to be cloned as per the readme on github)

Now Clion will import this script bit you will get some errors, you need to remove the question mark in the regular expressions as described here: https://github.com/fantaosha/LLDB-Eigen-Pretty-Printer/issues/4#issuecomment-747329527 Now CLion will be able to show you the matrix, vector etc. values (but without newline - at least on windows).

For gdb specifically it should be what uta answered but I haven't tried it because I'm using lldb. Maybe you can try changing the debugger to lldb if you don't use anything specific related to that. Hope this helps in some way!

bartfer
  • 111
  • 1
  • 8