Skip to content

Commit 022e403

Browse files
committed
package.json: add showLog/logOutput/dlvFlags to go.delveConfig setting
These allow to enable delve-side logging and set custom dlv flags for debug sessions started with debug test codelens. Fixes #1723 Change-Id: I3ff423ae81e6b482e14d009232860e31838200cf Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/351249 Trust: Hyang-Ah Hana Kim <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]> Reviewed-by: Suzy Mueller <[email protected]>
1 parent 6f98706 commit 022e403

File tree

4 files changed

+56
-51
lines changed

4 files changed

+56
-51
lines changed

docs/settings.md

+4-18
Original file line numberDiff line numberDiff line change
@@ -142,28 +142,14 @@ Default: `"showBothCoveredAndUncoveredCode"`
142142
Delve settings that applies to all debugging sessions. Debug configuration in the launch.json file will override these values.
143143
| Properties | Description |
144144
| --- | --- |
145-
| `apiVersion` | Delve Api Version to use. Default value is 2. <br/> Allowed Options: `1`, `2` <br/> Default: `2` |
145+
| `apiVersion` | Delve Api Version to use. Default value is 2. This applies only when using the 'legacy' debug adapter. <br/> Allowed Options: `1`, `2` <br/> Default: `2` |
146146
| `debugAdapter` | Select which debug adapter to use by default. This is also used for choosing which debug adapter to use when no launch.json is present and with codelenses. <br/> Allowed Options: `legacy`, `dlv-dap` <br/> Default: `"dlv-dap"` |
147+
| `dlvFlags` | Extra flags for `dlv`. See `dlv help` for the full list of supported. Flags such as `--log-output`, `--log`, `--log-dest`, `--api-version`, `--output`, `--backend` already have corresponding properties in the debug configuration, and flags such as `--listen` and `--headless` are used internally. If they are specified in `dlvFlags`, they may be ignored or cause an error. |
147148
| `dlvLoadConfig` | LoadConfig describes to delve, how to load values from target's memory. Ignored by 'dlv-dap'. <br/> Default: ``` { <pre>"followPointers" : true,<br/>"maxArrayValues" : 64,<br/>"maxStringLen" : 64,<br/>"maxStructFields" : -1,<br/>"maxVariableRecurse" : 1,</pre>} ``` |
149+
| `logOutput` | Comma separated list of components that should produce debug output. Maps to dlv's `--log-output` flag. Check `dlv log` for details. <br/> Allowed Options: `debugger`, `gdbwire`, `lldbout`, `debuglineerr`, `rpc`, `dap` <br/> Default: `"debugger"` |
148150
| `showGlobalVariables` | Boolean value to indicate whether global package variables should be shown in the variables pane or not. <br/> Default: `false` |
151+
| `showLog` | Show log output from the delve debugger. Maps to dlv's `--log` flag. <br/> Default: `false` |
149152
| `substitutePath` | An array of mappings from a local path to the remote path that is used by the debuggee. The debug adapter will replace the local path with the remote path in all of the calls. Overriden by `remotePath` (in attach request). |
150-
151-
Default:
152-
```
153-
{
154-
"apiVersion" : 2,
155-
"debugAdapter" : "legacy",
156-
"dlvLoadConfig" : {
157-
"followPointers" : true,
158-
"maxArrayValues" : 64,
159-
"maxStringLen" : 64,
160-
"maxStructFields" : -1,
161-
"maxVariableRecurse" : 1,
162-
},
163-
"showGlobalVariables" : false,
164-
"substitutePath" : [],
165-
}
166-
```
167153
### `go.disableConcurrentTests`
168154

169155
If true, tests will not run concurrently. When a new test run is started, the previous will be cancelled.

package.json

+28-14
Original file line numberDiff line numberDiff line change
@@ -1794,14 +1794,32 @@
17941794
1,
17951795
2
17961796
],
1797-
"description": "Delve Api Version to use. Default value is 2.",
1797+
"description": "Delve Api Version to use. Default value is 2. This applies only when using the 'legacy' debug adapter.",
17981798
"default": 2
17991799
},
18001800
"showGlobalVariables": {
18011801
"type": "boolean",
18021802
"description": "Boolean value to indicate whether global package variables should be shown in the variables pane or not.",
18031803
"default": false
18041804
},
1805+
"showLog": {
1806+
"type": "boolean",
1807+
"description": "Show log output from the delve debugger. Maps to dlv's `--log` flag.",
1808+
"default": false
1809+
},
1810+
"logOutput": {
1811+
"type": "string",
1812+
"enum": [
1813+
"debugger",
1814+
"gdbwire",
1815+
"lldbout",
1816+
"debuglineerr",
1817+
"rpc",
1818+
"dap"
1819+
],
1820+
"description": "Comma separated list of components that should produce debug output. Maps to dlv's `--log-output` flag. Check `dlv log` for details.",
1821+
"default": "debugger"
1822+
},
18051823
"debugAdapter": {
18061824
"type": "string",
18071825
"enum": [
@@ -1811,6 +1829,14 @@
18111829
"description": "Select which debug adapter to use by default. This is also used for choosing which debug adapter to use when no launch.json is present and with codelenses.",
18121830
"default": "dlv-dap"
18131831
},
1832+
"dlvFlags": {
1833+
"type": "array",
1834+
"description": "Extra flags for `dlv`. See `dlv help` for the full list of supported. Flags such as `--log-output`, `--log`, `--log-dest`, `--api-version`, `--output`, `--backend` already have corresponding properties in the debug configuration, and flags such as `--listen` and `--headless` are used internally. If they are specified in `dlvFlags`, they may be ignored or cause an error.",
1835+
"items": {
1836+
"type": "string"
1837+
},
1838+
"default": []
1839+
},
18141840
"substitutePath": {
18151841
"type": "array",
18161842
"items": {
@@ -1832,19 +1858,7 @@
18321858
"default": []
18331859
}
18341860
},
1835-
"default": {
1836-
"dlvLoadConfig": {
1837-
"followPointers": true,
1838-
"maxVariableRecurse": 1,
1839-
"maxStringLen": 64,
1840-
"maxArrayValues": 64,
1841-
"maxStructFields": -1
1842-
},
1843-
"apiVersion": 2,
1844-
"showGlobalVariables": false,
1845-
"debugAdapter": "legacy",
1846-
"substitutePath": []
1847-
},
1861+
"default": {},
18481862
"description": "Delve settings that applies to all debugging sessions. Debug configuration in the launch.json file will override these values.",
18491863
"scope": "resource"
18501864
},

src/goDebugConfiguration.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,18 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
197197
"'dlvLoadConfig' is deprecated with dlv-dap debug adapter.\n\nDlv-dap loads composite data on demand and uses increased string limits on source code hover, in Debug Console and via Copy Value. Please file an issue if these are not sufficient for your use case."
198198
);
199199
}
200-
if (!debugConfiguration.hasOwnProperty('dlvLoadConfig') && dlvConfig.hasOwnProperty('dlvLoadConfig')) {
201-
debugConfiguration['dlvLoadConfig'] = dlvConfig['dlvLoadConfig'];
202-
}
203-
if (
204-
!debugConfiguration.hasOwnProperty('showGlobalVariables') &&
205-
dlvConfig.hasOwnProperty('showGlobalVariables')
206-
) {
207-
debugConfiguration['showGlobalVariables'] = dlvConfig['showGlobalVariables'];
208-
}
209-
if (!debugConfiguration.hasOwnProperty('substitutePath') && dlvConfig.hasOwnProperty('substitutePath')) {
210-
debugConfiguration['substitutePath'] = dlvConfig['substitutePath'];
200+
201+
// Reflect the defaults set through go.delveConfig setting.
202+
const dlvProperties = ['showGlobalVariables', 'substitutePath', 'showLog', 'logOutput', 'dlvFlags'];
203+
if (debugAdapter !== 'dlv-dap') {
204+
dlvProperties.push('dlvLoadConfig');
211205
}
206+
dlvProperties.forEach((p) => {
207+
if (!debugConfiguration.hasOwnProperty(p) && dlvConfig.hasOwnProperty(p)) {
208+
debugConfiguration[p] = dlvConfig[p];
209+
}
210+
});
211+
212212
if (debugAdapter !== 'dlv-dap' && debugConfiguration.request === 'attach' && !debugConfiguration['cwd']) {
213213
debugConfiguration['cwd'] = '${workspaceFolder}';
214214
if (vscode.workspace.workspaceFolders?.length > 1) {

test/integration/goDebugConfiguration.test.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ suite('Debug Configuration Merge User Settings', () => {
280280
apiVersion: 1,
281281
showGlobalVariables: true,
282282
debugAdapter: 'dlv-dap',
283-
substitutePath: [{ from: 'hello', to: 'goodbye' }]
283+
substitutePath: [{ from: 'hello', to: 'goodbye' }],
284+
showLog: true,
285+
logOutput: 'dap,debugger',
286+
dlvFlags: ['--check-go-version=false']
284287
}
285288
});
286289
sinon.stub(config, 'getGoConfig').returns(goConfig);
@@ -300,12 +303,11 @@ suite('Debug Configuration Merge User Settings', () => {
300303
assert.strictEqual(result.substitutePath.length, 1);
301304
assert.strictEqual(result.substitutePath[0].from, 'hello');
302305
assert.strictEqual(result.substitutePath[0].to, 'goodbye');
306+
assert.strictEqual(result.showLog, true);
307+
assert.strictEqual(result.logOutput, 'dap,debugger');
308+
assert.deepStrictEqual(result.dlvFlags, ['--check-go-version=false']);
303309
const dlvLoadConfig = result.dlvLoadConfig;
304-
assert.strictEqual(dlvLoadConfig.followPointers, false);
305-
assert.strictEqual(dlvLoadConfig.maxVariableRecurse, 3);
306-
assert.strictEqual(dlvLoadConfig.maxStringLen, 32);
307-
assert.strictEqual(dlvLoadConfig.maxArrayValues, 32);
308-
assert.strictEqual(dlvLoadConfig.maxStructFields, 5);
310+
assert.strictEqual(dlvLoadConfig, undefined); // dlvLoadConfig does not apply in dlv-dap mode.
309311
});
310312

311313
test('delve config in settings.json is overriden by launch.json', async () => {
@@ -337,8 +339,8 @@ suite('Debug Configuration Merge User Settings', () => {
337339
request: 'launch',
338340
mode: 'auto',
339341
program: '${fileDirname}',
340-
apiVersion: 2,
341342
showGlobalVariables: false,
343+
apiVersion: 2,
342344
dlvLoadConfig: {
343345
followPointers: true,
344346
maxVariableRecurse: 6,
@@ -347,14 +349,17 @@ suite('Debug Configuration Merge User Settings', () => {
347349
maxStructFields: -1
348350
},
349351
debugAdapter: 'legacy',
350-
substitutePath: []
352+
substitutePath: [],
353+
logOutput: 'rpc'
351354
};
352355

353356
const result = await debugConfigProvider.resolveDebugConfiguration(undefined, cfg);
354357
assert.strictEqual(result.apiVersion, 2);
355358
assert.strictEqual(result.showGlobalVariables, false);
356359
assert.strictEqual(result.debugAdapter, 'legacy');
357360
assert.strictEqual(result.substitutePath.length, 0);
361+
assert.strictEqual(result.showLog, undefined);
362+
assert.strictEqual(result.logOutput, 'rpc');
358363
const dlvLoadConfig = result.dlvLoadConfig;
359364
assert.strictEqual(dlvLoadConfig.followPointers, true);
360365
assert.strictEqual(dlvLoadConfig.maxVariableRecurse, 6);

0 commit comments

Comments
 (0)