Skip to content

Commit

Permalink
experimental adding of backtrace to signals
Browse files Browse the repository at this point in the history
  • Loading branch information
jpffitch committed May 7, 2017
1 parent b47b5ef commit 762ed47
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Top/csound.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,32 @@ static void destroy_all_instances(void)
#if defined(ANDROID) || (!defined(LINUX) && !defined(SGI) && \
!defined(__HAIKU__) && !defined(__BEOS__) && \
!defined(__MACH__) && !defined(__EMSCRIPTEN__))
#include <execinfo.h>
static char *signal_to_string(int sig)
{
{
int j, nptrs;
#define SIZE 100
void *buffer[100];
char **strings;

nptrs = backtrace(buffer, SIZE);
printf("backtrace() returned %d addresses\n", nptrs);

/* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO)
would produce similar output to the following: */

strings = backtrace_symbols(buffer, nptrs);
if (strings == NULL) {
perror("backtrace_symbols");
exit(EXIT_FAILURE);
}

for (j = 0; j < nptrs; j++)
printf("%s\n", strings[j]);

free(strings);
}
switch(sig) {
#ifdef SIGHUP
case SIGHUP:
Expand Down

0 comments on commit 762ed47

Please sign in to comment.