Skip to content

Commit

Permalink
Fixes Bug #911: ROS2 C++ Debug failing (#913)
Browse files Browse the repository at this point in the history
* Fixes Bug #911: ROS2 C++ Debug failing

* Reorder environment selection for determinisim
  • Loading branch information
ooeygui authored Mar 30, 2023
1 parent 6871a50 commit 773e8a6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-ros",
"version": "0.9.1",
"version": "0.9.2",
"publisher": "ms-iot",
"engines": {
"vscode": "^1.69.0"
Expand Down
56 changes: 40 additions & 16 deletions src/debugger/configuration/resolvers/ros2/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class LaunchResolver implements vscode.DebugConfigurationProvider {
return pythonLaunchConfig;
}

private createCppLaunchConfig(request: ILaunchRequest, stopOnEntry: boolean): ICppvsdbgLaunchConfiguration {
private createCppLaunchConfig(request: ILaunchRequest, stopOnEntry: boolean): ICppvsdbgLaunchConfiguration | ICppdbgLaunchConfiguration {
const envConfigs: ICppEnvConfig[] = [];
for (const key in request.env) {
if (request.env.hasOwnProperty(key)) {
Expand All @@ -215,21 +215,45 @@ export class LaunchResolver implements vscode.DebugConfigurationProvider {
}
}

const cppvsdbgLaunchConfig: ICppvsdbgLaunchConfiguration = {
name: request.nodeName,
type: "cppvsdbg",
request: "launch",
cwd: ".",
program: request.executable,
args: request.arguments,
environment: envConfigs,
stopAtEntry: stopOnEntry,
symbolSearchPath: request.symbolSearchPath,
sourceFileMap: request.sourceFileMap

};

return cppvsdbgLaunchConfig;
if (os.platform() === "win32") {
const cppvsdbgLaunchConfig: ICppvsdbgLaunchConfiguration = {
name: request.nodeName,
type: "cppvsdbg",
request: "launch",
cwd: ".",
program: request.executable,
args: request.arguments,
environment: envConfigs,
stopAtEntry: stopOnEntry,
symbolSearchPath: request.symbolSearchPath,
sourceFileMap: request.sourceFileMap

};

return cppvsdbgLaunchConfig;
} else {
const cppdbgLaunchConfig: ICppdbgLaunchConfiguration = {
name: request.nodeName,
type: "cppdbg",
request: "launch",
cwd: ".",
program: request.executable,
args: request.arguments,
environment: envConfigs,
stopAtEntry: stopOnEntry,
additionalSOLibSearchPath: request.additionalSOLibSearchPath,
sourceFileMap: request.sourceFileMap,
setupCommands: [
{
text: "-enable-pretty-printing",
description: "Enable pretty-printing for gdb",
ignoreFailures: true
}
]
};

return cppdbgLaunchConfig;
}
}

private async executeLaunchRequest(request: ILaunchRequest, stopOnEntry: boolean) {
Expand Down
4 changes: 4 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ async function activateEnvironment(context: vscode.ExtensionContext) {
// http://www.ros.org/reps/rep-0149.html#environment-variables
// Learn more about ROS_VERSION definition.
selectROSApi(env.ROS_VERSION);

// Do this again, after the build tool has been determined.
await sourceRosAndWorkspace();

rosApi.setContext(context, env);

subscriptions.push(rosApi.activateCoreMonitor());
Expand Down

0 comments on commit 773e8a6

Please sign in to comment.