gdb - 为什么这个静态函数没有调试符号?

标签 gdb debug-symbols

(gdb) l main
...

4614        if (do_daemonize)
4615            save_pid(getpid(), pid_file);
(gdb) l save_pid
  Function "save_pid" not defined.

在源文件中有它的定义:

static void save_pid(const pid_t pid, const char *pid_file) {
    FILE *fp;
    ...
}

save_pidmain在同一个源文件中,但是只有main有调试符号,为什么??

更新

另一个具有非常简单的静态函数的测试用例:

#include <stdio.h>

static int test()
{
        return 0;
}
int main(void)
{
        //int i = 6;
        printf("%f",6.4);
        return 0;
}

gcc -Wall -g test.c test

但是符号 test 在那里!

最佳答案

如果函数足够简单并且它的地址从未被使用过,它是static,它可能已经被内联然后被丢弃(因为它不可能从其他地方被调用)。

关于gdb - 为什么这个静态函数没有调试符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5509913/

相关文章:

linux - 为什么GDB运行前设置的断点不起作用?

macos - lldb:如何从特定库/框架调用函数

c# - Visual Studio 符号缓存中的 D0C3BDDD4ADD4E87B2B5E803303B8D772 等目录名称是什么意思?

gcc - 如何在MacPorts gcc 4.5中调试C++ 0x程序?

xcode - 带有 XCode 目标的 CMake,生成忽略发布配置的调试符号设置

debugging - 为什么 SASM 的调试器在存储后不显示 "result"变量更新的值?

Java jar 符号信息 : what is the equivalent of tdstrip?

c - 堆栈损坏;跨函数调用时存储在寄存器中的变量会发生什么?

c - gdb - cygexpat-1.dll 缺失

c++ - 如何在 OSX 上获取 "codesigned"gdb?