From df46bfda4caa16961e3ab02a5f78fea405c5a602 Mon Sep 17 00:00:00 2001 From: karthikraobr Date: Wed, 17 Oct 2018 16:11:42 +0200 Subject: [PATCH 1/7] Fixed copying values from variables in debug mode --- src/debugAdapter/goDebug.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts index 61c25eabe..1838a7937 100644 --- a/src/debugAdapter/goDebug.ts +++ b/src/debugAdapter/goDebug.ts @@ -850,7 +850,7 @@ class GoDebugSession extends DebugSession { let initdoneIndex = -1; for (let i = 0; i < globals.length; i++) { globals[i].name = globals[i].name.substr(packageName.length + 1); - if (initdoneIndex === -1 && globals[i].name === this.initdone) { + if (initdoneIndex === -1 && globals[i].name === this.initdone) { initdoneIndex = i; } } @@ -979,6 +979,7 @@ class GoDebugSession extends DebugSession { variables.push({ name: mapKey.result, value: mapValue.result, + evaluateName: mapValue.result, variablesReference: mapValue.variablesReference }); } @@ -988,6 +989,7 @@ class GoDebugSession extends DebugSession { return { name: v.name, value: result, + evaluateName: v.name, variablesReference }; }); From 804e9f262c013a1f7e712959ec3e5f51104ec95c Mon Sep 17 00:00:00 2001 From: karthikraobr Date: Wed, 17 Oct 2018 16:13:24 +0200 Subject: [PATCH 2/7] fixed missing evaluateName for array type --- src/debugAdapter/goDebug.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts index 1838a7937..899e5a2d8 100644 --- a/src/debugAdapter/goDebug.ts +++ b/src/debugAdapter/goDebug.ts @@ -965,6 +965,7 @@ class GoDebugSession extends DebugSession { return { name: '[' + i + ']', value: result, + evaluateName: '[' + i + ']', variablesReference }; }); From c1507574801330d748126e91f2e23e2eb05b492a Mon Sep 17 00:00:00 2001 From: karthikraobr Date: Sun, 21 Oct 2018 22:30:08 +0200 Subject: [PATCH 3/7] Fixed evaluateName --- src/debugAdapter/goDebug.ts | 39 ++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts index 899e5a2d8..0b6418072 100644 --- a/src/debugAdapter/goDebug.ts +++ b/src/debugAdapter/goDebug.ts @@ -157,6 +157,7 @@ interface DebugVariable { cap: number; children: DebugVariable[]; unreadable: string; + fqn: string; } interface ListGoroutinesOut { @@ -808,6 +809,14 @@ class GoDebugSession extends DebugSession { } const locals = this.delve.isApiV1 ? out : (out).Variables; verbose('locals', locals); + locals.every(local => { + local.fqn = local.name; + local.children.every(child => { + child.fqn = local.name; + return true; + }); + return true; + }) let listLocalFunctionArgsIn = { goroutineID: this.debugState.currentGoroutine.id, frame: args.frameId }; this.delve.call('ListFunctionArgs', this.delve.isApiV1 ? [listLocalFunctionArgsIn] : [{ scope: listLocalFunctionArgsIn, cfg: this.delve.loadConfig }], (err, outArgs) => { if (err) { @@ -816,8 +825,17 @@ class GoDebugSession extends DebugSession { } const args = this.delve.isApiV1 ? outArgs : (outArgs).Args; verbose('functionArgs', args); + args.every(local => { + local.fqn = local.name; + local.children.every(child => { + child.fqn = local.name; + return true; + }); + return true; + }) let vars = args.concat(locals); + let scopes = new Array(); let localVariables = { name: 'Local', @@ -829,8 +847,10 @@ class GoDebugSession extends DebugSession { len: 0, cap: 0, children: vars, - unreadable: '' + unreadable: '', + fqn: '', }; + scopes.push(new Scope('Local', this._variableHandles.create(localVariables), false)); response.body = { scopes }; @@ -869,7 +889,8 @@ class GoDebugSession extends DebugSession { len: 0, cap: 0, children: globals, - unreadable: '' + unreadable: '', + fqn: '', }; scopes.push(new Scope('Global', this._variableHandles.create(globalVariables), false)); this.sendResponse(response); @@ -922,6 +943,13 @@ class GoDebugSession extends DebugSession { variablesReference: 0 }; } else { + if(v.children[0].children.length > 0){ + v.children[0].fqn=v.fqn; + v.children[0].children.every(child=>{ + child.fqn=v.fqn+'.'+child.name; + return true; + }); + } return { result: '<' + v.type + '>', variablesReference: v.children[0].children.length > 0 ? this._variableHandles.create(v.children[0]) : 0 @@ -965,7 +993,7 @@ class GoDebugSession extends DebugSession { return { name: '[' + i + ']', value: result, - evaluateName: '[' + i + ']', + evaluateName: vari.fqn+'[' + i + ']', variablesReference }; }); @@ -980,17 +1008,18 @@ class GoDebugSession extends DebugSession { variables.push({ name: mapKey.result, value: mapValue.result, - evaluateName: mapValue.result, + evaluateName: vari.fqn+'[' + mapKey.result + ']', variablesReference: mapValue.variablesReference }); } } else { variables = vari.children.map((v, i) => { let { result, variablesReference } = this.convertDebugVariableToProtocolVariable(v, i); + v.fqn = v.fqn == undefined ? vari.fqn + '.' + v.name : v.fqn; return { name: v.name, value: result, - evaluateName: v.name, + evaluateName: v.fqn == undefined ? vari.fqn + '.' + v.name : v.fqn, variablesReference }; }); From ada1a115b53b0f76da0f1ac7a74b60f195a337a6 Mon Sep 17 00:00:00 2001 From: karthikraobr Date: Sun, 21 Oct 2018 22:36:34 +0200 Subject: [PATCH 4/7] Formeatting --- src/debugAdapter/goDebug.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts index 5c30939eb..37cb1370d 100644 --- a/src/debugAdapter/goDebug.ts +++ b/src/debugAdapter/goDebug.ts @@ -943,10 +943,10 @@ class GoDebugSession extends DebugSession { variablesReference: 0 }; } else { - if(v.children[0].children.length > 0){ - v.children[0].fqn=v.fqn; - v.children[0].children.every(child=>{ - child.fqn=v.fqn+'.'+child.name; + if (v.children[0].children.length > 0) { + v.children[0].fqn = v.fqn; + v.children[0].children.every(child => { + child.fqn = v.fqn + '.' + child.name; return true; }); } @@ -993,7 +993,7 @@ class GoDebugSession extends DebugSession { return { name: '[' + i + ']', value: result, - evaluateName: vari.fqn+'[' + i + ']', + evaluateName: vari.fqn + '[' + i + ']', variablesReference }; }); @@ -1008,14 +1008,14 @@ class GoDebugSession extends DebugSession { variables.push({ name: mapKey.result, value: mapValue.result, - evaluateName: vari.fqn+'[' + mapKey.result + ']', + evaluateName: vari.fqn + '[' + mapKey.result + ']', variablesReference: mapValue.variablesReference }); } } else { variables = vari.children.map((v, i) => { let { result, variablesReference } = this.convertDebugVariableToProtocolVariable(v, i); - v.fqn = v.fqn == undefined ? vari.fqn + '.' + v.name : v.fqn; + v.fqn = v.fqn == undefined ? vari.fqn + '.' + v.name : v.fqn; return { name: v.name, value: result, From 44734f990531daf9eca250e4da3c0905da357990 Mon Sep 17 00:00:00 2001 From: karthikraobr Date: Tue, 23 Oct 2018 11:50:36 +0200 Subject: [PATCH 5/7] Incorporated review comments --- src/debugAdapter/goDebug.ts | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts index 37cb1370d..443e4cd3c 100644 --- a/src/debugAdapter/goDebug.ts +++ b/src/debugAdapter/goDebug.ts @@ -809,14 +809,7 @@ class GoDebugSession extends DebugSession { } const locals = this.delve.isApiV1 ? out : (out).Variables; verbose('locals', locals); - locals.every(local => { - local.fqn = local.name; - local.children.every(child => { - child.fqn = local.name; - return true; - }); - return true; - }) + this.addFullyQualifiedName(locals); let listLocalFunctionArgsIn = { goroutineID: this.debugState.currentGoroutine.id, frame: args.frameId }; this.delve.call('ListFunctionArgs', this.delve.isApiV1 ? [listLocalFunctionArgsIn] : [{ scope: listLocalFunctionArgsIn, cfg: this.delve.loadConfig }], (err, outArgs) => { if (err) { @@ -825,14 +818,7 @@ class GoDebugSession extends DebugSession { } const args = this.delve.isApiV1 ? outArgs : (outArgs).Args; verbose('functionArgs', args); - args.every(local => { - local.fqn = local.name; - local.children.every(child => { - child.fqn = local.name; - return true; - }); - return true; - }) + this.addFullyQualifiedName(args); let vars = args.concat(locals); @@ -1015,11 +1001,11 @@ class GoDebugSession extends DebugSession { } else { variables = vari.children.map((v, i) => { let { result, variablesReference } = this.convertDebugVariableToProtocolVariable(v, i); - v.fqn = v.fqn == undefined ? vari.fqn + '.' + v.name : v.fqn; + v.fqn = v.fqn === undefined ? vari.fqn + '.' + v.name : v.fqn; return { name: v.name, value: result, - evaluateName: v.fqn == undefined ? vari.fqn + '.' + v.name : v.fqn, + evaluateName: v.fqn, variablesReference }; }); @@ -1172,6 +1158,17 @@ class GoDebugSession extends DebugSession { verbose('EvaluateResponse'); }); } + + private addFullyQualifiedName(data: DebugVariable[]) { + data.every(local => { + local.fqn = local.name; + local.children.every(child => { + child.fqn = local.name; + return true; + }); + return true; + }); + } } function random(low: number, high: number): number { From f347024e4aa3c190e7e032ecd3757afa38b11404 Mon Sep 17 00:00:00 2001 From: karthikraobr Date: Tue, 23 Oct 2018 12:09:03 +0200 Subject: [PATCH 6/7] Changed fqn -> fullyQualifiedName --- src/debugAdapter/goDebug.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts index 443e4cd3c..4fcb37a64 100644 --- a/src/debugAdapter/goDebug.ts +++ b/src/debugAdapter/goDebug.ts @@ -157,7 +157,7 @@ interface DebugVariable { cap: number; children: DebugVariable[]; unreadable: string; - fqn: string; + fullyQualifiedName: string; } interface ListGoroutinesOut { @@ -834,7 +834,7 @@ class GoDebugSession extends DebugSession { cap: 0, children: vars, unreadable: '', - fqn: '', + fullyQualifiedName: '', }; scopes.push(new Scope('Local', this._variableHandles.create(localVariables), false)); @@ -876,7 +876,7 @@ class GoDebugSession extends DebugSession { cap: 0, children: globals, unreadable: '', - fqn: '', + fullyQualifiedName: '', }; scopes.push(new Scope('Global', this._variableHandles.create(globalVariables), false)); this.sendResponse(response); @@ -930,9 +930,9 @@ class GoDebugSession extends DebugSession { }; } else { if (v.children[0].children.length > 0) { - v.children[0].fqn = v.fqn; + v.children[0].fullyQualifiedName = v.fullyQualifiedName; v.children[0].children.every(child => { - child.fqn = v.fqn + '.' + child.name; + child.fullyQualifiedName = v.fullyQualifiedName + '.' + child.name; return true; }); } @@ -979,7 +979,7 @@ class GoDebugSession extends DebugSession { return { name: '[' + i + ']', value: result, - evaluateName: vari.fqn + '[' + i + ']', + evaluateName: vari.fullyQualifiedName + '[' + i + ']', variablesReference }; }); @@ -994,18 +994,18 @@ class GoDebugSession extends DebugSession { variables.push({ name: mapKey.result, value: mapValue.result, - evaluateName: vari.fqn + '[' + mapKey.result + ']', + evaluateName: vari.fullyQualifiedName + '[' + mapKey.result + ']', variablesReference: mapValue.variablesReference }); } } else { variables = vari.children.map((v, i) => { let { result, variablesReference } = this.convertDebugVariableToProtocolVariable(v, i); - v.fqn = v.fqn === undefined ? vari.fqn + '.' + v.name : v.fqn; + v.fullyQualifiedName = v.fullyQualifiedName === undefined ? vari.fullyQualifiedName + '.' + v.name : v.fullyQualifiedName; return { name: v.name, value: result, - evaluateName: v.fqn, + evaluateName: v.fullyQualifiedName, variablesReference }; }); @@ -1161,9 +1161,9 @@ class GoDebugSession extends DebugSession { private addFullyQualifiedName(data: DebugVariable[]) { data.every(local => { - local.fqn = local.name; + local.fullyQualifiedName = local.name; local.children.every(child => { - child.fqn = local.name; + child.fullyQualifiedName = local.name; return true; }); return true; From c2dd843cb2c3abdb176a08632260e11e123caac8 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Wed, 31 Oct 2018 22:11:52 -0700 Subject: [PATCH 7/7] Slight refactoring --- src/debugAdapter/goDebug.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts index 4fcb37a64..77c6b125b 100644 --- a/src/debugAdapter/goDebug.ts +++ b/src/debugAdapter/goDebug.ts @@ -821,7 +821,6 @@ class GoDebugSession extends DebugSession { this.addFullyQualifiedName(args); let vars = args.concat(locals); - let scopes = new Array(); let localVariables = { name: 'Local', @@ -931,9 +930,8 @@ class GoDebugSession extends DebugSession { } else { if (v.children[0].children.length > 0) { v.children[0].fullyQualifiedName = v.fullyQualifiedName; - v.children[0].children.every(child => { + v.children[0].children.forEach(child => { child.fullyQualifiedName = v.fullyQualifiedName + '.' + child.name; - return true; }); } return { @@ -1001,7 +999,9 @@ class GoDebugSession extends DebugSession { } else { variables = vari.children.map((v, i) => { let { result, variablesReference } = this.convertDebugVariableToProtocolVariable(v, i); - v.fullyQualifiedName = v.fullyQualifiedName === undefined ? vari.fullyQualifiedName + '.' + v.name : v.fullyQualifiedName; + if (v.fullyQualifiedName === undefined) { + v.fullyQualifiedName = vari.fullyQualifiedName + '.' + v.name; + } return { name: v.name, value: result, @@ -1159,14 +1159,12 @@ class GoDebugSession extends DebugSession { }); } - private addFullyQualifiedName(data: DebugVariable[]) { - data.every(local => { + private addFullyQualifiedName(variables: DebugVariable[]) { + variables.forEach(local => { local.fullyQualifiedName = local.name; - local.children.every(child => { + local.children.forEach(child => { child.fullyQualifiedName = local.name; - return true; }); - return true; }); } }