# HG changeset patch # User Gordon Prieur # Date 1207242015 25200 # Node ID b89dc7d05d97d91387c3616fd05c3912b35a945f # Parent 15f5fd8e03ea37703ee6a33e7c64942c5322d679 Fixed 131802 Gdb could not be started diff -r 15f5fd8e03ea -r b89dc7d05d97 cnd.debugger.gdb/src/org/netbeans/modules/cnd/debugger/gdb/GdbDebugger.java --- a/cnd.debugger.gdb/src/org/netbeans/modules/cnd/debugger/gdb/GdbDebugger.java Thu Apr 03 15:42:58 2008 +0400 +++ b/cnd.debugger.gdb/src/org/netbeans/modules/cnd/debugger/gdb/GdbDebugger.java Thu Apr 03 10:00:15 2008 -0700 @@ -65,6 +65,9 @@ import org.netbeans.api.debugger.Session import org.netbeans.api.debugger.Session; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectInformation; +import org.netbeans.modules.cnd.api.compilers.CompilerSet.CompilerFlavor; +import org.netbeans.modules.cnd.api.compilers.CompilerSetManager; +import org.netbeans.modules.cnd.api.utils.CppUtils; import org.netbeans.modules.cnd.debugger.gdb.actions.GdbActionHandler; import org.netbeans.modules.cnd.debugger.gdb.breakpoints.AddressBreakpoint; import org.netbeans.modules.cnd.debugger.gdb.breakpoints.BreakpointImpl; @@ -80,6 +83,7 @@ import org.netbeans.modules.cnd.debugger import org.netbeans.modules.cnd.debugger.gdb.utils.GdbUtils; import org.netbeans.modules.cnd.makeproject.api.MakeArtifact; import org.netbeans.modules.cnd.makeproject.api.ProjectActionEvent; +import org.netbeans.modules.cnd.makeproject.api.configurations.CompilerSet2Configuration; import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationDescriptorProvider; import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration; import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfigurationDescriptor; @@ -254,8 +258,9 @@ public class GdbDebugger implements Prop } else if (gdbCommand.toLowerCase().contains("mingw")) { // NOI18N mingw = true; } + String cspath = getCompilerSetPath(pae); gdb = new GdbProxy(this, gdbCommand, pae.getProfile().getEnvironment().getenv(), - runDirectory, termpath); + runDirectory, termpath, cspath); gdb.gdb_version(); gdb.environment_directory(runDirectory); gdb.gdb_show("language"); // NOI18N @@ -385,6 +390,21 @@ public class GdbDebugger implements Prop setExited(); finish(false); } + } + + private String getCompilerSetPath(ProjectActionEvent pae) { + CompilerSet2Configuration cs = ((MakeConfiguration) pae.getConfiguration()).getCompilerSet(); + String csname = cs.getOption(); + String csdirs = CompilerSetManager.getDefault().getCompilerSet(csname).getDirectory(); + + if (cs.getFlavor().equals(CompilerFlavor.MinGW.toString())) { + String msysBase = CppUtils.getMSysBase(); + if (msysBase != null && msysBase.length() > 0) { + csdirs += File.pathSeparator + msysBase + File.separator + "bin"; // NOI18N; + } + } + + return csdirs; } private String getGdbHelper() { diff -r 15f5fd8e03ea -r b89dc7d05d97 cnd.debugger.gdb/src/org/netbeans/modules/cnd/debugger/gdb/proxy/GdbProxy.java --- a/cnd.debugger.gdb/src/org/netbeans/modules/cnd/debugger/gdb/proxy/GdbProxy.java Thu Apr 03 15:42:58 2008 +0400 +++ b/cnd.debugger.gdb/src/org/netbeans/modules/cnd/debugger/gdb/proxy/GdbProxy.java Thu Apr 03 10:00:15 2008 -0700 @@ -94,7 +94,8 @@ public class GdbProxy implements GdbMiDe * @param workingDirectory The directory to start the debugger from * @throws IOException Pass this on to the caller */ - public GdbProxy(GdbDebugger debugger, String debuggerCommand, String[] debuggerEnvironment, String workingDirectory, String termpath) throws IOException { + public GdbProxy(GdbDebugger debugger, String debuggerCommand, String[] debuggerEnvironment, + String workingDirectory, String termpath, String cspath) throws IOException { this.debugger = debugger; log.setLevel(Level.FINE); @@ -105,7 +106,7 @@ public class GdbProxy implements GdbMiDe dc.add("--silent"); // NOI18N dc.add("--interpreter=mi"); // NOI18N gdbLogger = new GdbLogger(debugger, this); - engine = new GdbProxyEngine(debugger, this, dc, debuggerEnvironment, workingDirectory, termpath); + engine = new GdbProxyEngine(debugger, this, dc, debuggerEnvironment, workingDirectory, termpath, cspath); } protected GdbProxyEngine getProxyEngine() { diff -r 15f5fd8e03ea -r b89dc7d05d97 cnd.debugger.gdb/src/org/netbeans/modules/cnd/debugger/gdb/proxy/GdbProxyEngine.java --- a/cnd.debugger.gdb/src/org/netbeans/modules/cnd/debugger/gdb/proxy/GdbProxyEngine.java Thu Apr 03 15:42:58 2008 +0400 +++ b/cnd.debugger.gdb/src/org/netbeans/modules/cnd/debugger/gdb/proxy/GdbProxyEngine.java Thu Apr 03 10:00:15 2008 -0700 @@ -92,7 +92,8 @@ public class GdbProxyEngine { * @param stepIntoProject - a flag to stop at first source line */ public GdbProxyEngine(GdbDebugger debugger, GdbProxy gdbProxy, List debuggerCommand, - String[] debuggerEnvironment, String workingDirectory, String termpath) throws IOException { + String[] debuggerEnvironment, String workingDirectory, String termpath, + String cspath) throws IOException { if (Utilities.isUnix() && termpath != null) { ExternalTerminal eterm = new ExternalTerminal(debugger, termpath, debuggerEnvironment); @@ -117,16 +118,23 @@ public class GdbProxyEngine { Map env = pb.environment(); Process proc = null; + String pathname = Path.getPathName(); for (String var : debuggerEnvironment) { String key, value; int idx = var.indexOf('='); if (idx != -1) { key = var.substring(0, idx); value = var.substring(idx + 1); - env.put(key, value); + if (key.equals(pathname)) { + env.put(key, value + File.pathSeparator + cspath); + } else { + env.put(key, value); + } } } - env.put("PATH", Path.getPathAsString()); // NOI18N + if (!env.containsKey(pathname)) { + env.put(pathname, Path.getPathAsString() + File.pathSeparator + cspath); // NOI18N + } pb.directory(new File(workingDirectory)); pb.redirectErrorStream(true);