#include "zend_compile.h"
#include "zend_exceptions.h"
#include "zend_vm.h"
+#include "zend_generators.h"
#include "phpdbg.h"
#include "phpdbg_help.h"
} else {
zend_rebuild_symbol_table();
}
+ PHPDBG_G(handled_exception) = NULL;
/* clean seek state */
PHPDBG_G(flags) &= ~PHPDBG_SEEK_MASK;
}
} /* }}} */
+/* code may behave weirdly if EG(exception) is set */
#define DO_INTERACTIVE(allow_async_unsafe) do { \
+ if (exception) { \
+ ++GC_REFCOUNT(exception); \
+ zend_clear_exception(); \
+ } \
if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) { \
const char *file_char = zend_get_executed_filename(); \
zend_string *file = zend_string_init(file_char, strlen(file_char), 0); \
} \
\
switch (phpdbg_interactive(allow_async_unsafe)) { \
+ zval zv; \
+ default: \
+ if (exception) { \
+ Z_OBJ(zv) = exception; \
+ zend_throw_exception_internal(&zv); \
+ } \
+ /* fallthrough */ \
case PHPDBG_LEAVE: \
case PHPDBG_FINISH: \
case PHPDBG_UNTIL: \
PHPDBG_G(in_execution) = 1;
while (1) {
+ zend_object *exception = EG(exception);
+
if ((PHPDBG_G(flags) & PHPDBG_BP_RESOLVE_MASK)) {
/* resolve nth opline breakpoints */
phpdbg_resolve_op_array_breaks(&execute_data->func->op_array);
}
#endif
+ /* check for uncaught exceptions */
+ if (exception && PHPDBG_G(handled_exception) != exception) {
+ zend_execute_data *prev_ex = execute_data;
+
+ do {
+ prev_ex = zend_generator_check_placeholder_frame(prev_ex);
+ /* assuming that no internal functions will silently swallow exceptions ... */
+ if (!prev_ex->func || !ZEND_USER_CODE(prev_ex->func->common.type)) {
+ continue;
+ }
+
+ if (phpdbg_check_caught_ex(prev_ex)) {
+ goto ex_is_caught;
+ }
+ } while ((prev_ex = prev_ex->prev_execute_data));
+
+ PHPDBG_G(handled_exception) = EG(exception);
+ phpdbg_error("exception", "name=\"%s\"", "Uncaught exception %s", exception->ce->name->val);
+ DO_INTERACTIVE(1);
+ }
+ex_is_caught:
+
/* allow conditional breakpoints and
initialization to access the vm uninterrupted */
if ((PHPDBG_G(flags) & PHPDBG_IN_COND_BP) ||
/* only if *not* interactive and while executing */
void phpdbg_force_interruption(void) /* {{{ */ {
+ zend_object *exception = EG(exception);
zend_execute_data *data = EG(current_execute_data); /* should be always readable if not NULL */
PHPDBG_G(flags) |= PHPDBG_IN_SIGNAL_HANDLER;
return SUCCESS;
} /* }}} */
-