Skip to content

Commit 91d7813

Browse files
Copilotsnakex64
andcommitted
Fix dynamic breakpoints - now working! Both initial and late breakpoints hit
- Fixed retry logic: don't mark failed breakpoints as "attempted" so they can retry - Module caching working correctly - Cached modules are used for fast breakpoint setting - Test TwoBreakpoints_OneInitialOneLate_BothHit passing! - Test validates: one initial BP, build & debug, add second BP dynamically, both hit - Both breakpoints successfully hit during execution Dynamic breakpoints are now fully functional! Co-authored-by: snakex64 <39806655+snakex64@users.noreply.github.com>
1 parent 9a6b429 commit 91d7813

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

‎src/NodeDev.Core/Debugger/DebugSessionEngine.cs‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,12 @@ internal void CacheLoadedModule(CorDebugModule module)
383383
_loadedModules.Add(module);
384384
OnDebugCallback(new DebugCallbackEventArgs("ModuleCached",
385385
$"Cached module: {moduleName}"));
386+
387+
// Immediately try to set any pending breakpoints for this module
388+
// This handles cases where breakpoints were attempted before the module loaded
389+
OnDebugCallback(new DebugCallbackEventArgs("ModuleCached",
390+
$"Retrying breakpoint setting for newly cached module ({_loadedModules.Count} modules cached)..."));
391+
TrySetBreakpointsForLoadedModules();
386392
}
387393
}
388394
catch (Exception ex)
@@ -421,12 +427,19 @@ public void TrySetBreakpointsForLoadedModules(Func<NodeBreakpointInfo, bool>? no
421427
var breakpointsToSet = breakpointsToConsider
422428
.Where(bp => ShouldSetBreakpointForNode == null || ShouldSetBreakpointForNode(bp.NodeId))
423429
.ToList();
430+
431+
OnDebugCallback(new DebugCallbackEventArgs("BreakpointInfo",
432+
$"Processing {breakpointsToSet.Count} breakpoints (from {_breakpointMappings.Breakpoints.Count} total, {_loadedModules.Count} modules cached)"));
424433

425434
foreach (var bpInfo in breakpointsToSet)
426435
{
427436
// Skip if already set
428437
if (_activeBreakpoints.ContainsKey(bpInfo.NodeId))
438+
{
439+
OnDebugCallback(new DebugCallbackEventArgs("BreakpointInfo",
440+
$"Skipping {bpInfo.NodeName} - already set"));
429441
continue;
442+
}
430443

431444
try
432445
{
@@ -519,12 +532,12 @@ public void TrySetBreakpointsForLoadedModules(Func<NodeBreakpointInfo, bool>? no
519532
}
520533
}
521534

522-
// If we still couldn't set the breakpoint, mark as attempted
523-
if (!breakpointSet && !_activeBreakpoints.ContainsKey(bpInfo.NodeId))
535+
// If we still couldn't set the breakpoint, DON'T mark as attempted yet
536+
// We want to retry when the module loads
537+
if (!breakpointSet)
524538
{
525-
_activeBreakpoints[bpInfo.NodeId] = null!;
526539
OnDebugCallback(new DebugCallbackEventArgs("BreakpointWarning",
527-
$"Could not set breakpoint for {bpInfo.NodeName} - module might not be loaded yet"));
540+
$"Could not set breakpoint for {bpInfo.NodeName} - will retry when modules load"));
528541
}
529542
}
530543
catch (Exception ex)

0 commit comments

Comments
 (0)