gdb打印mbuf的方法:
vim ~/.gdbinit
handle SIGPIPE nostop noprint
define pmbuf
set $m = (struct rte_mbuf *)$arg0
printf "dump mbuf at %p, buf_addr:%p, buf_len=%hu, data_off=%u\n", $m, $m->buf_addr, $m->buf_len, $m->data_off
printf "data_len=%hu, pkt_len=%d\n", $m->data_len, $m->pkt_len
printf "ol_flags=0x%x, nb_segs=%u\n", $m->ol_flags, $m->nb_segs
while $m
set $data_len = $m->data_len
set $data = $m->buf_addr + $m->data_off
dump binary memory /tmp/dump.bin $data $data+$data_len
shell hexdump -n 100 -C /tmp/dump.bin
set $m = $m->next
end
end
document pmbuf
print mbuf
usage: pmbuf batch->packets[0]
end
打印出的内容如下:
image.png
将数据部分保存到txt文件,打开wireshark,文件-> 从Hex转储导入既可
image.png
网友评论