C 代码解析器,用于跟踪项目中的函数调用和变量访问(emacs 兼容性会很好)

标签 c parsing emacs function-calls

我想要的是一个能够告诉我哪些函数调用特定函数 A()(在 C 项目中)以及哪些函数调用这些函数等的工具,这样我就可以得到一个函数列表知道当它们被调用时,有可能调用函数 A()。

例如我们在一个项目中分散了以下功能:

 void A()
 { /*does something*/ }

 void B()
 {
   A();
   /*and more stuff*/
 }

 void C()
 {
if(unlikely_to_be_false)
    A()
/* moar stoff */
 }

 void D()
 {
/* code that does not refer to A() at all */
 }

 void E()
 {
C()
 }

当使用参数 A 运行 awesome 工具时,它将以某种方式返回函数 B C 和 E。

接近这个但不完全是我想完成的: 给定一个项目中某处的变量,找到对它的所有读/写操作(直接或间接)。

例如:

void A()
{
    char* c; // this is our little variable

    B(c); // this is in the resulting list
}

void B(char* x)
{
    printf("%c", x); // this is definately in the list

    *x='d' // this is also in the list

    C(x); // also in the list
}

void C(void* ptr)
{
    ptr = something; // also in the list
}

如果以上内容可以很好地与 emacs 一起使用,我将非常高兴!

最佳答案

您可以查看 cscope 工具 (http://cscope.sourceforge.net/)。它支持非常大的项目和许多不同的查询类型:

  • 找到这个 C 符号
  • 找到这个全局定义
  • 查找该函数调用的函数
  • 查找调用此函数的函数 ...

关于C 代码解析器,用于跟踪项目中的函数调用和变量访问(emacs 兼容性会很好),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9445437/

相关文章:

C 带 block : Stack-based blocks going out of scope

c - scanf 不起作用(整数)

android - 崩溃的JSON解析Android应用

emacs - 使用 Emacs 和 Cider 进行 Clojure 编码

macos - Emacs 可以跟踪像 BBEdit 这样的文件吗?

c - 使用二叉树

c - c中stm32l中的数据损坏

c - 如何在 Linux 下获取 C 中的原始命令行?

python - 使用 Python 解析和渲染 Kinesis Video Streams 并获取输入帧的图像表示

sql - 在 Emacs sql-mysql 中指定端口号