2020-02-17 03:59:33 +08:00
|
|
|
/*********************************************************************
|
|
|
|
* 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
|
|
|
|
|
2021-09-03 07:04:26 +08:00
|
|
|
#ifdef H5BACKTRACE
|
|
|
|
# if !defined _WIN32 && !defined __CYGWIN__
|
2020-02-17 03:59:33 +08:00
|
|
|
static void* stacktrace[STSIZE];
|
2021-09-03 07:04:26 +08:00
|
|
|
# endif
|
2020-03-30 02:48:59 +08:00
|
|
|
#endif
|
2020-02-17 03:59:33 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
nch5breakpoint(int err)
|
|
|
|
{
|
2021-09-03 07:04:26 +08:00
|
|
|
#ifdef H5BACKTRACE
|
|
|
|
# if !defined _WIN32 && !defined __CYGWIN__
|
2020-02-17 03:59:33 +08:00
|
|
|
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]);
|
2021-09-03 07:04:26 +08:00
|
|
|
# if 0
|
2020-02-17 03:59:33 +08:00
|
|
|
if(trace != NULL) free(trace);
|
2021-09-03 07:04:26 +08:00
|
|
|
# endif
|
|
|
|
# endif
|
2020-02-17 03:59:33 +08:00
|
|
|
#endif
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2021-12-24 13:18:56 +08:00
|
|
|
nch5throw(int err, int line)
|
2020-02-17 03:59:33 +08:00
|
|
|
{
|
|
|
|
if(err == 0) return err;
|
2021-12-24 13:18:56 +08:00
|
|
|
fprintf(stderr,">>> hdf5throw: line=%d err=%d\n",line,err); fflush(stderr);
|
2020-02-17 03:59:33 +08:00
|
|
|
return nch5breakpoint(err);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|