graphviz画结构体的图-手动

论坛 期权论坛 脚本     
已经匿名di用户   2022-5-29 19:20   2571   0

先上代码

digraph mtd_info{
 node [shape=record, fontsize=12, style=filled];
 edge[color=blue];
 rankdir=LR;

 subgraph struct_mtd_info {
  node[shape=record style=filled];
  color=lightgray;
  style=filled;
  label = "struct mtd_info";
  edge[color="#2e3436"];
  node_mtd_info[shape=record,label="<f0>u_char type\
         |<f1>uint32_t flags\
         |<f2>uint64_t size\
         |<f3>uint32_t erasesize\
         |<f4>uint32_t writesize\
         |<f4>uint32_t oobsize\
         |<f5>uint32_t oobavail\
         |<f6>unsigned int erasesize_shift\
         |<f7>unsigned int writesize_shift\
         |<f8>unsigned int erasesize_mask\
         |<f9>unsigned int writesize_mask\
         |<f10>const char *name\
         |<f11>int index\
         |<f12>struct nand_ecclayout *ecclayout\
         |<f13>int numeraseregions\
         |<f14>struct mtd_erase_region_info *eraseregions\
         |<f15>int (*erase)(struct mtd_info *mtd, struct erase_info *instr)\
         |<f16>int (*point)(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, void **virt, resource_size_t *phys)\
         |<f17>void (*unpoint)(struct mtd_info *mtd, loff_t from, size_t len)\
         |<f18>unsigned long (*get_unmapped_area)(struct mtd_info *mtd, unsigned long len, unsigned long offset, unsigned long flags)\
         |<f19>struct backing_dev_info *backing_dev_info\
         |<f20>int (*read)(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)\
         |<f21>int (*write)(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)\
         |<f22>int (*panic_write)(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)\
         |<f23>int (*read_oob)(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)\
         |<f24>int (*write_oob)(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops)\
         |<f25>int (*get_fact_prot_info)(struct mtd_info *mtd, struct otp_info *buf, size_t len)\
         |<f26>int (*read_fact_prot_reg)(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)\
         |<f27>int (*get_user_prot_info)(struct mtd_info *mtd, struct otp_info *buf, size_t len)\
         |f<28>int (*read_user_prot_reg)(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)\
         |f<29>int (*write_user_prot_reg)(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)\
         |f<30>int (*lock_user_prot_reg)(struct mtd_info *mtd, loff_t from, size_t len)\
         |f<31>int (*writev)(struct mtd_info *mtd, cosnt struct kvec *vecs, unsigned long count,loff_t to, size_t *retlen)\
         |f<32>void (*sync)(struct mtd_info *mtd)\
         |f<33>int (*lock)(struct mtd_info *mtd, loff_t ofs, uint64_t len)\
         |f<34>int (*unlock)(struct mtd_info *mtd, loff_t ofs, uint64_t len)\
         |f<35>int (*suspend)(struct mtd_info *mtd)\
         |f<36>void (*resume)(struct mtd_info *mtd)\
         |f<37>int (*block_isbad)(struct mtd_info *mtd, loff_t ofs)\
         |f<38>int (*block_markbad)(struct mtd_info *mtd, loff_t ofs)\
         |f<39>struct notifier_block reboot_notifier\
         |f<40>struct mtd_ecc_stats ecc_stats\
         |f<41>int subpage_sft\
         |f<42>void *priv\
         |f<43>struct module *owner\
         |f<44>struct device dev\
         |f<45>int usecount\
         |f<46>int (*get_device)(struct mtd_info *mtd)\
         |f<47>void (*put_device)(struct mtd_info *mtd)\
         |f<999>"];
 }
}

这里面用到了子图,还用到了node相关的东西。

生成了一个结构体而已

之间的调用关系可以写到一起,先声明后使用,箭头指指就好了。


这里很笨的用的手动方式,用脚本的话可以自动哦

不过,需要解析文件,找出结构体等成员才是算法最难的地方

这里,我们也可以看到,算法+辅助工具的用处,也体现了算法才是核心

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:81
帖子:4969
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP