From b5ecbda2c5e3dc016b50fae0e8d28b6bf1e83e32 Mon Sep 17 00:00:00 2001 From: lightovernight Date: Sun, 17 Aug 2025 19:00:37 +0800 Subject: [PATCH] fix bp not hit because of path format --- src/debugger/core.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/debugger/core.c b/src/debugger/core.c index 0a9d0df1..78a37d3d 100644 --- a/src/debugger/core.c +++ b/src/debugger/core.c @@ -136,6 +136,21 @@ int c11_debugger_reset_breakpoints_by_source(const char* sourcesname) { return debugger.breakpoints.length; } +bool c11_debugger_path_equal(const char* path1, const char* path2) { + if (path1 == NULL || path2 == NULL) return false; + while (*path1 && *path2) { + char c1 = (*path1 == '\\') ? '/' : *path1; + char c2 = (*path2 == '\\') ? '/' : *path2; + c1 = (char)tolower((unsigned char)c1); + c2 = (char)tolower((unsigned char)c2); + if (c1 != c2) return false; + path1++; + path2++; + } + return *path1 == *path2; +} + + int c11_debugger_should_pause() { if(debugger.current_event == TRACE_EVENT_POP) return false; bool should_pause = false; @@ -155,7 +170,7 @@ int c11_debugger_should_pause() { } if(debugger.step_mode == C11_STEP_CONTINUE) { c11__foreach(c11_debugger_breakpoint, &debugger.breakpoints, bp) { - if(strcmp(debugger.current_filename, bp->sourcename) == 0 && + if(c11_debugger_path_equal(debugger.current_filename, bp->sourcename) && debugger.current_line == bp->lineno) { should_pause = true; break; @@ -299,7 +314,7 @@ bool c11_debugger_unfold_var(int var_id, c11_sbuf* buffer) { // 5. dump & write if(!py_json_dumps(dap_obj, 0)) { - printf("dap_obj: %s\n", py_tpname(py_typeof(dap_obj))); + // printf("dap_obj: %s\n", py_tpname(py_typeof(dap_obj))); py_printexc(); return false; }