美文网首页
gdb打印DPDK mbuf

gdb打印DPDK mbuf

作者: _宋江_ | 来源:发表于2022-10-27 19:59 被阅读0次

    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

    相关文章

      网友评论

          本文标题:gdb打印DPDK mbuf

          本文链接:https://www.haomeiwen.com/subject/ifattdtx.html