diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/FinalLaunchSequence.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/FinalLaunchSequence.java index 609311e9e34..cd770d3c529 100644 --- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/FinalLaunchSequence.java +++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/FinalLaunchSequence.java @@ -10,9 +10,13 @@ *******************************************************************************/ package org.eclipse.dd.gdb.internal.provisional.launching; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector; import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants; +import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -34,6 +38,8 @@ import org.eclipse.dd.mi.service.command.commands.MIExecContinue; import org.eclipse.dd.mi.service.command.commands.MIExecRun; import org.eclipse.dd.mi.service.command.commands.MIFileExecFile; import org.eclipse.dd.mi.service.command.commands.MIFileSymbolFile; +import org.eclipse.dd.mi.service.command.commands.MIGDBSetAutoSolib; +import org.eclipse.dd.mi.service.command.commands.MIGDBSetSolibSearchPath; import org.eclipse.dd.mi.service.command.commands.MITargetSelect; import org.eclipse.dd.mi.service.command.output.MIBreakInsertInfo; import org.eclipse.dd.mi.service.command.output.MIInfo; @@ -71,8 +77,46 @@ public class FinalLaunchSequence extends Sequence { fCommandControl.queueCommand( new MIFileSymbolFile(fCommandControl.getControlDMContext(), fCommandControl.getExecutablePath().toOSString()), - new DataRequestMonitor(getExecutor(), requestMonitor)); + new DataRequestMonitor(getExecutor(), requestMonitor)); }}, + /* + * Tell GDB to automatically load or not the shared library symbols + */ + new Step() { @Override + public void execute(RequestMonitor requestMonitor) { + try { + boolean autolib = fLaunch.getLaunchConfiguration().getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, + IMILaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT); + fCommandControl.queueCommand( + new MIGDBSetAutoSolib(fCommandControl.getControlDMContext(), autolib), + new DataRequestMonitor(getExecutor(), requestMonitor)); + } catch (CoreException e) { + requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Cannot set shared library option", e)); //$NON-NLS-1$ + requestMonitor.done(); + } + }}, + /* + * Set the shared library paths + */ + new Step() { @Override + public void execute(RequestMonitor requestMonitor) { + try { + @SuppressWarnings("unchecked") + List p = fLaunch.getLaunchConfiguration().getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, + new ArrayList(1)); + if (p.size() > 0) { + String[] paths = p.toArray(new String[p.size()]); + fCommandControl.queueCommand( + new MIGDBSetSolibSearchPath(fCommandControl.getControlDMContext(), paths), + new DataRequestMonitor(getExecutor(), requestMonitor)); + } else { + requestMonitor.done(); + } + } catch (CoreException e) { + requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Cannot set share library paths", e)); //$NON-NLS-1$ + requestMonitor.done(); + } + }}, /* * Setup the source paths */ diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIFileExecFile.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIFileExecFile.java index 97728cb4b6d..29accf6a176 100644 --- a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIFileExecFile.java +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIFileExecFile.java @@ -27,7 +27,7 @@ import org.eclipse.dd.mi.service.command.output.MIInfo; public class MIFileExecFile extends MICommand { public MIFileExecFile(MIControlDMContext dmc, String file) { - super(dmc, "-file-exec-file", new String[] {file}); //$NON-NLS-1$ + super(dmc, "-file-exec-file", null, new String[] {file}); //$NON-NLS-1$ } public MIFileExecFile(MIControlDMContext dmc) { diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIFileSymbolFile.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIFileSymbolFile.java index 83ab8883f70..418082b6b89 100644 --- a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIFileSymbolFile.java +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIFileSymbolFile.java @@ -26,7 +26,7 @@ import org.eclipse.dd.mi.service.command.output.MIInfo; public class MIFileSymbolFile extends MICommand { public MIFileSymbolFile(MIControlDMContext dmc, String file) { - super(dmc, "-file-symbol-file", new String[] {file}); //$NON-NLS-1$ + super(dmc, "-file-symbol-file", null, new String[] {file}); //$NON-NLS-1$ } public MIFileSymbolFile(MIControlDMContext dmc) { diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIGDBSet.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIGDBSet.java new file mode 100644 index 00000000000..d142e8d8119 --- /dev/null +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIGDBSet.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2008 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ +package org.eclipse.dd.mi.service.command.commands; + +import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.mi.service.command.output.MIInfo; + +/** + * + * -gdb-set + * + */ +public class MIGDBSet extends MICommand +{ + public MIGDBSet(IDMContext ctx, String[] params) { + super(ctx, "-gdb-set", null, params); //$NON-NLS-1$ + } +} \ No newline at end of file diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIGDBSetAutoSolib.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIGDBSetAutoSolib.java new file mode 100644 index 00000000000..4c6e19bda93 --- /dev/null +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIGDBSetAutoSolib.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2008 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ +package org.eclipse.dd.mi.service.command.commands; + +import org.eclipse.dd.mi.service.command.MIControlDMContext; + +/** + * + * -gdb-set + * + */ +public class MIGDBSetAutoSolib extends MIGDBSet +{ + public MIGDBSetAutoSolib(MIControlDMContext ctx, boolean isSet) { + super(ctx, new String[] {"auto-solib-add", isSet ? "on" : "off"});//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + } +} \ No newline at end of file diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIGDBSetSolibSearchPath.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIGDBSetSolibSearchPath.java new file mode 100644 index 00000000000..cc27b724634 --- /dev/null +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIGDBSetSolibSearchPath.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2008 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ +package org.eclipse.dd.mi.service.command.commands; + +import org.eclipse.dd.mi.service.command.MIControlDMContext; + +/** + * + * -gdb-set + * + */ +public class MIGDBSetSolibSearchPath extends MIGDBSet +{ + public MIGDBSetSolibSearchPath(MIControlDMContext ctx, String[] paths) { + super(ctx, paths); + // Overload the parameter + String sep = System.getProperty("path.separator", ":"); //$NON-NLS-1$ //$NON-NLS-2$ + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < paths.length; i++) { + if (buffer.length() == 0) { + buffer.append(paths[i]); + } else { + buffer.append(sep).append(paths[i]); + } + } + String[] p = new String [] {"solib-search-path", buffer.toString()}; //$NON-NLS-1$ + setParameters(p); + } +} \ No newline at end of file