Przeglądaj źródła

fix OS macro for debugger

blueloveTH 6 miesięcy temu
rodzic
commit
b6c030ac15

+ 1 - 1
CMakeLists.txt

@@ -17,7 +17,7 @@ endif()
 
 if(MSVC)
     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")
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Ox")

+ 4 - 0
include/pocketpy/debugger/core.h

@@ -5,6 +5,8 @@
 #include "pocketpy/common/vector.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_DEBUGGER_NOSTOP, C11_DEBUGGER_STEP, C11_DEBUGGER_EXCEPTION, C11_DEBUGGER_BP} C11_STOP_REASON;
 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);
 C11_STOP_REASON c11_debugger_should_pause(void);
 int c11_debugger_should_keep_pause(void);
+
+#endif // PK_ENABLE_OS

+ 7 - 0
include/pocketpy/pocketpy.h

@@ -708,10 +708,17 @@ PK_API void py_profiler_reset();
 PK_API char* py_profiler_report();
 
 /************* DAP *************/
+#if PK_ENABLE_OS
 PK_API void py_debugger_waitforattach(const char* hostname, unsigned short port);
 PK_API bool py_debugger_isattached();
 PK_API void py_debugger_exceptionbreakpoint(py_Ref exc);
 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 *************/
 

+ 4 - 0
src/debugger/core.c

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

+ 5 - 1
src/debugger/dap.c

@@ -6,6 +6,8 @@
 #include "pocketpy/objects/exception.h"
 #include "pocketpy/pocketpy.h"
 
+#if PK_ENABLE_OS
+
 #define DAP_COMMAND_LIST(X)                                                                        \
     X(initialize)                                                                                  \
     X(setBreakpoints)                                                                              \
@@ -550,4 +552,6 @@ void py_debugger_exceptionbreakpoint(py_Ref exc) {
             c11_dap_handle_message();
         }
     }
-}
+}
+
+#endif // PK_ENABLE_OS