导读:
试验了一下,好像只能打印出地址,但是有函数名更方便些
在11楼的提示下在网上找了篇文章,自己裁减了一下
CODE:
试验了一下,好像只能打印出地址,但是有函数名更方便些
在11楼的提示下在网上找了篇文章,自己裁减了一下
CODE:
//funstack.c
#define _GNU_SOURCE
#include
#include
#include
#include
#include
#include
#include
#if defined(REG_RIP)
# define SIGSEGV_STACK_IA64
# define REGFORMAT "%016lx"
#elif defined(REG_EIP)
# define SIGSEGV_STACK_X86
# define REGFORMAT "%08x"
#else
# define SIGSEGV_STACK_GENERIC
# define REGFORMAT "%x
#define _GNU_SOURCE
#include
#include
#include
#include
#include
#include
#include
#if defined(REG_RIP)
# define SIGSEGV_STACK_IA64
# define REGFORMAT "%016lx"
#elif defined(REG_EIP)
# define SIGSEGV_STACK_X86
# define REGFORMAT "%08x"
#else
# define SIGSEGV_STACK_GENERIC
# define REGFORMAT "%x

这篇博客介绍了如何在C语言中通过信号处理函数`signal_segv`获取并打印函数调用堆栈,包括X86和IA64架构下的实现。通过`backtrace`和`dladdr`函数获取调用栈信息,并打印函数名和地址。
7162

被折叠的 条评论
为什么被折叠?



