开发者

Why this static function has no debug symbol?

开发者 https://www.devze.com 2023-02-21 21:38 出处:网络
(gdb) l main ... 4614if (开发者_JAVA百科do_daemonize) 4615save_pid(getpid(), pid_file); (gdb) l save_pid
(gdb) l main
...

4614        if (开发者_JAVA百科do_daemonize)
4615            save_pid(getpid(), pid_file);
(gdb) l save_pid
  Function "save_pid" not defined.

and there's its definition in source file:

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

save_pid and main are in the same source file,but only main has debug symbol,why??

UPDATE

Another test case with a really simple static function:

#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

But the symbol test is there!


If the function is simple enough and its address is never used, being static it may have been inlined and then discarded (since there is no possibility of it being called from elsewhere).

0

精彩评论

暂无评论...
验证码 换一张
取 消