From 1137e9290a67a5ccea0c8dcf0229a8ec511638e0 Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Sat, 3 Nov 2018 13:25:36 -0400 Subject: [PATCH 1/4] Add stacktrace paging support to debug adapter Fixes #946 --- src/debugAdapter/goDebug.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts index 3369c03b5..01781d727 100644 --- a/src/debugAdapter/goDebug.ts +++ b/src/debugAdapter/goDebug.ts @@ -770,7 +770,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: 50 }; if (!this.delve.isApiV1) { Object.assign(stackTraceIn, { full: false, cfg: this.delve.loadConfig }); } @@ -793,7 +794,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'); }); From 6d3476914e841008e1692960b3f64904b5684b69 Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Tue, 13 Nov 2018 15:53:05 -0500 Subject: [PATCH 2/4] Add configuration setting for maximum stack trace depth --- package.json | 5 +++++ src/debugAdapter/goDebug.ts | 6 +++++- src/goDebugConfiguration.ts | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 71bf3746d..88a778c21 100644 --- a/package.json +++ b/package.json @@ -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": 50 } } } diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts index 01781d727..f52071581 100644 --- a/src/debugAdapter/goDebug.ts +++ b/src/debugAdapter/goDebug.ts @@ -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) => { @@ -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); @@ -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; @@ -771,7 +775,7 @@ class GoDebugSession extends DebugSession { protected stackTraceRequest(response: DebugProtocol.StackTraceResponse, args: DebugProtocol.StackTraceArguments): void { verbose('StackTraceRequest'); // delve does not support frame paging, so we ask for a large depth - let stackTraceIn = { id: args.threadId, depth: 50 }; + let stackTraceIn = { id: args.threadId, depth: this.delve.stackTraceDepth }; if (!this.delve.isApiV1) { Object.assign(stackTraceIn, { full: false, cfg: this.delve.loadConfig }); } diff --git a/src/goDebugConfiguration.ts b/src/goDebugConfiguration.ts index 1cdc25b42..6420ed817 100644 --- a/src/goDebugConfiguration.ts +++ b/src/goDebugConfiguration.ts @@ -77,6 +77,9 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr if (!debugConfiguration.hasOwnProperty('dlvLoadConfig') && dlvConfig.hasOwnProperty('dlvLoadConfig')) { debugConfiguration['dlvLoadConfig'] = dlvConfig['dlvLoadConfig']; } + if (!debugConfiguration.hasOwnProperty('stackTraceDepth') && dlvConfig.hasOwnProperty('stackTraceDepth')) { + debugConfiguration['stackTraceDepth'] = dlvConfig['stackTraceDepth']; + } if (debugConfiguration['mode'] === 'auto') { debugConfiguration['mode'] = (activeEditor && activeEditor.document.fileName.endsWith('_test.go')) ? 'test' : 'debug'; From c7b723f452bad8933f84e229130ef2528a0211af Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Tue, 13 Nov 2018 17:31:58 -0800 Subject: [PATCH 3/4] Use current default of 20 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 88a778c21..165381a6c 100644 --- a/package.json +++ b/package.json @@ -500,7 +500,7 @@ "stackTraceDepth": { "type": "number", "description": "Maximum depth of stack trace collected from Delve", - "default": 50 + "default": 20 } } } From 3c70376a00775c8b2e022c552aab0b3d18a02402 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Tue, 13 Nov 2018 17:32:17 -0800 Subject: [PATCH 4/4] Fallback to settings wont work --- src/goDebugConfiguration.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/goDebugConfiguration.ts b/src/goDebugConfiguration.ts index 6420ed817..1cdc25b42 100644 --- a/src/goDebugConfiguration.ts +++ b/src/goDebugConfiguration.ts @@ -77,9 +77,6 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr if (!debugConfiguration.hasOwnProperty('dlvLoadConfig') && dlvConfig.hasOwnProperty('dlvLoadConfig')) { debugConfiguration['dlvLoadConfig'] = dlvConfig['dlvLoadConfig']; } - if (!debugConfiguration.hasOwnProperty('stackTraceDepth') && dlvConfig.hasOwnProperty('stackTraceDepth')) { - debugConfiguration['stackTraceDepth'] = dlvConfig['stackTraceDepth']; - } if (debugConfiguration['mode'] === 'auto') { debugConfiguration['mode'] = (activeEditor && activeEditor.document.fileName.endsWith('_test.go')) ? 'test' : 'debug';