Create views of OpenCASCADE objects in the Debugger
Create views of OpenCASCADE objects in the Debugger
Abstract. The Visual Studio Natvis framework lets you customize the way Visual Studio displays native types in debugger variable windows such as the Watch, Locals and Data Tips windows. It supersedes the autoexp.dat file that has been used in earlier versions of Visual Studio and offers XML syntax, better diagnostics, versioning, and multiple file support. The container in OpenCASCADE is difficult for debugging, such as TColStd_Array1OfInteger in the TColStd package, .etc. Use the natvis framework to create views of these objects will make it easy for developers to inspect them during debugging and so accelerate the debug process.
Key Words. Visual Studio Natvis, OpenCASCADE
1. Introduction
因 为OpenCASCADE早期使用C开发,所以自定义了一些容器类,如包TColStd中的类,TColGeom包及包TopTools中的类等,这些类 在C++中都可以使用STL来替代了。这些类在Debug过程中,很难查看其中的值,如TColStd_Array1OfInteger,这个类相当于 std::vector<int>,但是Debug时只能看到数据的指针,不容易查看容器中每个元素的值,如下图1.1所示:
Figure 1.1 View of TColStd_Array1OfInteger in Locals Window
由 上图1.1可知,对于这个类的对象,Debug时只能看到数据的起始指针。为了方便自定义类型调试,Visual Studio在2012版本以后,引入了Natvis框架,用来替代原来的autoexp.dat来为自定义类型定义调试时的数据显示。Natvis使用 了XML文件,可读性更好,易于实现。
本文使用Visual Studio的Natvis框架,来对OpenCASCADE中的一些容器类数据进行可视化,方便开发者对OpenCASCADE的调试。
2.For Array Container
对于OpenCASCADE的包TColStd中的数组类,定义其natvis如下所示:
<Type Name="TColStd_Array1OfInteger">
<DisplayString Condition="isAllocated != 1">empty</DisplayString>
<DisplayString>{{size = {myUpperBound - myLowerBound + 1}}}</DisplayString>
<Expand>
<Item Condition="isAllocated == 1" Name="[size]">myUpperBound - myLowerBound + 1</Item>
<ArrayItems Condition="isAllocated == 1">
<Size>myUpperBound - myLowerBound + 1</Size>
<ValuePointer>(Standard_Integer*)(myStart) + myLowerBound</ValuePointer>
</ArrayItems>
</Expand>
</Type>
调试时数据显示如下图2.1所示:
Figure 2.1 OpenCASCADE array in Locals Windows
同理,可对此包中其他一维数组使用同样的规则,即可对其中的数据可视化,与std::vector显示的效果一样,方便调试。
3.For List Container
对于OpenCASCADE的包TColStd中的链表类,定义其natvis如下所示:
<Type Name="TColStd_ListNodeOfListOfInteger">
<DisplayString>{{current = {myValue}}}</DisplayString>
<Expand>
<LinkedListItems>
<HeadPointer>this</HeadPointer>
<NextPointer>(TColStd_ListNodeOfListOfInteger*)myNext</NextPointer>
<ValueNode>this->myValue</ValueNode>
</LinkedListItems>
</Expand>
</Type> <Type Name="TColStd_ListOfInteger">
<DisplayString Condition="myFirst == 0">empty</DisplayString>
<Expand>
<Item Name="first">(TColStd_ListNodeOfListOfInteger*)myFirst</Item>
</Expand>
</Type>
调试时对于类TColStd_ListOfInteger,natvis诊断说找不到类TColStd_ListNodeOfListOfInteger定义,当跟踪到此类一个具体函数时,就可以看到具体的值了:
Figure 3.1 Natvis gives a Error info
跟踪到TColStd_ListOfInteger内部后,就可以看到类TColStd_ListNodeOfListOfInteger中的数据了,但是从TColStd_ListOfInteger的函数中出来后,就看不到了。
如果这个问题解决了,对于类TopoDS_ListOfShape中的数据也可以用同样的方式来显示,极大地方便了开发者对其调试。如果你对此有解决办法,欢迎不吝赐教。
Figure 3.2 Data view for TColStd_ListNodeOfListOfInteger
先从简单的容器类着手,解决后可将TopoDS_ListOfShape中的数据显示出来,为OpenCASCADE程序的调试提供方便。
4.Conclusion
Visual Studio 2012版本以后引入了Natvis框架来对自定义的类进行可视化,方便调试。OpenCASCADE中有很多容器类直接使用了指针,调试程序时数据很不 直观。应用Natvis来对一些类在调试时的视图进行配置,可以方便查看其中数据,使OpenCASCADE的调试更轻松。
对于一维数组的natvis定义还是很简单的,但是对于List出现了问题。如果这个问题解决了,对TopoDS_ListOfShape的可视化也可做同样的处理,方便造型算法调试。若您有解决方案,望不吝赐教。
5. References
1. Create custom views of native objects in the debugger.
https://msdn.microsoft.com/en-us/library/vstudio/jj620914.aspx
2. Writing debugger type visualizers for C++ using .natvis files
https://code.msdn.microsoft.com/Writing-type-visualizers-2eae77a2#content
3. vczh. C++实用技巧之配置Visual C++的调试器显示数据结构的格式.
http://www.cppblog.com/vczh/archive/2013/03/21/198665.html
4. stl.natvis in %VSINSTALLDIR%\Common7\Packages\Debugger\Visualizers
5. qt5.natvis in %VSINSTALLDIR%\Common7\Packages\Debugger\Visualizers
PDF Version: Create views of OpenCASCADE objects in the Debugger
Create views of OpenCASCADE objects in the Debugger的更多相关文章
- 【IOS笔记】Views
Views Because view objects are the main way your application interacts with the user, they have many ...
- View Programming Guide for iOS ---- iOS 视图编程指南(四)---Views
Views Because view objects are the main way your application interacts with the user, they have many ...
- Create view failed with ORA-01031:insufficient privileges
有时候在ORACLE数据库创建视图时会遇到:ORA-01031:insufficient privileges错误,我也多次碰到了各种创建视图出错的情况,很多时候也没有太在意,今天被一同事问起这个问题 ...
- Chapter 7 Integrity(完整性), Views(视图), Security(安全性), and Catalogs(目录)
from Database Design to Physical Form CREATE TABLE integrity constraints (完整性约束) CREATE VIEW Securit ...
- iOS学习笔记(6)——翻译苹果文档About Windows and Views
About Windows and Views 关于窗口和视图 In iOS, you use windows and views to present your application’s cont ...
- Django基础(一)_URLconf、Views、template、ORM
一 什么是web框架? 框架,即framework,特指为解决一个开放性问题而设计的具有一定约束性的支撑结构,使用框架可以帮你快速开发特定的系统,简单地说,就是你用别人搭建好的舞台来做表演. 对于所有 ...
- create feature from text file
'''---------------------------------------------------------------------------------- Tool Name: Cre ...
- Note of IOS 7 - Views
1. Views presentation: A view (an object whose class is UIView or a subclass of UIView) knows how to ...
- Node.js log3:create ejs engine and jade engine
The base condition is ensure that you have installed express. 1.create ejs engine Using windows d ...
随机推荐
- bzoj 4327: JSOI2012 玄武密码
听说这题不公开.. 那就不贴题意了 一眼看上去还以为是exkmp的裸题.. 看了数据范围,呵呵.. 多串匹配嘛.. 就用AC自动机咯,而且每个点最多也就只有$4$个孩子 用原串在AC自动机上走,碰到的 ...
- [题解+总结]NOIP2010-2015后四题汇总
1.前言 正式开始的第一周的任务--把NOIP2010至NOIP2015的所有D1/2的T2/3写出暴力.共22题. 暴力顾名思义,用简单粗暴的方式解题,不以正常的思路思考.能够较好的保证正确性,但是 ...
- WP8如何添加Newtonsoft.Json包
WP8开发的时候如何使用Newtonsoft.Json包呢?我在网上包括官网下的DLL文件,添加引用时都给出了这样的提示: 而后在网上找到的解决办法是:使用NuGet程序包来添加. 首先点击工具--& ...
- 关于zepto(相似于jquery、jQuery用于网页浏览器,zepto用于手机浏览器)
http://blog.csdn.net/kongjiea/article/details/42522305 -----关于zepto和jquery的差别 jQuery 使用 .width() 和 ...
- qunit 前端脚本测试用例
首先引用qunit 测试框架文件 <link rel="stylesheet" href="qunit-1.22.0.css"> <scrip ...
- 2014 summer training总结篇
还有一周暑期集训就要结束了,从7月份结束军训到现在一个多月的时间,收获也是有的只不过与之前预想的相比显得十分微薄. 无论是前两天的两场个人赛还是之前的组队赛自己始终是在ranklist的后半部分.一开 ...
- HTML5开发手机应用--viewport的作用
在用HTML5开发手机应用或手机网页时,<head>部分总会有如下一段代码,这段代码到底什么意思呢.在网上,大家会得到很多答案.我从网上搜集了部分介绍,整理一下,以留备用. <met ...
- 解决:No module named pkg_resources
今天在装bleach的时候,发现bleach依赖的其中的一个库是html5lib,从pypi下载源码包,执行python setup.py install,报错了: 提示我的setuptools版本过 ...
- 配置Spark on YARN集群内存
参考原文:http://blog.javachen.com/2015/06/09/memory-in-spark-on-yarn.html?utm_source=tuicool 运行文件有几个G大,默 ...
- chrome浏览器js 导出excel
<table id="table"> <tr> <th>ID</th> <th>姓名</th> <th ...