Skip to content

Library to generate call graph for cpp functions

License

Notifications You must be signed in to change notification settings

purcell/call-graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

call-graph - Library to generate call graph for cpp functions

Generate call graph for cpp functions.

Where does this library come from?

How many times have you had this feeling that why can't we have this in emacs when you see the fancy function call hierarchy in "modern" IDEs? I hope one day, with this library, we won't have to envy those "modern" IDEs for this again.

Installation

Clone the repo, then in your Emacs init file:

(add-to-list 'load-path "/path/to/repo")
(require 'call-graph)
(call-graph) ;; to launch it

Dependencies

  • GNU Global
  • hierarchy
  • tree-mode

Basicly call-graph just recursively call Global to find caller of current function and eventually build up a call-graph tree.

Usage

Place your cursor in the cpp function which you want to generate call-graph for and execute call-graph. You could bind it to C-c g.

    (global-set-key (kbd "C-c g") 'call-graph)

Keys

    (define-key map (kbd "e") 'call-graph-widget-expand-all)
    (define-key map (kbd "c") 'call-graph-widget-collapse-all)
    (define-key map (kbd "p") 'widget-backward)
    (define-key map (kbd "n") 'widget-forward)
    (define-key map (kbd "q") 'call-graph-quit)
    (define-key map (kbd "d") 'call-graph-display-file-at-point)
    (define-key map (kbd "o") 'call-graph-goto-file-at-point)
    (define-key map (kbd "+") 'call-graph-expand)
    (define-key map (kbd "_") 'call-graph-collapse)
    (define-key map (kbd "g") 'call-graph)
    (define-key map (kbd "<RET>") 'call-graph-goto-file-at-point)

Customization

Specify the parse depth of the call-graph. default is 2, the more the depth is, the longer it takes.

    (setq call-graph-initial-max-depth 3)

Exclude UT/CT directories like /Dummy_SUITE/ /Dummy_Test/.

    (setq call-graph-filters '("grep -v \"Test/\"" "grep -v \"_SUITE/\""))

Screenshots

call-graph-demo-1.gif call-graph-demo-2.gif

Limitations

Currently when parsing calling relations, header files is excluded. Lots more need to be improved.

Features

  • Navigate to the caller file location.
  • Support filter when searching for callers.
  • Incrementally generate sub caller.
  • Support mark sub caller tree as negtive match.
  • Add font to distinguish between active/non-active caller.
  • Support persistence of call-graph cache data.
  • Add async support for call-graph generation.

Contributing

Yes, please do! See CONTRIBUTING for guidelines.

License

Copyright (c) 2018 Huming Chen [email protected]

About

Library to generate call graph for cpp functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published