Skip to content

Commit

Permalink
move check to HandleStackTraceRequest and do it in parallel with a ti…
Browse files Browse the repository at this point in the history
…meout
  • Loading branch information
Trass3r committed Sep 17, 2020
1 parent 8931a75 commit 529241d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 14 additions & 1 deletion src/OpenDebugAD7/AD7DebugSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ protected override void HandleStackTraceRequestAsync(IRequestResponder<StackTrac
levels = Math.Min((int)frameEnumInfo.TotalFrames - startFrame, levels);
}

FRAMEINFO[] frameInfoArray = new FRAMEINFO[levels];
var frameInfoArray = new FRAMEINFO[levels];
uint framesFetched = 0;
frameEnumInfo.FrameEnum.Next((uint)frameInfoArray.Length, frameInfoArray, ref framesFetched);
frameEnumInfo.CurrentPosition += framesFetched;
Expand Down Expand Up @@ -1288,6 +1288,19 @@ protected override void HandleStackTraceRequestAsync(IRequestResponder<StackTrac
});
}

Parallel.ForEach(response.StackFrames, frame =>
{
if (frame.Source == null)
return;
var task = new Task<bool>(() => File.Exists(frame.Source.Path));
task.Start();
if (task.Wait(500) && !task.Result)
{
// mark the stack frame to be skipped by default
frame.Source.PresentationHint = Source.PresentationHintValue.Deemphasize;
}
});

response.TotalFrames = (int)frameEnumInfo.TotalFrames;
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/OpenDebugAD7/TextPositionTuple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ public static TextPositionTuple GetTextPositionOfFrame(PathConverter converter,
Path = convertedFilePath,
Name = Path.GetFileName(convertedFilePath)
};
if (!File.Exists(convertedFilePath))
{
// mark the stack frame to be skipped by default
source.PresentationHint = Source.PresentationHintValue.Deemphasize;
}

int line = converter.ConvertDebuggerLineToClient((int)beginPosition[0].dwLine);
int column = unchecked((int)(beginPosition[0].dwColumn + 1));
Expand Down

0 comments on commit 529241d

Please sign in to comment.