Tag: 堆栈跟踪

调用C函数,该函数不带参数参数

关于C调用约定和64/32位编译之间可能存在未定义的行为,我有一些奇怪的问题。 首先是我的代码: int f() { return 0; } int main() { int x = 42; return f(x); } 正如你所看到的,我用参数调用f,而f不带参数。 我的第一个问题是这个论点在调用时是否真的给了f。 神秘的线条 经过一点点objdump我得到了好奇的结果。 传递x作为f的参数: 00000000004004b6 : 4004b6: 55 push %rbp 4004b7: 48 89 e5 mov %rsp,%rbp 4004ba: b8 00 00 00 00 mov $0x0,%eax 4004bf: 5d pop %rbp 4004c0: c3 retq 00000000004004c1 : 4004c1: 55 push […]

如何在SIGSEGV上使用_Unwind_Backtrace获取fullstacktrace

我通过代码处理SIGSEGV: int C() { int *i = NULL; *i = 10; // Crash there } int B() { return C(); } int A() { return B(); } int main(void) { struct sigaction handler; memset(&handler,0,sizeof(handler)); handler.sa_sigaction = handler_func; handler.sa_flags = SA_SIGINFO; sigaction(SIGSEGV,&handler,NULL); return(C()); } 处理程序代码是: static int handler_func(int signal, siginfo_t info, void* rserved) { const void* […]