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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/client/debugger/extension/attachQuickPick/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class AttachProcessProvider implements IAttachProcessProvider {

public getAttachItems(): Promise<IAttachItem[]> {
return this._getInternalProcessEntries().then(processEntries => {
processEntries.sort(({ label: aLabel, detail: aDetail }, { label: bLabel, detail: bDetail }) => {
processEntries.sort(({ processName: aprocessName, commandLine: aCommandLine }, { processName: bProcessName, commandLine: bCommandLine }) => {
const compare = (aString: string, bString: string): number => {
// localeCompare is significantly slower than < and > (2000 ms vs 80 ms for 10,000 elements)
// We can change to localeCompare if this becomes an issue
Expand All @@ -34,8 +34,8 @@ export class AttachProcessProvider implements IAttachProcessProvider {
return aLower < bLower ? -1 : 1;
};

const aPython = aLabel.startsWith('python');
const bPython = bLabel.startsWith('python');
const aPython = aprocessName.startsWith('python');
const bPython = bProcessName.startsWith('python');

if (aPython || bPython) {
if (aPython && !bPython) {
Expand All @@ -45,10 +45,10 @@ export class AttachProcessProvider implements IAttachProcessProvider {
return 1;
}

return aPython ? compare(aDetail!, bDetail!) : compare(bDetail!, aDetail!);
return aPython ? compare(aCommandLine!, bCommandLine!) : compare(bCommandLine!, aCommandLine!);
}

return compare(aLabel, bLabel);
return compare(aprocessName, bProcessName);
});

return processEntries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ export namespace PsProcessParser {
label: executable,
description: pid,
detail: cmdline,
id: pid
id: pid,
processName: executable,
commandLine: cmdline
};
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/client/debugger/extension/attachQuickPick/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export type ProcessListCommand = { command: string; args: string[] };

export interface IAttachItem extends QuickPickItem {
id: string;
processName: string;
commandLine: string;
}

export interface IAttachProcessProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export namespace WmicProcessParser {
label: '',
description: '',
detail: '',
id: ''
id: '',
processName: '',
commandLine: ''
};

// Perf numbers on Win10:
Expand Down Expand Up @@ -60,6 +62,7 @@ export namespace WmicProcessParser {

if (key === wmicNameTitle) {
currentItem.label = value;
currentItem.processName = value;
} else if (key === wmicPidTitle) {
currentItem.description = value;
currentItem.id = value;
Expand All @@ -70,6 +73,7 @@ export namespace WmicProcessParser {
}

currentItem.detail = value;
currentItem.commandLine = value;
}
}

Expand Down
105 changes: 79 additions & 26 deletions src/test/debugger/extension/attachQuickPick/provider.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,25 @@ suite('Attach to process - process provider', () => {
label: 'launchd',
description: '1',
detail: 'launchd',
id: '1'
id: '1',
processName: 'launchd',
commandLine: 'launchd'
},
{
label: 'syslogd',
description: '41',
detail: 'syslogd',
id: '41'
id: '41',
processName: 'syslogd',
commandLine: 'syslogd'
},
{
label: 'kextd',
description: '146',
detail: 'kextd',
id: '146'
id: '146',
processName: 'kextd',
commandLine: 'kextd'
}
];
when(processService.exec(PsProcessParser.psLinuxCommand.command, anything(), anything())).thenResolve({ stdout: psOutput });
Expand All @@ -82,19 +88,25 @@ suite('Attach to process - process provider', () => {
label: 'launchd',
description: '1',
detail: 'launchd',
id: '1'
id: '1',
processName: 'launchd',
commandLine: 'launchd'
},
{
label: 'syslogd',
description: '41',
detail: 'syslogd',
id: '41'
id: '41',
processName: 'syslogd',
commandLine: 'syslogd'
},
{
label: 'kextd',
description: '146',
detail: 'kextd',
id: '146'
id: '146',
processName: 'kextd',
commandLine: 'kextd'
}
];
when(processService.exec(PsProcessParser.psDarwinCommand.command, anything(), anything())).thenResolve({ stdout: psOutput });
Expand Down Expand Up @@ -125,19 +137,25 @@ ProcessId=5912\r
label: 'System',
description: '4',
detail: '',
id: '4'
id: '4',
processName: 'System',
commandLine: ''
},
{
label: 'sihost.exe',
description: '5728',
detail: 'sihost.exe',
id: '5728'
id: '5728',
processName: 'sihost.exe',
commandLine: 'sihost.exe'
},
{
label: 'svchost.exe',
description: '5912',
detail: 'C:\\WINDOWS\\system32\\svchost.exe -k UnistackSvcGroup -s CDPUserSvc',
id: '5912'
id: '5912',
processName: 'svchost.exe',
commandLine: 'C:\\WINDOWS\\system32\\svchost.exe -k UnistackSvcGroup -s CDPUserSvc'
}
];
when(platformService.isMac).thenReturn(false);
Expand All @@ -162,6 +180,7 @@ ProcessId=5912\r
await expect(promise).to.eventually.be.rejectedWith(`Operating system '${OSType.Unknown}' not supported.`);
});

// tslint:disable-next-line: max-func-body-length
suite('POSIX getAttachItems (Linux)', () => {
setup(() => {
when(platformService.isMac).thenReturn(false);
Expand All @@ -179,19 +198,25 @@ ProcessId=5912\r
label: 'kextd',
description: '146',
detail: 'kextd',
id: '146'
id: '146',
processName: 'kextd',
commandLine: 'kextd'
},
{
label: 'launchd',
description: '1',
detail: 'launchd',
id: '1'
id: '1',
processName: 'launchd',
commandLine: 'launchd'
},
{
label: 'syslogd',
description: '41',
detail: 'syslogd',
id: '41'
id: '41',
processName: 'syslogd',
commandLine: 'syslogd'
}
];
when(processService.exec(PsProcessParser.psLinuxCommand.command, anything(), anything())).thenResolve({ stdout: psOutput });
Expand All @@ -214,31 +239,41 @@ ProcessId=5912\r
label: 'python',
description: '96',
detail: 'python',
id: '96'
id: '96',
processName: 'python',
commandLine: 'python'
},
{
label: 'python',
description: '31896',
detail: 'python script.py',
id: '31896'
id: '31896',
processName: 'python',
commandLine: 'python script.py'
},
{
label: 'kextd',
description: '146',
detail: 'kextd',
id: '146'
id: '146',
processName: 'kextd',
commandLine: 'kextd'
},
{
label: 'launchd',
description: '1',
detail: 'launchd',
id: '1'
id: '1',
processName: 'launchd',
commandLine: 'launchd'
},
{
label: 'syslogd',
description: '41',
detail: 'syslogd',
id: '41'
id: '41',
processName: 'syslogd',
commandLine: 'syslogd'
}
];
when(processService.exec(PsProcessParser.psLinuxCommand.command, anything(), anything())).thenResolve({ stdout: psOutput });
Expand Down Expand Up @@ -277,19 +312,25 @@ ProcessId=5728\r
label: 'sihost.exe',
description: '5728',
detail: 'sihost.exe',
id: '5728'
id: '5728',
processName: 'sihost.exe',
commandLine: 'sihost.exe'
},
{
label: 'svchost.exe',
description: '5372',
detail: '',
id: '5372'
id: '5372',
processName: 'svchost.exe',
commandLine: ''
},
{
label: 'System',
description: '4',
detail: '',
id: '4'
id: '4',
processName: 'System',
commandLine: ''
}
];
when(processService.exec(WmicProcessParser.wmicCommand.command, anything(), anything())).thenResolve({ stdout: windowsOutput });
Expand Down Expand Up @@ -334,37 +375,49 @@ ProcessId=8026\r
label: 'python.exe',
description: '8026',
detail: 'C:\\Users\\Contoso\\AppData\\Local\\Programs\\Python\\Python37\\python.exe c:/Users/Contoso/Documents/foo_bar.py',
id: '8026'
id: '8026',
processName: 'python.exe',
commandLine: 'C:\\Users\\Contoso\\AppData\\Local\\Programs\\Python\\Python37\\python.exe c:/Users/Contoso/Documents/foo_bar.py'
},
{
label: 'python.exe',
description: '6028',
detail: 'C:\\Users\\Contoso\\AppData\\Local\\Programs\\Python\\Python37\\python.exe c:/Users/Contoso/Documents/hello_world.py',
id: '6028'
id: '6028',
processName: 'python.exe',
commandLine: 'C:\\Users\\Contoso\\AppData\\Local\\Programs\\Python\\Python37\\python.exe c:/Users/Contoso/Documents/hello_world.py'
},
{
label: 'sihost.exe',
description: '5728',
detail: 'sihost.exe',
id: '5728'
id: '5728',
processName: 'sihost.exe',
commandLine: 'sihost.exe'
},
{
label: 'svchost.exe',
description: '5372',
detail: '',
id: '5372'
id: '5372',
processName: 'svchost.exe',
commandLine: ''
},
{
label: 'svchost.exe',
description: '5912',
detail: 'C:\\WINDOWS\\system32\\svchost.exe -k UnistackSvcGroup -s CDPUserSvc',
id: '5912'
id: '5912',
processName: 'svchost.exe',
commandLine: 'C:\\WINDOWS\\system32\\svchost.exe -k UnistackSvcGroup -s CDPUserSvc'
},
{
label: 'System',
description: '4',
detail: '',
id: '4'
id: '4',
processName: 'System',
commandLine: ''
}
];
when(processService.exec(WmicProcessParser.wmicCommand.command, anything(), anything())).thenResolve({ stdout: windowsOutput });
Expand Down
Loading