in src/csharp/MonoDebugSession.cs [592:644]
public override void StackTrace(Response response, dynamic args)
{
int maxLevels = getInt(args, "levels", 10);
int threadReference = getInt(args, "threadId", 0);
WaitForSuspend();
ThreadInfo thread = DebuggerActiveThread();
if (thread.Id != threadReference) {
// Program.Log("stackTrace: unexpected: active thread should be the one requested");
thread = FindThread(threadReference);
if (thread != null) {
thread.SetActive();
}
}
var stackFrames = new List<StackFrame>();
int totalFrames = 0;
var bt = thread.Backtrace;
if (bt != null && bt.FrameCount >= 0) {
totalFrames = bt.FrameCount;
for (var i = 0; i < Math.Min(totalFrames, maxLevels); i++) {
var frame = bt.GetFrame(i);
string path = frame.SourceLocation.FileName;
var hint = "subtle";
Source source = null;
if (!string.IsNullOrEmpty(path)) {
string sourceName = Path.GetFileName(path);
if (!string.IsNullOrEmpty(sourceName)) {
if (File.Exists(path)) {
source = new Source(sourceName, ConvertDebuggerPathToClient(path), 0, "normal");
hint = "normal";
} else {
source = new Source(sourceName, null, 1000, "deemphasize");
}
}
}
var frameHandle = _frameHandles.Create(frame);
string name = frame.SourceLocation.MethodName;
int line = frame.SourceLocation.Line;
stackFrames.Add(new StackFrame(frameHandle, name, source, ConvertDebuggerLineToClient(line), 0, hint));
}
}
SendResponse(response, new StackTraceResponseBody(stackFrames, totalFrames));
}