Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Add stacktrace paging support to debug adapter #2080

Merged
merged 4 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,11 @@
],
"description": "Delve Api Version to use. Default value is 2.",
"default": 2
},
"stackTraceDepth": {
"type": "number",
"description": "Maximum depth of stack trace collected from Delve",
"default": 20
}
}
}
Expand Down
15 changes: 13 additions & 2 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
dlvLoadConfig?: LoadConfig;
/** Delve Version */
apiVersion: number;
/** Delve maximum stack trace depth */
stackTraceDepth: number;
}

process.on('uncaughtException', (err: any) => {
Expand Down Expand Up @@ -258,6 +260,7 @@ class Delve {
noDebug: boolean;
isApiV1: boolean;
dlvEnv: any;
stackTraceDepth: number;

constructor(remotePath: string, port: number, host: string, program: string, launchArgs: LaunchRequestArguments) {
this.program = normalizePath(program);
Expand All @@ -268,6 +271,7 @@ class Delve {
} else if (typeof launchArgs['useApiV1'] === 'boolean') {
this.isApiV1 = launchArgs['useApiV1'];
}
this.stackTraceDepth = launchArgs.stackTraceDepth;
let mode = launchArgs.mode;
let dlvCwd = dirname(program);
let isProgramDirectory = false;
Expand Down Expand Up @@ -770,7 +774,8 @@ class GoDebugSession extends DebugSession {

protected stackTraceRequest(response: DebugProtocol.StackTraceResponse, args: DebugProtocol.StackTraceArguments): void {
verbose('StackTraceRequest');
let stackTraceIn = { id: args.threadId, depth: args.levels };
// delve does not support frame paging, so we ask for a large depth
let stackTraceIn = { id: args.threadId, depth: this.delve.stackTraceDepth };
if (!this.delve.isApiV1) {
Object.assign(stackTraceIn, { full: false, cfg: this.delve.loadConfig });
}
Expand All @@ -793,7 +798,13 @@ class GoDebugSession extends DebugSession {
0
)
);
response.body = { stackFrames };
if (args.startFrame > 0) {
stackFrames = stackFrames.slice(args.startFrame);
}
if (args.levels > 0) {
stackFrames = stackFrames.slice(0, args.levels);
}
response.body = { stackFrames, totalFrames: locations.length };
this.sendResponse(response);
verbose('StackTraceResponse');
});
Expand Down