diff --git a/include/pocketpy/pocketpy.h b/include/pocketpy/pocketpy.h index 2a3705c3..fab5b4b3 100644 --- a/include/pocketpy/pocketpy.h +++ b/include/pocketpy/pocketpy.h @@ -664,7 +664,7 @@ PK_API void py_debugger_exceptionbreakpoint(py_Ref exc); PK_API void py_debugger_exit(int code); #else #define py_debugger_waitforattach(hostname, port) -#define py_debugger_isattached() (false) +#define py_debugger_status() 0 #define py_debugger_exceptionbreakpoint(exc) #define py_debugger_exit(code) #endif diff --git a/src/interpreter/ceval.c b/src/interpreter/ceval.c index ad5368c1..0d31e735 100644 --- a/src/interpreter/ceval.c +++ b/src/interpreter/ceval.c @@ -116,7 +116,7 @@ __NEXT_STEP: #if PK_ENABLE_WATCHDOG if(self->watchdog_info.max_reset_time > 0) { - if(!py_debugger_isattached() && clock() > self->watchdog_info.max_reset_time) { + if(py_debugger_status() != 0 && clock() > self->watchdog_info.max_reset_time) { self->watchdog_info.max_reset_time = 0; TimeoutError("watchdog timeout"); goto __ERROR; diff --git a/src/public/PyException.c b/src/public/PyException.c index 18c976cc..cc1008bb 100644 --- a/src/public/PyException.c +++ b/src/public/PyException.c @@ -12,7 +12,7 @@ void py_BaseException__stpush(py_Frame* frame, int lineno, const char* func_name) { BaseException* ud = py_touserdata(self); - int max_frame_dumps = py_debugger_isattached() ? 31 : 7; + int max_frame_dumps = py_debugger_status() == 1 ? 31 : 7; if(ud->stacktrace.length >= max_frame_dumps) return; BaseExceptionFrame* frame_dump = c11_vector__emplace(&ud->stacktrace); PK_INCREF(src); @@ -20,7 +20,7 @@ void py_BaseException__stpush(py_Frame* frame, frame_dump->lineno = lineno; frame_dump->name = func_name ? c11_string__new(func_name) : NULL; - if(py_debugger_isattached()) { + if(py_debugger_status() == 1) { if(frame != NULL) { py_Frame_newlocals(frame, &frame_dump->locals); py_Frame_newglobals(frame, &frame_dump->globals); @@ -225,7 +225,7 @@ char* py_formatexc() { VM* vm = pk_current_vm; if(py_isnil(&vm->unhandled_exc)) return NULL; char* res = formatexc_internal(&vm->unhandled_exc); - if(py_debugger_isattached()) py_debugger_exceptionbreakpoint(&vm->unhandled_exc); + if(py_debugger_status() == 1) py_debugger_exceptionbreakpoint(&vm->unhandled_exc); return res; }