利用Graphviz dot画函数调用图

比如addr2line的函数调用关系用dot语法表示如下:(存为call.dot)
digraph g  {
translate_addresses
->bfd_scan_vma;
translate_addresses
->bfd_map_over_sections;
translate_addresses
->find_address_in_section;
translate_addresses
->cplus_demangle;
find_address_in_section
->bfd_get_section_flags;
find_address_in_section
->bfd_get_section_vma;
find_address_in_section
->bfd_get_section_size_before_reloc;
find_address_in_section
->bfd_find_nearest_line;
process_file
->bfd_openr;
process_file
->bfd_fatal;
process_file
->bfd_check_format;
process_file
->bfd_check_format_matches;
process_file
->bfd_get_filename;
process_file
->bfd_get_error;
process_file
->list_matching_formats;
process_file
->slurp_symtab;
process_file
->translate_addresses;
process_file
->bfd_close;
main
->setlocale;
main
->bindtextdomain;
main
->textdomain;
main
->xmalloc_set_program_name;
main
->bfd_init;
main
->set_default_bfd_target;
main
->getopt_long;
main
->cplus_demangle_name_to_style;
main
->cplus_demangle_set_style;
main
->print_version;
main
->process_file;
main
->usage;
slurp_symtab
->bfd_get_file_flags;
slurp_symtab
->bfd_get_symtab_upper_bound;
slurp_symtab
->bfd_get_filename;
slurp_symtab
->xmalloc;
slurp_symtab
->bfd_canonicalize_symtab;
usage
->list_supported_targets;
}
然后在cmd下输入 dot -Tjpg call.dot -o Addr2line.jpg
就得到了函数调用关系图

你可能感兴趣的:(graphviz,file,list,cmd)