Skip to content

Commit 618f6d7

Browse files
karthiknadigDonJayamanne
authored andcommitted
Add support for ShowReturnValue Debugger setting (microsoft#2852)
* Add showReturnValue debugger setting * Update tests to support showReturnValue setting * Address comments
1 parent 5507f5d commit 618f6d7

File tree

12 files changed

+38
-12
lines changed

12 files changed

+38
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ obj/**
2222
.pytest_cache
2323
tmp/**
2424
.python-version
25+
.vs/

news/1 Enhancements/2463.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added a debugger setting to show return values of functions while stepping.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,11 @@
490490
"description": "Automatically stop after launch.",
491491
"default": false
492492
},
493+
"showReturnValue": {
494+
"type": "boolean",
495+
"description": "Show return value of functions when stepping.",
496+
"default": false
497+
},
493498
"console": {
494499
"enum": [
495500
"none",

src/client/debugger/debugAdapter/DebugClients/LocalDebugClient.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import { DebugClientHelper } from './helper';
2020
const VALID_DEBUG_OPTIONS = [
2121
'RedirectOutput',
2222
'DebugStdLib',
23-
'stopOnEntry',
23+
'StopOnEntry',
24+
'ShowReturnValue',
2425
'BreakOnSystemExitZero',
2526
'DjangoDebugging',
2627
'Django'];

src/client/debugger/extension/configProviders/baseProvider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ export abstract class BaseConfigurationProvider implements DebugConfigurationPro
7272
if (typeof debugConfiguration.stopOnEntry !== 'boolean') {
7373
debugConfiguration.stopOnEntry = false;
7474
}
75+
if (typeof debugConfiguration.showReturnValue !== 'boolean') {
76+
debugConfiguration.showReturnValue = false;
77+
}
7578
if (!debugConfiguration.console) {
7679
debugConfiguration.console = 'integratedTerminal';
7780
}

src/client/debugger/extension/configProviders/pythonV2Provider.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide
2828
if (debugConfiguration.stopOnEntry) {
2929
this.debugOption(debugOptions, DebugOptions.StopOnEntry);
3030
}
31+
if (debugConfiguration.showReturnValue) {
32+
this.debugOption(debugOptions, DebugOptions.ShowReturnValue);
33+
}
3134
if (debugConfiguration.django) {
3235
this.debugOption(debugOptions, DebugOptions.Django);
3336
}
@@ -136,7 +139,8 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide
136139
isSudo: !!debugConfiguration.sudo,
137140
jinja: !!debugConfiguration.jinja,
138141
pyramid: !!debugConfiguration.pyramid,
139-
stopOnEntry: !!debugConfiguration.stopOnEntry
142+
stopOnEntry: !!debugConfiguration.stopOnEntry,
143+
showReturnValue: !!debugConfiguration.showReturnValue
140144
};
141145
sendTelemetryEvent(DEBUGGER, undefined, telemetryProps);
142146
}

src/client/debugger/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export enum DebugOptions {
1717
FixFilePathCase = 'FixFilePathCase',
1818
WindowsClient = 'WindowsClient',
1919
UnixClient = 'UnixClient',
20-
StopOnEntry = 'StopOnEntry'
20+
StopOnEntry = 'StopOnEntry',
21+
ShowReturnValue = 'ShowReturnValue'
2122
}
2223

2324
// tslint:disable-next-line:interface-name
@@ -30,6 +31,7 @@ interface AdditionalLaunchDebugOptions {
3031
sudo?: boolean;
3132
pyramid?: boolean;
3233
stopOnEntry?: boolean;
34+
showReturnValue?: boolean;
3335
}
3436

3537
// tslint:disable-next-line:interface-name
@@ -50,6 +52,8 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
5052
pythonPath: string;
5153
// Automatically stop target after launch. If not specified, target does not stop.
5254
stopOnEntry?: boolean;
55+
/** Show return values of functions while stepping. */
56+
showReturnValue?: boolean;
5357
args: string[];
5458
cwd?: string;
5559
debugOptions?: DebugOptions[];

src/client/telemetry/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export type DebuggerTelemetryV2 = {
5555
isModule: boolean;
5656
isSudo: boolean;
5757
stopOnEntry: boolean;
58+
showReturnValue: boolean;
5859
pyramid: boolean;
5960
};
6061
export type DebuggerPerformanceTelemetry = {

src/test/debugger/configProvider/provider.unit.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,9 @@ suite('Debugging - Config Provider', () => {
270270

271271
expect(debugConfig).to.have.property('console', 'integratedTerminal');
272272
expect(debugConfig).to.have.property('stopOnEntry', false);
273+
expect(debugConfig).to.have.property('showReturnValue', false);
273274
expect(debugConfig).to.have.property('debugOptions');
274-
expect((debugConfig as any).debugOptions).to.be.deep.equal(['RedirectOutput']);
275+
expect((debugConfig as any).debugOptions).to.be.deep.equal([DebugOptions.RedirectOutput]);
275276
});
276277
test('Test defaults of python debugger', async () => {
277278
if ('python' === DebuggerTypeName) {
@@ -286,6 +287,7 @@ suite('Debugging - Config Provider', () => {
286287
const debugConfig = await debugProvider.resolveDebugConfiguration!(workspaceFolder, {} as DebugConfiguration);
287288

288289
expect(debugConfig).to.have.property('stopOnEntry', false);
290+
expect(debugConfig).to.have.property('showReturnValue', false);
289291
expect(debugConfig).to.have.property('debugOptions');
290292
expect((debugConfig as any).debugOptions).to.be.deep.equal([DebugOptions.RedirectOutput]);
291293
});
@@ -300,6 +302,7 @@ suite('Debugging - Config Provider', () => {
300302

301303
expect(debugConfig).to.have.property('console', 'integratedTerminal');
302304
expect(debugConfig).to.have.property('stopOnEntry', false);
305+
expect(debugConfig).to.have.property('showReturnValue', false);
303306
expect(debugConfig).to.have.property('debugOptions');
304307
expect((debugConfig as any).debugOptions).to.be.deep.equal([]);
305308
});

src/test/debugger/misc.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ suite(`Standard Debugging - Misc tests: ${debuggerType}`, () => {
5656
return new DebugClientEx(testAdapterFilePath, debuggerType, coverageDirectory, { cwd: EXTENSION_ROOT_DIR });
5757
}
5858
}
59-
function buildLaunchArgs(pythonFile: string, stopOnEntry: boolean = false): LaunchRequestArguments {
59+
function buildLaunchArgs(pythonFile: string, stopOnEntry: boolean = false, showReturnValue: boolean = false): LaunchRequestArguments {
6060
const env = { PYTHONPATH: PTVSD_PATH };
6161
// tslint:disable-next-line:no-unnecessary-local-variable
6262
const options = {
6363
program: path.join(debugFilesPath, pythonFile),
6464
cwd: debugFilesPath,
6565
stopOnEntry,
66+
showReturnValue,
6667
debugOptions: [DebugOptions.RedirectOutput],
6768
pythonPath: PYTHON_PATH,
6869
args: [],

0 commit comments

Comments
 (0)