Show Array's Content in a Range in Qt Debugger

旧城冷巷雨未停 提交于 2019-12-13 16:02:43

问题


I'm using QT Creator debugger. When I try to debug a large array (i.e. 1000,000 elements), it hangs for trying to retrieve the whole array's values, though I'm trying to see the first few elements only. In KDevelop the debugger shows the first 5 elements only, then I press click to show another 5 elements and so on.

Is it possible to do the same in QT Creator?


回答1:


The answer depends on the debugging backend you use, and the version of Qt Creator.

With GDB as debugging backend you can use 'Add New Expression Evaluator' form the the 'Locals and Expression' view's context menu, and enter '{Type[100]}a' to see the items a[0] through a[99] of an array defined as 'Type a[100000];'.

In Qt Creator 3.2 the simpler 'a[0..100]' works as expression, too, with both GDB and LLDB as debugging backend.




回答2:


It also works if you right click on the array variable in the Locals and Expressions pane and select "Add expression evaluator for [array variable]". Then the watched variable will show up in a divided pane. You should double click on the variable name, add a * before and a @qty after. Eg.: if the array variable is called myArray and you need to see the first 10 elements, then it should look like this: *myArray@10.



来源:https://stackoverflow.com/questions/24739414/show-arrays-content-in-a-range-in-qt-debugger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!