Commit fb290604 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

reshGetElem: call show_stackframe() to print a backtrace

parent 985d9e9a
......@@ -3,6 +3,10 @@
* Version 1.7.0 released
* using CGRIBEX library version 1.7.0
2014-08-21 Uwe Schulzweida
* reshGetElem: call show_stackframe() to print a backtrace
2014-08-20 Uwe Schulzweida
* added CDI function gribapiLibraryVersion(major_version, minor_version, revision_version) [Feature #5043]
......
......@@ -24337,6 +24337,18 @@ fi
 
done
 
for ac_header in execinfo.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "execinfo.h" "ac_cv_header_execinfo_h" "$ac_includes_default"
if test "x$ac_cv_header_execinfo_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_EXECINFO_H 1
_ACEOF
fi
done
# ----------------------------------------------------------------------
# Checks for the availability of functions
for ac_func in mallinfo
......
......@@ -65,6 +65,7 @@ AC_CHECK_MEMBERS([struct stat.st_blksize])
# ----------------------------------------------------------------------
# Checks for header files
AC_CHECK_HEADERS(malloc.h)
AC_CHECK_HEADERS(execinfo.h)
# ----------------------------------------------------------------------
# Checks for the availability of functions
AC_CHECK_FUNCS([mallinfo])
......
......@@ -23,6 +23,9 @@
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <execinfo.h> header file. */
#undef HAVE_EXECINFO_H
/* Define to 1 if you have the `getline' function. */
#undef HAVE_GETLINE
......
......@@ -9,6 +9,23 @@
#include <stdlib.h>
#include <stdio.h>
#if defined (HAVE_EXECINFO_H)
#include <execinfo.h>
#endif
static
void show_stackframe()
{
#if defined (HAVE_EXECINFO_H)
void *trace[16];
size_t trace_size = backtrace(trace, 16);
char **messages = backtrace_symbols(trace, trace_size);
fprintf(stderr, "[bt] Execution path:\n");
for ( size_t i=0; i<trace_size; ++i ) fprintf(stderr, "[bt] %s\n", messages[i]);
#endif
}
#include "dmemory.h"
#include "resource_handle.h"
#include "namespace.h"
......@@ -379,13 +396,17 @@ reshGetElem(const char *caller, cdiResH resH, const resOps *ops)
else
{
LIST_UNLOCK();
show_stackframe();
xabortC(caller, "Invalid namespace %d or index %d for resource handle %d when using namespace %d of size %d!",
nspT.nsp, nspT.idx, (int)resH, nsp, resHList[nsp].size);
}
if ( !(listElem && listElem->res.v.ops == ops) )
xabortC(caller, "Invalid resource handle %d, list element not found!",
(int)resH);
{
show_stackframe();
xabortC(caller, "Invalid resource handle %d, list element not found!", (int)resH);
}
return listElem;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment