使用.natvis文件在visual studio 2015中自定义多维数组调试

时间:2022-01-16 19:31:58

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:

我正在使用arma Matrix,我想在调试期间查看该值。所以我添加一个natvis文件如下:

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

顺便说一句,我在选项中将Natvis诊断消息转为“错误”,但错误列表中没有任何内容。

Thanks for any help

谢谢你的帮助

1 个解决方案

#1


1  

Casting to int solved this for me:

Cast to int解决了这个问题:

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

$ i == 0?(int)n_rows:(int)n_cols

#1


1  

Casting to int solved this for me:

Cast to int解决了这个问题:

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

$ i == 0?(int)n_rows:(int)n_cols