From 4086e29e26fb21524cfbae1fb19fc375dccc9316 Mon Sep 17 00:00:00 2001 From: Erwin Waterlander Date: Thu, 16 Jan 2025 09:27:35 +0000 Subject: [PATCH] Search debugger first in selected CBS toolchain. For Core Build System local debug target. If there is no absolute path set in the Debugger tab of the launch configuration, try to find the debugger first in the selected toolchain. If the debugger is not found in the toolchain, let GdbLaunch search in PATH. If an absolute path is set, GdbLaunch will use that. Fixes #1008 --- .../CoreBuildLocalDebugLaunchDelegate.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/CoreBuildLocalDebugLaunchDelegate.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/CoreBuildLocalDebugLaunchDelegate.java index 5674ba063f3..37ca5ab01b7 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/CoreBuildLocalDebugLaunchDelegate.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/CoreBuildLocalDebugLaunchDelegate.java @@ -10,18 +10,22 @@ *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.launching; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.concurrent.ExecutionException; import org.eclipse.cdt.core.build.ICBuildConfiguration; +import org.eclipse.cdt.core.build.IToolChain; import org.eclipse.cdt.debug.core.launch.CoreBuildLaunchConfigDelegate; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.concurrent.Query; import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; import org.eclipse.cdt.dsf.concurrent.Sequence; +import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.gdb.internal.Messages; import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; @@ -78,6 +82,18 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun envProps.putAll(buildEnv); gdbLaunch.setInitialEnvironment(envProps); + String debugger = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, + IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT); + Path debuggerPath = Paths.get(debugger); + // Try to find the debugger in the toolchain if the name is not absolute. + if (!debuggerPath.isAbsolute()) { + IToolChain toolChain = buildConfig.getToolChain(); + Path gdbPath = toolChain.getCommandPath(debuggerPath); + if (gdbPath != null) { + gdbLaunch.setGDBPath(gdbPath.toString()); + } + // When not found, GdbLaunch will search the debugger in PATH. + } String gdbVersion = gdbLaunch.getGDBVersion(); gdbLaunch.setProgramPath(getProgramPath(configuration, buildConfig));