1

I am trying to add to the Eigen.natvis, found here, so that Eigen::Map objects can also be read in the Visual Studio debugger, Eigen library found here.

Here is what I put together:

<Type Name="Eigen::Map&lt;Eigen::Matrix&lt;*,-1,-1,*,*,*&gt;,*,*&gt;">
<DisplayString Condition="m_data == 0">empty</DisplayString>
<DisplayString Condition="m_data != 0">Map[{m_rows.m_value}, {m_cols.m_value}] (dynamic matrix)</DisplayString>
<Expand>
  <ArrayItems Condition="Flags%2"> <!-- row major layout -->
    <Rank>2</Rank>
    <Size>$i==0 ? m_rows.m_value : m_cols.m_value</Size>
    <ValuePointer>m_data</ValuePointer>
  </ArrayItems>
  <ArrayItems Condition="!(Flags%2)"> <!-- column major layout -->
    <Direction>Backward</Direction>
    <Rank>2</Rank>
    <Size>$i==0 ? m_rows.m_value : m_cols.m_value</Size>
    <ValuePointer>m_data</ValuePointer>
  </ArrayItems>
</Expand>
</Type>

The main problem I am facing is with this line (discovered by trial and error):

<Size>$i==0 ? m_rows.m_value : m_cols.m_value</Size>

If, instead, I use any of the following then it works, but incorrectly of course (specific number constants are irrelevant):

<Size>$i==0 ? 4 : 2</Size>
<Size>$i==0 ? 3 : m_cols.m_value</Size>
<Size>$i==0 ? m_rows.m_value : 5</Size>

What am I missing? How do I get this to run correctly? Also, the natvis for Eigen::Matrix does something similar and there it does work.

AOK
  • 493
  • 5
  • 16
  • Please explainh what exactly is not working. Did you turn on [natvis debugging](https://learn.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2017#BKMK_Diagnosing_Natvis_errors)? – Werner Henze Feb 17 '19 at 13:20
  • @WernerHenze, Thanks. I am knew to natvis debugging, but will check out the link and see what if I can figure out something. In short, when I say "not working" I mean that it just shows the base objects of `Eigen::Map` as opposed to [N, M] and so on, like it should show, mimicking `Eigen::MatrixXd` – AOK Feb 17 '19 at 13:54

0 Answers0