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

reshGetValue: added caller function name to error message

parent b87fcac1
2012-12-18 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* reshGetValue: added caller function name to error message
2012-12-17 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* Version 1.5.9 released
......
......@@ -18,8 +18,8 @@ char commands[][13] = { "FINALIZE\0",
"WRITETS\0"};
void pcdiAssert ( bool assumption, const char * filename,
const char * functionname, int line )
void pcdiAssert(bool assumption,
const char * filename, const char * functionname, int line )
{
if ( !assumption )
{
......@@ -45,6 +45,31 @@ void pcdiAssert ( bool assumption, const char * filename,
/****************************************************/
void pcdiAbortC(const char * caller, const char * filename, const char *functionname, int line,
const char * errorString, ... )
{
va_list ap;
va_start(ap, errorString);
#ifdef USE_MPI
{
int rank;
MPI_Comm_rank ( MPI_COMM_WORLD, &rank );
fprintf(stderr, "ERROR, pe%d in %s, %s, line %d, called from %s\nerrorString: \"",
rank, functionname, filename, line, caller);
}
vfprintf(stderr, errorString, ap);
fputs("\"\n", stderr);
MPI_Abort ( MPI_COMM_WORLD, 1 );
#else
fprintf(stderr, "ERROR, %s, %s, line %d, called from %s\nerrorString: \"",
functionname, filename, line, caller);
vfprintf(stderr, errorString, ap);
fputs("\"\n", stderr);
#endif
exit ( EXIT_FAILURE );
va_end(ap);
}
void pcdiAbort(const char * filename, const char *functionname, int line,
const char * errorString, ... )
{
......
......@@ -45,7 +45,7 @@
# define __attribute__(x) /*NOTHING*/
#endif
void pcdiAssert ( bool, const char *, const char *, int );
void pcdiAssert( bool, const char *, const char *, int );
#define xassert(arg) do { \
if ((arg)) { \
} else { \
......@@ -129,6 +129,10 @@ char * outTextComm ( MPI_Comm * );
}
#endif
void pcdiAbortC(const char *, const char *, const char *, int, const char *, ... )
__attribute__((noreturn));
#define xabortC(caller, ...) pcdiAbortC(caller, __FILE__, __func__, __LINE__, __VA_ARGS__ )
void pcdiAbort (const char *, const char *, int, const char *, ... )
__attribute__((noreturn));
#define xabort(...) pcdiAbort(__FILE__, __func__, __LINE__, __VA_ARGS__ )
......
......@@ -282,7 +282,7 @@ void reshRemove ( cdiResH resH, resOps * ops )
/**************************************************************/
void *reshGetVal ( cdiResH resH, resOps * ops )
void *reshGetValue(const char * caller, cdiResH resH, resOps * ops)
{
int nsp;
namespaceTuple_t nspT;
......@@ -298,9 +298,8 @@ void *reshGetVal ( cdiResH resH, resOps * ops )
nspT = namespaceResHDecode ( resH );
if (nspT.nsp == nsp &&
nspT.idx >= 0 &&
nspT.idx < listSizeAllocated[nsp])
if ( nspT.nsp == nsp &&
nspT.idx >= 0 && nspT.idx < listSizeAllocated[nsp] )
{
listElem = listResources[nsp] + nspT.idx;
LIST_UNLOCK();
......@@ -308,10 +307,11 @@ void *reshGetVal ( cdiResH resH, resOps * ops )
else
{
LIST_UNLOCK();
xabort("Invalid namespace %d or index %d for resH %d!", nspT.nsp, nspT.idx, (int)resH);
xabortC(caller, "Invalid namespace %d or index %d for resource handle %d!", nspT.nsp, nspT.idx, (int)resH);
}
xassert(listElem && listElem->ops == ops);
if ( !(listElem && listElem->ops == ops) )
xabortC(caller, "Invalid resource handle %d, list element not found!", (int)resH);
return listElem->val;
}
......
......@@ -47,7 +47,8 @@ void reshRemove ( cdiResH, resOps * );
int reshCountType ( resOps * );
void * reshGetVal ( cdiResH, resOps * );
void * reshGetValue(const char *, cdiResH, resOps * );
#define reshGetVal(resH, ops) reshGetValue(__func__, resH, ops)
void reshGetResHListOfType ( int, int *, resOps * );
......
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