Git Product home page Git Product logo

call-graph's Introduction

call-graph - Library to generate call graph for c/c++ functions

MIT licensed MELPA MELPA Stable 996.icu

Generate call graph for c/c++ 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

Or install from melpa.

Dependencies

  • GNU Global
  • hierarchy
  • tree-mode
  • ivy
  • anaconda-mode

For C++, call-graph will recursively call Global to find caller of current function and eventually build up a call-graph tree.

For python, call-graph rely on anaconda-mode to provide caller of current function and eventually build up a call-graph tree.

Usage

Place your cursor in the c/c++ 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") 'cg/widget-expand-all)
    (define-key map (kbd "c") 'cg/widget-collapse-all)
    (define-key map (kbd "p") 'widget-backward)
    (define-key map (kbd "n") 'widget-forward)
    (define-key map (kbd "q") 'cg/quit)
    (define-key map (kbd "+") 'cg/expand)
    (define-key map (kbd "_") 'cg/collapse)
    (define-key map (kbd "o") 'cg/goto-file-at-point)
    (define-key map (kbd "g") 'cg/at-point)
    (define-key map (kbd "d") 'cg/remove-caller)
    (define-key map (kbd "l") 'cg/select-caller-location)
    (define-key map (kbd "r") 'cg/reset-caller-cache)
    (define-key map (kbd "t") 'cg/toggle-show-func-args)
    (define-key map (kbd "f") 'cg/toggle-invalid-reference)
    (define-key map (kbd "<RET>") 'cg/goto-file-at-point)

Customization

Customize the location of the GNU GLOBAL binary.

    (setq cg-path-to-global "/home/huming/private/gtags-6.5.7/bin/")

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

    (setq cg-initial-max-depth 3)

Avoid truncating Imenu entries.

    (setq imenu-max-item-length "Unlimited")

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

    (dolist (filter '("grep -v \"Test/\""
                    "grep -v \"_SUITE/\""
                    "grep -v \"/test-src/\""
                    "grep -v \"/TestPkg/\""))
    (add-to-list 'cg-search-filters filter))

Save caller-relations in .session.

    (add-hook 'kill-emacs-hook #'cg/prepare-persistent-data)

    (setq desktop-globals-to-save
        (append '((cg-persist-caller-cache . 1000)
                  tags-file-name
                  tags-table-list)))

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 cache when searching for callers.
  • Incrementally generate sub caller.
  • Support manually remove wrong callers.
  • Support persistence of call-graph cache data.
  • Toggle show function args in call-graph.
  • Add basic python support.

Contributing

Yes, please do! See CONTRIBUTING for guidelines.

License

See LICENSE. Copyright (c) 2018-2019 Huming Chen [email protected]

call-graph's People

Contributors

beacoder avatar brightchikudza avatar kjmatsuda avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.