Skip to content

Commit 54bfc00

Browse files
committed
Latest update from @fearthecowboy. Still need to review lint issues.
1 parent b603db6 commit 54bfc00

File tree

17 files changed

+1374
-397
lines changed

17 files changed

+1374
-397
lines changed

Extension/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6510,9 +6510,6 @@
65106510
"attach": {
65116511
"type": "object",
65126512
"default": {},
6513-
"required": [
6514-
"program"
6515-
],
65166513
"properties": {
65176514
"program": {
65186515
"type": "string",
@@ -8040,7 +8037,7 @@
80408037
"xml2js": "^0.6.2"
80418038
},
80428039
"dependencies": {
8043-
"@github/copilot-language-server": "^1.266.0",
8040+
"@github/copilot-language-server": "^1.316.0",
80448041
"@vscode/extension-telemetry": "^0.9.6",
80458042
"chokidar": "^3.6.0",
80468043
"comment-json": "^4.2.3",

Extension/package.nls.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,10 @@
951951
"c_cpp.debuggers.vsCodeCommand.description": "VS Code command to be invoked. Can be a command in VS Code or an active extension.",
952952
"c_cpp.debuggers.vsCodeCommand.command.description": "VS Code command to be invoked.",
953953
"c_cpp.debuggers.vsCodeCommand.args.description": "Arguments to the VS Code command.",
954+
"c_cpp.debuggers.cpplldb.type.description": "The type of the engine. Must be \"cpplldb\".",
955+
"c_cpp.debuggers.debuggerPath.description": "Full path to the LLDB-DAP debugger executable. If not specified, the extension will search for the debugger in the system PATH.",
956+
"c_cpp.debuggers.debuggerArgs.description": "Additional arguments for the LLDB-DAP debugger.",
957+
"c_cpp.debuggers.cpplldb.externalConsole.description": "If true, launch the external console for the debugger.",
954958
"c_cpp.debuggers.cpplldb.debuggerPath.description": "Full path to the LLDB-DAP debugger executable. If not specified, the extension will search for the debugger in the system PATH.",
955959
"c_cpp.debuggers.cpplldb.debuggerArgs.description": "Additional arguments for the LLDB-DAP debugger.",
956960
"c_cpp.debuggers.cpplldb.disableAslr.description": "Disable Address Space Layout Randomization (if supported).",

Extension/src/Debugger/attachToProcess.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as path from 'path';
1212
import * as vscode from 'vscode';
1313
import * as nls from 'vscode-nls';
1414
import * as util from '../common';
15+
import { executableName, ProcessReturnType, spawnChildProcess } from '../common-remote-safe';
1516
import * as debugUtils from './utils';
1617

1718
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
@@ -21,12 +22,26 @@ export interface AttachItemsProvider {
2122
getAttachItems(token?: vscode.CancellationToken): Promise<AttachItem[]>;
2223
}
2324

25+
/**
26+
* Determines if a process matches the specified filter criteria.
27+
*
28+
* This function checks if the given process name or its full path matches
29+
* the provided filter string. It also normalizes the filter string to handle
30+
* relative paths and compares the executable name derived from the filter
31+
* with the executable name of the process.
32+
*
33+
* @param filterTo - The filter string to match against. This can be a process name,
34+
* an executable name, or a file path.
35+
* @param processName - The name of the process to check.
36+
* @param fullPath - The full path of the process executable, if available.
37+
* @returns `true` if the process matches the filter criteria; otherwise, `false`.
38+
*/
2439
export function processMatches(filterTo: string, processName: string, fullPath: string | undefined) {
2540
const normalized = path.resolve(filterTo);
26-
const executable = util.executableName(filterTo);
41+
const executable = executableName(filterTo);
2742

2843
// Filter out the processes that do not somehow match.
29-
return processName === filterTo || util.executableName(processName) === executable || fullPath === filterTo || fullPath === normalized;
44+
return processName === filterTo || executableName(processName) === executable || fullPath === filterTo || fullPath === normalized;
3045
}
3146

3247
export class AttachPicker {
@@ -209,10 +224,10 @@ export class RemoteAttachPicker {
209224

210225
private async getRemoteProcessesExtendedRemote(miDebuggerPath: string, miDebuggerServerAddress: string): Promise<AttachItem[]> {
211226
const args: string[] = [`-ex "target extended-remote ${miDebuggerServerAddress}"`, '-ex "info os processes"', '-batch'];
212-
let processListOutput: util.ProcessReturnType = await util.spawnChildProcess(miDebuggerPath, args);
227+
let processListOutput: ProcessReturnType = await spawnChildProcess(miDebuggerPath, args);
213228
// The device may not be responsive for a while during the restart after image deploy. Retry 5 times.
214229
for (let i: number = 0; i < 5 && !processListOutput.succeeded && processListOutput.outputError.length === 0; i++) {
215-
processListOutput = await util.spawnChildProcess(miDebuggerPath, args);
230+
processListOutput = await spawnChildProcess(miDebuggerPath, args);
216231
}
217232

218233
if (!processListOutput.succeeded) {

Extension/src/Debugger/configurationProvider.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { promisify } from 'util';
1212
import * as vscode from 'vscode';
1313
import * as nls from 'vscode-nls';
1414
import * as util from '../common';
15+
import { executableName, ProcessReturnType, spawnChildProcess } from '../common-remote-safe';
1516
import { isWindows } from '../constants';
1617
import { expandAllStrings, ExpansionOptions, ExpansionVars } from '../expand';
1718
import { CppBuildTask, CppBuildTaskDefinition, cppBuildTaskProvider } from '../LanguageServer/cppBuildTaskProvider';
@@ -527,25 +528,27 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
527528
newConfig.type = DebuggerType.cppvsdbg;
528529
return newConfig;
529530
} else {
530-
debuggerName = util.executableName("gdb");
531+
debuggerName = executableName("gdb");
531532
}
532533
const compilerDirname: string = path.dirname(compilerPath);
533534
const debuggerPath: string = path.join(compilerDirname, debuggerName);
534535

535-
// Check if debuggerPath exists.
536-
if (await util.checkFileExists(debuggerPath)) {
537-
newConfig.miDebuggerPath = debuggerPath;
538-
} else if (await util.whichAsync(debuggerName) !== undefined) {
539-
// Check if debuggerName exists on $PATH
540-
newConfig.miDebuggerPath = debuggerName;
541-
} else {
542-
// Try the usr path for non-Windows platforms.
543-
const usrDebuggerPath: string = path.join("/usr", "bin", debuggerName);
544-
if (!isWindows && await util.checkFileExists(usrDebuggerPath)) {
545-
newConfig.miDebuggerPath = usrDebuggerPath;
536+
if (newConfig.type === DebuggerType.cppdbg) {
537+
// Check if debuggerPath exists.
538+
if (await util.checkFileExists(debuggerPath)) {
539+
newConfig.miDebuggerPath = debuggerPath;
540+
} else if (await util.whichAsync(debuggerName) !== undefined) {
541+
// Check if debuggerName exists on $PATH
542+
newConfig.miDebuggerPath = debuggerName;
546543
} else {
547-
logger.getOutputChannelLogger().appendLine(localize('debugger.path.not.exists', "Unable to find the {0} debugger. The debug configuration for {1} is ignored.", `\"${debuggerName}\"`, compilerName));
548-
return undefined;
544+
// Try the usr path for non-Windows platforms.
545+
const usrDebuggerPath: string = path.join("/usr", "bin", debuggerName);
546+
if (!isWindows && await util.checkFileExists(usrDebuggerPath)) {
547+
newConfig.miDebuggerPath = usrDebuggerPath;
548+
} else {
549+
logger.getOutputChannelLogger().appendLine(localize('debugger.path.not.exists', "Unable to find the {0} debugger. The debug configuration for {1} is ignored.", `\"${debuggerName}\"`, compilerName));
550+
return undefined;
551+
}
549552
}
550553
}
551554
}
@@ -1126,7 +1129,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
11261129
return false;
11271130
}
11281131

1129-
let scpResult: util.ProcessReturnType;
1132+
let scpResult: ProcessReturnType;
11301133
if (isScp) {
11311134
scpResult = await scp(files, host, step.targetDir, config.scpPath, config.recursive, jumpHosts, cancellationToken);
11321135
} else {
@@ -1147,7 +1150,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
11471150
const jumpHosts: util.ISshHostInfo[] = step.host.jumpHosts;
11481151
const localForwards: util.ISshLocalForwardInfo[] = step.host.localForwards;
11491152
const continueOn: string = step.continueOn;
1150-
const sshResult: util.ProcessReturnType = await ssh(host, step.command, config.sshPath, jumpHosts, localForwards, continueOn, cancellationToken);
1153+
const sshResult: ProcessReturnType = await ssh(host, step.command, config.sshPath, jumpHosts, localForwards, continueOn, cancellationToken);
11511154
if (!sshResult.succeeded || cancellationToken?.isCancellationRequested) {
11521155
return false;
11531156
}
@@ -1158,7 +1161,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
11581161
void logger.getOutputChannelLogger().showErrorMessage(localize('missing.properties.shell', '"command" is required for shell steps.'));
11591162
return false;
11601163
}
1161-
const taskResult: util.ProcessReturnType = await util.spawnChildProcess(step.command, undefined, step.continueOn);
1164+
const taskResult: ProcessReturnType = await spawnChildProcess(step.command, undefined, step.continueOn);
11621165
if (!taskResult.succeeded || cancellationToken?.isCancellationRequested) {
11631166
void logger.getOutputChannelLogger().showErrorMessage(taskResult.output);
11641167
return false;

Extension/src/Debugger/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { SshTargetsProvider, getActiveSshTarget, initializeSshTargets, selectSsh
1414
import { TargetLeafNode, setActiveSshTarget } from '../SSH/TargetsView/targetNodes';
1515
import { sshCommandToConfig } from '../SSH/sshCommandToConfig';
1616
import { getSshConfiguration, getSshConfigurationFiles, parseFailures, writeSshConfiguration } from '../SSH/sshHosts';
17-
import { pathAccessible } from '../common';
17+
import { pathAccessible } from '../common-remote-safe';
1818
import { instrument } from '../instrumentation';
1919
import { getSshChannel } from '../logger';
2020
import { AttachItemsProvider, AttachPicker, RemoteAttachPicker } from './attachToProcess';

0 commit comments

Comments
 (0)