在 gdb 中打印整个链表? [英] Print the whole linked list in gdb?
本文介绍了在 gdb 中打印整个链表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I have a linked list
struct node {
data_t data;
node_t *next;
};
typedef struct {
node_t *head;
node_t *foot;
node_t *curr; // for iterator
unsigned int size;
} list_t;
with this structure, let say I defined a list
list_t* myList;
How can I use GDB to print the whole linked list?
解决方案
This should work (but untested):
define plist
set var $n = $arg0->head
while $n
printf "%d ", $n->data
set var $n = $n->next
end
end
(gdb) plist myList
You could put plist
into ~/.gdbinit
这篇关于在 gdb 中打印整个链表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文