问题 Emacs可以告诉我调用特定函数的位置吗?


在Emacs中有没有办法找出代码中哪些其他地方调用特定函数?使用我当前的设置(GNU emacs 23.1.1,C代码库),我通常必须在整个代码库中搜索函数名称,以查看其他函数调用它。如果我能够有效地显示调用我正在查看的这个特定函数的函数的所有名称,那将是很好的。


12752
2018-06-02 05:12


起源

哪种语言? - Noufal Ibrahim
我在Linux上使用Emacs进行C编程编译与GCC 4.4.3 - ant2009


答案:


我用 xcscope 为了这。它是一个使Emacs与外部交互的库 cscope 工具。

设置完成后,即可使用 cscope-find-functions-calling-this-function 获取调用某个函数的源代码目标列表。

http://www-inst.eecs.berkeley.edu/~cs186/fa05/debugging/xcscope.el http://www.emacswiki.org/emacs/CScopeAndEmacs


2
2018-06-02 06:34





您可以使用 semantic-symref 功能(C-c , G)来自CEDET包。它可以使用GNU Global或CTags数据库来查找呼叫者(如果存在)。它还可以解析源以查找事件。


11
2018-06-02 07:26





这是我旧的.emacs文件的片段

它确实:要求从etags-tagfile中找到的东西(find-tag-tag) 根据模式grep它

(defun find-caller (tagname)
  "Find occurences of tagname in files in the current directory
matching extension of current file."
  (interactive (list (find-tag-tag "Find caller: ")))
  (let ((cmd "grep -n "))
    (cond
     ((member major-mode '(lisp-mode cmulisp-mode))
      (grep (concat cmd "-i '" tagname "' *.lisp")))
     ((eq major-mode 'c-mode)
      (grep (concat cmd "'" tagname "' *.[ch]")))
     ((member major-mode '(latex-mode tex-mode))
      (grep (concat cmd "-i '" tagname "' *.tex")))
     ((eq major-mode 'emacs-lisp-mode)
      (grep (concat cmd "'" tagname "' *.el")))
     (t (grep (concat cmd "'" tagname "' *"))))))

1
2018-06-02 12:51



仅供参考:CEDET可以使用grep查找来电者 - Alex Ott