日本好好热aⅴ|国产99视频精品免费观看|日本成人aV在线|久热香蕉国产在线

  • <cite id="ikgdy"><table id="ikgdy"></table></cite>
    1. 西西軟件園多重安全檢測下載網(wǎng)站、值得信賴的軟件下載站!
      軟件
      軟件
      文章
      搜索

      首頁編程開發(fā)其它知識 → Emacs & cflow 生成函數(shù)調(diào)用樹 (call graph)

      Emacs & cflow 生成函數(shù)調(diào)用樹 (call graph)

      相關(guān)軟件相關(guān)文章發(fā)表評論 來源:本站整理時間:2010/11/29 11:16:17字體大小:A-A+

      作者:佚名點擊:177次評論:0次標簽: Emacs elisp cflow

      • 類型:Mac編程軟件大。27.5M語言:英文 評分:10.0
      • 標簽:
      立即下載

      介紹了 Emacs 配合 cflow 制作函數(shù)的調(diào)用樹 (call graph)Table of Contents

      1、Introduction to cflow

      GNU cflow analyzes a collection of C source files and prints a graph, charting control flow within the program.

      GNU cflow is able to produce both direct and inverted flowgraphs for C sources. Optionally a cross-reference listing can be generated. Two output formats are implemented: POSIX and GNU (extended).

      Input files can optionally be preprocessed before analyzing.

      The package also provides Emacs major mode for examining the produced flowcharts in Emacs.

      以上內(nèi)容取自 cflow 的網(wǎng)站: http://www.gnu.org/software/cflow/manual/html_node/Intro.html#Intro。

      2、Emacs & cflow

      cflow 的代碼包中提供了cflow-mode.el, 該文件提供了 emacs 的 cflow-mode, 用于顯示 cflow 輸出的內(nèi)容,但該文件中并未提供自動生成指定函數(shù)的 call tree 的功能,用起來多少有點不方便。

      下面是一個簡單的 elisp 函數(shù),通過該函數(shù)可以為指定的函數(shù)生成調(diào)用樹。

      (defvar cmd nil nil)
      (defvar cflow-buf nil nil)
      (defvar cflow-buf-name nil nil)

      (defun yyc/cflow-function (function-name)
      "Get call graph of inputed function. "
      ;(interactive "sFunction name:\n")
      (interactive (list (car (senator-jump-interactive "Function name: "
      nil nil nil))))
      (setq cmd (format "cflow -b --main=%s %s" function-name buffer-file-name))
      (setq cflow-buf-name (format "**cflow-%s:%s**"
      (file-name-nondirectory buffer-file-name)
      function-name))
      (setq cflow-buf (get-buffer-create cflow-buf-name))
      (set-buffer cflow-buf)
      (setq buffer-read-only nil)
      (erase-buffer)
      (insert (shell-command-to-string cmd))
      (pop-to-buffer cflow-buf)
      (goto-char (point-min))
      (cflow-mode)
      )

      函數(shù)中使用了 CEDET 提供的 senator-jump-interactive 用于實現(xiàn)函數(shù)名的自動補全, 如果你的機器上沒有 CEDET, 那么就把 (interactive "sFunction name:\n") 的注釋去掉, 而將后面的那句話注釋掉即可。
      用法很簡單,將上面的代碼添加到 ~/.emacs 中后,重新載入配置文件,然后打開一個 C 文件, M-x, 輸入: yyc/cflow-function , 隨后在 Mini-buffer 中輸入函數(shù)名字, 回車,即可生成一個新的 buffer, 并在其中填寫了生成的調(diào)用樹。

      如下圖所示:

      在調(diào)用樹中,還可以通過鍵盤從調(diào)用樹中跳轉(zhuǎn)到相應的源代碼中。

      這樣, cflow 配置 GNU Global 和 cedet , 代碼的閱讀和理解效率會大大提高。

        相關(guān)評論

        閱讀本文后您有什么感想? 已有人給出評價!

        • 8 喜歡喜歡
        • 3 頂
        • 1 難過難過
        • 5 囧
        • 3 圍觀圍觀
        • 2 無聊無聊

        熱門評論

        最新評論

        發(fā)表評論 查看所有評論(0)

        昵稱:
        表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
        字數(shù): 0/500 (您的評論需要經(jīng)過審核才能顯示)