From e42056257a03ec17cb27262a997b6ff1ba07bbd2 Mon Sep 17 00:00:00 2001 From: John Cortell Date: Thu, 6 May 2010 20:17:04 +0000 Subject: [PATCH] [310304] GDB (DSF) Hardware Debugging Launcher ignores application program path --- .../eclipse/cdt/debug/core/CDebugUtils.java | 129 +++++++- .../cdt/debug/core/DebugCoreMessages.java | 10 + .../debug/core/DebugCoreMessages.properties | 8 + .../core/GDBJtagDSFFinalLaunchSequence.java | 203 +++++++----- .../debug/gdbjtag/core/GDBJtagDebugger.java | 117 +++++-- .../GDBJtagLaunchConfigurationDelegate.java | 12 +- .../debug/gdbjtag/core/IGDBJtagConstants.java | 28 +- .../cdt/debug/gdbjtag/core/Message.properties | 8 +- .../jtagdevice/DefaultGDBJtagDeviceImpl.java | 23 +- .../gdbjtag/ui/GDBJtagDSFDebuggerTab.java | 10 +- .../debug/gdbjtag/ui/GDBJtagDebuggerTab.java | 14 +- .../debug/gdbjtag/ui/GDBJtagStartupTab.java | 297 +++++++++++++----- .../cdt/debug/gdbjtag/ui/JtagUi.properties | 3 + .../cdt/launch/AbstractCLaunchDelegate.java | 62 +--- .../internal/CoreFileLaunchDelegate.java | 4 +- .../internal/LocalAttachLaunchDelegate.java | 4 +- .../internal/LocalCDILaunchDelegate.java | 25 +- .../internal/LocalRunLaunchDelegate.java | 7 +- 18 files changed, 681 insertions(+), 283 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java index 3652f785363..24b757c7a3a 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java @@ -12,10 +12,10 @@ package org.eclipse.cdt.debug.core; import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; -import com.ibm.icu.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; @@ -40,6 +40,7 @@ import org.eclipse.cdt.debug.core.model.ICValue; import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint2; import org.eclipse.cdt.debug.internal.core.model.CFloatingPointValue; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; @@ -47,12 +48,15 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.IStatusHandler; import org.eclipse.debug.core.model.IBreakpoint; import org.w3c.dom.Document; +import com.ibm.icu.text.MessageFormat; + /** * Utility methods. */ @@ -561,4 +565,127 @@ public class CDebugUtils { } return new Path(path); } + + /** + * Returns the ICProject associated with the project setting in the Main tab + * of a CDT launch configuration, or throws a CoreException providing a + * reason (e.g., the setting is empty, the project no longer exists, the + * isn't a CDT one, etc). + * + * @param config + * the launch configuration + * @return an ICProject; never null. + * @throws CoreException + * @since 7.0 + */ + public static ICProject verifyCProject(ILaunchConfiguration config) throws CoreException { + String name = CDebugUtils.getProjectName(config); + if (name == null) { + throwCoreException(DebugCoreMessages.getString("CDebugUtils.C_Project_not_specified"), //$NON-NLS-1$ + ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT); + } + ICProject cproject = CDebugUtils.getCProject(config); + if (cproject == null) { + IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(name); + if (!proj.exists()) { + throwCoreException(DebugCoreMessages.getFormattedString("CDebugUtils.Project_NAME_does_not_exist", name), //$NON-NLS-1$ + ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); + } else if (!proj.isOpen()) { + throwCoreException(DebugCoreMessages.getFormattedString("CDebugUtils.Project_NAME_is_closed", name), //$NON-NLS-1$ + ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); + } + throwCoreException(DebugCoreMessages.getString("CDebugUtils.Not_a_C_CPP_project"), //$NON-NLS-1$ + ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); + } + return cproject; + } + + /** + * Returns an IPath for the file referenced in the C/C++ Application + * setting of a CDT launch configuration. Typically, the file is obtained by + * combining the C/C++ Application setting with the Project + * setting. If unable to combine and resolve these settings to a valid file, + * a CoreException is thrown that provides the reason why. There are many + * such possible reasons (a problem with the Project setting, an + * empty C/C++ Application setting, the combined settings doesn't + * resolve to an existing file, etc). + * + * @param config + * the launch configuration + * @param ignoreProjectSetting + * if true, resolve the file using only the C/C++ + * Application setting. Do not take the Project + * setting into account. + * @return an IPath; never null + * @throws CoreException + * @since 7.0 + */ + public static IPath verifyProgramPath(ILaunchConfiguration config, boolean ignoreProjectSetting) throws CoreException { + ICProject cproject = null; + if (!ignoreProjectSetting) { + cproject = verifyCProject(config); // will throw exception if project setting not valid + } + IPath programPath = CDebugUtils.getProgramPath(config); + if (programPath == null || programPath.isEmpty()) { + throwCoreException(DebugCoreMessages.getString("CDebugUtils.Program_file_not_specified"), //$NON-NLS-1$ + ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM); + } + + if (programPath != null) { // this check is here only to avoid warning; compiler can't tell we'll throw an exception above + if (!programPath.isAbsolute() && (cproject != null)) { + // See if we can brute-force append the program path to the + // project location. This allows us to support the program file + // being outside the project, even outside the workspace, without + // requiring a linked resource (e.g., the setting could be + // "..\..\some\dir\myprogram.exe") + IPath location = cproject.getProject().getLocation(); + if (location != null) { + programPath = location.append(programPath); + if (!programPath.toFile().exists()) { + // Try looking in the project for the file. This + // supports linked resources. + IFile projFile = null; + try { + projFile = cproject.getProject().getFile(CDebugUtils.getProgramPath(config)); + } + catch (IllegalArgumentException exc) { + // thrown if relative path that resolves to a root file (e.g., "..\somefile") + } + if (projFile != null && projFile.exists()) { + programPath = projFile.getLocation(); + } + } + } + } + if (!programPath.toFile().exists()) { + throwCoreException( + DebugCoreMessages.getString("CDebugUtils.Program_file_does_not_exist"), //$NON-NLS-1$ + new FileNotFoundException( + DebugCoreMessages.getFormattedString("CDebugUtils.PROGRAM_PATH_not_found", programPath.toOSString())), //$NON-NLS-1$ + ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST); + } + } + return programPath; + } + + /** + * Variant that expects (requires) the launch configuration to have a valid + * Project setting. See + * {@link #verifyProgramPath(ILaunchConfiguration, boolean)} + * + * @since 7.0 + */ + public static IPath verifyProgramPath(ILaunchConfiguration config) throws CoreException { + return verifyProgramPath(config, false); + } + + /** Throws a CoreException. Clutter-reducing utility method. */ + private static void throwCoreException(String msg, int code) throws CoreException { + throwCoreException(msg, null, code); + } + + /** Throws a CoreException. Clutter-reducing utility method. */ + private static void throwCoreException(String msg, Exception innerException, int code) throws CoreException { + throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), code, msg, innerException)); + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.java index 43c04ad556e..5334aa6e227 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.java @@ -13,6 +13,8 @@ package org.eclipse.cdt.debug.core; import java.util.MissingResourceException; import java.util.ResourceBundle; +import com.ibm.icu.text.MessageFormat; + public class DebugCoreMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.core.DebugCoreMessages";//$NON-NLS-1$ @@ -22,6 +24,14 @@ public class DebugCoreMessages { private DebugCoreMessages() { } + static String getFormattedString(String key, String arg) { + return MessageFormat.format(getString(key), new String[]{arg}); + } + + static String getFormattedString(String key, String[] args) { + return MessageFormat.format(getString(key), args); + } + public static String getString( String key ) { try { return RESOURCE_BUNDLE.getString( key ); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.properties b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.properties index b6cbb475d0d..53222bf4ebd 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.properties +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.properties @@ -23,4 +23,12 @@ CDebugUtils.Regular=Regular CDebugUtils.Hardware=Hardware CDebugUtils.Temporary=Temporary CDebugUtils.Software=Software +CDebugUtils.C_Project_not_specified=A project was not specified in the launch configuration. +CDebugUtils.Not_a_C_CPP_project=The project specified in the launch configuration is not a C/C++ one. +CDebugUtils.PROGRAM_PATH_not_found={0} not found +CDebugUtils.Program_file_does_not_exist=The program file specified in the launch configuration does not exist +CDebugUtils.Program_file_not_specified=A program file was not specified in the launch configuration. +CDebugUtils.Project_NAME_does_not_exist=Project {0} does not exist. Please check that your launch configuration specifies a valid project in your workspace. +CDebugUtils.Project_NAME_is_closed=Project {0} is closed + CDIDebugModel.0=Unable to parser binary information from file diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java index e83f410b223..8503233e3bd 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java @@ -27,6 +27,7 @@ import java.util.Iterator; import java.util.List; import java.util.Properties; +import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GDBJtagDeviceContribution; import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GDBJtagDeviceContributionFactory; import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.IGDBJtagDevice; @@ -350,7 +351,7 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence { // Below steps are specific to JTag hardware debugging /* - * Retrieve the JTag device + * Retrieve the IGDBJtagDevice instance */ new Step() { @Override @@ -369,6 +370,61 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence { } rm.done(); }}, + /* + * Execute symbol loading + */ + new Step() { + @Override + public void execute(RequestMonitor rm) { + ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); + try { + if (config.getAttribute(IGDBJtagConstants.ATTR_LOAD_SYMBOLS, IGDBJtagConstants.DEFAULT_LOAD_SYMBOLS)) { + String symbolsFileName = null; + + // New setting in Helios. Default is true. Check for existence + // in order to support older launch configs + if (config.hasAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_SYMBOLS) && + config.getAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_SYMBOLS, IGDBJtagConstants.DEFAULT_USE_PROJ_BINARY_FOR_SYMBOLS)) { + IPath programFile = CDebugUtils.verifyProgramPath(config); + if (programFile != null) { + symbolsFileName = programFile.toOSString(); + } + } + else { + symbolsFileName = config.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_FILE_NAME, IGDBJtagConstants.DEFAULT_SYMBOLS_FILE_NAME); + if (symbolsFileName.length() > 0) { + symbolsFileName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(symbolsFileName); + } else { + symbolsFileName = null; + } + } + + if (symbolsFileName == null) { + rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, Messages.getString("GDBJtagDebugger.err_no_img_file"), null)); //$NON-NLS-1$ + rm.done(); + return; + } + + // Escape windows path separator characters TWICE, once for Java and once for GDB. + symbolsFileName = symbolsFileName.replace("\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$ + + String symbolsOffset = config.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_OFFSET, IGDBJtagConstants.DEFAULT_SYMBOLS_OFFSET); + if (symbolsOffset.length() > 0) { + symbolsOffset = "0x" + symbolsOffset; + } + List commands = new ArrayList(); + fGdbJtagDevice.doLoadSymbol(symbolsFileName, symbolsOffset, commands); + queueCommands(commands, rm); + + } else { + rm.done(); + } + } catch (CoreException e) { + rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot load symbol", e)); //$NON-NLS-1$ + rm.done(); + } + }}, + /* * Hook up to remote target */ @@ -410,7 +466,7 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence { public void execute(RequestMonitor rm) { ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); try { - if (config.getAttribute(IGDBJtagConstants.ATTR_DO_RESET, true)) { + if (config.getAttribute(IGDBJtagConstants.ATTR_DO_RESET, IGDBJtagConstants.DEFAULT_DO_RESET)) { List commands = new ArrayList(); fGdbJtagDevice.doReset(commands); queueCommands(commands, rm); @@ -447,7 +503,7 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence { public void execute(RequestMonitor rm) { ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); try { - if (config.getAttribute(IGDBJtagConstants.ATTR_DO_HALT, true)) { + if (config.getAttribute(IGDBJtagConstants.ATTR_DO_HALT, IGDBJtagConstants.DEFAULT_DO_HALT)) { List commands = new ArrayList(); fGdbJtagDevice.doHalt(commands); queueCommands(commands, rm); @@ -467,16 +523,21 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence { public void execute(RequestMonitor rm) { ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); try { - String userCmd = config.getAttribute(IGDBJtagConstants.ATTR_INIT_COMMANDS, ""); //$NON-NLS-1$ + String userCmd = config.getAttribute(IGDBJtagConstants.ATTR_INIT_COMMANDS, IGDBJtagConstants.DEFAULT_INIT_COMMANDS); userCmd = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(userCmd); - String[] commands = userCmd.split("\\r?\\n"); //$NON-NLS-1$ - - CountingRequestMonitor crm = new CountingRequestMonitor(getExecutor(), rm); - crm.setDoneCount(commands.length); - for (int i = 0; i < commands.length; ++i) { - fCommandControl.queueCommand( - new CLICommand(fCommandControl.getContext(), commands[i]), - new DataRequestMonitor(getExecutor(), crm)); + if (userCmd.length() > 0) { + String[] commands = userCmd.split("\\r?\\n"); //$NON-NLS-1$ + + CountingRequestMonitor crm = new CountingRequestMonitor(getExecutor(), rm); + crm.setDoneCount(commands.length); + for (int i = 0; i < commands.length; ++i) { + fCommandControl.queueCommand( + new CLICommand(fCommandControl.getContext(), commands[i]), + new DataRequestMonitor(getExecutor(), crm)); + } + } + else { + rm.done(); } } catch (CoreException e) { rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot run user defined init commands", e)); //$NON-NLS-1$ @@ -491,20 +552,44 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence { public void execute(RequestMonitor rm) { ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); try { + String imageFileName = null; if (config.getAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, IGDBJtagConstants.DEFAULT_LOAD_IMAGE)) { - // Escape windows path separator characters TWICE, once for Java and once for GDB. - String imageFileName = config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, ""); //$NON-NLS-1$ - if (imageFileName.length() > 0) { - imageFileName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(imageFileName).replace("\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$ - String imageOffset = (imageFileName.endsWith(".elf")) ? "" : "0x" + config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - List commands = new ArrayList(); - fGdbJtagDevice.doLoadImage(imageFileName, imageOffset, commands); - queueCommands(commands, rm); - } else { - rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Image name cannot be empty", null)); //$NON-NLS-1$ - rm.done(); + // New setting in Helios. Default is true. Check for existence + // in order to support older launch configs + if (config.hasAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_IMAGE) && + config.getAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_IMAGE, IGDBJtagConstants.DEFAULT_USE_PROJ_BINARY_FOR_IMAGE)) { + IPath programFile = CDebugUtils.verifyProgramPath(config); + if (programFile != null) { + imageFileName = programFile.toOSString(); + } } - } else { + else { + imageFileName = config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, IGDBJtagConstants.DEFAULT_IMAGE_FILE_NAME); //$NON-NLS-1$ + if (imageFileName.length() > 0) { + imageFileName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(imageFileName); + } else { + imageFileName = null; + } + } + + if (imageFileName == null) { + rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, Messages.getString("GDBJtagDebugger.err_no_img_file"), null)); //$NON-NLS-1$ + rm.done(); + return; + } + + // Escape windows path separator characters TWICE, once for Java and once for GDB. + imageFileName = imageFileName.replace("\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$ + + String imageOffset = config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, IGDBJtagConstants.DEFAULT_IMAGE_OFFSET); + if (imageOffset.length() > 0) { + imageOffset = (imageFileName.endsWith(".elf")) ? "" : "0x" + config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, IGDBJtagConstants.DEFAULT_IMAGE_OFFSET); //$NON-NLS-2$ //$NON-NLS-4$ + } + List commands = new ArrayList(); + fGdbJtagDevice.doLoadImage(imageFileName, imageOffset, commands); + queueCommands(commands, rm); + } + else { rm.done(); } } catch (CoreException e) { @@ -512,36 +597,6 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence { rm.done(); } }}, - /* - * Execute symbol loading - */ - new Step() { - @Override - public void execute(RequestMonitor rm) { - ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); - try { - if (config.getAttribute(IGDBJtagConstants.ATTR_LOAD_SYMBOLS, IGDBJtagConstants.DEFAULT_LOAD_SYMBOLS)) { - // Escape windows path separator characters TWICE, once for Java and once for GDB. - String symbolsFileName = config.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_FILE_NAME, ""); //$NON-NLS-1$ - if (symbolsFileName.length() > 0) { - symbolsFileName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(symbolsFileName).replace("\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$ - String symbolsOffset = "0x" + config.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_OFFSET, ""); //$NON-NLS-1$ //$NON-NLS-2$ - List commands = new ArrayList(); - fGdbJtagDevice.doLoadSymbol(symbolsFileName, symbolsOffset, commands); - queueCommands(commands, rm); - } else { - rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Symbol name cannot be empty", null)); //$NON-NLS-1$ - rm.done(); - } - } else { - rm.done(); - } - } catch (CoreException e) { - rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot load symbol", e)); //$NON-NLS-1$ - rm.done(); - } - } - }, /* * Start tracking the breakpoints once we know we are connected to the target (necessary for remote debugging) */ @@ -566,7 +621,7 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence { ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); try { if (config.getAttribute(IGDBJtagConstants.ATTR_SET_PC_REGISTER, IGDBJtagConstants.DEFAULT_SET_PC_REGISTER)) { - String pcRegister = config.getAttribute(IGDBJtagConstants.ATTR_PC_REGISTER, config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, "")); //$NON-NLS-1$ + String pcRegister = config.getAttribute(IGDBJtagConstants.ATTR_PC_REGISTER, config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, IGDBJtagConstants.DEFAULT_PC_REGISTER)); //$NON-NLS-1$ List commands = new ArrayList(); fGdbJtagDevice.doSetPC(pcRegister, commands); queueCommands(commands, rm); @@ -587,7 +642,7 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence { ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); try { if (config.getAttribute(IGDBJtagConstants.ATTR_SET_STOP_AT, IGDBJtagConstants.DEFAULT_SET_STOP_AT)) { - String stopAt = config.getAttribute(IGDBJtagConstants.ATTR_STOP_AT, ""); //$NON-NLS-1$ + String stopAt = config.getAttribute(IGDBJtagConstants.ATTR_STOP_AT, IGDBJtagConstants.DEFAULT_STOP_AT); //$NON-NLS-1$ List commands = new ArrayList(); fGdbJtagDevice.doStopAt(stopAt, commands); queueCommands(commands, rm); @@ -628,16 +683,21 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence { public void execute(RequestMonitor rm) { ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); try { - String userCmd = config.getAttribute(IGDBJtagConstants.ATTR_RUN_COMMANDS, ""); //$NON-NLS-1$ - userCmd = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(userCmd); - String[] commands = userCmd.split("\\r?\\n"); //$NON-NLS-1$ - - CountingRequestMonitor crm = new CountingRequestMonitor(getExecutor(), rm); - crm.setDoneCount(commands.length); - for (int i = 0; i < commands.length; ++i) { - fCommandControl.queueCommand( - new CLICommand(fCommandControl.getContext(), commands[i]), - new DataRequestMonitor(getExecutor(), crm)); + String userCmd = config.getAttribute(IGDBJtagConstants.ATTR_RUN_COMMANDS, IGDBJtagConstants.DEFAULT_RUN_COMMANDS); //$NON-NLS-1$ + if (userCmd.length() > 0) { + userCmd = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(userCmd); + String[] commands = userCmd.split("\\r?\\n"); //$NON-NLS-1$ + + CountingRequestMonitor crm = new CountingRequestMonitor(getExecutor(), rm); + crm.setDoneCount(commands.length); + for (int i = 0; i < commands.length; ++i) { + fCommandControl.queueCommand( + new CLICommand(fCommandControl.getContext(), commands[i]), + new DataRequestMonitor(getExecutor(), crm)); + } + } + else { + rm.done(); } } catch (CoreException e) { rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot run user defined run commands", e)); //$NON-NLS-1$ @@ -703,12 +763,11 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence { private IGDBJtagDevice getGDBJtagDevice (ILaunchConfiguration config) throws CoreException, NullPointerException { IGDBJtagDevice gdbJtagDevice = null; - String jtagDeviceName = config.getAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, ""); //$NON-NLS-1$ - GDBJtagDeviceContribution[] availableDevices = GDBJtagDeviceContributionFactory. - getInstance().getGDBJtagDeviceContribution(); - for (int i = 0; i < availableDevices.length; i++) { - if (jtagDeviceName.equals(availableDevices[i].getDeviceName())) { - gdbJtagDevice = availableDevices[i].getDevice(); + String jtagDeviceName = config.getAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, IGDBJtagConstants.DEFAULT_JTAG_DEVICE); //$NON-NLS-1$ + GDBJtagDeviceContribution[] availableDevices = GDBJtagDeviceContributionFactory.getInstance().getGDBJtagDeviceContribution(); + for (GDBJtagDeviceContribution availableDevice : availableDevices) { + if (jtagDeviceName.equals(availableDevice.getDeviceName())) { + gdbJtagDevice = availableDevice.getDevice(); break; } } diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDebugger.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDebugger.java index 845370eec7c..3041cc66ad4 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDebugger.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDebugger.java @@ -24,6 +24,7 @@ import java.util.List; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.cdi.ICDISession; import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; @@ -41,6 +42,7 @@ import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIGDBSetNewConsole; import org.eclipse.cdt.debug.mi.core.output.MIInfo; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; @@ -117,14 +119,58 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger { List commands = new ArrayList(); - // hook up to remote target if (submonitor.isCanceled()) { throw new OperationCanceledException(); } + // execute symbol load + boolean doLoadSymbols = config.getAttribute(IGDBJtagConstants.ATTR_LOAD_SYMBOLS, IGDBJtagConstants.DEFAULT_LOAD_SYMBOLS); + if (doLoadSymbols) { + String symbolsFileName = null; + // New setting in Helios. Default is true. Check for existence + // in order to support older launch configs + if (config.hasAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_SYMBOLS) && + config.getAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_SYMBOLS, IGDBJtagConstants.DEFAULT_USE_PROJ_BINARY_FOR_SYMBOLS)) { + IPath programFile = CDebugUtils.verifyProgramPath(config); + if (programFile != null) { + symbolsFileName = programFile.toOSString(); + } + } + else { + symbolsFileName = config.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_FILE_NAME, IGDBJtagConstants.DEFAULT_SYMBOLS_FILE_NAME); + if (symbolsFileName.length() > 0) { + symbolsFileName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(symbolsFileName); + } + } + if (symbolsFileName == null) { + // The launch config GUI should prevent this from happening, but just in case + throw new CoreException(new Status( IStatus.ERROR, + Activator.getUniqueIdentifier(), + -1, Messages.getString("GDBJtagDebugger.err_no_sym_file"), null)); + } + + // Escape windows path separator characters TWICE, once for Java and once for GDB. + symbolsFileName = symbolsFileName.replace("\\", "\\\\"); + + String symbolsOffset = config.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_OFFSET, IGDBJtagConstants.DEFAULT_SYMBOLS_OFFSET); + if (symbolsOffset.length() > 0) { + symbolsOffset = "0x" + symbolsOffset; + } + commands.clear(); + gdbJtagDevice.doLoadSymbol(symbolsFileName, symbolsOffset, commands); + monitor.beginTask(Messages.getString("GDBJtagDebugger.loading_symbols"), 1); //$NON-NLS-1$ + executeGDBScript(getGDBScript(commands), miSession, submonitor.newChild(15)); + } + + if (submonitor.isCanceled()) { + throw new OperationCanceledException(); + } + + // hook up to remote target boolean useRemote = config.getAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET); if (useRemote) { submonitor.subTask(Messages.getString("GDBJtagDebugger.2")); //$NON-NLS-1$ try { + commands.clear(); if (gdbJtagDevice instanceof IGDBJtagConnection) { URI connection = new URI(config.getAttribute(IGDBJtagConstants.ATTR_CONNECTION, IGDBJtagConstants.DEFAULT_CONNECTION)); IGDBJtagConnection device = (IGDBJtagConnection)gdbJtagDevice; @@ -149,7 +195,7 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger { submonitor.setWorkRemaining(80); // compensate for optional work above // Run device-specific code to reset the board - if (config.getAttribute(IGDBJtagConstants.ATTR_DO_RESET, true)) { + if (config.getAttribute(IGDBJtagConstants.ATTR_DO_RESET, IGDBJtagConstants.DEFAULT_DO_RESET)) { commands.clear(); gdbJtagDevice.doReset(commands); int defaultDelay = gdbJtagDevice.getDefaultDelay(); @@ -159,7 +205,7 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger { submonitor.setWorkRemaining(65); // compensate for optional work above // Run device-specific code to halt the board - if (config.getAttribute(IGDBJtagConstants.ATTR_DO_HALT, true)) { + if (config.getAttribute(IGDBJtagConstants.ATTR_DO_HALT, IGDBJtagConstants.DEFAULT_DO_HALT)) { commands.clear(); gdbJtagDevice.doHalt(commands); executeGDBScript(getGDBScript(commands), miSession, submonitor.newChild(15)); @@ -172,31 +218,44 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger { // execute load boolean doLoad = config.getAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, IGDBJtagConstants.DEFAULT_LOAD_IMAGE); if (doLoad) { - // Escape windows path separator characters TWICE, once for Java and once for GDB. - String imageFileName = config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, ""); //$NON-NLS-1$ - if (imageFileName.length() > 0) { - monitor.beginTask(Messages.getString("GDBJtagDebugger.5"), 1); //$NON-NLS-1$ - imageFileName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(imageFileName).replace("\\", "\\\\"); - String imageOffset = (imageFileName.endsWith(".elf")) ? "" : "0x" + config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, ""); //$NON-NLS-2$ //$NON-NLS-4$ - commands.clear(); - gdbJtagDevice.doLoadImage(imageFileName, imageOffset, commands); - executeGDBScript(getGDBScript(commands), miSession, submonitor.newChild(20)); + String imageFileName = null; + + // New setting in Helios. Default is true. Check for existence + // in order to support older launch configs + if (config.hasAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_IMAGE) && + config.getAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_IMAGE, IGDBJtagConstants.DEFAULT_USE_PROJ_BINARY_FOR_IMAGE)) { + IPath programFile = CDebugUtils.verifyProgramPath(config); + if (programFile != null) { + imageFileName = programFile.toOSString(); + } } + else { + imageFileName = config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, IGDBJtagConstants.DEFAULT_IMAGE_FILE_NAME); + if (imageFileName.length() > 0) { + imageFileName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(imageFileName); + } + } + if (imageFileName == null) { + // The launch config GUI should prevent this from happening, but just in case + throw new CoreException(new Status( IStatus.ERROR, + Activator.getUniqueIdentifier(), + -1, Messages.getString("GDBJtagDebugger.err_no_img_file"), null)); + } + imageFileName = imageFileName.replace("\\", "\\\\"); + + String imageOffset = config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, IGDBJtagConstants.DEFAULT_IMAGE_OFFSET); + if (imageOffset.length() > 0) { + imageOffset = (imageFileName.endsWith(".elf")) ? "" : "0x" + config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, IGDBJtagConstants.DEFAULT_IMAGE_OFFSET); + } + + commands.clear(); + gdbJtagDevice.doLoadImage(imageFileName, imageOffset, commands); + monitor.beginTask(Messages.getString("GDBJtagDebugger.loading_image"), 1); //$NON-NLS-1$ + executeGDBScript(getGDBScript(commands), miSession, submonitor.newChild(20)); + + } submonitor.setWorkRemaining(15); // compensate for optional work above - - // execute symbol load - boolean doLoadSymbols = config.getAttribute(IGDBJtagConstants.ATTR_LOAD_SYMBOLS, IGDBJtagConstants.DEFAULT_LOAD_SYMBOLS); - if (doLoadSymbols) { - String symbolsFileName = config.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_FILE_NAME, ""); //$NON-NLS-1$ - if (symbolsFileName.length() > 0) { - symbolsFileName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(symbolsFileName).replace("\\", "\\\\"); - String symbolsOffset = "0x" + config.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_OFFSET, ""); //$NON-NLS-2$ - commands.clear(); - gdbJtagDevice.doLoadSymbol(symbolsFileName, symbolsOffset, commands); - executeGDBScript(getGDBScript(commands), miSession, submonitor.newChild(15)); - } - } } catch (OperationCanceledException e) { if (launch != null && launch.canTerminate()) { launch.terminate(); @@ -229,7 +288,7 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger { // Set program counter boolean setPc = config.getAttribute(IGDBJtagConstants.ATTR_SET_PC_REGISTER, IGDBJtagConstants.DEFAULT_SET_PC_REGISTER); if (setPc) { - String pcRegister = config.getAttribute(IGDBJtagConstants.ATTR_PC_REGISTER, config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, "")); //$NON-NLS-1$ + String pcRegister = config.getAttribute(IGDBJtagConstants.ATTR_PC_REGISTER, config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, IGDBJtagConstants.DEFAULT_PC_REGISTER)); //$NON-NLS-1$ gdbJtagDevice.doSetPC(pcRegister, commands); executeGDBScript(getGDBScript(commands), miSession, submonitor.newChild(20)); } @@ -239,7 +298,7 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger { monitor.beginTask(Messages.getString("GDBJtagDebugger.18"), 1); //$NON-NLS-1$ boolean setStopAt = config.getAttribute(IGDBJtagConstants.ATTR_SET_STOP_AT, IGDBJtagConstants.DEFAULT_SET_STOP_AT); if (setStopAt) { - String stopAt = config.getAttribute(IGDBJtagConstants.ATTR_STOP_AT, ""); //$NON-NLS-1$ + String stopAt = config.getAttribute(IGDBJtagConstants.ATTR_STOP_AT, IGDBJtagConstants.DEFAULT_STOP_AT); //$NON-NLS-1$ commands.clear(); gdbJtagDevice.doStopAt(stopAt, commands); executeGDBScript(getGDBScript(commands), miSession, submonitor.newChild(20)); @@ -266,7 +325,7 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger { private void executeGDBScript(String script, MISession miSession, IProgressMonitor monitor) throws CoreException { // Try to execute any extra command - if (script == null) + if (script == null || script.length() == 0) return; script = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(script); String[] commands = script.split("\\r?\\n"); @@ -309,7 +368,7 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger { private IGDBJtagDevice getGDBJtagDevice (ILaunchConfiguration config) throws CoreException, NullPointerException { IGDBJtagDevice gdbJtagDevice = null; - String jtagDeviceName = config.getAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, ""); //$NON-NLS-1$ + String jtagDeviceName = config.getAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, IGDBJtagConstants.DEFAULT_JTAG_DEVICE); //$NON-NLS-1$ GDBJtagDeviceContribution[] availableDevices = GDBJtagDeviceContributionFactory. getInstance().getGDBJtagDeviceContribution(); for (int i = 0; i < availableDevices.length; i++) { diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagLaunchConfigurationDelegate.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagLaunchConfigurationDelegate.java index dd59117d858..55d28124f6c 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagLaunchConfigurationDelegate.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagLaunchConfigurationDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 QNX Software Systems and others. + * Copyright (c) 2007 - 2010 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 @@ -10,11 +10,10 @@ *******************************************************************************/ package org.eclipse.cdt.debug.gdbjtag.core; -import java.io.File; - import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.debug.core.CDIDebugModel; +import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDISession; @@ -48,10 +47,9 @@ public class GDBJtagLaunchConfigurationDelegate extends AbstractCLaunchDelegate if (mode.equals(ILaunchManager.DEBUG_MODE)) { GDBJtagDebugger debugger = new GDBJtagDebugger(); - ICProject project = verifyCProject(configuration); - IPath exePath = verifyProgramPath(configuration); - File exeFile = exePath != null ? exePath.toFile() : null; - ICDISession session = debugger.createSession(launch, exeFile, submonitor.newChild(1)); + ICProject project = CDebugUtils.verifyCProject(configuration); + IPath exePath = CDebugUtils.verifyProgramPath(configuration); + ICDISession session = debugger.createSession(launch, null, submonitor.newChild(1)); IBinaryObject exeBinary = null; if ( exePath != null ) { exeBinary = verifyBinary(project, exePath); diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/IGDBJtagConstants.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/IGDBJtagConstants.java index aa8905f6e81..9a53d8aa8ee 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/IGDBJtagConstants.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/IGDBJtagConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 - 2008 QNX Software Systems and others. + * Copyright (c) 2007 - 2010 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 @@ -52,15 +52,33 @@ public interface IGDBJtagConstants { public static final String ATTR_STOP_AT = Activator.PLUGIN_ID + ".stopAt"; //$NON-NLS-1$ public static final String ATTR_SET_RESUME = Activator.PLUGIN_ID + ".setResume"; //$NON-NLS-1$ public static final String ATTR_RUN_COMMANDS = Activator.PLUGIN_ID + ".runCommands"; //$NON-NLS-1$ - + /** @since 7.0 */ public static final String ATTR_USE_PROJ_BINARY_FOR_IMAGE = Activator.PLUGIN_ID + ".useProjBinaryForImage"; //$NON-NLS-1$ + /** @since 7.0 */ public static final String ATTR_USE_FILE_FOR_IMAGE = Activator.PLUGIN_ID + ".useFileForImage"; //$NON-NLS-1$ + /** @since 7.0 */ public static final String ATTR_USE_PROJ_BINARY_FOR_SYMBOLS = Activator.PLUGIN_ID + ".useProjBinaryForSymbols"; //$NON-NLS-1$ + /** @since 7.0 */ public static final String ATTR_USE_FILE_FOR_SYMBOLS = Activator.PLUGIN_ID + ".useFileForSymbols"; //$NON-NLS-1$ + public static final boolean DEFAULT_DO_RESET = true; public static final boolean DEFAULT_DO_HALT = true; public static final int DEFAULT_DELAY = 3; - public static final boolean DEFAULT_LOAD_IMAGE = false; - public static final boolean DEFAULT_LOAD_SYMBOLS = false; + public static final boolean DEFAULT_LOAD_IMAGE = true; + public static final boolean DEFAULT_LOAD_SYMBOLS = true; public static final boolean DEFAULT_SET_PC_REGISTER = false; public static final boolean DEFAULT_SET_STOP_AT = false; public static final boolean DEFAULT_SET_RESUME = false; public static final boolean DEFAULT_USE_DEFAULT_RUN = true; - + + /** @since 7.0 */ public static final String DEFAULT_INIT_COMMANDS = ""; //$NON-NLS-1$ + /** @since 7.0 */ public static final String DEFAULT_IMAGE_FILE_NAME = ""; //$NON-NLS-1$ + /** @since 7.0 */ public static final String DEFAULT_SYMBOLS_FILE_NAME = ""; //$NON-NLS-1$ + /** @since 7.0 */ public static final String DEFAULT_RUN_COMMANDS = ""; //$NON-NLS-1$ + /** @since 7.0 */ public static final boolean DEFAULT_USE_PROJ_BINARY_FOR_IMAGE = true; + /** @since 7.0 */ public static final boolean DEFAULT_USE_FILE_FOR_IMAGE = false; + /** @since 7.0 */ public static final boolean DEFAULT_USE_PROJ_BINARY_FOR_SYMBOLS = true; + /** @since 7.0 */ public static final boolean DEFAULT_USE_FILE_FOR_SYMBOLS = false; + /** @since 7.0 */ public static final String DEFAULT_IMAGE_OFFSET = ""; //$NON-NLS-1$ + /** @since 7.0 */ public static final String DEFAULT_SYMBOLS_OFFSET = ""; //$NON-NLS-1$ + /** @since 7.0 */ public static final String DEFAULT_PC_REGISTER = ""; //$NON-NLS-1$ + /** @since 7.0 */ public static final String DEFAULT_STOP_AT = ""; //$NON-NLS-1$ + /** @since 7.0 */ public static final String DEFAULT_JTAG_DEVICE = ""; //$NON-NLS-1$ + } diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/Message.properties b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/Message.properties index bcded8c7a41..5eb05951eb0 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/Message.properties +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/Message.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2008 QNX Software Systems and others. +# Copyright (c) 2008 - 2010 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 @@ -15,5 +15,9 @@ GDBJtagDebugger.2=Connecting to remote GDBJtagDebugger.21=GDB command: GDBJtagDebugger.22=Failed command GDBJtagDebugger.3=Executing init commands -GDBJtagDebugger.5=Loading image +GDBJtagDebugger.loading_image=Loading image +GDBJtagDebugger.loading_symbols=Loading symbolics src.common.No_answer=No answer + +GDBJtagDebugger.err_no_sym_file=Symbolics loading was requested but file was not specified or not found. +GDBJtagDebugger.err_no_img_file=Image loading was requested but file was not specified or not found. diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagDeviceImpl.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagDeviceImpl.java index 2a2aea38803..47260a32612 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagDeviceImpl.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagDeviceImpl.java @@ -77,8 +77,19 @@ public class DefaultGDBJtagDeviceImpl implements IGDBJtagDevice { */ public void doLoadImage(String imageFileName, String imageOffset, Collection commands) { String file = escapeScpaces(imageFileName); - String cmd = "restore " + file + " " + imageOffset; //$NON-NLS-1$ //$NON-NLS-2$ - addCmd(commands, cmd); + if (imageOffset.length() > 0) { + // 'restore' simply puts the program into memory. + addCmd(commands, "restore " + file + " " + imageOffset); + } + else { + // 'load' puts the program into memory and sets the PC. To see why + // we do this when no offset is specified, see + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310304#c20 + addCmd(commands, "load " + file); + } + // 'exec-file' specifies the program as the context for getting memory. + // Basically, it tells gdb "this is the program we'll be debugging" + addCmd(commands, "exec-file " + file); } /* (non-Javadoc) @@ -86,8 +97,12 @@ public class DefaultGDBJtagDeviceImpl implements IGDBJtagDevice { */ public void doLoadSymbol(String symbolFileName, String symbolOffset, Collection commands) { String file = escapeScpaces(symbolFileName); - String cmd = "add-sym " + file + " " + symbolOffset; //$NON-NLS-1$ //$NON-NLS-2$ - addCmd(commands, cmd); + if (symbolOffset == null || (symbolOffset.length() == 0)) { + addCmd(commands, "symbol-file " + file); + } + else { + addCmd(commands, "add-sym " + file + " " + symbolOffset); + } } protected String escapeScpaces(String file) { diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagDSFDebuggerTab.java b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagDSFDebuggerTab.java index a8479447bbe..036d9849307 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagDSFDebuggerTab.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagDSFDebuggerTab.java @@ -159,7 +159,7 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab { gdbCommand.setLayoutData(gd); gdbCommand.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); // provides much better performance for Text listeners } }); @@ -216,7 +216,7 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab { jtagDevice.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { updateDeviceIpPort(jtagDevice.getText()); - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); // provides much better performance for Text listeners } }); @@ -275,7 +275,7 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab { ipAddress.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); // provides much better performance for Text listeners } }); portNumber.addVerifyListener(new VerifyListener() { @@ -285,13 +285,13 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab { }); portNumber.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); // provides much better performance for Text listeners } }); connection.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); // provides much better performance for Text listeners } }); } diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagDebuggerTab.java b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagDebuggerTab.java index 41528453566..6fc9143b264 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagDebuggerTab.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagDebuggerTab.java @@ -160,7 +160,7 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab { gdbCommand.setLayoutData(gd); gdbCommand.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); // provides much better performance for Text listeners } }); @@ -200,7 +200,7 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab { commandFactory.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { commandFactoryChanged(); - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); // provides much better performance for Text listeners } }); } @@ -215,7 +215,7 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab { miProtocol = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN); miProtocol.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); // provides much better performance for Text listeners } }); } @@ -285,7 +285,7 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab { jtagDevice.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { updateDeviceIpPort(jtagDevice.getText()); - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); // provides much better performance for Text listeners } }); @@ -344,7 +344,7 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab { ipAddress.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); // provides much better performance for Text listeners } }); portNumber.addVerifyListener(new VerifyListener() { @@ -354,13 +354,13 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab { }); portNumber.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); // provides much better performance for Text listeners } }); connection.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); // provides much better performance for Text listeners } }); } diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagStartupTab.java b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagStartupTab.java index 46ee2652f76..3e7297920c7 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagStartupTab.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagStartupTab.java @@ -15,7 +15,7 @@ package org.eclipse.cdt.debug.gdbjtag.ui; import java.io.File; -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConstants; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; @@ -33,6 +33,7 @@ import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.events.VerifyEvent; import org.eclipse.swt.events.VerifyListener; import org.eclipse.swt.graphics.Image; @@ -82,6 +83,16 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { boolean resume = false; Text runCommands; + + // New GUI added to address bug 310304 + private Button useProjectBinaryForImage; + private Button useFileForImage; + private Button useProjectBinaryForSymbols; + private Button useFileForSymbols; + private Label imageOffsetLabel; + private Label symbolsOffsetLabel; + private Label projBinaryLabel1; + private Label projBinaryLabel2; public String getName() { return TAB_NAME; @@ -170,7 +181,7 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { }); delay.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); } }); @@ -197,7 +208,7 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { initCommands.setLayoutData(gd); initCommands.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); } }); @@ -231,15 +242,42 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); comp.setLayout(layout); - Label imageLabel = new Label(comp, SWT.NONE); - imageLabel.setText(Messages.getString("GDBJtagStartupTab.imageLabel_Text")); + SelectionListener radioButtonListener = new SelectionListener() { + public void widgetSelected(SelectionEvent e) { + updateLaunchConfigurationDialog(); + updateUseFileEnablement(); + } + public void widgetDefaultSelected(SelectionEvent e) { + } + }; + + useProjectBinaryForImage = new Button(comp, SWT.RADIO); + useProjectBinaryForImage.setText(Messages.getString("GDBJtagStartupTab.useProjectBinary_Label")); + useProjectBinaryForImage.setToolTipText(Messages.getString("GDBJtagStartupTab.useProjectBinary_ToolTip")); + gd = new GridData(); + gd.horizontalSpan = 1; + useProjectBinaryForImage.setLayoutData(gd); + useProjectBinaryForImage.addSelectionListener(radioButtonListener); + + projBinaryLabel1 = new Label(comp, SWT.NONE); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 3; + projBinaryLabel1.setLayoutData(gd); + + useFileForImage = new Button(comp, SWT.RADIO); + useFileForImage.setText(Messages.getString("GDBJtagStartupTab.useFile_Label")); + gd = new GridData(); + gd.horizontalSpan = 1; + useFileForImage.setLayoutData(gd); + useFileForImage.addSelectionListener(radioButtonListener); + imageFileName = new Text(comp, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 1; imageFileName.setLayoutData(gd); imageFileName.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); } }); @@ -257,7 +295,7 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { } }); - Label imageOffsetLabel = new Label(comp, SWT.NONE); + imageOffsetLabel = new Label(comp, SWT.NONE); imageOffsetLabel.setText(Messages.getString("GDBJtagStartupTab.imageOffsetLabel_Text")); imageOffset = new Text(comp, SWT.BORDER); gd = new GridData(); @@ -271,10 +309,11 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { }); imageOffset.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); } }); + loadSymbols = new Button(group, SWT.CHECK); loadSymbols.setText(Messages.getString("GDBJtagStartupTab.loadSymbols_Text")); gd = new GridData(); @@ -292,16 +331,34 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { layout.numColumns = 4; comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); comp.setLayout(layout); + + useProjectBinaryForSymbols = new Button(comp, SWT.RADIO); + useProjectBinaryForSymbols.setText(Messages.getString("GDBJtagStartupTab.useProjectBinary_Label")); + useProjectBinaryForSymbols.setToolTipText(Messages.getString("GDBJtagStartupTab.useProjectBinary_ToolTip")); + gd = new GridData(); + gd.horizontalSpan = 1; + useProjectBinaryForSymbols.setLayoutData(gd); + useProjectBinaryForSymbols.addSelectionListener(radioButtonListener); + + projBinaryLabel2 = new Label(comp, SWT.NONE); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 3; + projBinaryLabel2.setLayoutData(gd); + + useFileForSymbols = new Button(comp, SWT.RADIO); + useFileForSymbols.setText(Messages.getString("GDBJtagStartupTab.useFile_Label")); + gd = new GridData(); + gd.horizontalSpan = 1; + useFileForSymbols.setLayoutData(gd); + useFileForSymbols.addSelectionListener(radioButtonListener); - Label symbolLabel = new Label(comp, SWT.NONE); - symbolLabel.setText(Messages.getString("GDBJtagStartupTab.symbolsLabel_Text")); symbolsFileName = new Text(comp, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 1; symbolsFileName.setLayoutData(gd); symbolsFileName.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); } }); @@ -319,7 +376,7 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { } }); - Label symbolsOffsetLabel = new Label(comp, SWT.NONE); + symbolsOffsetLabel = new Label(comp, SWT.NONE); symbolsOffsetLabel.setText(Messages.getString("GDBJtagStartupTab.symbolsOffsetLabel_Text")); symbolsOffset = new Text(comp, SWT.BORDER); gd = new GridData(); @@ -333,12 +390,24 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { }); symbolsOffset.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); } }); } + private void updateUseFileEnablement() { + boolean enabled = loadImage.getSelection() && useFileForImage.getSelection(); + imageFileName.setEnabled(enabled); + imageFileBrowseWs.setEnabled(enabled); + imageFileBrowse.setEnabled(enabled); + + enabled = loadSymbols.getSelection() && useFileForSymbols.getSelection(); + symbolsFileName.setEnabled(enabled); + symbolsFileBrowseWs.setEnabled(enabled); + symbolsFileBrowse.setEnabled(enabled); + } + public void createRunOptionGroup(Composite parent) { Group group = new Group(parent, SWT.NONE); GridLayout layout = new GridLayout(); @@ -373,7 +442,7 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { }); pcRegister.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); } }); @@ -396,7 +465,7 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { stopAt.setLayoutData(gd); stopAt.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); } }); @@ -419,18 +488,20 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { private void loadImageChanged() { boolean enabled = loadImage.getSelection(); - imageFileName.setEnabled(enabled); - imageFileBrowseWs.setEnabled(enabled); - imageFileBrowse.setEnabled(enabled); + useProjectBinaryForImage.setEnabled(enabled); + useFileForImage.setEnabled(enabled); imageOffset.setEnabled(enabled); + imageOffsetLabel.setEnabled(enabled); + updateUseFileEnablement(); } private void loadSymbolsChanged() { boolean enabled = loadSymbols.getSelection(); - symbolsFileName.setEnabled(enabled); - symbolsFileBrowseWs.setEnabled(enabled); - symbolsFileBrowse.setEnabled(enabled); + useProjectBinaryForSymbols.setEnabled(enabled); + useFileForSymbols.setEnabled(enabled); symbolsOffset.setEnabled(enabled); + symbolsOffsetLabel.setEnabled(enabled); + updateUseFileEnablement(); } private void pcRegisterChanged() { @@ -459,7 +530,7 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { runCommands.setLayoutData(gd); runCommands.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); + scheduleUpdateJob(); } }); } @@ -474,40 +545,45 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { setMessage(null); if (loadImage.getSelection()) { - if (imageFileName.getText().trim().length() == 0) { - setErrorMessage(Messages.getString("GDBJtagStartupTab.imageFileName_not_specified")); - return false; - } - - String path; - try { - path = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(imageFileName.getText().trim()); - IPath filePath = new Path(path); - if (!filePath.toFile().exists()) { + if (!useProjectBinaryForImage.getSelection()) { + if (imageFileName.getText().trim().length() == 0) { + setErrorMessage(Messages.getString("GDBJtagStartupTab.imageFileName_not_specified")); + return false; + } + + try { + String path = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(imageFileName.getText().trim()); + IPath filePath = new Path(path); + if (!filePath.toFile().exists()) { + setErrorMessage(Messages.getString("GDBJtagStartupTab.imageFileName_does_not_exist")); + return false; + } + } catch (CoreException e) { // string substitution throws this if expression doesn't resolve setErrorMessage(Messages.getString("GDBJtagStartupTab.imageFileName_does_not_exist")); return false; } - } catch (CoreException e) { - Activator.getDefault().getLog().log(e.getStatus()); } } else { setErrorMessage(null); } if (loadSymbols.getSelection()) { - if (symbolsFileName.getText().trim().length() == 0) { - setErrorMessage(Messages.getString("GDBJtagStartupTab.symbolsFileName_not_specified")); - return false; - } - String path; - try { - path = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(symbolsFileName.getText().trim()); - IPath filePath = new Path(path); - if (!filePath.toFile().exists()) { + if (!useProjectBinaryForSymbols.getSelection()) { + if (symbolsFileName.getText().trim().length() == 0) { + setErrorMessage(Messages.getString("GDBJtagStartupTab.symbolsFileName_not_specified")); + return false; + } + + try { + String path = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(symbolsFileName.getText().trim()); + IPath filePath = new Path(path); + if (!filePath.toFile().exists()) { + setErrorMessage(Messages.getString("GDBJtagStartupTab.symbolsFileName_does_not_exist")); + return false; + } + } catch (CoreException e) { // string substitution throws this if expression doesn't resolve setErrorMessage(Messages.getString("GDBJtagStartupTab.symbolsFileName_does_not_exist")); return false; } - } catch (CoreException e) { - Activator.getDefault().getLog().log(e.getStatus()); } } else { setErrorMessage(null); @@ -540,72 +616,135 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab { } /* (non-Javadoc) - * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog() + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) */ -// protected void updateLaunchConfigurationDialog() { -// super.updateLaunchConfigurationDialog(); -// isValid(getLaunchConfigurationDialog()); -// } - public void initializeFrom(ILaunchConfiguration configuration) { try { - initCommands.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_INIT_COMMANDS, "")); //$NON-NLS-1$ + // Initialization Commands doReset.setSelection(configuration.getAttribute(IGDBJtagConstants.ATTR_DO_RESET, IGDBJtagConstants.DEFAULT_DO_RESET)); - doResetChanged(); - doHalt.setSelection(configuration.getAttribute(IGDBJtagConstants.ATTR_DO_HALT, IGDBJtagConstants.DEFAULT_DO_HALT)); delay.setText(String.valueOf(configuration.getAttribute(IGDBJtagConstants.ATTR_DELAY, IGDBJtagConstants.DEFAULT_DELAY))); + doHalt.setSelection(configuration.getAttribute(IGDBJtagConstants.ATTR_DO_HALT, IGDBJtagConstants.DEFAULT_DO_HALT)); + initCommands.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_INIT_COMMANDS, IGDBJtagConstants.DEFAULT_INIT_COMMANDS)); + + // Load Image... loadImage.setSelection(configuration.getAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, IGDBJtagConstants.DEFAULT_LOAD_IMAGE)); - loadImageChanged(); - String defaultImageFileName = configuration.getAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, ""); //$NON-NLS-1$ - if (defaultImageFileName.equals("")) { - defaultImageFileName = configuration.getWorkingCopy().getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""); //$NON-NLS-1$ - } - imageFileName.setText(defaultImageFileName); - imageOffset.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, "")); //$NON-NLS-1$ + useProjectBinaryForImage.setSelection(configuration.getAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_IMAGE, IGDBJtagConstants.DEFAULT_USE_PROJ_BINARY_FOR_IMAGE)); + useFileForImage.setSelection(configuration.getAttribute(IGDBJtagConstants.ATTR_USE_FILE_FOR_IMAGE, IGDBJtagConstants.DEFAULT_USE_FILE_FOR_IMAGE)); + imageFileName.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, IGDBJtagConstants.DEFAULT_IMAGE_FILE_NAME)); + imageOffset.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, IGDBJtagConstants.DEFAULT_IMAGE_OFFSET)); + + //.. and Symbols loadSymbols.setSelection(configuration.getAttribute(IGDBJtagConstants.ATTR_LOAD_SYMBOLS, IGDBJtagConstants.DEFAULT_LOAD_SYMBOLS)); - loadSymbolsChanged(); - symbolsFileName.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_FILE_NAME, "")); //$NON-NLS-1$ - symbolsOffset.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_OFFSET, "")); //$NON-NLS-1$ + useProjectBinaryForSymbols.setSelection(configuration.getAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_SYMBOLS, IGDBJtagConstants.DEFAULT_USE_PROJ_BINARY_FOR_SYMBOLS)); + useFileForSymbols.setSelection(configuration.getAttribute(IGDBJtagConstants.ATTR_USE_FILE_FOR_SYMBOLS, IGDBJtagConstants.DEFAULT_USE_FILE_FOR_SYMBOLS)); + symbolsFileName.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_FILE_NAME, IGDBJtagConstants.DEFAULT_SYMBOLS_FILE_NAME)); + symbolsOffset.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_OFFSET, IGDBJtagConstants.DEFAULT_SYMBOLS_OFFSET)); + + // Runtime Options setPcRegister.setSelection(configuration.getAttribute(IGDBJtagConstants.ATTR_SET_PC_REGISTER, IGDBJtagConstants.DEFAULT_SET_PC_REGISTER)); - pcRegisterChanged(); - pcRegister.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_PC_REGISTER, "")); //$NON-NLS-1$ + pcRegister.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_PC_REGISTER, IGDBJtagConstants.DEFAULT_PC_REGISTER)); setStopAt.setSelection(configuration.getAttribute(IGDBJtagConstants.ATTR_SET_STOP_AT, IGDBJtagConstants.DEFAULT_SET_STOP_AT)); - stopAtChanged(); - stopAt.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_STOP_AT, "")); //$NON-NLS-1$ + stopAt.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_STOP_AT, IGDBJtagConstants.DEFAULT_STOP_AT)); setResume.setSelection(configuration.getAttribute(IGDBJtagConstants.ATTR_SET_RESUME, IGDBJtagConstants.DEFAULT_SET_RESUME)); + + // Run Commands + runCommands.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_RUN_COMMANDS, IGDBJtagConstants.DEFAULT_RUN_COMMANDS)); + + String programName = CDebugUtils.getProgramName(configuration); + if (programName != null) { + int lastSlash = programName.indexOf('\\'); + if (lastSlash >= 0) { + programName = programName.substring(lastSlash + 1); + } + lastSlash = programName.indexOf('/'); + if (lastSlash >= 0) { + programName = programName.substring(lastSlash + 1); + } + projBinaryLabel1.setText(programName); + projBinaryLabel2.setText(programName); + } + + doResetChanged(); + loadImageChanged(); + loadSymbolsChanged(); + pcRegisterChanged(); + stopAtChanged(); resumeChanged(); - runCommands.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_RUN_COMMANDS, "")); //$NON-NLS-1$) + updateUseFileEnablement(); + } catch (CoreException e) { Activator.getDefault().getLog().log(e.getStatus()); } } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ public void performApply(ILaunchConfigurationWorkingCopy configuration) { - configuration.setAttribute(IGDBJtagConstants.ATTR_INIT_COMMANDS, initCommands.getText()); - configuration.setAttribute(IGDBJtagConstants.ATTR_DELAY, Integer.parseInt(delay.getText())); + + // Initialization Commands configuration.setAttribute(IGDBJtagConstants.ATTR_DO_RESET, doReset.getSelection()); + configuration.setAttribute(IGDBJtagConstants.ATTR_DELAY, Integer.parseInt(delay.getText())); configuration.setAttribute(IGDBJtagConstants.ATTR_DO_HALT, doHalt.getSelection()); + configuration.setAttribute(IGDBJtagConstants.ATTR_INIT_COMMANDS, initCommands.getText()); + + // Load Image... configuration.setAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, loadImage.getSelection()); + configuration.setAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_IMAGE, useProjectBinaryForImage.getSelection()); + configuration.setAttribute(IGDBJtagConstants.ATTR_USE_FILE_FOR_IMAGE, useFileForImage.getSelection()); configuration.setAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, imageFileName.getText().trim()); configuration.setAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, imageOffset.getText()); + + //.. and Symbols configuration.setAttribute(IGDBJtagConstants.ATTR_LOAD_SYMBOLS, loadSymbols.getSelection()); - configuration.setAttribute(IGDBJtagConstants.ATTR_SYMBOLS_OFFSET, symbolsOffset.getText()); + configuration.setAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_SYMBOLS, useProjectBinaryForSymbols.getSelection()); + configuration.setAttribute(IGDBJtagConstants.ATTR_USE_FILE_FOR_SYMBOLS, useFileForSymbols.getSelection()); configuration.setAttribute(IGDBJtagConstants.ATTR_SYMBOLS_FILE_NAME, symbolsFileName.getText().trim()); + configuration.setAttribute(IGDBJtagConstants.ATTR_SYMBOLS_OFFSET, symbolsOffset.getText()); + + // Runtime Options configuration.setAttribute(IGDBJtagConstants.ATTR_SET_PC_REGISTER, setPcRegister.getSelection()); configuration.setAttribute(IGDBJtagConstants.ATTR_PC_REGISTER, pcRegister.getText()); configuration.setAttribute(IGDBJtagConstants.ATTR_SET_STOP_AT, setStopAt.getSelection()); configuration.setAttribute(IGDBJtagConstants.ATTR_STOP_AT, stopAt.getText()); configuration.setAttribute(IGDBJtagConstants.ATTR_SET_RESUME, setResume.getSelection()); + + // Run Commands configuration.setAttribute(IGDBJtagConstants.ATTR_RUN_COMMANDS, runCommands.getText()); } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { - configuration.setAttribute(IGDBJtagConstants.ATTR_INIT_COMMANDS, ""); //$NON-NLS-1$ - configuration.setAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, IGDBJtagConstants.DEFAULT_LOAD_IMAGE); - configuration.setAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, ""); //$NON-NLS-1$ - configuration.setAttribute(IGDBJtagConstants.ATTR_RUN_COMMANDS, ""); //$NON-NLS-1$ - configuration.setAttribute(IGDBJtagConstants.ATTR_DO_RESET, true); - configuration.setAttribute(IGDBJtagConstants.ATTR_DO_HALT, true); - } + // Initialization Commands + configuration.setAttribute(IGDBJtagConstants.ATTR_DO_RESET, IGDBJtagConstants.DEFAULT_DO_RESET); + configuration.setAttribute(IGDBJtagConstants.ATTR_DELAY, IGDBJtagConstants.DEFAULT_DELAY); + configuration.setAttribute(IGDBJtagConstants.ATTR_DO_HALT, IGDBJtagConstants.DEFAULT_DO_HALT); + configuration.setAttribute(IGDBJtagConstants.ATTR_INIT_COMMANDS, IGDBJtagConstants.DEFAULT_INIT_COMMANDS); + // Load Image... + configuration.setAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, IGDBJtagConstants.DEFAULT_LOAD_IMAGE); + configuration.setAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_IMAGE, IGDBJtagConstants.DEFAULT_USE_PROJ_BINARY_FOR_IMAGE); + configuration.setAttribute(IGDBJtagConstants.ATTR_USE_FILE_FOR_IMAGE, IGDBJtagConstants.DEFAULT_USE_FILE_FOR_IMAGE); + configuration.setAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, IGDBJtagConstants.DEFAULT_IMAGE_FILE_NAME); + configuration.setAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, IGDBJtagConstants.DEFAULT_IMAGE_OFFSET); + + //.. and Symbols + configuration.setAttribute(IGDBJtagConstants.ATTR_LOAD_SYMBOLS, IGDBJtagConstants.DEFAULT_LOAD_SYMBOLS); + configuration.setAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_SYMBOLS, IGDBJtagConstants.DEFAULT_USE_PROJ_BINARY_FOR_SYMBOLS); + configuration.setAttribute(IGDBJtagConstants.ATTR_USE_FILE_FOR_SYMBOLS, IGDBJtagConstants.DEFAULT_USE_FILE_FOR_SYMBOLS); + configuration.setAttribute(IGDBJtagConstants.ATTR_SYMBOLS_FILE_NAME, IGDBJtagConstants.DEFAULT_SYMBOLS_FILE_NAME); + configuration.setAttribute(IGDBJtagConstants.ATTR_SYMBOLS_OFFSET, IGDBJtagConstants.DEFAULT_SYMBOLS_OFFSET); + + // Runtime Options + configuration.setAttribute(IGDBJtagConstants.ATTR_SET_PC_REGISTER, IGDBJtagConstants.DEFAULT_SET_PC_REGISTER); + configuration.setAttribute(IGDBJtagConstants.ATTR_PC_REGISTER, IGDBJtagConstants.DEFAULT_PC_REGISTER); + configuration.setAttribute(IGDBJtagConstants.ATTR_SET_STOP_AT, IGDBJtagConstants.DEFAULT_SET_STOP_AT); + configuration.setAttribute(IGDBJtagConstants.ATTR_STOP_AT, IGDBJtagConstants.DEFAULT_STOP_AT); + configuration.setAttribute(IGDBJtagConstants.ATTR_SET_RESUME, IGDBJtagConstants.DEFAULT_SET_RESUME); + + // Run Commands + configuration.setAttribute(IGDBJtagConstants.ATTR_RUN_COMMANDS, IGDBJtagConstants.DEFAULT_RUN_COMMANDS); + } } diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/JtagUi.properties b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/JtagUi.properties index 999ee921d38..72b7724cc1e 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/JtagUi.properties +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/JtagUi.properties @@ -31,6 +31,9 @@ GDBJtagStartupTab.symbolsLabel_Text=Symbols file name: GDBJtagStartupTab.symbolsFileBrowseWs_Title=Select symbols file GDBJtagStartupTab.symbolsFileBrowse_Title=Select symbols file GDBJtagStartupTab.symbolsOffsetLabel_Text=Symbols offset (hex): +GDBJtagStartupTab.useProjectBinary_Label=Use project binary: +GDBJtagStartupTab.useFile_Label=Use file: +GDBJtagStartupTab.useProjectBinary_ToolTip=Use C/C++ application specified in the Main tab. GDBJtagStartupTab.runOptionGroup_Text=Runtime Options GDBJtagStartupTab.setPcRegister_Text=Set program counter at (hex): diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java index a080fbde0f1..1a46a467cf5 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java @@ -398,7 +398,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat */ @Deprecated protected IFile getProgramFile(ILaunchConfiguration config) throws CoreException { - ICProject cproject = verifyCProject(config); + ICProject cproject = CDebugUtils.verifyCProject(config); String fileName = CDebugUtils.getProgramName(config); if (fileName == null) { abort(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$ @@ -417,62 +417,18 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat return programPath; } + /** + * @deprecated use {@link CDebugUtils#verifyCProject(ILaunchConfiguration)} + */ protected ICProject verifyCProject(ILaunchConfiguration config) throws CoreException { - String name = CDebugUtils.getProjectName(config); - if (name == null) { - abort(LaunchMessages.getString("AbstractCLaunchDelegate.C_Project_not_specified"), null, //$NON-NLS-1$ - ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT); - } - ICProject cproject = CDebugUtils.getCProject(config); - if (cproject == null) { - IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(name); - if (!proj.exists()) { - abort( - LaunchMessages.getFormattedString("AbstractCLaunchDelegate.Project_NAME_does_not_exist", name), null, //$NON-NLS-1$ - ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); - } else if (!proj.isOpen()) { - abort(LaunchMessages.getFormattedString("AbstractCLaunchDelegate.Project_NAME_is_closed", name), null, //$NON-NLS-1$ - ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); - } - abort(LaunchMessages.getString("AbstractCLaunchDelegate.Not_a_C_CPP_project"), null, //$NON-NLS-1$ - ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); - } - return cproject; + return CDebugUtils.verifyCProject(config); } + /** + * @deprecated use {@link CDebugUtils#verifyProgramPath(ILaunchConfiguration) + */ protected IPath verifyProgramPath(ILaunchConfiguration config) throws CoreException { - ICProject cproject = verifyCProject(config); - IPath programPath = CDebugUtils.getProgramPath(config); - if (programPath == null || programPath.isEmpty()) { - abort(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$ - ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM); - } - if (!programPath.isAbsolute()) { - IPath location = cproject.getProject().getLocation(); - if (location != null) { - programPath = location.append(programPath); - if (!programPath.toFile().exists()) { - // Try the old way, which is required to support linked resources. - IFile projFile = null; - try { - projFile = project.getFile(CDebugUtils.getProgramPath(config)); - } - catch (IllegalArgumentException exc) {} // thrown if relative path that resolves to a root file (e.g., "..\somefile") - if (projFile != null && projFile.exists()) { - programPath = projFile.getLocation(); - } - } - } - } - if (!programPath.toFile().exists()) { - abort( - LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_does_not_exist"), //$NON-NLS-1$ - new FileNotFoundException( - LaunchMessages.getFormattedString( - "AbstractCLaunchDelegate.PROGRAM_PATH_not_found", programPath.toOSString())), //$NON-NLS-1$ - ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST); - } - return programPath; + return CDebugUtils.verifyProgramPath(config); } protected IPath verifyProgramFile(ILaunchConfiguration config) throws CoreException { diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java index 6ea910f8d43..2611fa47ce9 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java @@ -53,8 +53,8 @@ public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate { } try { monitor.worked(1); - IPath exePath = verifyProgramPath(config); - ICProject project = verifyCProject(config); + IPath exePath = CDebugUtils.verifyProgramPath(config); + ICProject project = CDebugUtils.verifyCProject(config); IBinaryObject exeFile = verifyBinary(project, exePath); ICDebugConfiguration debugConfig = getDebugConfig(config); diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java index 77d17eb9692..d0059c9267b 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 QNX Software Systems and others. + * Copyright (c) 2004, 2010 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 @@ -62,7 +62,7 @@ public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate { } try { monitor.worked(1); - ICProject cproject = verifyCProject(config); + ICProject cproject = CDebugUtils.verifyCProject(config); IPath exePath = CDebugUtils.getProgramPath(config); if (exePath != null && !exePath.isEmpty()) { if (!exePath.isAbsolute()) { diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalCDILaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalCDILaunchDelegate.java index 4ad47f58513..c0effdd5792 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalCDILaunchDelegate.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalCDILaunchDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 QNX Software Systems and others. + * Copyright (c) 2004, 2010 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 @@ -23,6 +23,7 @@ import org.eclipse.cdt.core.IProcessList; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.debug.core.CDIDebugModel; +import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.ICDIDebugger; import org.eclipse.cdt.debug.core.ICDIDebugger2; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; @@ -80,7 +81,7 @@ public class LocalCDILaunchDelegate extends AbstractCLaunchDelegate { } monitor.worked( 1 ); try { - IPath exePath = verifyProgramPath( config ); + IPath exePath = CDebugUtils.verifyProgramPath( config ); File wd = getWorkingDirectory( config ); if ( wd == null ) { wd = new File( System.getProperty( "user.home", "." ) ); //$NON-NLS-1$ //$NON-NLS-2$ @@ -130,8 +131,8 @@ public class LocalCDILaunchDelegate extends AbstractCLaunchDelegate { monitor.subTask( LaunchMessages.getString( "LocalCDILaunchDelegate.2" ) ); //$NON-NLS-1$ ICDISession dsession = null; try { - IPath exePath = verifyProgramPath( config ); - ICProject project = verifyCProject( config ); + IPath exePath = CDebugUtils.verifyProgramPath( config ); + ICProject project = CDebugUtils.verifyCProject( config ); IBinaryObject exeFile = null; if ( exePath != null ) { exeFile = verifyBinary( project, exePath ); @@ -201,11 +202,11 @@ public class LocalCDILaunchDelegate extends AbstractCLaunchDelegate { } cancel( "", -1 ); //$NON-NLS-1$ } - IPath exePath = verifyProgramPath( config ); + IPath exePath = CDebugUtils.verifyProgramPath( config ); if (exePath == null) { exePath= getProgramPathForPid(pid); } - ICProject project = verifyCProject( config ); + ICProject project = CDebugUtils.verifyCProject( config ); IBinaryObject exeFile = null; if ( exePath != null ) { exeFile = verifyBinary( project, exePath ); @@ -273,7 +274,7 @@ public class LocalCDILaunchDelegate extends AbstractCLaunchDelegate { ICDebugConfiguration debugConfig = getDebugConfig( config ); String path = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, (String)null ); if ( path == null || path.length() == 0) { - ICProject project = verifyCProject( config ); + ICProject project = CDebugUtils.verifyCProject( config ); IPath corefile = promptForCoreFilePath( (IProject)project.getResource(), debugConfig ); if ( corefile == null ) { cancel( LaunchMessages.getString( "LocalCDILaunchDelegate.6" ), ICDTLaunchConfigurationConstants.ERR_NO_COREFILE ); //$NON-NLS-1$ @@ -289,8 +290,8 @@ public class LocalCDILaunchDelegate extends AbstractCLaunchDelegate { cancel( "", -1 ); //$NON-NLS-1$ } - IPath exePath = verifyProgramPath( config ); - ICProject project = verifyCProject( config ); + IPath exePath = CDebugUtils.verifyProgramPath( config ); + ICProject project = CDebugUtils.verifyCProject( config ); IBinaryObject exeFile = null; if ( exePath != null ) { exeFile = verifyBinary( project, exePath ); @@ -329,8 +330,8 @@ public class LocalCDILaunchDelegate extends AbstractCLaunchDelegate { private ICDISession launchOldDebugSession( ILaunchConfiguration config, ILaunch launch, ICDIDebugger debugger, IProgressMonitor monitor ) throws CoreException { IBinaryObject exeFile = null; - IPath exePath = verifyProgramPath( config ); - ICProject project = verifyCProject( config ); + IPath exePath = CDebugUtils.verifyProgramPath( config ); + ICProject project = CDebugUtils.verifyCProject( config ); if ( exePath != null ) { exeFile = verifyBinary( project, exePath ); } @@ -338,7 +339,7 @@ public class LocalCDILaunchDelegate extends AbstractCLaunchDelegate { } private ICDISession launchDebugSession( ILaunchConfiguration config, ILaunch launch, ICDIDebugger2 debugger, IProgressMonitor monitor ) throws CoreException { - IPath path = verifyProgramPath( config ); + IPath path = CDebugUtils.verifyProgramPath( config ); File exeFile = path != null ? path.toFile() : null; return debugger.createSession( launch, exeFile, monitor ); } diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java index 0647770fb82..31713ce452c 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 QNX Software Systems and others. + * Copyright (c) 2005, 2010 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 @@ -18,6 +18,7 @@ import java.util.Arrays; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.debug.core.CDIDebugModel; +import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.core.cdi.CDIException; @@ -57,8 +58,8 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate { } try { monitor.worked(1); - IPath exePath = verifyProgramPath(config); - ICProject project = verifyCProject(config); + IPath exePath = CDebugUtils.verifyProgramPath(config); + ICProject project = CDebugUtils.verifyCProject(config); if (exePath != null) { exeFile = verifyBinary(project, exePath); }