| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#ifdef RPY_LL_ASSERT |
| 25 |
# define PYPY_DEBUG_TRACEBACK_DEPTH 8192 |
| 26 |
#else |
| 27 |
# define PYPY_DEBUG_TRACEBACK_DEPTH 128 |
| 28 |
#endif |
| 29 |
|
| 30 |
#define PYPYDTPOS_RERAISE ((struct pypydtpos_s *) -1) |
| 31 |
#define PYPYDTSTORE(loc, etype) \ |
| 32 |
pypy_debug_tracebacks[pypydtcount].location = loc; \ |
| 33 |
pypy_debug_tracebacks[pypydtcount].exctype = etype; \ |
| 34 |
pypydtcount = (pypydtcount + 1) & (PYPY_DEBUG_TRACEBACK_DEPTH-1) |
| 35 |
|
| 36 |
#define OP_DEBUG_START_TRACEBACK(etype, _) PYPYDTSTORE(NULL, etype) |
| 37 |
#define OP_DEBUG_RERAISE_TRACEBACK(etp, _) PYPYDTSTORE(PYPYDTPOS_RERAISE, etp) |
| 38 |
#define OP_DEBUG_PRINT_TRACEBACK() pypy_debug_traceback_print() |
| 39 |
|
| 40 |
#define PYPY_DEBUG_RECORD_TRACEBACK(funcname) { \ |
| 41 |
static struct pypydtpos_s loc = { \ |
| 42 |
PYPY_FILE_NAME, funcname, __LINE__ }; \ |
| 43 |
PYPYDTSTORE(&loc, NULL); \ |
| 44 |
} |
| 45 |
#define PYPY_DEBUG_CATCH_EXCEPTION(funcname, etype, is_fatal) { \ |
| 46 |
static struct pypydtpos_s loc = { \ |
| 47 |
PYPY_FILE_NAME, funcname, __LINE__ }; \ |
| 48 |
PYPYDTSTORE(&loc, etype); \ |
| 49 |
if (is_fatal) pypy_debug_catch_fatal_exception(); \ |
| 50 |
} |
| 51 |
|
| 52 |
struct pypydtpos_s { |
| 53 |
const char *filename; |
| 54 |
const char *funcname; |
| 55 |
int lineno; |
| 56 |
}; |
| 57 |
|
| 58 |
struct pypydtentry_s { |
| 59 |
struct pypydtpos_s *location; |
| 60 |
void *exctype; |
| 61 |
}; |
| 62 |
|
| 63 |
RPY_EXTERN int pypydtcount; |
| 64 |
RPY_EXTERN struct pypydtentry_s pypy_debug_tracebacks[PYPY_DEBUG_TRACEBACK_DEPTH]; |
| 65 |
|
| 66 |
RPY_EXTERN void pypy_debug_traceback_print(void); |
| 67 |
RPY_EXTERN void pypy_debug_catch_fatal_exception(void); |