dsp*_*pGI 5 debugging visual-studio visual-studio-debugging armadillo visual-studio-2012
I'm wondering whether there is any method to show vector/matrix entries values in the debugging section on Visual Studio (in particular VS2012).
This question is very similar to the one posted in:
但是我没有弄清楚这种方法是否也适用于 VS。
谢谢。
此.natvisXML 代码在 Visual Studio 2013 中运行良好。我在 Visual Studio 2013 中添加了 @Claes Rolen XML,但这对我来说效果不佳。
诀窍是使用<IndexListItems>可视化犰狳矩阵
声明并初始化代码
mat tMat(3, 3);
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
tMat(i, j) = i + j;
}
Run Code Online (Sandbox Code Playgroud)
.Natvis 文件
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="arma::Col<*>">
<DisplayString>{{ Size = {n_elem} }}</DisplayString>
<Expand>
<Item Name="[size]">n_elem</Item>
<ArrayItems>
<Size>n_elem </Size>
<ValuePointer>mem</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="arma::Mat<*>">
<DisplayString>{{ {n_rows} x {n_cols} = {n_elem} }}</DisplayString>
<Expand>
<IndexListItems>
<Size>n_cols</Size>
<ValueNode >
mem+($i*n_rows),[n_rows]
</ValueNode>
</IndexListItems>
</Expand>
</Type>
<Type Name="arma::subview_col<*>">
<DisplayString>{{ {n_rows} }}</DisplayString>
<Expand>
<ArrayItems>
<Size>n_rows</Size>
<ValuePointer>colmem</ValuePointer>
</ArrayItems>
</Expand>
</Type>
</AutoVisualizer>
Run Code Online (Sandbox Code Playgroud)
以及调试器中的结果图像:
您可以在 Visual Studio 中使用可视化工具,不知道来自哪个版本,但在 Visual Studio 2015 中您可以将文件添加.natvis到项目中。
武装.natvis:
\n\n<?xml version="1.0" encoding="utf-8"?>\n<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">\n <Type Name="arma::Col<*>">\n <DisplayString>{{ Size = {n_elem} }}</DisplayString>\n <Expand>\n <Item Name="[size]">n_elem</Item>\n <ArrayItems>\n <Size>n_elem </Size>\n <ValuePointer>mem</ValuePointer>\n </ArrayItems>\n </Expand>\n </Type>\n <Type Name="arma::Mat<*>">\n <DisplayString>{{ Size = {n_rows} x {n_cols} }}</DisplayString>\n <Expand>\n <Item Name="[size]">n_elem</Item>\n <ArrayItems>\n <Direction>Backward</Direction>\n <Rank>2</Rank>\n <Size>$i==0 ? n_rows : n_cols</Size>\n <ValuePointer>mem</ValuePointer>\n </ArrayItems>\n </Expand>\n </Type>\n</AutoVisualizer>\nRun Code Online (Sandbox Code Playgroud)\n\n这将向您显示基本ARMADILLO类型的可读数据。
| 归档时间: |
|
| 查看次数: |
1354 次 |
| 最近记录: |