clioneigen3

Eigen3 and Clion: How to display matrix contents in Clion ide?


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?


Solution

  • 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.