This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Debugger Visualizer for Eigen in MSVS 2012

Tags: None
(comma "," separated)
ansar
Registered Member
Posts
15
Karma
0
Hi,

I am trying to view data in Eigen containers via debugger visulaizers. I use this for UBLAS containers:

Code: Select all
<?xml version='1.0' encoding='utf-8'?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">

  <Type Name="boost::numeric::ublas::unbounded_array&lt;*,*&gt;">
    <DisplayString>{{ size={size_} }}</DisplayString>
    <Expand>
      <Item Name="[size]">size_</Item>
      <ArrayItems>
        <Size>size_</Size>
        <ValuePointer>data_</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>

  <Type Name="boost::numeric::ublas::vector&lt;*&gt;">
    <DisplayString>{data_}</DisplayString>
    <Expand>
      <ExpandedItem>data_</ExpandedItem>
    </Expand>
  </Type>

  <Type Name="boost::numeric::ublas::matrix&lt;*&gt;">
    <DisplayString>{{ size={size1_}x{size2_} }}</DisplayString>
    <Expand>
      <ExpandedItem>data_</ExpandedItem>
    </Expand>
  </Type>

</AutoVisualizer>


I tried to get something similar for Eigen working but no luck as I am still getting used to C++. Could you please help me setting up the MSVS debugger visualizer file for Eigen? Thanks!
jitseniesen
Registered Member
Posts
204
Karma
2
The file eigen/debug/msvc/eigen.natvis that was added a few days ago to the development branch may be helpful. I think you can find it on the web at https://bitbucket.org/eigen/eigen/src/d ... gen.natvis .
ansar
Registered Member
Posts
15
Karma
0
This is great. I am able to visualize most Eigen containers with this. Thanks!

However, I am an R user struggling with C++; I can't seem to use the examples to write a visualizer for Map<VectorXd> or Map<MatrixXd>. Possible to get some help setting those up. Regards.
Hauke
Registered Member
Posts
109
Karma
3
OS
Here you go

Code: Select all
  <Type Name="Eigen::Map&lt;Eigen::Matrix&lt;*,-1,1,*,*,*&gt;,*,*&gt;">
    <DisplayString>Map</DisplayString>
      <Expand>
        <Item Name="[size]">m_rows.m_value</Item>
        <ArrayItems>
          <Size>m_rows.m_value</Size>
          <ValuePointer>m_data</ValuePointer>
        </ArrayItems>
      </Expand>   
  </Type>


For most types, it is quite easy. First, you have to define the type name. This is a little bit funny because you have to write your template declaractions with '&lt;' and '&gt;' instead of actual angle brackets. Each free template parameter is represented by an asterisk and can be accessed via $Ti, where i is the ith asterisk.

Every symbol you can write in the 'Watch' window of the MSVC IDE while debugging can be expanded and renamed through the visualizers. Once you declare a Map named 'm', you can access 'm.m_rows.m_value' in the debug window. In the example above, I just named it [size]. The ArrayItems section expands the pointer m_data for all rows.

If you want more fancy stuff like conditional names, etc. please take a closer look at the example code I pushed a few days ago. This link (http://code.msdn.microsoft.com/windowsdesktop/Writing-type-visualizers-2eae77a2) was helpful too though not everything is yet well documented.

HTH,
Hauke
ansar
Registered Member
Posts
15
Karma
0
Thanks for a very good explanation. Tried it and it works great. Being able to visualize data is definitely making debugging really simple.

And as an aside, writing C++ code with Eigen is remarkably straightforward and almost proving easier than R. So much numerical firepower, yet code that is entirely natural to read/write. Thank you creators and community for an awesome product.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]