void IDebugCallback.OnDebugEvent(TraceEventKind kind, DebugThread thread, FunctionInfo functionInfo, int sequencePointIndex, int stackDepth, object payload)
{
ITraceCallback traceCallback = _traceCallback;
if (traceCallback != null)
{
// $TODO: what if the callback throws an exception? should we swallow it?
var curThread = _traceFrame.Value;
try {
if (kind == TraceEventKind.FrameExit || kind == TraceEventKind.ThreadExit)
{
traceCallback.OnTraceEvent(
kind,
kind == TraceEventKind.FrameExit ? functionInfo.Name : null,
null,
SourceSpan.None,
null,
payload,
functionInfo != null ? functionInfo.CustomPayload : null
);
}
else
{
DebugFrame leafFrame = thread.GetLeafFrame();
_traceFrame.Value = leafFrame;
Debug.Assert(sequencePointIndex >= 0 && sequencePointIndex < functionInfo.SequencePoints.Length);
DebugSourceSpan sourceSpan = functionInfo.SequencePoints[sequencePointIndex];
traceCallback.OnTraceEvent(
kind,
functionInfo.Name,
sourceSpan.SourceFile.Name,
sourceSpan.ToDlrSpan(),
() => { return(leafFrame.GetLocalsScope()); },
payload,
functionInfo.CustomPayload
);
}
} finally {
_traceFrame.Value = curThread;
}
}
}