2

I am using arma Matrix and I would like to have a look at the value during debugging. So I add a natvis file as followed:

<?xml version="1.0" encoding="utf-8"?> 
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
  <Type Name="arma::Mat&lt;*&gt;">
    <DisplayString>{{ Size = {n_rows} x {n_cols} }}</DisplayString>
    <Expand>
      <Item Name="[size]">n_elem</Item>
      <ArrayItems>
        <Direction>Backward</Direction>
        <Rank>2</Rank>
        <Size> $i==0?n_rows:n_cols </Size>
        <ValuePointer>mem</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>
</AutoVisualizer>

However, it doesn't work at all.

Sooner I relize the problem may be

<Size> $i==0?n_rows:n_rows </Size>

So I try to replace it with any of the following statements and it works

<size> $i==0?5:8 </Size>    
<size> $i==0?n_rows:8 </Size>
<Size> $i==0?5:n_cols</Size>

However, if I try any of the following statements, I get nothing again

<size> $i==0?n_rows:n_cols </Size>
<size> $i==0?n_rows:n_rows </Size>

By the way, I've turned the Natvis diagnostic messages to "Error" in options but nothing is there in the error list.

Thanks for any help

user3003238
  • 1,517
  • 10
  • 17
  • my understanding is that it would be not an error, it just means that the debugger window couldn't recognize the specific tags/property parameter under the ArrayItems, you could view this sample about how to use "ArrayItems Expansion" here: https://code.msdn.microsoft.com/windowsdesktop/Writing-type-visualizers-2eae77a2 – Jack Zhai Oct 21 '16 at 12:47
  • Thanks Jack, but it only give an example of 1D array. Besides, I've read the MSDN explanation and they used size[$i] in the filed i.e. they store the size in a 1*2 array so that it can be called without a if statement. However, I am using armadillo and the matrix size is defined by two ints instead of an array. – user3003238 Oct 21 '16 at 14:56
  • can you share me a simple sample using one drive? I will debug it in my side using the same Environment as yours. – Jack Zhai Oct 24 '16 at 08:20

1 Answers1

1

Casting to int solved this for me:

<Size> $i==0?(int)n_rows:(int)n_cols </Size>

Joe
  • 11
  • 1