我是靠谱客的博主 背后灰狼,这篇文章主要介绍c语言打印栈的函数,c中如何打印函数调用堆栈?,现在分享给大家,希望可以做个参考。

//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"

#endif

static void signal_segv(int signum, siginfo_t* info, void*ptr) {

static const char *si_codes[3] = {"", "SEGV_MAPERR", "SEGV_ACCERR"};

size_t i;

ucontext_t *ucontext = (ucontext_t*)ptr;

#if defined(SIGSEGV_STACK_X86) || defined(SIGSEGV_STACK_IA64)

int f = 0;

Dl_info dlinfo;

void **bp = 0;

void *ip = 0;

#else

最后

以上就是背后灰狼最近收集整理的关于c语言打印栈的函数,c中如何打印函数调用堆栈?的全部内容,更多相关c语言打印栈内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(64)

评论列表共有 0 条评论

立即
投稿
返回
顶部