/* do not include execinfo.h directly since it's not always available.
Instead, copy the parts we need (and fake when it's not there) */
/* do not include execinfo.h directly since it's not always available.
Instead, copy the parts we need (and fake when it's not there) */
- gras_os_getpid(),__FILE__,__LINE__, \
+ (*xbt_getpid)(),__FILE__,__LINE__, \
- gras_os_getpid(),__FILE__,__LINE__, \
+ (*xbt_getpid)(),__FILE__,__LINE__, \
- gras_os_getpid(),__FILE__,__LINE__, \
+ (*xbt_getpid)(),__FILE__,__LINE__, \
#if defined(__EX_MCTX_MCSC__)
#include <ucontext.h> /* POSIX.1 ucontext(3) */
#define __ex_mctx_struct ucontext_t uc;
#if defined(__EX_MCTX_MCSC__)
#include <ucontext.h> /* POSIX.1 ucontext(3) */
#define __ex_mctx_struct ucontext_t uc;
* This is because there is some hidden setup and
* cleanup that needs to be done regardless of whether an exception is
* caught. Bypassing these steps will break the exception handling facility.
* This is because there is some hidden setup and
* cleanup that needs to be done regardless of whether an exception is
* caught. Bypassing these steps will break the exception handling facility.
+ * The symptom are likely to be a segfault at the next exception raising point,
+ * ie far away from the point where you did the mistake. If you suspect
+ * that kind of error in your code, have a look at the little script
+ * <tt>tools/xbt_exception_checker</tt> in the CVS. It extracts all the TRY
+ * blocks from a set of C files you give it and display them (and only
+ * them) on the standard output. You can then grep for the forbidden
+ * keywords on that output.
+ *
* The CLEANUP and CATCH blocks are regular ISO-C language statement
* blocks without any restrictions. You are even allowed to throw (and, in the
* CATCH block, to re-throw) exceptions.
* The CLEANUP and CATCH blocks are regular ISO-C language statement
* blocks without any restrictions. You are even allowed to throw (and, in the
* CATCH block, to re-throw) exceptions.
* There is one subtle detail you should remember about TRY blocks:
* Variables used in the CLEANUP or CATCH clauses must be declared with
* the storage class "volatile", otherwise they might contain outdated
* There is one subtle detail you should remember about TRY blocks:
* Variables used in the CLEANUP or CATCH clauses must be declared with
* the storage class "volatile", otherwise they might contain outdated
/** @brief different kind of errors */
typedef enum {
unknown_error=0, /**< unknown error */
/** @brief different kind of errors */
typedef enum {
unknown_error=0, /**< unknown error */
system_error, /**< a syscall did fail */
network_error, /**< error while sending/receiving data */
timeout_error, /**< not quick enough, dude */
system_error, /**< a syscall did fail */
network_error, /**< error while sending/receiving data */
timeout_error, /**< not quick enough, dude */
xbt_errcat_t category; /**< category like HTTP (what went wrong) */
int value; /**< like errno (why did it went wrong) */
/* throw point */
xbt_errcat_t category; /**< category like HTTP (what went wrong) */
int value; /**< like errno (why did it went wrong) */
/* throw point */
- short int remote; /* whether it was raised remotely */
- char *host; /* NULL for localhost; hostname if remote */
+ short int remote; /**< whether it was raised remotely */
+ char *host; /**< NULL locally thrown exceptions; full hostname if remote ones */
- char *procname;
- long int pid;
- char *file; /**< to be freed only for remote exceptions */
- int line;
- char *func; /**< to be freed only for remote exceptions */
+ char *procname; /**< Name of the process who thrown this */
+ int pid; /**< PID of the process who thrown this */
+ char *file; /**< Thrown point */
+ int line; /**< Thrown point */
+ char *func; /**< Thrown point */
extern ex_ctx_t *__xbt_ex_ctx_default(void);
/* the termination handler */
typedef void (*ex_term_cb_t)(xbt_ex_t *);
extern ex_ctx_t *__xbt_ex_ctx_default(void);
/* the termination handler */
typedef void (*ex_term_cb_t)(xbt_ex_t *);
extern void __xbt_ex_terminate_default(xbt_ex_t *e);
/** @brief Introduce a block where exception may be dealed with
extern void __xbt_ex_terminate_default(xbt_ex_t *e);
/** @brief Introduce a block where exception may be dealed with
__xbt_ex_ctx()->ctx_ex.remote = 0; \
__xbt_ex_ctx()->ctx_ex.host = (char*)NULL; \
__xbt_ex_ctx()->ctx_ex.procname = (char*)xbt_procname(); \
__xbt_ex_ctx()->ctx_ex.remote = 0; \
__xbt_ex_ctx()->ctx_ex.host = (char*)NULL; \
__xbt_ex_ctx()->ctx_ex.procname = (char*)xbt_procname(); \
__xbt_ex_ctx()->ctx_ex.file = (char*)__FILE__; \
__xbt_ex_ctx()->ctx_ex.line = __LINE__; \
__xbt_ex_ctx()->ctx_ex.func = (char*)_XBT_FUNCTION; \
__xbt_ex_ctx()->ctx_ex.file = (char*)__FILE__; \
__xbt_ex_ctx()->ctx_ex.line = __LINE__; \
__xbt_ex_ctx()->ctx_ex.func = (char*)_XBT_FUNCTION; \
#define THROW7(c,v,m,a1,a2,a3,a4,a5,a6,a7) _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5,a6,a7))
#define THROW_IMPOSSIBLE THROW0(unknown_error,0,"The Impossible Did Happen (yet again)")
#define THROW7(c,v,m,a1,a2,a3,a4,a5,a6,a7) _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5,a6,a7))
#define THROW_IMPOSSIBLE THROW0(unknown_error,0,"The Impossible Did Happen (yet again)")
-#define THROW_UNIMPLEMENTED THROW1(unknown_error,0,"Function %s unimplemented",__FUNCTION__)
+#define THROW_UNIMPLEMENTED THROW1(unknown_error,0,"Function %s unimplemented",_XBT_FUNCTION)
#define RETHROW5(msg,a,b,c,d,e) _XBT_PRE_RETHROW msg,a,b,c,d,e, _XBT_POST_RETHROW
/** @brief Exception destructor */
#define RETHROW5(msg,a,b,c,d,e) _XBT_PRE_RETHROW msg,a,b,c,d,e, _XBT_POST_RETHROW
/** @brief Exception destructor */