fix OS macro for debugger

This commit is contained in:
blueloveTH 2025-08-26 23:44:47 +08:00
parent e40c4af55c
commit b6c030ac15
5 changed files with 21 additions and 2 deletions

View File

@ -17,7 +17,7 @@ endif()
if(MSVC) if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8 /jumptablerdata") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8 /jumptablerdata")
add_compile_options(/wd4267 /wd4244 /wd4146 /experimental:c11atomics) add_compile_options(/wd4267 /wd4244 /wd4146 /wd4819 /experimental:c11atomics)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Ox") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Ox")

View File

@ -5,6 +5,8 @@
#include "pocketpy/common/vector.h" #include "pocketpy/common/vector.h"
#include "pocketpy/pocketpy.h" #include "pocketpy/pocketpy.h"
#if PK_ENABLE_OS
typedef enum { C11_STEP_IN, C11_STEP_OVER, C11_STEP_OUT, C11_STEP_CONTINUE } C11_STEP_MODE; typedef enum { C11_STEP_IN, C11_STEP_OVER, C11_STEP_OUT, C11_STEP_CONTINUE } C11_STEP_MODE;
typedef enum { C11_DEBUGGER_NOSTOP, C11_DEBUGGER_STEP, C11_DEBUGGER_EXCEPTION, C11_DEBUGGER_BP} C11_STOP_REASON; typedef enum { C11_DEBUGGER_NOSTOP, C11_DEBUGGER_STEP, C11_DEBUGGER_EXCEPTION, C11_DEBUGGER_BP} C11_STOP_REASON;
typedef enum { typedef enum {
@ -26,3 +28,5 @@ int c11_debugger_setbreakpoint(const char* filename, int lineno);
int c11_debugger_reset_breakpoints_by_source(const char* sourcesname); int c11_debugger_reset_breakpoints_by_source(const char* sourcesname);
C11_STOP_REASON c11_debugger_should_pause(void); C11_STOP_REASON c11_debugger_should_pause(void);
int c11_debugger_should_keep_pause(void); int c11_debugger_should_keep_pause(void);
#endif // PK_ENABLE_OS

View File

@ -708,10 +708,17 @@ PK_API void py_profiler_reset();
PK_API char* py_profiler_report(); PK_API char* py_profiler_report();
/************* DAP *************/ /************* DAP *************/
#if PK_ENABLE_OS
PK_API void py_debugger_waitforattach(const char* hostname, unsigned short port); PK_API void py_debugger_waitforattach(const char* hostname, unsigned short port);
PK_API bool py_debugger_isattached(); PK_API bool py_debugger_isattached();
PK_API void py_debugger_exceptionbreakpoint(py_Ref exc); PK_API void py_debugger_exceptionbreakpoint(py_Ref exc);
PK_API void py_debugger_exit(int exitCode); PK_API void py_debugger_exit(int exitCode);
#else
#define py_debugger_waitforattach(hostname, port)
#define py_debugger_isattached() (false)
#define py_debugger_exceptionbreakpoint(exc)
#define py_debugger_exit(exitCode)
#endif
/************* Unchecked Functions *************/ /************* Unchecked Functions *************/

View File

@ -3,6 +3,8 @@
#include "pocketpy/pocketpy.h" #include "pocketpy/pocketpy.h"
#include <ctype.h> #include <ctype.h>
#if PK_ENABLE_OS
#include "pocketpy/debugger/core.h" #include "pocketpy/debugger/core.h"
typedef struct c11_debugger_breakpoint { typedef struct c11_debugger_breakpoint {
@ -396,3 +398,5 @@ bool c11_debugger_unfold_var(int var_id, c11_sbuf* buffer) {
} }
#undef python_vars #undef python_vars
#endif // PK_ENABLE_OS

View File

@ -6,6 +6,8 @@
#include "pocketpy/objects/exception.h" #include "pocketpy/objects/exception.h"
#include "pocketpy/pocketpy.h" #include "pocketpy/pocketpy.h"
#if PK_ENABLE_OS
#define DAP_COMMAND_LIST(X) \ #define DAP_COMMAND_LIST(X) \
X(initialize) \ X(initialize) \
X(setBreakpoints) \ X(setBreakpoints) \
@ -551,3 +553,5 @@ void py_debugger_exceptionbreakpoint(py_Ref exc) {
} }
} }
} }
#endif // PK_ENABLE_OS