Sysprogs forums › Forums › VisualGDB › Embedded Eigen Matrix Debugging Visualizer
- This topic has 5 replies, 2 voices, and was last updated 7 years ago by codex653.
-
AuthorPosts
-
October 30, 2017 at 16:49 #12790codex653Participant
Hi,
I am using the Eigen matrix math library to implement a UKF on my STM32 device in VS2017 with VisualGDB 5.3R5. One of the things I noticed in debug mode (OpenOCD) is that I can only view the first value in my matrix. Eigen stores data in arrays and the matrix class templates store the pointer to the first element in that array. I really need to see the full matrix. Apparently Visual Studio needs to be told to recognize the data types properly in order to display the full contents of the matrix type: http://eigen.tuxfamily.org/index.php?title=Developer%27s_Corner#Debugging_under_Visual_Studio
Per the included link, I was able to download the latest eigen.natvis file and properly locate it under my VS2017 install directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Packages\Debugger\Visualizers
Unfortunately, VisualGDB still does not recognize the matrix data types and does not display the contents of the array in the watch windows. Is there something specific that I need to do to get VisualGDB to recognize the data properly?
October 30, 2017 at 21:24 #12792supportKeymasterHi,
Please try adding the .natvis file directly to your VS project (via right-click->Add->Existing Item). This should help VisualGDB recognize it.
October 31, 2017 at 16:55 #12800codex653ParticipantI have done this, but I still only see the first value in memory. I’ve experiment with the .natvis file a bit and it seems that the XML structure is unable to discern what value is associated with the wildcard character “*” in the DisplayString block. For example, if I have a dynamic [3×3] matrix, the value in the debugger window will read “[ERROR, ERROR] (fixed matrix)”. For whatever reason, the wildcard * is not read into $T2 and $T3, and the matrix is not identified as dynamic. An example of the XML section that gets triggered is shown below:
<!-- Fixed x Fixed Matrix --> <Type Name="Eigen::Matrix<*,*,*,*,*,*>"> <DisplayString>[{$T2},{$T3}] (fixed matrix)</DisplayString> <Expand> <ArrayItems Condition="Flags%2"> <!-- row major layout --> <Rank>2</Rank> <Size>$i==0 ? $T2 : $T3</Size> <ValuePointer>m_storage.m_data.array</ValuePointer> </ArrayItems> <ArrayItems Condition="!(Flags%2)"> <!-- column major layout --> <Direction>Backward</Direction> <Rank>2</Rank> <Size>$i==0 ? $T2 : $T3</Size> <ValuePointer>m_storage.m_data.array</ValuePointer> </ArrayItems> </Expand> </Type>
- This reply was modified 7 years ago by codex653.
November 1, 2017 at 19:58 #12813codex653ParticipantFor anyone coming across this later, I’ve ended up using what I think might be a better option for viewing the full matrix in a manner similar to Matlab. I wrote a quick ‘n dirty function that prints out the contents of a generic Eigen matrix to the VisualGDB provided ARM Semihosting Console. It actually works pretty well! I’d like to still get the .natvis file working, but this is ok for now.
template <typename T> void prettyPrint(T matrix, std::string name) { size_t num_rows = matrix.rows(); size_t num_cols = matrix.cols(); //Matrix header name printf(name.data()); printf("Size: [%d,%d]\n", num_rows, num_cols); //Create column labels printf("\t"); for (size_t col = 0; col < num_cols; col++) printf("[%d]\t", col); printf("\n\n"); //Create row data double data = 0.0; for (size_t row = 0; row < num_rows; row++) { printf("[%d]\t", row); for (size_t col = 0; col < num_cols; col++) { data = matrix(row, col); printf("%.2f\t", data); } printf("\n\n\n"); } }
November 3, 2017 at 01:18 #12843supportKeymasterHi,
We have managed to reproduce the problem with the Eigen natvis file. It is caused by VisualGDB not supporting the $Tx syntax and the multi-dimensional ArrayItems.
We have added support for the $Tx syntax to the upcoming maintenance release, however we currently don’t have any plans for supporting multi-dimensional arrays. As a workaround we would advise creating a basic visualizer using our managed visualizer API described here. It allows using arbitrary logic for analyzing visualized expressions and would support multi-dimensional arrays as well.
November 3, 2017 at 04:10 #12845codex653ParticipantGood to know! I’ll try that out.
-
AuthorPosts
- You must be logged in to reply to this topic.