customize multi-dimension array debugging in visual studio 2015 with .natvis file

天大地大妈咪最大 提交于 2019-12-11 03:37:01

问题


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


回答1:


Casting to int solved this for me:

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



来源:https://stackoverflow.com/questions/40171957/customize-multi-dimension-array-debugging-in-visual-studio-2015-with-natvis-fil

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!