Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
duk_error_misc.c File Reference
#include "duk_internal.h"

Go to the source code of this file.

Functions

DUK_INTERNAL duk_hobjectduk_error_prototype_from_code (duk_hthread *thr, duk_errcode_t code)
 
DUK_INTERNAL void duk_err_setup_heap_ljstate (duk_hthread *thr, duk_small_int_t lj_type)
 

Function Documentation

◆ duk_err_setup_heap_ljstate()

DUK_INTERNAL void duk_err_setup_heap_ljstate ( duk_hthread * thr,
duk_small_int_t lj_type )

Definition at line 74 of file duktape-1.8.0/src-separate/duk_error_misc.c.

74 {
75#if defined(DUK_USE_DEBUGGER_SUPPORT)
76 /* If something is thrown with the debugger attached and nobody will
77 * catch it, execution is paused before the longjmp, turning over
78 * control to the debug client. This allows local state to be examined
79 * before the stack is unwound. Errors are not intercepted when debug
80 * message loop is active (e.g. for Eval).
81 */
82
83 /* XXX: Allow customizing the pause and notify behavior at runtime
84 * using debugger runtime flags. For now the behavior is fixed using
85 * config options.
86 */
87#if defined(DUK_USE_DEBUGGER_THROW_NOTIFY) || defined(DUK_USE_DEBUGGER_PAUSE_UNCAUGHT)
88 if (DUK_HEAP_IS_DEBUGGER_ATTACHED(thr->heap) &&
89 !thr->heap->dbg_processing &&
90 lj_type == DUK_LJ_TYPE_THROW) {
91 duk_context *ctx = (duk_context *) thr;
93 duk_hobject *h_obj;
94
95 /* Don't intercept a DoubleError, we may have caused the initial double
96 * fault and attempting to intercept it will cause us to be called
97 * recursively and exhaust the C stack.
98 */
99 h_obj = duk_get_hobject(ctx, -1);
100 if (h_obj == thr->builtins[DUK_BIDX_DOUBLE_ERROR]) {
101 DUK_D(DUK_DPRINT("built-in DoubleError instance thrown, not intercepting"));
102 goto skip_throw_intercept;
103 }
104
105 DUK_D(DUK_DPRINT("throw with debugger attached, report to client"));
106
107 fatal = !duk__have_active_catcher(thr);
108
109#if defined(DUK_USE_DEBUGGER_THROW_NOTIFY)
110 /* Report it to the debug client */
111 duk_debug_send_throw(thr, fatal);
112#endif
113
114#if defined(DUK_USE_DEBUGGER_PAUSE_UNCAUGHT)
115 if (fatal) {
116 DUK_D(DUK_DPRINT("throw will be fatal, halt before longjmp"));
117 duk_debug_halt_execution(thr, 1 /*use_prev_pc*/);
118 }
119#endif
120 }
121
122 skip_throw_intercept:
123#endif /* DUK_USE_DEBUGGER_THROW_NOTIFY || DUK_USE_DEBUGGER_PAUSE_UNCAUGHT */
124#endif /* DUK_USE_DEBUGGER_SUPPORT */
125
126 thr->heap->lj.type = lj_type;
127
128 DUK_ASSERT(thr->valstack_top > thr->valstack);
129 DUK_TVAL_SET_TVAL_UPDREF(thr, &thr->heap->lj.value1, thr->valstack_top - 1); /* side effects */
130
131 duk_pop((duk_context *) thr);
132}
duk_small_int_t duk_bool_t
#define DUK_BIDX_DOUBLE_ERROR
#define DUK_TVAL_SET_TVAL_UPDREF
DUK_EXTERNAL void duk_pop(duk_context *ctx)
DUK_INTERNAL_DECL duk_hobject * duk_get_hobject(duk_context *ctx, duk_idx_t index)
static void fatal(const char *message)
duk_hobject * builtins[DUK_NUM_BUILTINS]

References duk_hthread::builtins, DUK_ASSERT, DUK_BIDX_DOUBLE_ERROR, DUK_D, DUK_DPRINT, duk_get_hobject(), DUK_LJ_TYPE_THROW, duk_pop(), DUK_TVAL_SET_TVAL_UPDREF, fatal(), duk_hthread::heap, duk_heap::lj, duk_ljstate::type, duk_hthread::valstack, duk_hthread::valstack_top, and duk_ljstate::value1.

◆ duk_error_prototype_from_code()

DUK_INTERNAL duk_hobject * duk_error_prototype_from_code ( duk_hthread * thr,
duk_errcode_t code )

Definition at line 43 of file duktape-1.8.0/src-separate/duk_error_misc.c.

43 {
44 switch (code) {
57
58 /* XXX: more specific error classes? */
64 case DUK_ERR_ERROR:
65 default:
67 }
68}
#define DUK_BIDX_EVAL_ERROR_PROTOTYPE
#define DUK_BIDX_TYPE_ERROR_PROTOTYPE
#define DUK_BIDX_ERROR_PROTOTYPE
#define DUK_BIDX_REFERENCE_ERROR_PROTOTYPE
#define DUK_BIDX_URI_ERROR_PROTOTYPE
#define DUK_BIDX_SYNTAX_ERROR_PROTOTYPE
#define DUK_BIDX_RANGE_ERROR_PROTOTYPE
#define DUK_ERR_ALLOC_ERROR
#define DUK_ERR_INTERNAL_ERROR
#define DUK_ERR_SYNTAX_ERROR
#define DUK_ERR_RANGE_ERROR
#define DUK_ERR_UNIMPLEMENTED_ERROR
#define DUK_ERR_ASSERTION_ERROR
#define DUK_ERR_REFERENCE_ERROR

References duk_hthread::builtins, DUK_BIDX_ERROR_PROTOTYPE, DUK_BIDX_EVAL_ERROR_PROTOTYPE, DUK_BIDX_RANGE_ERROR_PROTOTYPE, DUK_BIDX_REFERENCE_ERROR_PROTOTYPE, DUK_BIDX_SYNTAX_ERROR_PROTOTYPE, DUK_BIDX_TYPE_ERROR_PROTOTYPE, DUK_BIDX_URI_ERROR_PROTOTYPE, DUK_ERR_ALLOC_ERROR, DUK_ERR_API_ERROR, DUK_ERR_ASSERTION_ERROR, DUK_ERR_ERROR, DUK_ERR_EVAL_ERROR, DUK_ERR_INTERNAL_ERROR, DUK_ERR_RANGE_ERROR, DUK_ERR_REFERENCE_ERROR, DUK_ERR_SYNTAX_ERROR, DUK_ERR_TYPE_ERROR, DUK_ERR_UNIMPLEMENTED_ERROR, and DUK_ERR_URI_ERROR.