如何生成模块中的头文件引用关系图

本文介绍了一个脚本,用于生成C代码模块间的头文件引用关系图。通过解析代码并使用dot工具,可以直观展示模块调用关系。使用者只需修改脚本中的代码路径,运行脚本并利用dot命令即可生成SVG图像。
摘要由CSDN通过智能技术生成

背景

当拿到一个模块的代码,我们自然而然的想要生成了解代码中的模块调用关系。
那么下面的脚本就是生成了模块之间的调用关系,图示如下:
在这里插入图片描述

原理

使用dot画图
以上的图示,dot源文件如下:

digraph spdk {
    graph [
        rankdir = "LR"
        //splines=polyline
        overlap=false
    ];

    node [
        fontsize = "16"
        shape = "ellipse"
    ];

    edge [
    ];
    "acl" [
        label = "<head> acl\l|
            {|{
                <f2fs> f2fs.h\l|
                <xattr> xattr.h\l|
                <acl> acl.h\l|
            }}"
        shape = "record"
    ];

    "checkpoint" [
        label = "<head> checkpoint\l|
            {|{
                <f2fs> f2fs.h\l|
                <node1> node.h\l|
                <segment> segment.h\l|
                <iostat> iostat.h\l|
            }}"
        shape = "record"
    ];

    "compress" [
        label = "<head> compress\l|
            {|{
                <f2fs> f2fs.h\l|
                <node1> node.h\l|
                <segment> segment.h\l|
            }}"
        shape = "record"
    ];

    "data" [
        label = "<head> data\l|
            {|{
                <f2fs> f2fs.h\l|
                <node1> node.h\l|
                <segment> segment.h\l|
                <iostat> iostat.h\l|
            }}"
        shape = "record"
    ];

    "debug" [
        label = "<head> debug\l|
            {|{
                <f2fs> f2fs.h\l|
                <node1> node.h\l|
                <segment> segment.h\l|
                <gc> gc.h\l|
            }}"
        shape = "record"
    ];

    "dir" [
        label = "<head> dir\l|
            {|{
                <f2fs> f2fs.h\l|
                <node1> node.h\l|
                <acl> acl.h\l|
                <xattr> xattr.h\l|
            }}"
        shape = "record"
    ];

    "extent_cache" [
        label = "<head> extent_cache\l|
            {|{
                <f2fs> f2fs.h\l|
                <node1> node.h\l|
            }}"
        shape = "record"
    ];

    "file" [
        label = "<head> file\l|
            {|{
                <f2fs> f2fs.h\l|
                <node1> node.h\l|
                <segment> segment.h\l|
                <xattr> xattr.h\l|
                <acl> acl.h\l|
                <gc> gc.h\l|
                <iostat> iostat.h\l|
            }}"
        shape = "record"
    ];

    "gc" [
        label = "<head> gc\l|
            {|{
                <f2fs> f2fs.h\l|
                <node1> node.h\l|
                <segment> segment.h\l|
                <gc> gc.h\l|
       
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值