when debugging with Itom in C++ some data types are not really readable, especially ito::Param. The view while debugging can be enhanced with ".natvis" files. With the code pasted here below the parameters name, type and value are displayed readably but yet not for pointer types.
For this to also work with e.g. QVectorito::ParamBase, the qt6.natvis file does also have to be used. It can be downloaded e.g. from here:
https://github.com/KDABLabs/KDToolBox/blob/master/qt/qt6_natvis/qt6.natvis
This file is used implicitly be the QT extension for visual studio. I can not test how to include an additional .natvis file right now but it should be possible.
When using Visual Studio Code, a natvis file can be added via the "visualizerFile" setting in launch.json. Unfortunately there can be only one file, so the contents from below would have to be copied together with the qt6.natvis into a single file.
Maybe this is a useful starting point to create a helpful .natvis file for Itom to enhance the debugging experience.
P.S. I would have loved to show you some pictures of the improvements but the PNG upload did take so long, that it was not possible.
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="ito::ByteArray">
<DisplayString>{d->m_pData,sb}</DisplayString>
<Expand>
<Item Name="[value]">d->m_pData,sb</Item>
</Expand>
</Type>
<Type Name="ito::RetVal">
<DisplayString Condition="m_retValue != ito::tRetValue::retOk">{m_retValue} [{m_retCode}] {m_retMessage}</DisplayString>
<DisplayString>{m_retValue}</DisplayString>
<Expand>
<Item Name="[value]">m_retValue</Item>
<Item Condition="m_retValue != ito::tRetValue::retOk" Name="[code]">m_retCode</Item>
<Item Condition="m_retValue != ito::tRetValue::retOk" Name="[message]">m_retMessage</Item>
</Expand>
</Type>
<!-- Tags are nearly impossible to display because they are defined in the .cpp
file. -->
<Type Name="ito::DataObject">
<DisplayString Condition="m_data == nullptr">DataObject(empty)</DisplayString>
<DisplayString Condition="m_dims == 2">DataObject({(ito::tDataType)m_type}, {m_osize.m_p[0]} x {m_osize.m_p[1]})</DisplayString>
<DisplayString Condition="m_dims == 3">DataObject({(ito::tDataType)m_type}, {m_osize.m_p[0]} x {m_osize.m_p[1]} x {m_osize.m_p[2]})</DisplayString>
<DisplayString>DataObject({(ito::tDataType)m_type}, dims={m_dims})</DisplayString>
<Expand>
<Item Condition="m_data == nullptr" Name="[data]">nullptr</Item>
<Item Condition="m_dims == 2" Name="[data]">(cv::Mat*)m_data[0]</Item>
<Synthetic Condition="m_dims == 3" Name="[data]">
<DisplayString>{{{(ito::tDataType)m_type}, {m_osize.m_p[0]} x {m_osize.m_p[1]} x {m_osize.m_p[2]}}}</DisplayString>
<Expand>
<IndexListItems>
<Size>m_osize.m_p[0]</Size>
<ValueNode>(cv::Mat*)m_data[$i]</ValueNode>
</IndexListItems>
</Expand>
</Synthetic>
<Item Name="[continuous]">(bool)m_continuous</Item>
<Item Name="[owndata]">(bool)m_owndata</Item>
<Item Name="[type]">(ito::tDataType)m_type</Item>
<Item Name="[refCount]">*m_pRefCount</Item>
<Item Name="[dims]">m_dims</Item>
<Synthetic Name="[origSize]">
<DisplayString>{*m_osize.m_p}, ...</DisplayString>
<Expand>
<ArrayItems>
<Size>m_dims</Size>
<ValuePointer>m_osize.m_p</ValuePointer>
</ArrayItems>
</Expand>
</Synthetic>
<Synthetic Name="[roiOffset]">
<DisplayString>{*m_roi.m_p}, ...</DisplayString>
<Expand>
<ArrayItems>
<Size>m_dims</Size>
<ValuePointer>m_roi.m_p</ValuePointer>
</ArrayItems>
</Expand>
</Synthetic>
<Synthetic Name="[roiSize]">
<DisplayString>{*m_size.m_p}, ...</DisplayString>
<Expand>
<ArrayItems>
<Size>m_dims</Size>
<ValuePointer>m_size.m_p</ValuePointer>
</ArrayItems>
</Expand>
</Synthetic>
</Expand>
</Type>
<Type Name="ito::ParamBase">
<DisplayString Condition="d->type == ito::ParamBase::Type::Char">{d->name,sb} = {d->data.i8Val}</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::Int">{d->name,sb} = {d->data.i32Val}</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::Double">{d->name,sb} = {d->data.f64Val}</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::Complex">{d->name,sb} = {d->data.c128Val.real}</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::DObjPtr">{d->name,sb} = {(ito::DataObject*)d->data.ptrVal,na}</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::String">{d->name,sb} = "{(char*)d->data.ptrVal,sb}"</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::HWRef">{d->name,sb} = {(ito::AddInBase*)d->data.ptrVal,na}</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::CharArray">{d->name,sb} = {(char*)d->data.ptrVal,na}</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::IntArray">{d->name,sb} = {(int*)d->data.ptrVal,na}</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::DoubleArray">{d->name,sb} = {(double*)d->data.ptrVal,na}</DisplayString>
<DisplayString>{d->name,sb}</DisplayString>
<Expand>
<Item Name="[name]">d->name</Item>
<Item Name="[type]">(ito::ParamBase::Type)d->type</Item>
<Item Condition="d->type == ito::ParamBase::Type::Char" Name="[value]">d->data.i8Val</Item>
<Item Condition="d->type == ito::ParamBase::Type::Int" Name="[value]">d->data.i32Val</Item>
<Item Condition="d->type == ito::ParamBase::Type::Double" Name="[value]">d->data.f64Val</Item>
<Item Condition="d->type == ito::ParamBase::Type::Complex" Name="[value]">d->data.c128Val.real</Item>
<Item Condition="d->type == ito::ParamBase::Type::DObjPtr" Name="[value]">(ito::DataObject*)d->data.ptrVal,na</Item>
<Item Condition="d->type == ito::ParamBase::Type::String" Name="[value]">(char*)d->data.ptrVal,sb</Item>
<Item Condition="d->type == ito::ParamBase::Type::HWRef" Name="[value]">(ito::AddInBase*)d->data.ptrVal,na</Item>
<Item Condition="d->type == ito::ParamBase::Type::CharArray" Name="[value]">(char*)d->data.ptrVal,na</Item>
<Item Condition="d->type == ito::ParamBase::Type::IntArray" Name="[value]">(int*)d->data.ptrVal,na</Item>
<Item Condition="d->type == ito::ParamBase::Type::DoubleArray" Name="[value]">(double*)d->data.ptrVal,na</Item>
</Expand>
</Type>
<!-- This is a special view when the params are in a param map (usually m_params)
which excludes the case for HWRef since this leads to cyclic recursion errors
because HWRefs (usually plugins) contain a param map themselves. -->
<Type Name="ito::ParamBase" IncludeView="ParamMap">
<DisplayString Condition="d->type == ito::ParamBase::Type::Char">{d->name,sb} = {d->data.i8Val}</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::Int">{d->name,sb} = {d->data.i32Val}</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::Double">{d->name,sb} = {d->data.f64Val}</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::Complex">{d->name,sb} = {d->data.c128Val.real}</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::String">{d->name,sb} = "{(char*)d->data.ptrVal,sb}"</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::CharArray">{d->name,sb} = {(char*)d->data.ptrVal,na}</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::IntArray">{d->name,sb} = {(int*)d->data.ptrVal,na}</DisplayString>
<DisplayString Condition="d->type == ito::ParamBase::Type::DoubleArray">{d->name,sb} = {(double*)d->data.ptrVal,na}</DisplayString>
<DisplayString>{d->name,sb}</DisplayString>
<Expand>
<Item Name="[name]">d->name</Item>
<Item Name="[type]">(ito::ParamBase::Type)d->type</Item>
<Item Condition="d->type == ito::ParamBase::Type::Char" Name="[value]">d->data.i8Val</Item>
<Item Condition="d->type == ito::ParamBase::Type::Int" Name="[value]">d->data.i32Val</Item>
<Item Condition="d->type == ito::ParamBase::Type::Double" Name="[value]">d->data.f64Val</Item>
<Item Condition="d->type == ito::ParamBase::Type::Complex" Name="[value]">d->data.c128Val.real</Item>
<Item Condition="d->type == ito::ParamBase::Type::String" Name="[value]">(char*)d->data.ptrVal,sb</Item>
<Item Condition="d->type == ito::ParamBase::Type::CharArray" Name="[value]">(char*)d->data.ptrVal,na</Item>
<Item Condition="d->type == ito::ParamBase::Type::IntArray" Name="[value]">(int*)d->data.ptrVal,na</Item>
<Item Condition="d->type == ito::ParamBase::Type::DoubleArray" Name="[value]">(double*)d->data.ptrVal,na</Item>
</Expand>
</Type>
<!-- Redefine QMap for the special case of a params map for better display. -->
<Type Name="QMap<QString,ito::Param>">
<DisplayString>{{ size={d.d->m._Mypair._Myval2._Myval2._Mysize} }}</DisplayString>
<Expand>
<TreeItems>
<Size>d.d->m._Mypair._Myval2._Myval2._Mysize</Size>
<HeadPointer>d.d->m._Mypair._Myval2._Myval2._Myhead->_Parent</HeadPointer>
<LeftPointer>_Left</LeftPointer>
<RightPointer>_Right</RightPointer>
<ValueNode Condition="_Isnil == 0" Name="[{_Myval.first}]">_Myval.second,view(ParamMap)</ValueNode>
</TreeItems>
</Expand>
</Type>
<Type Name="ito::AddInBase">
<DisplayString>{m_identifier}</DisplayString>
<Expand>
<Item Name="[identifier]">m_identifier</Item>
<Item Name="[m_params]">m_params</Item>
</Expand>
</Type>
<Type Name="SerialIO">
<DisplayString>SerialIO ({m_identifier})</DisplayString>
<Expand>
<Item Name="[m_identifier]">m_identifier</Item>
<Item Name="[m_params]">m_params</Item>
</Expand>
</Type>
</AutoVisualizer>
Hello,
when debugging with Itom in C++ some data types are not really readable, especially ito::Param. The view while debugging can be enhanced with ".natvis" files. With the code pasted here below the parameters name, type and value are displayed readably but yet not for pointer types.
For this to also work with e.g. QVectorito::ParamBase, the qt6.natvis file does also have to be used. It can be downloaded e.g. from here:
https://github.com/KDABLabs/KDToolBox/blob/master/qt/qt6_natvis/qt6.natvis
This file is used implicitly be the QT extension for visual studio. I can not test how to include an additional .natvis file right now but it should be possible.
When using Visual Studio Code, a natvis file can be added via the "visualizerFile" setting in launch.json. Unfortunately there can be only one file, so the contents from below would have to be copied together with the qt6.natvis into a single file.
Maybe this is a useful starting point to create a helpful .natvis file for Itom to enhance the debugging experience.
Cheers
Thomas
P.S. I would have loved to show you some pictures of the improvements but the PNG upload did take so long, that it was not possible.