fix bp not hit because of path format

This commit is contained in:
lightovernight 2025-08-17 19:00:37 +08:00
parent 0c3b0e0f05
commit b5ecbda2c5

View File

@ -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;
}