Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to enable robot code debugging for 2022 #487

Merged
merged 3 commits into from
Nov 25, 2021
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
64 changes: 43 additions & 21 deletions vscode-wpilib/src/cpp/deploydebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { IUnixSimulateCommands, startUnixSimulation } from './simulateunix';
import { IWindowsSimulateCommands, startWindowsSimulation } from './simulatewindows';

interface ICppDebugInfo {
debugfile: string;
artifact: string;
name: string;
path: string;
}

interface ICppSimExtensions {
Expand All @@ -26,26 +26,24 @@ interface ICppSimulateInfo {
extensions: ICppSimExtensions[];
launchfile: string;
clang: boolean;
env?: Map<string, string>;
environment?: Map<string, string>;
srcpaths: string[];
headerpaths: string[];
libpaths: string[];
libsrcpaths: string[];
}

interface ICppDebugCommand {
name?: string;
extensions: string;
clang?: boolean;
launchfile: string;
type: string;
name: string;
port: number;
target: string;
launchfile: string;
gdb: string;
env?: Map<string, string>;
sysroot: string | null;
sysroot: string | undefined;
srcpaths: string[];
headerpaths: string[];
libpaths: string[];
debugpaths: string[];
libsrcpaths: string[];
}

Expand Down Expand Up @@ -91,10 +89,10 @@ class DebugCodeDeployer implements ICodeDeployer {
return false;
}

const debugInfo = await readFileAsync(path.join(workspace.uri.fsPath, 'build', 'debug', 'debuginfo.json'), 'utf8');
const debugInfo = await readFileAsync(path.join(workspace.uri.fsPath, 'build', 'debug', 'debug_info.json'), 'utf8');
const parsedDebugInfo: ICppDebugInfo[] = jsonc.parse(debugInfo) as ICppDebugInfo[];
if (parsedDebugInfo.length === 0) {
await vscode.window.showInformationMessage('No debug configurations found. Is this a robot project?', {
await vscode.window.showInformationMessage('No target configurations found. Is this a robot project?', {
modal: true,
});
return false;
Expand All @@ -103,22 +101,46 @@ class DebugCodeDeployer implements ICodeDeployer {
if (parsedDebugInfo.length > 1) {
const arr: CppQuickPick<ICppDebugInfo>[] = [];
for (const i of parsedDebugInfo) {
arr.push(new CppQuickPick<ICppDebugInfo>(i, i.artifact));
arr.push(new CppQuickPick<ICppDebugInfo>(i, i.name));
}
const picked = await vscode.window.showQuickPick(arr, {
placeHolder: 'Select an artifact',
placeHolder: 'Select a target',
});
if (picked === undefined) {
vscode.window.showInformationMessage('Artifact cancelled');
vscode.window.showInformationMessage('Target cancelled');
return false;
}
targetDebugInfo = picked.debugInfo;
}

const debugPath = path.join(workspace.uri.fsPath, 'build', 'debug', targetDebugInfo.debugfile);
const debugPath = targetDebugInfo.path;

const targetReadInfo = await readFileAsync(debugPath, 'utf8');
const targetInfoParsed: ICppDebugCommand = jsonc.parse(targetReadInfo) as ICppDebugCommand;
const targetInfoArray: ICppDebugCommand[] = jsonc.parse(targetReadInfo) as ICppDebugCommand[];

if (targetInfoArray.length === 0) {
await vscode.window.showInformationMessage('No debug configurations found. Is this a robot project?', {
modal: true,
});
return false;
}

// TODO Filter this off of type
let targetInfoParsed = targetInfoArray[0];
if (targetInfoArray.length > 1) {
const arr: CppQuickPick<ICppDebugCommand>[] = [];
for (const i of targetInfoArray) {
arr.push(new CppQuickPick<ICppDebugCommand>(i, i.name));
}
const picked = await vscode.window.showQuickPick(arr, {
placeHolder: 'Select an artifact',
});
if (picked === undefined) {
vscode.window.showInformationMessage('Artifact cancelled');
return false;
}
targetInfoParsed = picked.debugInfo;
}

const set = new Set<string>(targetInfoParsed.libpaths);

Expand All @@ -132,7 +154,7 @@ class DebugCodeDeployer implements ICodeDeployer {

let sysroot = '';

if (targetInfoParsed.sysroot !== null) {
if (targetInfoParsed.sysroot !== undefined) {
sysroot = targetInfoParsed.sysroot;
}

Expand All @@ -147,7 +169,7 @@ class DebugCodeDeployer implements ICodeDeployer {
soLibPath: soPath,
srcPaths: new Set<string>(srcArrs),
sysroot,
target: targetInfoParsed.target,
target: targetInfoParsed.target + ':' + targetInfoParsed.port.toString(10),
workspace,
};

Expand Down Expand Up @@ -291,7 +313,7 @@ class SimulateCodeDeployer implements ICodeDeployer {

const config: IUnixSimulateCommands = {
clang: targetSimulateInfo.clang,
environment: targetSimulateInfo.env,
environment: targetSimulateInfo.environment,
executablePath: targetSimulateInfo.launchfile,
extensions,
ldPath: path.dirname(targetSimulateInfo.launchfile), // gradle puts all the libs in the same dir as the executable
Expand All @@ -305,7 +327,7 @@ class SimulateCodeDeployer implements ICodeDeployer {
} else {
const config: IWindowsSimulateCommands = {
debugPaths: targetSimulateInfo.libpaths,
environment: targetSimulateInfo.env,
environment: targetSimulateInfo.environment,
extensions,
launchfile: targetSimulateInfo.launchfile,
srcPaths: targetSimulateInfo.srcpaths,
Expand Down
58 changes: 42 additions & 16 deletions vscode-wpilib/src/java/deploydebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ import { IDebugCommands, startDebugging } from './debug';
import { ISimulateCommands, startSimulation } from './simulate';

interface IJavaDebugInfo {
debugfile: string;
project: string;
artifact: string;
name: string;
path: string;
}

interface ITargetInfo {
ipAddress: string;
port: string;
type: string;
name: string;
port: number;
target: string;
project: string;
}

interface IJavaSimExtensions {
Expand All @@ -29,7 +31,7 @@ interface IJavaSimulateInfo {
name: string;
type: string;
extensions: IJavaSimExtensions[];
env?: Map<string, string>;
environment?: Map<string, string>;
libraryDir: string;
mainClassName: string;
}
Expand Down Expand Up @@ -79,7 +81,7 @@ class DebugCodeDeployer implements ICodeDeployer {
return false;
}

const debugInfo = await readFileAsync(path.join(workspace.uri.fsPath, 'build', 'debug', 'debuginfo.json'), 'utf8');
const debugInfo = await readFileAsync(path.join(workspace.uri.fsPath, 'build', 'debug', 'debug_info.json'), 'utf8');
const parsedDebugInfo: IJavaDebugInfo[] = jsonc.parse(debugInfo) as IJavaDebugInfo[];
if (parsedDebugInfo.length === 0) {
await vscode.window.showInformationMessage('No debug configurations found. Is this a robot project?', {
Expand All @@ -91,27 +93,51 @@ class DebugCodeDeployer implements ICodeDeployer {
if (parsedDebugInfo.length > 1) {
const arr: JavaQuickPick<IJavaDebugInfo>[] = [];
for (const i of parsedDebugInfo) {
arr.push(new JavaQuickPick<IJavaDebugInfo>(i, i.artifact));
arr.push(new JavaQuickPick<IJavaDebugInfo>(i, i.name));
}
const picked = await vscode.window.showQuickPick(arr, {
placeHolder: 'Select an artifact',
placeHolder: 'Select a target',
});
if (picked === undefined) {
vscode.window.showInformationMessage('Artifact cancelled');
vscode.window.showInformationMessage('Target cancelled');
return false;
}
targetDebugInfo = picked.debugInfo;
}

const debugPath = path.join(workspace.uri.fsPath, 'build', 'debug', targetDebugInfo.debugfile);
const debugPath = targetDebugInfo.path;

const targetReadInfo = await readFileAsync(debugPath, 'utf8');
const targetInfoParsed = jsonc.parse(targetReadInfo) as ITargetInfo;
const targetInfoArray = jsonc.parse(targetReadInfo) as ITargetInfo[];

if (targetInfoArray.length === 0) {
await vscode.window.showInformationMessage('No debug configurations found. Is this a robot project?', {
modal: true,
});
return false;
}

// TODO Filter this off of type
let targetInfoParsed = targetInfoArray[0];
if (targetInfoArray.length > 1) {
const arr: JavaQuickPick<ITargetInfo>[] = [];
for (const i of targetInfoArray) {
arr.push(new JavaQuickPick<ITargetInfo>(i, i.name));
}
const picked = await vscode.window.showQuickPick(arr, {
placeHolder: 'Select an artifact',
});
if (picked === undefined) {
vscode.window.showInformationMessage('Artifact cancelled');
return false;
}
targetInfoParsed = picked.debugInfo;
}

const config: IDebugCommands = {
project: targetDebugInfo.project,
serverAddress: targetInfoParsed.ipAddress,
serverPort: targetInfoParsed.port,
project: targetInfoParsed.project,
serverAddress: targetInfoParsed.target,
serverPort: targetInfoParsed.port.toString(10),
workspace,
};

Expand Down Expand Up @@ -246,7 +272,7 @@ class SimulateCodeDeployer implements ICodeDeployer {
}

const config: ISimulateCommands = {
environment: targetSimulateInfo.env,
environment: targetSimulateInfo.environment,
extensions,
librarydir: targetSimulateInfo.libraryDir,
mainclass: targetSimulateInfo.mainClassName,
Expand Down