GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - cppcoffee/libstacktrace: When the process crashes, output stack trace to STDERR.

BranchesTags
Open more actions menu

Latest commit

 

History

4 Commits
4 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.gitignore
.gitignore
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
example.c
example.c
 
 
stacktrace.c
stacktrace.c
 
 
stacktrace.h
stacktrace.h
 
 
symbol_table.c
symbol_table.c
 
 
symbol_table.h
symbol_table.h
 
 

Repository files navigation

Introduce

The libstacktrace is a c library that provides a simple API to output the crash call stack to STDERR when the process crash.

Build

$ make

Usage

Include stacktrace.h to project, and call init_stacktrace() API to initialize library.

#include "stacktrace.h"

int main(int argc, char *argv[]) {
{
    // initialize library.
    init_stacktrace();

    // do some thing.
}

Example

Examples of use are provided in example.c of the repository, which makes null pointer access, and the process crashes with the following output:

[root@localhost libstacktrace]# ./example
/home/sharp/libstacktrace/example - STACK TRACE:
/lib64/libc.so.6(+0x36450) [0x7fca8db52450]
./example() [0x4036f0] example.c bar()
./example() [0x403703] example.c foo()
./example() [0x40371d] ?? main()
/lib64/libc.so.6(__libc_start_main+0xf5) [0x7fca8db3e555]
./example() [0x402c9a] ?? _start()
Segmentation fault

If CCFLAGS is added -g flag, more detailed information will be output:

[root@localhost libstacktrace]# ./example
/home/sharp/libstacktrace/example - STACK TRACE:
/lib64/libc.so.6(+0x36450) [0x7fa21a2e0450]
./example() [0x4036f0] /home/sharp/libstacktrace/example.c bar():8
./example() [0x403703] /home/sharp/libstacktrace/example.c foo():15
./example() [0x40371d] /home/sharp/libstacktrace/example.c main():24
/lib64/libc.so.6(__libc_start_main+0xf5) [0x7fa21a2cc555]
./example() [0x402c9a] ?? _start()
Segmentation fault

Dependence

The libstacktrace dependence on libbfd (Binary File Descriptor library).

bfd build elf sections data, find the file name, function name, and source line where the stack pointer is located based on the elf sections data.

bfd is provided by the binutils package, which can be installed in CentOS distributions with the following command:

yum install binutils-devel -y

Reference

https://man7.org/linux/man-pages/man1/addr2line.1.html

https://sourceware.org/binutils/docs/bfd/

About

When the process crashes, output stack trace to STDERR.

Resources

Readme
Activity

Stars

9 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.