使用 gdb-python 脚本,我正在尝试打印包括内核数据结构和列表(例如 struct list_head)的数据结构,该结构是
struct my_struct {
struct my_hardware_context ahw;
struct net_device *netdev;
struct pci_dev *pdev;
struct list_head mac_list;
struct list_head wait_list;
....
....
};
因此,在迭代这个 struct my_struct 时,如何识别这个结构内有一个链表,因为 gdb 手册中没有任何 TYPE_CODE_ 常量用于链表,如果确定,在识别后如何在迭代列表时打印取消引用的结构。我在此链接gdb-python 中使用 scottt 的代码:解析结构的每个字段并以适当的值打印它们(如果存在)