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

fak*_*ake 4 c emacs parsing 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()
 }
Run Code Online (Sandbox Code Playgroud)

当使用参数A运行真棒工具时,它将以某种方式返回函数BC和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
}
Run Code Online (Sandbox Code Playgroud)

如果以上可以与emacs很好地合作,我会非常高兴!

Nic*_*tfm 7

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

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