added epicsAssertPrintf

This commit is contained in:
Jeff Hill
1999-08-16 17:21:47 +00:00
parent 84ddc6291e
commit 5aaadb706f
4 changed files with 85 additions and 40 deletions
+20 -4
View File
@@ -27,6 +27,9 @@
* Modification Log:
* -----------------
* $Log$
* Revision 1.11 1998/02/27 01:34:07 jhill
* cleaned up the DLL symbol export
*
* Revision 1.10 1998/01/20 21:36:51 mrk
* add dbDefs.h
*
@@ -66,14 +69,25 @@
/*
* epicsAssert ()
* epicsAssertPrintf ()
*/
epicsShareFunc void epicsShareAPI
epicsAssert (const char *pFile, const unsigned line, const char *pMsg,
const char *pAuthorName)
epicsAssertPrintf (const char *pFile, const unsigned line,
const char *pExp, const char *pAuthorName, const char *pFormat, ...
)
{
va_list pvar;
va_start (pvar, pFormat);
epicsPrintf (
"\n\n\nA call to \"assert (%s)\" failed in %s line %d.\n", pMsg, pFile, line);
"\n\n\nA call to \"assert (%s)\" failed in %s line %d.\n", pExp, pFile, line);
if (pFormat) {
epicsPrintf ("When: ");
epicsVprintf (pFormat, pvar);
epicsPrintf ("\n");
}
epicsPrintf (
"The file \"core\" will be created in the current working directory.\n");
@@ -104,6 +118,8 @@ epicsShareFunc void epicsShareAPI
}
epicsPrintf ("This problem occurred in \"%s\"\n", epicsReleaseVersion);
va_end (pvar);
abort ();
}
+21 -6
View File
@@ -27,6 +27,9 @@
* Modification Log:
* -----------------
* $Log$
* Revision 1.10 1998/02/27 01:34:07 jhill
* cleaned up the DLL symbol export
*
* Revision 1.9 1998/02/20 21:45:08 evans
* Made a large number of changes to epicsShareThings in libCom routines
* to get imports and exports straight on WIN32. Not everything is fixed
@@ -69,24 +72,34 @@
/*
* epicsAssert ()
* epicsAssertPrintf ()
*
* This forces assert failures into the log file and then
* calls taskSuspend() instead of exit() so that we can debug
* the problem.
*/
void epicsAssert (const char *pFile, const unsigned line, const char *pMsg,
const char *pAuthorName)
void epicsAssertPrintf (const char *pFile, const unsigned line, const char *pExp,
const char *pAuthorName, const char *pFormat, ...)
{
int taskId = taskIdSelf();
va_list pvar;
epicsPrintf (
va_start (pvar, pFormat);
epicsPrintf (
"\n\n\n%s: A call to \"assert (%s)\" failed in %s at %d\n",
taskName (taskId),
pMsg,
pExp,
pFile,
line);
if (pFormat) {
epicsPrintf ("When: ");
epicsVprintf (pFormat, pvar);
epicsPrintf ("\n");
}
if (pAuthorName) {
epicsPrintf (
@@ -110,6 +123,8 @@ void epicsAssert (const char *pFile, const unsigned line, const char *pMsg,
}
epicsPrintf ("This problem occurred in \"%s\"\n", epicsReleaseVersion);
taskSuspend (taskId);
va_end (pvar);
taskSuspend (taskId);
}
+22 -15
View File
@@ -41,6 +41,12 @@ extern "C" {
#undef assert
#ifndef epicsAssertAuthor
# define epicsAssertAuthor 0
#endif
#define assertParenStrip(ARG) ARG
#ifdef NDEBUG
# define assert(ignore) ((void) 0)
#else /* NDEBUG */
@@ -48,8 +54,8 @@ extern "C" {
#if defined(__STDC__) || defined(__cplusplus)
epicsShareFunc extern void epicsShareAPI
epicsAssert (const char *pFile, const unsigned line,
const char *pMsg, const char *pAuthorName);
epicsAssertPrintf (const char *pFile, const unsigned line,
const char *pExp, const char *pAuthorName, const char *pFormat, ...);
#else /*__STDC__ or __cplusplus*/
@@ -59,24 +65,25 @@ epicsShareFunc extern void epicsShareAPI
#if (defined(__STDC__) || defined(__cplusplus)) && !defined(VAXC)
#ifdef epicsAssertAuthor
#define assert(exp) \
{if (!(exp)) epicsAssert (__FILE__, __LINE__, #exp, epicsAssertAuthor);}
#else /* epicsAssertAuthor */
#define assert(exp) \
{if (!(exp)) epicsAssert (__FILE__, __LINE__, #exp, 0);}
#endif /* epicsAssertAuthor */
{if (!(exp)) epicsAssertPrintf (__FILE__, __LINE__, #exp, epicsAssertAuthor, 0);}
/*
* Because C macros dont allow variable numbers of arguments we must
* use this as follows
*
* assertPrintf (a==b, ("bad news, a=%d b=%d", a, b) );
*/
#define assertPrintf(exp, fmtAndArgsInParenthesis) \
{if (!(exp)) {epicsAssertPrintf (__FILE__, __LINE__, #exp, epicsAssertAuthor, assertParenStrip fmtAndArgsInParenthesis);}}
#else /*__STDC__ or __cplusplus*/
#define assert(exp) \
{if (!(exp)) epicsAssertPrintf (__FILE__, __LINE__, "", epicsAssertAuthor, 0);}
#ifdef epicsAssertAuthor
#define assert(exp) \
{if (!(exp)) epicsAssert (__FILE__, __LINE__, "", epicsAssertAuthor);}
#else /* epicsAssertAuthor */
#define assert(exp) \
{if (!(exp)) epicsAssert (__FILE__, __LINE__, "", 0);}
#endif /* epicsAssertAuthor */
#define assertPrintf(exp, fmtAndArgsInParenthesis) \
{if (!(exp)) {epicsAssertPrintf (__FILE__, __LINE__, "", epicsAssertAuthor, assertParenStrip fmtAndArgsInParenthesis);}}
#endif /* (__STDC__ or __cplusplus) and not VAXC */
+22 -15
View File
@@ -41,6 +41,12 @@ extern "C" {
#undef assert
#ifndef epicsAssertAuthor
# define epicsAssertAuthor 0
#endif
#define assertParenStrip(ARG) ARG
#ifdef NDEBUG
# define assert(ignore) ((void) 0)
#else /* NDEBUG */
@@ -48,8 +54,8 @@ extern "C" {
#if defined(__STDC__) || defined(__cplusplus)
epicsShareFunc extern void epicsShareAPI
epicsAssert (const char *pFile, const unsigned line,
const char *pMsg, const char *pAuthorName);
epicsAssertPrintf (const char *pFile, const unsigned line,
const char *pExp, const char *pAuthorName, const char *pFormat, ...);
#else /*__STDC__ or __cplusplus*/
@@ -59,24 +65,25 @@ epicsShareFunc extern void epicsShareAPI
#if (defined(__STDC__) || defined(__cplusplus)) && !defined(VAXC)
#ifdef epicsAssertAuthor
#define assert(exp) \
{if (!(exp)) epicsAssert (__FILE__, __LINE__, #exp, epicsAssertAuthor);}
#else /* epicsAssertAuthor */
#define assert(exp) \
{if (!(exp)) epicsAssert (__FILE__, __LINE__, #exp, 0);}
#endif /* epicsAssertAuthor */
{if (!(exp)) epicsAssertPrintf (__FILE__, __LINE__, #exp, epicsAssertAuthor, 0);}
/*
* Because C macros dont allow variable numbers of arguments we must
* use this as follows
*
* assertPrintf (a==b, ("bad news, a=%d b=%d", a, b) );
*/
#define assertPrintf(exp, fmtAndArgsInParenthesis) \
{if (!(exp)) {epicsAssertPrintf (__FILE__, __LINE__, #exp, epicsAssertAuthor, assertParenStrip fmtAndArgsInParenthesis);}}
#else /*__STDC__ or __cplusplus*/
#define assert(exp) \
{if (!(exp)) epicsAssertPrintf (__FILE__, __LINE__, "", epicsAssertAuthor, 0);}
#ifdef epicsAssertAuthor
#define assert(exp) \
{if (!(exp)) epicsAssert (__FILE__, __LINE__, "", epicsAssertAuthor);}
#else /* epicsAssertAuthor */
#define assert(exp) \
{if (!(exp)) epicsAssert (__FILE__, __LINE__, "", 0);}
#endif /* epicsAssertAuthor */
#define assertPrintf(exp, fmtAndArgsInParenthesis) \
{if (!(exp)) {epicsAssertPrintf (__FILE__, __LINE__, "", epicsAssertAuthor, assertParenStrip fmtAndArgsInParenthesis);}}
#endif /* (__STDC__ or __cplusplus) and not VAXC */