Skip to content

Commit

Permalink
Search debugger first in selected CBS toolchain. (#1033)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ewaterlander authored Jan 16, 2025
1 parent 2efeaae commit c4f22cd
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit c4f22cd

Please sign in to comment.