File: hdf5debug.c

package info (click to toggle)
netcdf-parallel 1%3A4.7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 105,352 kB
  • sloc: ansic: 229,114; sh: 11,180; yacc: 2,561; makefile: 1,390; lex: 1,173; xml: 173; awk: 2
file content (47 lines) | stat: -rw-r--r-- 981 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*********************************************************************
 *   Copyright 2018, UCAR/Unidata
 *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
 *********************************************************************/
#include "config.h"
#include <stdarg.h>
#include <stdio.h>
#if !defined _WIN32 && !defined __CYGWIN__
#include <execinfo.h>
#endif

#include "hdf5debug.h"

#ifdef H5CATCH

#define STSIZE 1000

static void* stacktrace[STSIZE];

int
nch5breakpoint(int err)
{
#if !defined _WIN32 && !defined __CYGWIN__
    int count = 0;
    char** trace = NULL;
    int i;

    count = backtrace(stacktrace,STSIZE);
    trace = backtrace_symbols(stacktrace, STSIZE);
    fprintf(stderr,"backtrace:\n");
    for(i=0;i<count;i++)
        fprintf(stderr,"[%03d] %s\n",i,trace[i]);
#if 0
    if(trace != NULL) free(trace);
#endif
#endif
    return err;
}

int
nch5throw(int err)
{
    if(err == 0) return err;
    return nch5breakpoint(err);
}
#endif