Nilorea Library
C utilities for networking, threading, graphics
|
signals general handling with stack printing More...
#include <signal.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <errno.h>
#include <string.h>
#include "nilorea/n_log.h"
#include "nilorea/n_signals.h"
#include "nilorea/n_str.h"
#include <err.h>
#include <execinfo.h>
Go to the source code of this file.
Macros | |
#define | LOGFPRT(...) fprintf( stderr , "Error: " __VA_ARGS__ ) |
internal: output to stderr More... | |
#define | LOGNLOG(...) n_log( LOG_ERR , __VA_ARGS__ ) |
internal: output to syslog More... | |
#define | LOGSIG LOGNLOG |
internal: output to syslog More... | |
Functions | |
int | addr2line (char const *const program_name, void const *const addr) |
Resolve symbol name and source location given the path to the executable and an address. More... | |
void | posix_print_stack_trace () |
print current stack More... | |
void | posix_signal_handler (int sig, siginfo_t *siginfo, void *context) |
decode a signal and call stack print More... | |
void | set_signal_handler (const char *progname) |
Install a signal handler for progname. More... | |
Variables | |
static const char * | __n_stack_traced_progam_name |
name of program to debug (addr2line & co) More... | |
static uint8_t | alternate_stack [SIGALTSTACK_SIZE] |
static block for alternate stack More... | |
static void * | stack_traces [MAX_STACK_FRAMES] |
static frame list More... | |
signals general handling with stack printing
Definition in file n_signals.c.
#define LOGFPRT | ( | ... | ) | fprintf( stderr , "Error: " __VA_ARGS__ ) |
internal: output to stderr
Definition at line 24 of file n_signals.c.
internal: output to syslog
Definition at line 27 of file n_signals.c.
#define LOGSIG LOGNLOG |
internal: output to syslog
Definition at line 30 of file n_signals.c.
int addr2line | ( | char const *const | program_name, |
void const *const | addr | ||
) |
Resolve symbol name and source location given the path to the executable and an address.
program_name | target filename |
addr | address to peek |
Definition at line 88 of file n_signals.c.
References free_nstr, LOGSIG, and n_popen().
Referenced by posix_print_stack_trace().
void posix_print_stack_trace | ( | ) |
print current stack
Definition at line 266 of file n_signals.c.
References __n_stack_traced_progam_name, addr2line(), LOGSIG, MAX_STACK_FRAMES, and stack_traces.
Referenced by posix_signal_handler().
void posix_signal_handler | ( | int | sig, |
siginfo_t * | siginfo, | ||
void * | context | ||
) |
decode a signal and call stack print
sig | signal to decode |
siginfo | details of the signal |
context | the context to unroll |
Definition at line 298 of file n_signals.c.
References LOGSIG, and posix_print_stack_trace().
Referenced by set_signal_handler().
|
static |
name of program to debug (addr2line & co)
Definition at line 33 of file n_signals.c.
Referenced by posix_print_stack_trace(), and set_signal_handler().
|
static |
static block for alternate stack
Definition at line 387 of file n_signals.c.
Referenced by set_signal_handler().
|
static |
static frame list
Definition at line 261 of file n_signals.c.
Referenced by posix_print_stack_trace().