[英]How can I print all of specific attributes in a whole linked struct list when debugging with gdb?
Supposing a linked-list have lots of nodes, and each node is a struct like this假设一个链表有很多节点,每个节点都是这样的结构
struct sth{
int key;
struct sth * next;
};
How could I print all the "key" values in gdb easily instead of input commands like print (*head).key
, print (*head->next).key
, print (*head->next->next).key
...如何轻松打印 gdb 中的所有“关键”值,而不是像
print (*head).key
、 print (*head->next).key
、 print (*head->next->next).key
这样的输入命令...
thx.谢谢。
You can write a custom pretty-printer in Python and plug it into gdb 7.0 or later.您可以在 Python 中编写自定义漂亮打印机并将其插入 gdb 7.0 或更高版本。 Here's a good-looking tutorial: http://blog.rethinkdb.com/make-debugging-easier-with-custom-pretty-prin
这里有一个好看的教程: http://blog.rethinkdb.com/make-debugging-easier-with-custom-pretty-prin
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.