百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

DeathHandler

> 编程语言
开源

SIGSEGV 处理程序,可在 Linux 上为 C/C++ 项目打印调试堆栈跟踪信息。它是可配置的,且相当强大。

185 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

SIGSEGV 处理程序,可在 Linux 上为 C/C++ 项目打印调试堆栈跟踪信息。它是可配置的,且相当强大。

DeathHandler C++03+ class installs SEGFAULT, SIGABRT and SIGFPE signal handlers to print a nice stack trace and (if requested) generate a core dump. In DeathHandler's constructor, signal handlers are installed through sigaction(). If your program encounters a segmentation fault, the call stack is unwinded with backtrace(), converted into function names with line numbers via addr2line (fork() + execlp()). Addresses from shared libraries are also converted thanks to dladdr(). All C++ symbols are demangled. Printed stack trace includes the faulty thread id obtained with pthread_self() and each line contains the process id to distinguish several stack traces printed by different processes at the same time.

The code works primarily on Linux and tested on x86_64 and ARM with glibc. Besides, there is a partial support of MacOSX (addr2line -> atos is not implemented).

Since backtrace() uses malloc() and the heap my be corrupted by the time it is called, malloc() and free() have to be overridden. On Linux, it is done via a simple symbol overload; on MacOSX, malloc_default_zone() approach is taken because overloading does not work out of the box.

Example

test.cc:

#include "death_handler.h"

int main() {
  Debug::DeathHandler dh;
  int* p = NULL;
  *p = 0;
  return 0;
}
g++ -g death_handler.cc test.cc -ldl -o test
./test

This project is released under the Simplified BSD License. Copyright 2012 Samsung R&D Institute Russia, 2016 Moscow Institute of Physics and Technology.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C++

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言