Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ obj/**
.pytest_cache
tmp/**
.python-version
.vs/
1 change: 1 addition & 0 deletions news/1 Enhancements/2463.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a debugger setting to show return values of functions while stepping.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,11 @@
"description": "Automatically stop after launch.",
"default": false
},
"showReturnValue": {
"type": "boolean",
"description": "Show return value of functions when stepping.",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic!

"default": false
},
"console": {
"enum": [
"none",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import { DebugClientHelper } from './helper';
const VALID_DEBUG_OPTIONS = [
'RedirectOutput',
'DebugStdLib',
'stopOnEntry',
'StopOnEntry',
'ShowReturnValue',
'BreakOnSystemExitZero',
'DjangoDebugging',
'Django'];
Expand Down
3 changes: 3 additions & 0 deletions src/client/debugger/extension/configProviders/baseProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export abstract class BaseConfigurationProvider implements DebugConfigurationPro
if (typeof debugConfiguration.stopOnEntry !== 'boolean') {
debugConfiguration.stopOnEntry = false;
}
if (typeof debugConfiguration.showReturnValue !== 'boolean') {
debugConfiguration.showReturnValue = false;
}
if (!debugConfiguration.console) {
debugConfiguration.console = 'integratedTerminal';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide
if (debugConfiguration.stopOnEntry) {
this.debugOption(debugOptions, DebugOptions.StopOnEntry);
}
if (debugConfiguration.showReturnValue) {
this.debugOption(debugOptions, DebugOptions.ShowReturnValue);
}
if (debugConfiguration.django) {
this.debugOption(debugOptions, DebugOptions.Django);
}
Expand Down Expand Up @@ -136,7 +139,8 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide
isSudo: !!debugConfiguration.sudo,
jinja: !!debugConfiguration.jinja,
pyramid: !!debugConfiguration.pyramid,
stopOnEntry: !!debugConfiguration.stopOnEntry
stopOnEntry: !!debugConfiguration.stopOnEntry,
showReturnValue: !!debugConfiguration.showReturnValue
};
sendTelemetryEvent(DEBUGGER, undefined, telemetryProps);
}
Expand Down
6 changes: 5 additions & 1 deletion src/client/debugger/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export enum DebugOptions {
FixFilePathCase = 'FixFilePathCase',
WindowsClient = 'WindowsClient',
UnixClient = 'UnixClient',
StopOnEntry = 'StopOnEntry'
StopOnEntry = 'StopOnEntry',
ShowReturnValue = 'ShowReturnValue'
}

// tslint:disable-next-line:interface-name
Expand All @@ -30,6 +31,7 @@ interface AdditionalLaunchDebugOptions {
sudo?: boolean;
pyramid?: boolean;
stopOnEntry?: boolean;
showReturnValue?: boolean;
}

// tslint:disable-next-line:interface-name
Expand All @@ -50,6 +52,8 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
pythonPath: string;
// Automatically stop target after launch. If not specified, target does not stop.
stopOnEntry?: boolean;
/** Show return values of functions while stepping. */
showReturnValue?: boolean;
args: string[];
cwd?: string;
debugOptions?: DebugOptions[];
Expand Down
1 change: 1 addition & 0 deletions src/client/telemetry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type DebuggerTelemetryV2 = {
isModule: boolean;
isSudo: boolean;
stopOnEntry: boolean;
showReturnValue: boolean;
pyramid: boolean;
};
export type DebuggerPerformanceTelemetry = {
Expand Down
5 changes: 4 additions & 1 deletion src/test/debugger/configProvider/provider.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,9 @@ suite('Debugging - Config Provider', () => {

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

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

expect(debugConfig).to.have.property('console', 'integratedTerminal');
expect(debugConfig).to.have.property('stopOnEntry', false);
expect(debugConfig).to.have.property('showReturnValue', false);
expect(debugConfig).to.have.property('debugOptions');
expect((debugConfig as any).debugOptions).to.be.deep.equal([]);
});
Expand Down
3 changes: 2 additions & 1 deletion src/test/debugger/misc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ suite(`Standard Debugging - Misc tests: ${debuggerType}`, () => {
return new DebugClientEx(testAdapterFilePath, debuggerType, coverageDirectory, { cwd: EXTENSION_ROOT_DIR });
}
}
function buildLaunchArgs(pythonFile: string, stopOnEntry: boolean = false): LaunchRequestArguments {
function buildLaunchArgs(pythonFile: string, stopOnEntry: boolean = false, showReturnValue: boolean = false): LaunchRequestArguments {
const env = { PYTHONPATH: PTVSD_PATH };
// tslint:disable-next-line:no-unnecessary-local-variable
const options = {
program: path.join(debugFilesPath, pythonFile),
cwd: debugFilesPath,
stopOnEntry,
showReturnValue,
debugOptions: [DebugOptions.RedirectOutput],
pythonPath: PYTHON_PATH,
args: [],
Expand Down
5 changes: 3 additions & 2 deletions src/test/debugger/portAndHost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ suite(`Standard Debugging of ports and hosts: ${debuggerType}`, () => {
} catch (ex) { }
});

function buildLauncArgs(pythonFile: string, stopOnEntry: boolean = false, port?: number, host?: string): LaunchRequestArguments {
function buildLaunchArgs(pythonFile: string, stopOnEntry: boolean = false, port?: number, host?: string, showReturnValue: boolean = false): LaunchRequestArguments {
return {
program: path.join(debugFilesPath, pythonFile),
cwd: debugFilesPath,
stopOnEntry,
showReturnValue,
logToFile: true,
debugOptions: [DebugOptions.RedirectOutput],
pythonPath: PYTHON_PATH,
Expand All @@ -64,7 +65,7 @@ suite(`Standard Debugging of ports and hosts: ${debuggerType}`, () => {
async function testDebuggingWithProvidedPort(port?: number | undefined, host?: string | undefined) {
await Promise.all([
debugClient.configurationSequence(),
debugClient.launch(buildLauncArgs('startAndWait.py', false, port, host)),
debugClient.launch(buildLaunchArgs('startAndWait.py', false, port, host)),
debugClient.waitForEvent('initialized')
]);

Expand Down
11 changes: 6 additions & 5 deletions src/test/debugger/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ suite('Run without Debugging', () => {
} catch (ex) { }
await sleep(1000);
});
function buildLauncArgs(pythonFile: string, stopOnEntry: boolean = false): LaunchRequestArguments {
function buildLaunchArgs(pythonFile: string, stopOnEntry: boolean = false, showReturnValue: boolean = false): LaunchRequestArguments {
// tslint:disable-next-line:no-unnecessary-local-variable
return {
program: path.join(debugFilesPath, pythonFile),
cwd: debugFilesPath,
stopOnEntry,
showReturnValue,
noDebug: true,
debugOptions: [DebugOptions.RedirectOutput],
pythonPath: PYTHON_PATH,
Expand All @@ -62,15 +63,15 @@ suite('Run without Debugging', () => {
test('Should run program to the end', async () => {
await Promise.all([
debugClient.configurationSequence(),
debugClient.launch(buildLauncArgs('simplePrint.py', false)),
debugClient.launch(buildLaunchArgs('simplePrint.py', false)),
debugClient.waitForEvent('initialized'),
debugClient.waitForEvent('terminated')
]);
});
test('test stderr output for Python', async () => {
await Promise.all([
debugClient.configurationSequence(),
debugClient.launch(buildLauncArgs('stdErrOutput.py', false)),
debugClient.launch(buildLaunchArgs('stdErrOutput.py', false)),
debugClient.waitForEvent('initialized'),
debugClient.assertOutput('stderr', 'error output'),
debugClient.waitForEvent('terminated')
Expand All @@ -79,7 +80,7 @@ suite('Run without Debugging', () => {
test('Test stdout output', async () => {
await Promise.all([
debugClient.configurationSequence(),
debugClient.launch(buildLauncArgs('stdOutOutput.py', false)),
debugClient.launch(buildLaunchArgs('stdOutOutput.py', false)),
debugClient.waitForEvent('initialized'),
debugClient.assertOutput('stdout', 'normal output'),
debugClient.waitForEvent('terminated')
Expand All @@ -102,7 +103,7 @@ suite('Run without Debugging', () => {
});
await Promise.all([
debugClient.configurationSequence(),
debugClient.launch(buildLauncArgs('sampleWithSleep.py', false)),
debugClient.launch(buildLaunchArgs('sampleWithSleep.py', false)),
debugClient.waitForEvent('initialized'),
processIdOutput
]);
Expand Down