c - addr2line - 在基本示例上失败

标签 c windows-subsystem-for-linux trace wsl-2 addr2line

#include <stdio.h>

void __cyg_profile_func_enter(void *func, void *caller) __attribute__((no_instrument_function));
void __cyg_profile_func_exit(void *this_fn, void *call_site) __attribute__((no_instrument_function));

void __cyg_profile_func_enter(void *func, void *caller)
{
    printf("%p\n", func);
    printf("%p\n", caller);
}

void __cyg_profile_func_exit(void *this_fn, void *call_site)
{
}

void my_function(int a, int b)
{
    a = a * b;
}

void dummy_function()
{
    int a = 10;
    int b = 20;
    my_function(a, b);
}

int main()
{
    int x = 42;
    int y = 73;
    dummy_function();
    my_function(x, y);

    return 0;
}

构建命令:

gcc -x c boost_stacktrace.cpp -finstrument-functions -rdynamic -g -O0 -o boost_stacktrace.exe
./boost_stacktrace.exe | tee addrs.txt
0x55d97d38324c
0x7f0fa12b0d90
0x55d97d3831f4
0x55d97d383287
0x55d97d3831a9
0x55d97d383233
0x55d97d3831a9
0x55d97d383296
addr2line -e boost_stacktrace.exe -f -i -p < addrs.txt
?? ??:0
?? ??:0
?? ??:0
?? ??:0
?? ??:0
?? ??:0
?? ??:0
?? ??:0

问题
我做错了什么?

最佳答案

-no-pie 添加到编译命令后,它起作用了。

关于c - addr2line - 在基本示例上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75978924/

相关文章:

c++ - VC++6中如何跟踪某个对象

c++ - 如何在 VSCode 上设置数据断点(即观察点)

serial-port - 在 W10 (WSL) 的 Ubuntu 中使用串口

ruby-on-rails - 在 Windows 上运行的 Ubuntu bash 上设置 PostgreSQL

bash - WSL 和 bash 命令

debugging - 如何使用 BPF (BCC) 跟踪 go 函数

c# - 如何在 .net core 3.1 应用程序中访问 W3C TraceContext header ?

无法确定为什么程序的函数将数组返回给主程序

消费者-生产者。没有错误。有时工作。为什么?

c - Eclipse CDT插件问题