1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

- Update to new ICDIDebugger interface deprecating old

- Added seperate launch configuration for attaching to pid
This commit is contained in:
David Inglis 2004-10-18 14:48:50 +00:00
parent 206203d375
commit a192c2f172
40 changed files with 1898 additions and 1329 deletions

View file

@ -1,3 +1,20 @@
2004-10-18 David Inglis
Update to new ICDIDebugger interface deprecating old
* src/org/eclipse/debug/core/CDebugModel.java
* src/org/eclipse/debug/core/CDIDebugModel.java
* src/org/eclipse/debug/core/ICDebugConfiguration.java
* src/org/eclipse/debug/core/ICDebugger.java
* src/org/eclipse/debug/core/ICDIDebugger.java
* src/org/eclipse/debug/core/ICDILaunchCOnfiguration.java
* src/org/eclipse/debug/core/model/IExecFileInfo.java
* src/org/eclipse/debug/internal/core/CBreakpointManager.java
* src/org/eclipse/debug/internal/core/CDebugAdapter.java
* src/org/eclipse/debug/internal/core/DebugConfiguration.java
* src/org/eclipse/debug/internal/core/model/CDebugTarget.java
* src/org/eclipse/debug/internal/core/model/CVariableFactory.java
* src/org/eclipse/debug/internal/core/model/DisassemblyBlock.java
2004-10-18 Mikhail Khodjaiants 2004-10-18 Mikhail Khodjaiants
Use characters instead of strings. Use characters instead of strings.
* CDIException.java * CDIException.java
@ -18,7 +35,7 @@
* CBreakpointManager.java * CBreakpointManager.java
* CDebugTarget.java * CDebugTarget.java
2004-10-14 2004-10-14 Mikhail Khodjaiants
Partial fix for bug 39936 GDB hits modified conditional breakpoints when condition not satisfied. Partial fix for bug 39936 GDB hits modified conditional breakpoints when condition not satisfied.
Condition has to be set at the mi level. Condition has to be set at the mi level.
* CBreakpointManager.java * CBreakpointManager.java

View file

@ -7,21 +7,23 @@
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.debug.core; package org.eclipse.cdt.debug.core;
import java.io.IOException;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.HashMap; import java.util.HashMap;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration; import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
import org.eclipse.cdt.debug.core.cdi.ICDILocation; import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.ICDISessionObject;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent;
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression; import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
@ -37,12 +39,12 @@ import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint;
import org.eclipse.cdt.debug.internal.core.model.CCoreFileDebugTarget;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget; import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.cdt.debug.internal.core.model.CExpression; import org.eclipse.cdt.debug.internal.core.model.CExpression;
import org.eclipse.cdt.debug.internal.core.model.CVariableFactory; import org.eclipse.cdt.debug.internal.core.model.CVariableFactory;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
@ -61,333 +63,302 @@ import org.eclipse.debug.core.model.IExpression;
import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IProcess;
/** /**
* Provides utility methods for creating debug sessions, targets and * Provides utility methods for creating debug sessions, targets and breakpoints
* breakpoints specific to the CDI debug model. * specific to the CDI debug model.
*/ */
public class CDIDebugModel { public class CDIDebugModel {
/** /**
* Returns the identifier for the CDI debug model plug-in * Returns the identifier for the CDI debug model plug-in
* *
* @return plugin identifier * @return plugin identifier
*/ */
public static String getPluginIdentifier() { public static String getPluginIdentifier() {
return CDebugCorePlugin.getUniqueIdentifier(); return CDebugCorePlugin.getUniqueIdentifier();
} }
/** /**
* Creates and returns a debug target for the given CDI target, * Creates and returns a debug target for the given CDI target, with the
* with the specified name, and associates it with the given process for console * specified name, and associates it with the given process for console I/O.
* I/O. The allow terminate flag specifies whether the debug target will support
* termination (<code>ITerminate</code>). The allow disconnect flag
* specifies whether the debug target will support disconnection
* (<code>IDisconnect</code>). The resume flag specifies if the target
* process should be resumed on startup.
* The debug target is added to the given launch. * The debug target is added to the given launch.
* *
* @param launch the launch the new debug target will be contained in * @param launch
* @param cdiTarget the CDI target to create a debug target for * the launch the new debug target will be contained in
* @param name the name to associate with this target, which will be returned from <code>IDebugTarget.getName</code>. * @param project
* @param debuggeeProcess the process to associate with the debug target, which will be returned from <code>IDebugTarget.getProcess</code> * the project to use to persist breakpoints.
* @param debuggerProcess the process to associate with the debugger. * @param cdiTarget
* @param file the executable to debug. * the CDI target to create a debug target for
* @param allowTerminate whether the target will support termianation * @param name
* @param allowDisconnect whether the target will support disconnection * the name to associate with this target, which will be returned
* @param stopInMain whether to set a temporary breakpoint in main. * from <code>IDebugTarget.getName</code>.
* @param debuggeeProcess
* the process to associate with the debug target, which will be
* returned from <code>IDebugTarget.getProcess</code>
* @param file
* the executable to debug.
* @return a debug target * @return a debug target
* @throws DebugException * @throws DebugException
*
*/ */
public static IDebugTarget newDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggeeProcess, final IProcess debuggerProcess, final IFile file, final boolean allowTerminate, final boolean allowDisconnect, final boolean stopInMain ) throws DebugException { public static IDebugTarget newDebugTarget(final ILaunch launch, final IProject project, final ICDITarget cdiTarget,
final String name, final IProcess debuggeeProcess, final IBinaryExecutable file, final boolean allowTerminate,
final boolean allowDisconnect, final boolean stopInMain) throws DebugException {
final IDebugTarget[] target = new IDebugTarget[1]; final IDebugTarget[] target = new IDebugTarget[1];
IWorkspaceRunnable r = new IWorkspaceRunnable() { IWorkspaceRunnable r = new IWorkspaceRunnable() {
public void run( IProgressMonitor m ) throws CoreException { public void run(IProgressMonitor m) throws CoreException {
target[0] = new CDebugTarget( launch, cdiTarget, name, debuggeeProcess, debuggerProcess, file, allowTerminate, allowDisconnect ); boolean stopInMain = launch.getLaunchConfiguration().getAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN,
false);
target[0] = new CDebugTarget(launch, project, cdiTarget, name, debuggeeProcess, file, allowTerminate,
allowDisconnect);
ICDIConfiguration config = cdiTarget.getSession().getConfiguration(); ICDIConfiguration config = cdiTarget.getSession().getConfiguration();
if ( config.supportsBreakpoints() && stopInMain ) { if (config.supportsBreakpoints() && stopInMain) {
stopInMain( (CDebugTarget)target[0] ); stopInMain((CDebugTarget)target[0]);
} }
if ( config.supportsResume() ) { if (config.supportsResume()) {
target[0].resume(); target[0].resume();
} }
} }
}; };
try { try {
ResourcesPlugin.getWorkspace().run( r, null ); ResourcesPlugin.getWorkspace().run(r, null);
} } catch (CoreException e) {
catch( CoreException e ) { CDebugCorePlugin.log(e);
CDebugCorePlugin.log( e ); throw new DebugException(e.getStatus());
throw new DebugException( e.getStatus() );
} }
return target[0]; return target[0];
} }
/** public static IDebugTarget newDebugTarget(ILaunch launch, IProject project, ICDITarget cdiTarget, final String name,
* Creates and returns an attached debug target for the given CDI target, IProcess debuggeeProcess, IBinaryExecutable file, boolean allowTerminate, boolean allowDisconnect)
* with the specified name. throws DebugException {
* return newDebugTarget(launch, project, cdiTarget, name, debuggeeProcess, file, allowTerminate, allowDisconnect, false);
* @param launch the launch the new debug target will be contained in
* @param cdiTarget the CDI target to create a debug target for
* @param name the name to associate with this target, which will be returned from <code>IDebugTarget.getName</code>.
* @param debuggerProcess the process to associate with the debugger.
* @param file the executable to debug.
* @return a debug target
* @throws DebugException
*/
public static IDebugTarget newAttachDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggerProcess, final IFile file ) throws DebugException {
final IDebugTarget[] target = new IDebugTarget[1];
IWorkspaceRunnable r = new IWorkspaceRunnable() {
public void run( IProgressMonitor m ) throws CoreException {
target[0] = new CDebugTarget( launch, cdiTarget, name, null, debuggerProcess, file, false, true );
ICDIEvent[] events = new ICDIEvent[]{ new ICDISuspendedEvent() {
public ICDISessionObject getReason() {
return null;
}
public ICDIObject getSource() {
return cdiTarget;
}
} };
((CDebugTarget)target[0]).handleDebugEvents( events );
}
};
try {
ResourcesPlugin.getWorkspace().run( r, null );
}
catch( CoreException e ) {
CDebugCorePlugin.log( e );
throw new DebugException( e.getStatus() );
}
return target[0];
} }
/** /**
* Creates and returns a post-mortem debug target for the given CDI target, * Creates and returns a line breakpoint for the source defined by the given
* with the specified name. * source handle, at the given line number. The marker associated with the
* breakpoint will be created on the specified resource.
* *
* @param launch the launch the new debug target will be contained in * @param sourceHandle
* @param cdiTarget the CDI target to create a debug target for * the handle to the breakpoint source
* @param name the name to associate with this target, which will be returned from <code>IDebugTarget.getName</code>. * @param resource
* @param debuggerProcess the process to associate with the debugger. * the resource on which to create the associated breakpoint
* @param file the executable to debug. * marker
* @return a debug target * @param lineNumber
* @throws DebugException * the line number on which the breakpoint is set - line numbers
*/ * are 1 based, associated with the source file in which the
public static IDebugTarget newCoreFileDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggerProcess, final IFile file ) throws DebugException { * breakpoint is set
final IDebugTarget[] target = new IDebugTarget[1]; * @param enabled
IWorkspaceRunnable r = new IWorkspaceRunnable() { * whether to enable or disable this breakpoint
* @param ignoreCount
public void run( IProgressMonitor m ) throws CoreException { * the number of times this breakpoint will be ignored
target[0] = new CCoreFileDebugTarget( launch, cdiTarget, name, debuggerProcess, file ); * @param condition
ICDIEvent[] events = new ICDIEvent[]{ new ICDISuspendedEvent() { * the breakpoint condition
* @param register
public ICDISessionObject getReason() { * whether to add this breakpoint to the breakpoint manager
return null;
}
public ICDIObject getSource() {
return cdiTarget;
}
} };
((CDebugTarget)target[0]).handleDebugEvents( events );
}
};
try {
ResourcesPlugin.getWorkspace().run( r, null );
}
catch( CoreException e ) {
CDebugCorePlugin.log( e );
throw new DebugException( e.getStatus() );
}
return target[0];
}
/**
* Creates and returns a line breakpoint for the source defined by
* the given source handle, at the given line number. The marker associated
* with the breakpoint will be created on the specified resource.
*
* @param sourceHandle the handle to the breakpoint source
* @param resource the resource on which to create the associated breakpoint marker
* @param lineNumber the line number on which the breakpoint is set - line
* numbers are 1 based, associated with the source file in which the breakpoint is set
* @param enabled whether to enable or disable this breakpoint
* @param ignoreCount the number of times this breakpoint will be ignored
* @param condition the breakpoint condition
* @param register whether to add this breakpoint to the breakpoint manager
* @return a line breakpoint * @return a line breakpoint
* @throws CoreException if this method fails. Reasons include:<ul> * @throws CoreException
* <li>Failure creating underlying marker. The exception's status contains * if this method fails. Reasons include:
* the underlying exception responsible for the failure.</li></ul> * <ul>
* <li>Failure creating underlying marker. The exception's
* status contains the underlying exception responsible for the
* failure.</li>
* </ul>
*/ */
public static ICLineBreakpoint createLineBreakpoint( String sourceHandle, public static ICLineBreakpoint createLineBreakpoint(String sourceHandle, IResource resource, int lineNumber, boolean enabled,
IResource resource, int ignoreCount, String condition, boolean register) throws CoreException {
int lineNumber, HashMap attributes = new HashMap(10);
boolean enabled, attributes.put(IBreakpoint.ID, getPluginIdentifier());
int ignoreCount, attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
String condition, attributes.put(IBreakpoint.ENABLED, new Boolean(enabled));
boolean register ) throws CoreException { attributes.put(ICBreakpoint.IGNORE_COUNT, new Integer(ignoreCount));
HashMap attributes = new HashMap( 10 ); attributes.put(ICBreakpoint.CONDITION, condition);
attributes.put( IBreakpoint.ID, getPluginIdentifier() ); attributes.put(ICBreakpoint.SOURCE_HANDLE, sourceHandle);
attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) ); return new CLineBreakpoint(resource, attributes, register);
attributes.put( IBreakpoint.ENABLED, new Boolean( enabled ) );
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
attributes.put( ICBreakpoint.CONDITION, condition );
attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
return new CLineBreakpoint( resource, attributes, register );
} }
/** /**
* Creates and returns an address breakpoint for the source defined by * Creates and returns an address breakpoint for the source defined by the
* the given source handle, at the given address. The marker associated * given source handle, at the given address. The marker associated with the
* with the breakpoint will be created on the specified resource. * breakpoint will be created on the specified resource.
*
* @param sourceHandle the handle to the breakpoint source
* @param resource the resource on which to create the associated breakpoint marker
* @param address the address on which the breakpoint is set
* @param enabled whether to enable or disable this breakpoint
* @param ignoreCount the number of times this breakpoint will be ignored
* @param condition the breakpoint condition
* @param register whether to add this breakpoint to the breakpoint manager
* @return an address breakpoint
* @throws CoreException if this method fails. Reasons include:<ul>
* <li>Failure creating underlying marker. The exception's status contains
* the underlying exception responsible for the failure.</li></ul>
*/
public static ICAddressBreakpoint createAddressBreakpoint( String sourceHandle,
IResource resource,
IAddress address,
boolean enabled,
int ignoreCount,
String condition,
boolean register ) throws CoreException {
HashMap attributes = new HashMap( 10 );
attributes.put( IBreakpoint.ID, getPluginIdentifier() );
attributes.put( IMarker.CHAR_START, new Integer( 0 ) );
attributes.put( IMarker.CHAR_END, new Integer( 0 ) );
attributes.put( IMarker.LINE_NUMBER, new Integer( -1 ) );
attributes.put( IMarker.LINE_NUMBER, new Integer( -1 ) );
attributes.put( ICLineBreakpoint.ADDRESS, address.toHexAddressString() );
attributes.put( IBreakpoint.ENABLED, new Boolean( enabled ) );
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
attributes.put( ICBreakpoint.CONDITION, condition );
attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
return new CAddressBreakpoint( resource, attributes, register );
}
/**
* Creates and returns a watchpoint for the source defined by
* the given source handle, at the given expression. The marker associated
* with the watchpoint will be created on the specified resource.
* *
* @param sourceHandle the handle to the watchpoint source * @param sourceHandle
* @param resource the resource on which to create the associated watchpoint marker * the handle to the breakpoint source
* @param writeAccess whether this is write watchpoint * @param resource
* @param readAccess whether this is read watchpoint * the resource on which to create the associated breakpoint
* @param expression the expression on which the watchpoint is set * marker
* @param enabled whether to enable or disable this breakpoint * @param address
* @param ignoreCount the number of times this breakpoint will be ignored * the address on which the breakpoint is set
* @param condition the breakpoint condition * @param enabled
* @param register whether to add this breakpoint to the breakpoint manager * whether to enable or disable this breakpoint
* @param ignoreCount
* the number of times this breakpoint will be ignored
* @param condition
* the breakpoint condition
* @param register
* whether to add this breakpoint to the breakpoint manager
* @return an address breakpoint
* @throws CoreException
* if this method fails. Reasons include:
* <ul>
* <li>Failure creating underlying marker. The exception's
* status contains the underlying exception responsible for the
* failure.</li>
* </ul>
*/
public static ICAddressBreakpoint createAddressBreakpoint(String sourceHandle, IResource resource, IAddress address,
boolean enabled, int ignoreCount, String condition, boolean register) throws CoreException {
HashMap attributes = new HashMap(10);
attributes.put(IBreakpoint.ID, getPluginIdentifier());
attributes.put(IMarker.CHAR_START, new Integer(0));
attributes.put(IMarker.CHAR_END, new Integer(0));
attributes.put(IMarker.LINE_NUMBER, new Integer(-1));
attributes.put(IMarker.LINE_NUMBER, new Integer(-1));
attributes.put(ICLineBreakpoint.ADDRESS, address.toHexAddressString());
attributes.put(IBreakpoint.ENABLED, new Boolean(enabled));
attributes.put(ICBreakpoint.IGNORE_COUNT, new Integer(ignoreCount));
attributes.put(ICBreakpoint.CONDITION, condition);
attributes.put(ICBreakpoint.SOURCE_HANDLE, sourceHandle);
return new CAddressBreakpoint(resource, attributes, register);
}
/**
* Creates and returns a watchpoint for the source defined by the given
* source handle, at the given expression. The marker associated with the
* watchpoint will be created on the specified resource.
*
* @param sourceHandle
* the handle to the watchpoint source
* @param resource
* the resource on which to create the associated watchpoint
* marker
* @param writeAccess
* whether this is write watchpoint
* @param readAccess
* whether this is read watchpoint
* @param expression
* the expression on which the watchpoint is set
* @param enabled
* whether to enable or disable this breakpoint
* @param ignoreCount
* the number of times this breakpoint will be ignored
* @param condition
* the breakpoint condition
* @param register
* whether to add this breakpoint to the breakpoint manager
* @return a watchpoint * @return a watchpoint
* @throws CoreException if this method fails. Reasons include:<ul> * @throws CoreException
* <li>Failure creating underlying marker. The exception's status contains * if this method fails. Reasons include:
* the underlying exception responsible for the failure.</li></ul> * <ul>
* <li>Failure creating underlying marker. The exception's
* status contains the underlying exception responsible for the
* failure.</li>
* </ul>
*/ */
public static ICWatchpoint createWatchpoint( String sourceHandle, public static ICWatchpoint createWatchpoint(String sourceHandle, IResource resource, boolean writeAccess, boolean readAccess,
IResource resource, String expression, boolean enabled, int ignoreCount, String condition, boolean register) throws CoreException {
boolean writeAccess, HashMap attributes = new HashMap(10);
boolean readAccess, attributes.put(IBreakpoint.ID, getPluginIdentifier());
String expression, attributes.put(IBreakpoint.ENABLED, new Boolean(enabled));
boolean enabled, attributes.put(ICBreakpoint.IGNORE_COUNT, new Integer(ignoreCount));
int ignoreCount, attributes.put(ICBreakpoint.CONDITION, condition);
String condition, attributes.put(ICBreakpoint.SOURCE_HANDLE, sourceHandle);
boolean register ) throws CoreException { attributes.put(ICWatchpoint.EXPRESSION, expression);
HashMap attributes = new HashMap( 10 ); attributes.put(ICWatchpoint.READ, new Boolean(readAccess));
attributes.put( IBreakpoint.ID, getPluginIdentifier() ); attributes.put(ICWatchpoint.WRITE, new Boolean(writeAccess));
attributes.put( IBreakpoint.ENABLED, new Boolean( enabled ) ); return new CWatchpoint(resource, attributes, register);
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
attributes.put( ICBreakpoint.CONDITION, condition );
attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
attributes.put( ICWatchpoint.EXPRESSION, expression );
attributes.put( ICWatchpoint.READ, new Boolean( readAccess ) );
attributes.put( ICWatchpoint.WRITE, new Boolean( writeAccess ) );
return new CWatchpoint( resource, attributes, register );
} }
/** /**
* Creates and returns a breakpoint for the function defined by * Creates and returns a breakpoint for the function defined by the given
* the given name. The marker associated with the breakpoint will * name. The marker associated with the breakpoint will be created on the
* be created on the specified resource. * specified resource.
*
* @param sourceHandle the handle to the breakpoint source
* @param resource the resource on which to create the associated breakpoint marker
* @param function the name of the function this breakpoint suspends execution in
* @param charStart the first character index associated with the breakpoint,
* or -1 if unspecified, in the source file in which the breakpoint is set
* @param charEnd the last character index associated with the breakpoint,
* or -1 if unspecified, in the source file in which the breakpoint is set
* @param lineNumber the lineNumber on which the breakpoint is set, or -1 if
* unspecified - line numbers are 1 based, associated with the source file
* in which the breakpoint is set
* @param enabled whether to enable or disable this breakpoint
* @param ignoreCount the number of times this breakpoint will be ignored
* @param condition the breakpoint condition
* @param register whether to add this breakpoint to the breakpoint manager
* @return an address breakpoint
* @throws CoreException if this method fails. Reasons include:<ul>
* <li>Failure creating underlying marker. The exception's status contains
* the underlying exception responsible for the failure.</li></ul>
*/
public static ICFunctionBreakpoint createFunctionBreakpoint( String sourceHandle,
IResource resource,
String function,
int charStart,
int charEnd,
int lineNumber,
boolean enabled,
int ignoreCount,
String condition,
boolean register ) throws CoreException {
HashMap attributes = new HashMap( 10 );
attributes.put( IBreakpoint.ID, getPluginIdentifier() );
attributes.put( IMarker.CHAR_START, new Integer( charStart ) );
attributes.put( IMarker.CHAR_END, new Integer( charEnd ) );
attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
attributes.put( ICLineBreakpoint.FUNCTION, function );
attributes.put( IBreakpoint.ENABLED, new Boolean( enabled ) );
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
attributes.put( ICBreakpoint.CONDITION, condition );
attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
return new CFunctionBreakpoint( resource, attributes, register );
}
/**
* Returns the line breakpoint that is already registered with the breakpoint
* manager for a source with the given handle and the given resource at the
* given line number.
* *
* @param sourceHandle the source handle * @param sourceHandle
* @param resource the breakpoint resource * the handle to the breakpoint source
* @param lineNumber the line number * @param resource
* @return the line breakpoint that is already registered with the breakpoint * the resource on which to create the associated breakpoint
* manager or <code>null</code> if no such breakpoint is registered * marker
* @exception CoreException if unable to retrieve the associated marker * @param function
* attributes (line number). * the name of the function this breakpoint suspends execution in
* @param charStart
* the first character index associated with the breakpoint, or
* -1 if unspecified, in the source file in which the breakpoint
* is set
* @param charEnd
* the last character index associated with the breakpoint, or -1
* if unspecified, in the source file in which the breakpoint is
* set
* @param lineNumber
* the lineNumber on which the breakpoint is set, or -1 if
* unspecified - line numbers are 1 based, associated with the
* source file in which the breakpoint is set
* @param enabled
* whether to enable or disable this breakpoint
* @param ignoreCount
* the number of times this breakpoint will be ignored
* @param condition
* the breakpoint condition
* @param register
* whether to add this breakpoint to the breakpoint manager
* @return an address breakpoint
* @throws CoreException
* if this method fails. Reasons include:
* <ul>
* <li>Failure creating underlying marker. The exception's
* status contains the underlying exception responsible for the
* failure.</li>
* </ul>
*/ */
public static ICLineBreakpoint lineBreakpointExists( String sourceHandle, IResource resource, int lineNumber ) throws CoreException { public static ICFunctionBreakpoint createFunctionBreakpoint(String sourceHandle, IResource resource, String function,
int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, String condition, boolean register)
throws CoreException {
HashMap attributes = new HashMap(10);
attributes.put(IBreakpoint.ID, getPluginIdentifier());
attributes.put(IMarker.CHAR_START, new Integer(charStart));
attributes.put(IMarker.CHAR_END, new Integer(charEnd));
attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
attributes.put(ICLineBreakpoint.FUNCTION, function);
attributes.put(IBreakpoint.ENABLED, new Boolean(enabled));
attributes.put(ICBreakpoint.IGNORE_COUNT, new Integer(ignoreCount));
attributes.put(ICBreakpoint.CONDITION, condition);
attributes.put(ICBreakpoint.SOURCE_HANDLE, sourceHandle);
return new CFunctionBreakpoint(resource, attributes, register);
}
/**
* Returns the line breakpoint that is already registered with the
* breakpoint manager for a source with the given handle and the given
* resource at the given line number.
*
* @param sourceHandle
* the source handle
* @param resource
* the breakpoint resource
* @param lineNumber
* the line number
* @return the line breakpoint that is already registered with the
* breakpoint manager or <code>null</code> if no such breakpoint
* is registered
* @exception CoreException
* if unable to retrieve the associated marker attributes
* (line number).
*/
public static ICLineBreakpoint lineBreakpointExists(String sourceHandle, IResource resource, int lineNumber)
throws CoreException {
String modelId = getPluginIdentifier(); String modelId = getPluginIdentifier();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId ); IBreakpoint[] breakpoints = manager.getBreakpoints(modelId);
for( int i = 0; i < breakpoints.length; i++ ) { for (int i = 0; i < breakpoints.length; i++) {
if ( !(breakpoints[i] instanceof ICLineBreakpoint) ) { if (! (breakpoints[i] instanceof ICLineBreakpoint)) {
continue; continue;
} }
ICLineBreakpoint breakpoint = (ICLineBreakpoint)breakpoints[i]; ICLineBreakpoint breakpoint = (ICLineBreakpoint)breakpoints[i];
if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) { if (sourceHandle != null && sourceHandle.equals(breakpoint.getSourceHandle())) {
if ( breakpoint.getMarker().getResource().equals( resource ) ) { if (breakpoint.getMarker().getResource().equals(resource)) {
if ( breakpoint.getLineNumber() == lineNumber ) { if (breakpoint.getLineNumber() == lineNumber) {
return breakpoint; return breakpoint;
} }
} }
@ -398,31 +369,36 @@ public class CDIDebugModel {
/** /**
* Returns the watchpoint that is already registered with the breakpoint * Returns the watchpoint that is already registered with the breakpoint
* manager for a source with the given handle and the given resource at the * manager for a source with the given handle and the given resource at the
* given expression. * given expression.
* *
* @param sourceHandle the source handle * @param sourceHandle
* @param resource the breakpoint resource * the source handle
* @param expression the expression * @param resource
* the breakpoint resource
* @param expression
* the expression
* @return the watchpoint that is already registered with the breakpoint * @return the watchpoint that is already registered with the breakpoint
* manager or <code>null</code> if no such watchpoint is registered * manager or <code>null</code> if no such watchpoint is
* @exception CoreException if unable to retrieve the associated marker * registered
* attributes (line number). * @exception CoreException
* if unable to retrieve the associated marker attributes
* (line number).
*/ */
public static ICWatchpoint watchpointExists( String sourceHandle, IResource resource, String expression ) throws CoreException { public static ICWatchpoint watchpointExists(String sourceHandle, IResource resource, String expression) throws CoreException {
String modelId = getPluginIdentifier(); String modelId = getPluginIdentifier();
String markerType = CWatchpoint.getMarkerType(); String markerType = CWatchpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId ); IBreakpoint[] breakpoints = manager.getBreakpoints(modelId);
for( int i = 0; i < breakpoints.length; i++ ) { for (int i = 0; i < breakpoints.length; i++) {
if ( !(breakpoints[i] instanceof ICWatchpoint) ) { if (! (breakpoints[i] instanceof ICWatchpoint)) {
continue; continue;
} }
ICWatchpoint breakpoint = (ICWatchpoint)breakpoints[i]; ICWatchpoint breakpoint = (ICWatchpoint)breakpoints[i];
if ( breakpoint.getMarker().getType().equals( markerType ) ) { if (breakpoint.getMarker().getType().equals(markerType)) {
if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) { if (sourceHandle != null && sourceHandle.equals(breakpoint.getSourceHandle())) {
if ( breakpoint.getMarker().getResource().equals( resource ) ) { if (breakpoint.getMarker().getResource().equals(resource)) {
if ( breakpoint.getExpression().equals( expression ) ) { if (breakpoint.getExpression().equals(expression)) {
return breakpoint; return breakpoint;
} }
} }
@ -433,32 +409,38 @@ public class CDIDebugModel {
} }
/** /**
* Returns the function breakpoint that is already registered with the breakpoint * Returns the function breakpoint that is already registered with the
* manager for a source with the given handle and the given resource with the * breakpoint manager for a source with the given handle and the given
* given function name. * resource with the given function name.
* *
* @param sourceHandle the source handle * @param sourceHandle
* @param resource the breakpoint resource * the source handle
* @param function the fully qualified function name * @param resource
* the breakpoint resource
* @param function
* the fully qualified function name
* @return the breakpoint that is already registered with the breakpoint * @return the breakpoint that is already registered with the breakpoint
* manager or <code>null</code> if no such breakpoint is registered * manager or <code>null</code> if no such breakpoint is
* @exception CoreException if unable to retrieve the associated marker * registered
* attributes (line number). * @exception CoreException
* if unable to retrieve the associated marker attributes
* (line number).
*/ */
public static ICFunctionBreakpoint functionBreakpointExists( String sourceHandle, IResource resource, String function ) throws CoreException { public static ICFunctionBreakpoint functionBreakpointExists(String sourceHandle, IResource resource, String function)
throws CoreException {
String modelId = getPluginIdentifier(); String modelId = getPluginIdentifier();
String markerType = CFunctionBreakpoint.getMarkerType(); String markerType = CFunctionBreakpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId ); IBreakpoint[] breakpoints = manager.getBreakpoints(modelId);
for( int i = 0; i < breakpoints.length; i++ ) { for (int i = 0; i < breakpoints.length; i++) {
if ( !(breakpoints[i] instanceof ICFunctionBreakpoint) ) { if (! (breakpoints[i] instanceof ICFunctionBreakpoint)) {
continue; continue;
} }
ICFunctionBreakpoint breakpoint = (ICFunctionBreakpoint)breakpoints[i]; ICFunctionBreakpoint breakpoint = (ICFunctionBreakpoint)breakpoints[i];
if ( breakpoint.getMarker().getType().equals( markerType ) ) { if (breakpoint.getMarker().getType().equals(markerType)) {
if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) { if (sourceHandle != null && sourceHandle.equals(breakpoint.getSourceHandle())) {
if ( breakpoint.getMarker().getResource().equals( resource ) ) { if (breakpoint.getMarker().getResource().equals(resource)) {
if ( breakpoint.getFunction() != null && breakpoint.getFunction().equals( function ) ) { if (breakpoint.getFunction() != null && breakpoint.getFunction().equals(function)) {
return breakpoint; return breakpoint;
} }
} }
@ -468,60 +450,134 @@ public class CDIDebugModel {
return null; return null;
} }
public static IExpression createExpression( IDebugTarget target, String text ) throws DebugException { public static IExpression createExpression(IDebugTarget target, String text) throws DebugException {
if ( target != null && target instanceof CDebugTarget ) { if (target != null && target instanceof CDebugTarget) {
try { try {
ICDIExpression cdiExpression = ((CDebugTarget)target).getCDISession().getExpressionManager().createExpression( text ); ICDIExpression cdiExpression = ((CDebugTarget)target).getCDISession().getExpressionManager().createExpression(text);
return new CExpression( (CDebugTarget)target, cdiExpression ); return new CExpression((CDebugTarget)target, cdiExpression);
} } catch (CDIException e) {
catch( CDIException e ) { throw new DebugException(new Status(IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED,
throw new DebugException( new Status( IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED, e.getMessage(), null ) ); e.getMessage(), null));
} }
} }
return null; return null;
} }
public static IExpression createExpressionForGlobalVariable( IDebugTarget target, IPath fileName, String name ) throws DebugException { public static IExpression createExpressionForGlobalVariable(IDebugTarget target, IPath fileName, String name)
if ( target != null && target instanceof CDebugTarget ) { throws DebugException {
if (target != null && target instanceof CDebugTarget) {
ICDIVariableObject vo = null; ICDIVariableObject vo = null;
try { try {
vo = ((CDebugTarget)target).getCDISession().getVariableManager().getGlobalVariableObject( fileName.lastSegment(), null, name ); vo = ((CDebugTarget)target).getCDISession().getVariableManager().getGlobalVariableObject(fileName.lastSegment(),
ICDIVariable cdiVariable = ((CDebugTarget)target).getCDISession().getVariableManager().createVariable( vo ); null, name);
return new CExpression( (CDebugTarget)target, cdiVariable ); ICDIVariable cdiVariable = ((CDebugTarget)target).getCDISession().getVariableManager().createVariable(vo);
} return new CExpression((CDebugTarget)target, cdiVariable);
catch( CDIException e ) { } catch (CDIException e) {
throw new DebugException( new Status( IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED, (vo != null) ? vo.getName() + ": " + e.getMessage() : e.getMessage(), null ) ); //$NON-NLS-1$ throw new DebugException(new Status(IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED,
(vo != null) ? vo.getName() + ": " + e.getMessage() : e.getMessage(), null)); //$NON-NLS-1$
} }
} }
return null; return null;
} }
public static ICGlobalVariable createGlobalVariable( IDebugTarget target, IGlobalVariableDescriptor info ) throws DebugException { public static ICGlobalVariable createGlobalVariable(IDebugTarget target, IGlobalVariableDescriptor info) throws DebugException {
if ( target != null && target instanceof CDebugTarget ) { if (target != null && target instanceof CDebugTarget) {
ICDIVariableObject vo = null; ICDIVariableObject vo = null;
try { try {
vo = ((CDebugTarget)target).getCDISession().getVariableManager().getGlobalVariableObject( info.getPath().lastSegment(), null, info.getName() ); vo = ((CDebugTarget)target).getCDISession().getVariableManager().getGlobalVariableObject(
return CVariableFactory.createGlobalVariable( (CDebugTarget)target, info, vo ); info.getPath().lastSegment(),
} null, info.getName());
catch( CDIException e ) { return CVariableFactory.createGlobalVariable((CDebugTarget)target, info, vo);
throw new DebugException( new Status( IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED, (vo != null) ? vo.getName() + ": " + e.getMessage() : e.getMessage(), null ) ); //$NON-NLS-1$ } catch (CDIException e) {
throw new DebugException(new Status(IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED,
(vo != null) ? vo.getName() + ": " + e.getMessage() : e.getMessage(), null)); //$NON-NLS-1$
} }
} }
return null; return null;
} }
protected static void stopInMain( CDebugTarget target ) throws DebugException { protected static void stopInMain(CDebugTarget target) throws DebugException {
ICDILocation location = target.getCDITarget().createLocation( "", "main", 0 ); //$NON-NLS-1$ //$NON-NLS-2$ ICDILocation location = target.getCDITarget().createLocation("", "main", 0); //$NON-NLS-1$ //$NON-NLS-2$
try { try {
target.setInternalTemporaryBreakpoint( location ); target.setInternalTemporaryBreakpoint(location);
} } catch (DebugException e) {
catch( DebugException e ) { String message = MessageFormat.format(
String message = MessageFormat.format( DebugCoreMessages.getString( "CDebugModel.0" ), new String[]{ e.getStatus().getMessage() } ); //$NON-NLS-1$ DebugCoreMessages.getString("CDebugModel.0"), new String[]{e.getStatus().getMessage()}); //$NON-NLS-1$
IStatus newStatus = new Status( IStatus.WARNING, e.getStatus().getPlugin(), ICDebugInternalConstants.STATUS_CODE_QUESTION, message, null ); IStatus newStatus = new Status(IStatus.WARNING, e.getStatus().getPlugin(),
if ( !CDebugUtils.question( newStatus, target ) ) { ICDebugInternalConstants.STATUS_CODE_QUESTION, message, null);
if (!CDebugUtils.question(newStatus, target)) {
target.terminate(); target.terminate();
throw new DebugException( new Status( IStatus.OK, e.getStatus().getPlugin(), e.getStatus().getCode(), e.getStatus().getMessage(), null ) ); throw new DebugException(new Status(IStatus.OK, e.getStatus().getPlugin(), e.getStatus().getCode(),
e.getStatus().getMessage(), null));
} }
} }
} }
}
/**
* @param launch
* @param target
* @param string
* @param iprocess
* @param debuggerProcess
* @param exeFile
* @param b
* @param c
* @param stopInMain
* @throws CoreException
* @deprecated
*/
public static IDebugTarget newDebugTarget(ILaunch launch, ICDITarget target, String name, IProcess iprocess,
IProcess debuggerProcess, IFile file, boolean allowTerminate, boolean allowDisconnect, boolean stopInMain)
throws CoreException {
IBinaryExecutable exeFile = getBinary(file);
return newDebugTarget(launch, file.getProject(), target, name, iprocess, exeFile, allowTerminate, allowDisconnect,
stopInMain);
}
/**
* @param launch
* @param target
* @param name
* @param debuggerProcess
* @param exeFile
* @throws CoreException
* @deprecated
*/
public static IDebugTarget newAttachDebugTarget(ILaunch launch, ICDITarget target, String name, IProcess debuggerProcess,
IFile file) throws CoreException {
IBinaryExecutable exeFile = getBinary(file);
return newDebugTarget(launch, file.getProject(), target, name, null, exeFile, false, true);
}
/**
* @param launch
* @param currentTarget
* @param string
* @param iprocess
* @param exeFile
* @throws CoreException
* @deprecated
*/
public static IDebugTarget newCoreFileDebugTarget(final ILaunch launch, final ICDITarget target, final String name,
final IProcess debuggerProcess, final IFile file) throws CoreException {
IBinaryExecutable exeFile = getBinary(file);
return newDebugTarget(launch, file.getProject(), target, name, null, exeFile, false, false);
}
private static IBinaryExecutable getBinary(IFile file) throws CoreException {
IProject project = file.getProject();
ICExtensionReference[] binaryParsersExt = CCorePlugin.getDefault().getBinaryParserExtensions(project);
for (int i = 0; i < binaryParsersExt.length; i++) {
IBinaryParser parser = (IBinaryParser)binaryParsersExt[i].createExtension();
try {
IBinaryFile exe = parser.getBinary(file.getLocation());
if (exe instanceof IBinaryExecutable) {
return (IBinaryExecutable)exe;
}
} catch (IOException e) {
}
}
throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), -1,
DebugCoreMessages.getString("CDIDebugModel.0"), null)); //$NON-NLS-1$
}
}

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget; import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.cdt.debug.internal.core.model.CFormattedMemoryBlock; import org.eclipse.cdt.debug.internal.core.model.CFormattedMemoryBlock;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
@ -50,26 +51,29 @@ public class CDebugModel {
} }
/** /**
* @throws CoreException
* @deprecated * @deprecated
* Use {@link CDIDebugModel#newDebugTarget(ILaunch, ICDITarget, String, IProcess, IProcess, IFile, boolean, boolean, boolean)}. * Use {@link CDIDebugModel#newDebugTarget(ILaunch, ICDITarget, String, IProcess, IProcess, IFile, boolean, boolean, boolean)}.
*/ */
public static IDebugTarget newDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggeeProcess, final IProcess debuggerProcess, final IFile file, final boolean allowTerminate, final boolean allowDisconnect, final boolean stopInMain ) throws DebugException { public static IDebugTarget newDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggeeProcess, final IProcess debuggerProcess, final IFile file, final boolean allowTerminate, final boolean allowDisconnect, final boolean stopInMain ) throws CoreException {
return CDIDebugModel.newDebugTarget( launch, cdiTarget, name, debuggeeProcess, debuggerProcess, file, allowTerminate, allowDisconnect, stopInMain ); return CDIDebugModel.newDebugTarget( launch, cdiTarget, name, debuggeeProcess, debuggerProcess, file, allowTerminate, allowDisconnect, stopInMain );
} }
/** /**
* @throws CoreException
* @deprecated * @deprecated
* Use {@link CDIDebugModel#newAttachDebugTarget(ILaunch, ICDITarget, String, IProcess, IFile)}. * Use {@link CDIDebugModel#newAttachDebugTarget(ILaunch, ICDITarget, String, IProcess, IFile)}.
*/ */
public static IDebugTarget newAttachDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggerProcess, final IFile file ) throws DebugException { public static IDebugTarget newAttachDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggerProcess, final IFile file ) throws CoreException {
return CDIDebugModel.newAttachDebugTarget( launch, cdiTarget, name, debuggerProcess, file ); return CDIDebugModel.newAttachDebugTarget( launch, cdiTarget, name, debuggerProcess, file );
} }
/** /**
* @throws CoreException
* @deprecated * @deprecated
* Use {@link CDIDebugModel#newCoreFileDebugTarget(ILaunch, ICDITarget, String, IProcess, IFile)}. * Use {@link CDIDebugModel#newCoreFileDebugTarget(ILaunch, ICDITarget, String, IProcess, IFile)}.
*/ */
public static IDebugTarget newCoreFileDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggerProcess, final IFile file ) throws DebugException { public static IDebugTarget newCoreFileDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggerProcess, final IFile file ) throws CoreException {
return CDIDebugModel.newCoreFileDebugTarget( launch, cdiTarget, name, debuggerProcess, file ); return CDIDebugModel.newCoreFileDebugTarget( launch, cdiTarget, name, debuggerProcess, file );
} }

View file

@ -10,3 +10,4 @@
############################################################################### ###############################################################################
CDebugCorePlugin.0=No such debugger CDebugCorePlugin.0=No such debugger
CDebugModel.0=Unable to set temporary breakpoint in main.\nReason: {0}\nContinue? CDebugModel.0=Unable to set temporary breakpoint in main.\nReason: {0}\nContinue?
CDIDebugModel.0=Unable to parser binary information from file

View file

@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Common Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.debug.core;
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch;
public interface ICDIDebugger {
public ICDISession createDebuggerSession(ILaunch launch, IBinaryExecutable exe, IProgressMonitor monitor) throws CoreException;
}

View file

@ -1,29 +1,25 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others. * Copyright (c) 2000, 2004 QNX Software Systems and others. All rights
* All rights reserved. This program and the accompanying materials * reserved. This program and the accompanying materials are made available
* are made available under the terms of the Common Public License v1.0 * under the terms of the Common Public License v1.0 which accompanies this
* which accompanies this distribution, and is available at * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
* http://www.eclipse.org/legal/cpl-v10.html
* *
* Contributors: * Contributors: QNX Software Systems - Initial API and implementation
* QNX Software Systems - Initial API and implementation ******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.debug.core; package org.eclipse.cdt.debug.core;
public interface ICDTLaunchConfigurationConstants { public interface ICDTLaunchConfigurationConstants {
public static final String CDT_LAUNCH_ID = "org.eclipse.cdt.launch"; //$NON-NLS-1$ public static final String CDT_LAUNCH_ID = "org.eclipse.cdt.launch"; //$NON-NLS-1$
/** /**
* This is the launch type id. * This is the launch type id.
*/ */
public static final String ID_LAUNCH_C_APP = "org.eclipse.cdt.launch.localCLaunch"; //$NON-NLS-1$ public static final String ID_LAUNCH_C_APP = "org.eclipse.cdt.launch.localCLaunch"; //$NON-NLS-1$
/** /**
* Launch configuration attribute key. The value is a name of * Launch configuration attribute key. The value is a name of a C/C++
* a C/C++ project associated with a C/C++ launch configuration. * project associated with a C/C++ launch configuration.
*/ */
public static final String ATTR_PROJECT_NAME = CDT_LAUNCH_ID + ".PROJECT_ATTR"; //$NON-NLS-1$ public static final String ATTR_PROJECT_NAME = CDT_LAUNCH_ID + ".PROJECT_ATTR"; //$NON-NLS-1$
@ -35,156 +31,173 @@ public interface ICDTLaunchConfigurationConstants {
/** /**
* Launch configuration attribute key. The value is a string specifying * Launch configuration attribute key. The value is a string specifying
* application arguments for a C/C++ launch configuration, as they should appear * application arguments for a C/C++ launch configuration, as they should
* on the command line. * appear on the command line.
*/ */
public static final String ATTR_PROGRAM_ARGUMENTS = CDT_LAUNCH_ID + ".PROGRAM_ARGUMENTS"; //$NON-NLS-1$ public static final String ATTR_PROGRAM_ARGUMENTS = CDT_LAUNCH_ID + ".PROGRAM_ARGUMENTS"; //$NON-NLS-1$
/** /**
* Launch configuration attribute key. The value is a string specifying a * Launch configuration attribute key. The value is a string specifying a
* path to the working directory to use when launching a the application. * path to the working directory to use when launching a the application.
* When unspecified, the working directory is inherited from the current process. * When unspecified, the working directory is inherited from the current
* When specified as an absolute path, the path represents a path in the local * process. When specified as an absolute path, the path represents a path
* file system. When specified as a full path, the path represents a workspace * in the local file system. When specified as a full path, the path
* relative path. * represents a workspace relative path.
*/ */
public static final String ATTR_WORKING_DIRECTORY = CDT_LAUNCH_ID + ".WORKING_DIRECTORY"; //$NON-NLS-1$ public static final String ATTR_WORKING_DIRECTORY = CDT_LAUNCH_ID + ".WORKING_DIRECTORY"; //$NON-NLS-1$
/** /**
* Launch configuration attribute key. The value is a boolean specifying * Launch configuration attribute key. The value is a boolean specifying
* whether the current enviroment should be inherited when the application * whether the current enviroment should be inherited when the application
* is launched. * is launched.
*/ */
public static final String ATTR_PROGRAM_ENVIROMENT_INHERIT = CDT_LAUNCH_ID + ".ENVIRONMENT_INHERIT"; //$NON-NLS-1$ public static final String ATTR_PROGRAM_ENVIROMENT_INHERIT = CDT_LAUNCH_ID + ".ENVIRONMENT_INHERIT"; //$NON-NLS-1$
/** /**
* Launch configuration attribute key. The value is a Map specifying the * Launch configuration attribute key. The value is a Map specifying the
* environment to use when launching a C/C++ application. * environment to use when launching a C/C++ application.
*/ */
public static final String ATTR_PROGRAM_ENVIROMENT_MAP = CDT_LAUNCH_ID + ".ENVIRONMENT_MAP"; //$NON-NLS-1$ public static final String ATTR_PROGRAM_ENVIROMENT_MAP = CDT_LAUNCH_ID + ".ENVIRONMENT_MAP"; //$NON-NLS-1$
/** /**
* Launch configuration attribute key. The value is the platform string of the launch configuration * Launch configuration attribute key. The value is the platform string of
* the launch configuration
*/ */
public static final String ATTR_PLATFORM = CDT_LAUNCH_ID + ".PLATFFORM"; //$NON-NLS-1$ public static final String ATTR_PLATFORM = CDT_LAUNCH_ID + ".PLATFFORM"; //$NON-NLS-1$
/** /**
* Launch configuration attribute key. The value is the debugger id * Launch configuration attribute key. The value is the debugger id used
* used when launching a C/C++ application for debug. * when launching a C/C++ application for debug.
*/ */
public static final String ATTR_DEBUGGER_ID = CDT_LAUNCH_ID + ".DEBUGGER_ID"; //$NON-NLS-1$ public static final String ATTR_DEBUGGER_ID = CDT_LAUNCH_ID + ".DEBUGGER_ID"; //$NON-NLS-1$
/** /**
* Launch configuration attribute key. The value is the platform string of the launch configuration * Launch configuration attribute key. The value is the platform string of
* the launch configuration
*/ */
public static final String ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP = CDT_LAUNCH_ID + ".DEBUGGER_SPECIFIC_ATTRS_MAP"; //$NON-NLS-1$ public static final String ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP = CDT_LAUNCH_ID + ".DEBUGGER_SPECIFIC_ATTRS_MAP"; //$NON-NLS-1$
/** /**
* Launch configuration attribute key. The value is a boolean specifying whether to stop at main(). * Launch configuration attribute key. The value is a boolean specifying
* whether to stop at main().
*/ */
public static final String ATTR_DEBUGGER_STOP_AT_MAIN = CDT_LAUNCH_ID + ".DEBUGGER_STOP_AT_MAIN"; //$NON-NLS-1$ public static final String ATTR_DEBUGGER_STOP_AT_MAIN = CDT_LAUNCH_ID + ".DEBUGGER_STOP_AT_MAIN"; //$NON-NLS-1$
/** /**
* Launch configuration attribute key. The value is an int specifying the process id to attach to * Launch configuration attribute key. The value is an int specifying the
* if the ATTR_DEBUGGER_START_MODE is DEBUGGER_MODE_ATTACH. A non existant value or -1 for this * process id to attach to if the ATTR_DEBUGGER_START_MODE is
* entry indicates that the user should be asked to supply this value. This value is primarily * DEBUGGER_MODE_ATTACH. A non existant value or -1 for this entry indicates
* designed to be used by programatic users of the debug interface. * that the user should be asked to supply this value by the launch
* delegate. This value is primarily designed to be used by programatic
* users of the debug interface.
*/ */
public static final String ATTR_ATTACH_PROCESS_ID = CDT_LAUNCH_ID + ".ATTACH_PROCESS_ID"; //$NON-NLS-1$ public static final String ATTR_ATTACH_PROCESS_ID = CDT_LAUNCH_ID + ".ATTACH_PROCESS_ID"; //$NON-NLS-1$
/** /**
* Launch configuration attribute key. The value is the startup mode for the debugger. * Launch configuration attribute key. The value is a String specifying the
* corefile path if the ATTR_DEBUGGER_START_MODE is DEBUGGER_MODE_COREFILE.
* A non existant value or null for this entry indicates that the user
* should be asked to supply this value by the launch delegate. This value
* is primarily designed to be used by programatic users of the debug
* interface.
*/
public static final String ATTR_COREFILE_PATH = CDT_LAUNCH_ID + ".COREFILE_PATH"; //$NON-NLS-1$
/**
* Launch configuration attribute key. The value is the startup mode for the
* debugger.
*/ */
public static final String ATTR_DEBUGGER_START_MODE = CDT_LAUNCH_ID + ".DEBUGGER_START_MODE"; //$NON-NLS-1$ public static final String ATTR_DEBUGGER_START_MODE = CDT_LAUNCH_ID + ".DEBUGGER_START_MODE"; //$NON-NLS-1$
/** /**
* Launch configuration attribute key. The value is a boolean specifying whether to enable variable bookkeeping. * Launch configuration attribute key. The value is a boolean specifying
* whether to enable variable bookkeeping.
*/ */
public static final String ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING = CDT_LAUNCH_ID + ".ENABLE_VARIABLE_BOOKKEEPING"; //$NON-NLS-1$ public static final String ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING = CDT_LAUNCH_ID + ".ENABLE_VARIABLE_BOOKKEEPING"; //$NON-NLS-1$
/** /**
* Launch configuration attribute key. The value is a boolean specifying whether to enable register bookkeeping. * Launch configuration attribute key. The value is a boolean specifying
* whether to enable register bookkeeping.
*/ */
public static final String ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING = CDT_LAUNCH_ID + ".ENABLE_REGISTER_BOOKKEEPING"; //$NON-NLS-1$ public static final String ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING = CDT_LAUNCH_ID + ".ENABLE_REGISTER_BOOKKEEPING"; //$NON-NLS-1$
/** /**
* Launch configuration attribute key. The value is a global variables' memento. * Launch configuration attribute key. The value is a global variables'
* memento.
*/ */
public static final String ATTR_DEBUGGER_GLOBAL_VARIABLES = CDT_LAUNCH_ID + ".GLOBAL_VARIABLES"; //$NON-NLS-1$ public static final String ATTR_DEBUGGER_GLOBAL_VARIABLES = CDT_LAUNCH_ID + ".GLOBAL_VARIABLES"; //$NON-NLS-1$
/** /**
* Launch configuration attribute value. The key is ATTR_DEBUGGER_STOP_AT_MAIN. * Launch configuration attribute value. The key is
* ATTR_DEBUGGER_STOP_AT_MAIN.
*/ */
public static boolean DEBUGGER_STOP_AT_MAIN_DEFAULT = true; public static boolean DEBUGGER_STOP_AT_MAIN_DEFAULT = true;
/** /**
* Launch configuration attribute value. The key is ATTR_DEBUGGER_START_MODE. * Launch configuration attribute value. The key is
* Startup debugger running the program. * ATTR_DEBUGGER_START_MODE. Startup debugger running the program.
*/ */
public static String DEBUGGER_MODE_RUN = "run"; //$NON-NLS-1$ public static String DEBUGGER_MODE_RUN = "run"; //$NON-NLS-1$
/** /**
* Launch configuration attribute value. The key is ATTR_DEBUGGER_START_MODE. * Launch configuration attribute value. The key is
* Startup debugger and attach to running process. * ATTR_DEBUGGER_START_MODE. Startup debugger and attach to running process.
*/ */
public static String DEBUGGER_MODE_ATTACH = "attach"; //$NON-NLS-1$ public static String DEBUGGER_MODE_ATTACH = "attach"; //$NON-NLS-1$
/** /**
* Launch configuration attribute value. The key is ATTR_DEBUGGER_START_MODE. * Launch configuration attribute value. The key is
* Startup debugger to view a core file. * ATTR_DEBUGGER_START_MODE. Startup debugger to view a core file.
*/ */
public static String DEBUGGER_MODE_CORE = "core"; //$NON-NLS-1$ public static String DEBUGGER_MODE_CORE = "core"; //$NON-NLS-1$
/** /**
* Status code indicating that the Eclipse runtime does not support * Status code indicating that the Eclipse runtime does not support
* launching a program with a working directory. This feature is only * launching a program with a working directory. This feature is only
* available if Eclipse is run on a 1.3 runtime or higher. * available if Eclipse is run on a 1.3 runtime or higher.
* <p> * <p>
* A status handler may be registered for this error condition, * A status handler may be registered for this error condition, and should
* and should return a Boolean indicating whether the program * return a Boolean indicating whether the program should be relaunched with
* should be relaunched with the default working directory. * the default working directory.
* </p> * </p>
*/ */
public static final int ERR_WORKING_DIRECTORY_NOT_SUPPORTED = 100; public static final int ERR_WORKING_DIRECTORY_NOT_SUPPORTED = 100;
/** /**
* Status code indicating the specified working directory * Status code indicating the specified working directory does not exist.
* does not exist.
*/ */
public static final int ERR_WORKING_DIRECTORY_DOES_NOT_EXIST = 101; public static final int ERR_WORKING_DIRECTORY_DOES_NOT_EXIST = 101;
/** /**
* Status code indicating a launch configuration does not * Status code indicating a launch configuration does not specify a project
* specify a project when a project is required. * when a project is required.
*/ */
public static final int ERR_UNSPECIFIED_PROJECT = 102; public static final int ERR_UNSPECIFIED_PROJECT = 102;
/** /**
* Status code indicating a launch configuration does not * Status code indicating a launch configuration does not specify a vaild
* specify a vaild project. * project.
*/ */
public static final int ERR_NOT_A_C_PROJECT = 103; public static final int ERR_NOT_A_C_PROJECT = 103;
/** /**
* Status code indicating a launch configuration does not * Status code indicating a launch configuration does not specify a vaild
* specify a vaild program. * program.
*/ */
public static final int ERR_PROGRAM_NOT_EXIST = 104; public static final int ERR_PROGRAM_NOT_EXIST = 104;
/** /**
* Status code indicating a launch configuration does not * Status code indicating a launch configuration does not specify a program
* specify a program name. * name.
*/ */
public static final int ERR_UNSPECIFIED_PROGRAM = 105; public static final int ERR_UNSPECIFIED_PROGRAM = 105;
/** /**
* Status code indicating that the CDT debugger is missing * Status code indicating that the CDT debugger is missing
* <p> * <p>
* A status handler may be registered for this error condition, * A status handler may be registered for this error condition, and should
* and should return a String indicating which debugger to use. * return a String indicating which debugger to use.
* </p> * </p>
*/ */
public static final int ERR_DEBUGGER_NOT_INSTALLED = 106; public static final int ERR_DEBUGGER_NOT_INSTALLED = 106;
@ -198,9 +211,9 @@ public interface ICDTLaunchConfigurationConstants {
* Status code indicating a the user did not specify a path to a corefile * Status code indicating a the user did not specify a path to a corefile
*/ */
public static final int ERR_NO_COREFILE = 108; public static final int ERR_NO_COREFILE = 108;
/** /**
* Status code indicating an unexpected internal error. * Status code indicating an unexpected internal error.
*/ */
public static final int ERR_INTERNAL_ERROR = 150; public static final int ERR_INTERNAL_ERROR = 150;
} }

View file

@ -15,7 +15,14 @@ import org.eclipse.core.runtime.CoreException;
public interface ICDebugConfiguration { public interface ICDebugConfiguration {
final static String CPU_NATIVE = "native"; //$NON-NLS-1$ final static String CPU_NATIVE = "native"; //$NON-NLS-1$
/**
* @return
* @throws CoreException
* @deprecated
*/
ICDebugger getDebugger() throws CoreException; ICDebugger getDebugger() throws CoreException;
ICDIDebugger createDebugger() throws CoreException;
String getName(); String getName();
String getID(); String getID();
String getPlatform(); String getPlatform();

View file

@ -16,6 +16,10 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
/**
*
* @deprecated - see ICDIDebugger
*/
public interface ICDebugger { public interface ICDebugger {
public ICDISession createLaunchSession(ILaunchConfiguration config, IFile exe) throws CDIException ; public ICDISession createLaunchSession(ILaunchConfiguration config, IFile exe) throws CDIException ;
public ICDISession createAttachSession(ILaunchConfiguration config, IFile exe, int pid) throws CDIException; public ICDISession createAttachSession(ILaunchConfiguration config, IFile exe, int pid) throws CDIException;

View file

@ -10,7 +10,7 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.debug.core.model; package org.eclipse.cdt.debug.core.model;
import org.eclipse.core.resources.IFile; import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
/** /**
@ -18,7 +18,7 @@ import org.eclipse.debug.core.DebugException;
*/ */
public interface IExecFileInfo { public interface IExecFileInfo {
public IFile getExecFile(); public IBinaryExecutable getExecFile();
public boolean isLittleEndian(); public boolean isLittleEndian();

View file

@ -50,6 +50,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
@ -225,9 +226,9 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
ICSourceLocator sl = getSourceLocator(); ICSourceLocator sl = getSourceLocator();
if ( sl != null ) if ( sl != null )
return sl.contains( project ); return sl.contains( project );
if ( project.equals( getExecFile().getProject() ) ) if ( project.equals( getProject() ) )
return true; return true;
return CDebugUtils.isReferencedProject( getExecFile().getProject(), project ); return CDebugUtils.isReferencedProject( getProject(), project );
} }
} }
return true; return true;
@ -239,7 +240,7 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
public boolean supportsAddressBreakpoint( ICAddressBreakpoint breakpoint ) { public boolean supportsAddressBreakpoint( ICAddressBreakpoint breakpoint ) {
try { try {
return ( getExecFile() != null && getExecFile().getLocation().toOSString().equals( breakpoint.getSourceHandle() ) ); return ( getExecFilePath().toOSString().equals( breakpoint.getSourceHandle() ) );
} }
catch( CoreException e ) { catch( CoreException e ) {
} }
@ -606,10 +607,10 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
} }
private ICFunctionBreakpoint createFunctionBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException { private ICFunctionBreakpoint createFunctionBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException {
IFile execFile = getExecFile(); IPath execFile = getExecFilePath();
String sourceHandle = execFile.getFullPath().toOSString(); String sourceHandle = execFile.toOSString();
ICFunctionBreakpoint breakpoint = CDIDebugModel.createFunctionBreakpoint( sourceHandle, ICFunctionBreakpoint breakpoint = CDIDebugModel.createFunctionBreakpoint( sourceHandle,
execFile, getProject(),
cdiBreakpoint.getLocation().getFunction(), cdiBreakpoint.getLocation().getFunction(),
-1, -1,
-1, -1,
@ -624,11 +625,11 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
} }
private ICAddressBreakpoint createAddressBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException { private ICAddressBreakpoint createAddressBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException {
IFile execFile = getExecFile(); IPath execFile = getExecFilePath();
String sourceHandle = execFile.getFullPath().toOSString(); String sourceHandle = execFile.toOSString();
IAddress address = getDebugTarget().getAddressFactory().createAddress( cdiBreakpoint.getLocation().getAddress() ); IAddress address = getDebugTarget().getAddressFactory().createAddress( cdiBreakpoint.getLocation().getAddress() );
ICAddressBreakpoint breakpoint = CDIDebugModel.createAddressBreakpoint( sourceHandle, ICAddressBreakpoint breakpoint = CDIDebugModel.createAddressBreakpoint( sourceHandle,
execFile, getProject(),
address, address,
cdiBreakpoint.isEnabled(), cdiBreakpoint.isEnabled(),
cdiBreakpoint.getCondition().getIgnoreCount(), cdiBreakpoint.getCondition().getIgnoreCount(),
@ -640,10 +641,10 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
} }
private ICWatchpoint createWatchpoint( ICDIWatchpoint cdiWatchpoint ) throws CDIException, CoreException { private ICWatchpoint createWatchpoint( ICDIWatchpoint cdiWatchpoint ) throws CDIException, CoreException {
IFile execFile = getExecFile(); IPath execFile = getExecFilePath();
String sourceHandle = execFile.getFullPath().toOSString(); String sourceHandle = execFile.toOSString();
ICWatchpoint watchpoint = CDIDebugModel.createWatchpoint( sourceHandle, ICWatchpoint watchpoint = CDIDebugModel.createWatchpoint( sourceHandle,
execFile.getProject(), getProject(),
cdiWatchpoint.isWriteType(), cdiWatchpoint.isWriteType(),
cdiWatchpoint.isReadType(), cdiWatchpoint.isReadType(),
cdiWatchpoint.getWatchExpression(), cdiWatchpoint.getWatchExpression(),
@ -661,8 +662,12 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
return (locator instanceof IAdaptable) ? (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class ) : null; return (locator instanceof IAdaptable) ? (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class ) : null;
} }
private IFile getExecFile() { private IProject getProject() {
return getDebugTarget().getExecFile(); return getDebugTarget().getProject();
}
private IPath getExecFilePath() {
return getDebugTarget().getExecFile().getPath();
} }
private CBreakpointNotifier getBreakpointNotifier() { private CBreakpointNotifier getBreakpointNotifier() {

View file

@ -0,0 +1,110 @@
/*******************************************************************************
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Common Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.debug.internal.core;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDIDebugger;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugger;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
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;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
public class CDebugAdapter implements ICDIDebugger {
final ICDebugger fDebugger;
/**
* @param debugger
*/
public CDebugAdapter(ICDebugger debugger) {
fDebugger = debugger;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICDIDebugger#createDebuggerSession(org.eclipse.debug.core.ILaunch,
* org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable,
* org.eclipse.core.runtime.IProgressMonitor)
*/
public ICDISession createDebuggerSession(ILaunch launch, IBinaryExecutable exe, IProgressMonitor monitor) throws CoreException {
ILaunchConfiguration config = launch.getLaunchConfiguration();
IFile[] exeFile = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(exe.getPath());
if (exeFile.length == 0) {
abort(InternalDebugCoreMessages.getString("CDebugAdapter.0"), null, -1); //$NON-NLS-1$
}
int pid = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_ATTACH_PROCESS_ID, -1);
String coreFile = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, (String)null);
ICDISession session;
try {
if (pid == -1 && coreFile == null) {
return fDebugger.createLaunchSession(config, exeFile[0]);
} else if (pid != -1) {
return fDebugger.createAttachSession(config, exeFile[0], pid);
}
return fDebugger.createCoreSession(config, exeFile[0], new Path(coreFile));
} catch (CDIException e) {
abort(e.getLocalizedMessage(), e, -1);
}
throw new IllegalStateException(); // should never happen
}
protected void abort(String message, Throwable exception, int code) throws CoreException {
MultiStatus status = new MultiStatus(CDebugCorePlugin.getUniqueIdentifier(), code, message, exception);
status.add(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), code, exception == null ? "" : exception.getLocalizedMessage(), //$NON-NLS-1$
exception));
throw new CoreException(status);
}
public static ICProject getCProject(ILaunchConfiguration configuration) throws CoreException {
String projectName = getProjectName(configuration);
if (projectName != null) {
projectName = projectName.trim();
if (projectName.length() > 0) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project);
if (cProject != null && cProject.exists()) {
return cProject;
}
}
}
return null;
}
public static String getProjectName(ILaunchConfiguration configuration) throws CoreException {
return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
}
public static String getProgramName(ILaunchConfiguration configuration) throws CoreException {
return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null);
}
public static IPath getProgramPath(ILaunchConfiguration configuration) throws CoreException {
String path = getProgramName(configuration);
if (path == null) {
return null;
}
return new Path(path);
}
}

View file

@ -13,11 +13,16 @@ package org.eclipse.cdt.debug.internal.core;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDIDebugger;
import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.debug.core.ICDebugger; import org.eclipse.cdt.debug.core.ICDebugger;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
public class DebugConfiguration implements ICDebugConfiguration { public class DebugConfiguration implements ICDebugConfiguration {
/** /**
@ -36,7 +41,19 @@ public class DebugConfiguration implements ICDebugConfiguration {
} }
public ICDebugger getDebugger() throws CoreException { public ICDebugger getDebugger() throws CoreException {
return (ICDebugger) getConfigurationElement().createExecutableExtension("class"); //$NON-NLS-1$ Object debugger = getConfigurationElement().createExecutableExtension("class"); //$NON-NLS-1$
if (debugger instanceof ICDebugger) {
return (ICDebugger)debugger;
}
throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), -1, InternalDebugCoreMessages.getString("DebugConfiguration.0"), null)); //$NON-NLS-1$
}
public ICDIDebugger createDebugger() throws CoreException {
Object debugger = getConfigurationElement().createExecutableExtension("class"); //$NON-NLS-1$
if (debugger instanceof ICDIDebugger) {
return (ICDIDebugger)debugger;
}
return new CDebugAdapter((ICDebugger)debugger);
} }
public String getName() { public String getName() {

View file

@ -16,3 +16,5 @@ CBreakpointManager.4=Change breakpoint properties failed. Reason: {0}.
CBreakpointManager.5=Change breakpoint properties failed. Reason: {0}. CBreakpointManager.5=Change breakpoint properties failed. Reason: {0}.
CGlobalVariableManager.0=Invalid global variables data. CGlobalVariableManager.0=Invalid global variables data.
CExtendedMemoryBlockRetrieval.0=Expression ''{0}'' evaluated to invalid address value: {1}. CExtendedMemoryBlockRetrieval.0=Expression ''{0}'' evaluated to invalid address value: {1}.
DebugConfiguration.0=This debugger no longer supports this operation
CDebugAdapter.0=This debugger does not support debugging external files

View file

@ -10,39 +10,33 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.core.model; package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.model.CDebugElementState; import org.eclipse.cdt.debug.core.model.CDebugElementState;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IProcess;
/** /**
* A debug target for the postmortem debugging. * A debug target for the postmortem debugging.
* @deprecated
*/ */
public class CCoreFileDebugTarget extends CDebugTarget { public class CCoreFileDebugTarget extends CDebugTarget {
public CCoreFileDebugTarget( ILaunch launch, ICDITarget cdiTarget, String name, IProcess debuggerProcess, IFile file ) {
super( launch, cdiTarget, name, null, debuggerProcess, file, true, false );
}
/* /**
* (non-Javadoc) * @param launch
* * @param project
* @see org.eclipse.debug.core.model.ITerminate#canTerminate() * @param cdiTarget
* @param name
* @param debuggeeProcess
* @param file
* @param allowsTerminate
* @param allowsDisconnect
*/ */
public boolean canTerminate() { public CCoreFileDebugTarget(ILaunch launch, IProject project, ICDITarget cdiTarget, String name, IProcess debuggeeProcess, IBinaryExecutable file) {
return !isTerminated() || !isTerminating(); super(launch, project, cdiTarget, name, debuggeeProcess, file, false, false);
} setState(CDebugElementState.TERMINATED);
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ITerminate#terminate()
*/
public void terminate() throws DebugException {
setState( CDebugElementState.TERMINATING );
terminated();
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -20,12 +20,9 @@ import java.util.StringTokenizer;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory; import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.IBinaryParser.ISymbol;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugModel; import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
@ -93,6 +90,7 @@ import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceManager; import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceManager;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarkerDelta; import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
@ -196,12 +194,17 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
* The global variable manager for this target. * The global variable manager for this target.
*/ */
private CGlobalVariableManager fGlobalVariableManager; private CGlobalVariableManager fGlobalVariableManager;
/** /**
* The executable file associated with this target. * The executable binary file associated with this target.
*/ */
private IFile fExecFile; private IBinaryExecutable fBinaryFile;
/**
* The project associated with this target.
*/
private IProject fProject;
/** /**
* Whether the target is little endian. * Whether the target is little endian.
*/ */
@ -222,12 +225,13 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
/** /**
* Constructor for CDebugTarget. * Constructor for CDebugTarget.
*/ */
public CDebugTarget( ILaunch launch, ICDITarget cdiTarget, String name, IProcess debuggeeProcess, IProcess debuggerProcess, IFile file, boolean allowsTerminate, boolean allowsDisconnect ) { public CDebugTarget( ILaunch launch, IProject project, ICDITarget cdiTarget, String name, IProcess debuggeeProcess, IBinaryExecutable file, boolean allowsTerminate, boolean allowsDisconnect) {
super( null ); super( null );
setLaunch( launch ); setLaunch( launch );
setDebugTarget( this ); setDebugTarget( this );
setName( name ); setName( name );
setProcess( debuggeeProcess ); setProcess( debuggeeProcess );
setProject(project);
setExecFile( file ); setExecFile( file );
setCDITarget( cdiTarget ); setCDITarget( cdiTarget );
setState( CDebugElementState.SUSPENDED ); setState( CDebugElementState.SUSPENDED );
@ -1401,54 +1405,59 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
public boolean isLittleEndian() { public boolean isLittleEndian() {
if ( fIsLittleEndian == null ) { if ( fIsLittleEndian == null ) {
fIsLittleEndian = Boolean.TRUE; fIsLittleEndian = Boolean.TRUE;
if ( getExecFile() != null && CoreModel.getDefault().isBinary( getExecFile() ) ) { IBinaryObject file;
ICElement cFile = CCorePlugin.getDefault().getCoreModel().create( getExecFile() ); file = getBinaryFile();
if ( cFile instanceof IBinary ) { if (file != null) {
fIsLittleEndian = new Boolean( ((IBinary)cFile).isLittleEndian() ); return file.isLittleEndian();
}
} }
} }
return fIsLittleEndian.booleanValue(); return fIsLittleEndian.booleanValue();
} }
public IFile getExecFile() {
return fExecFile; /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IExecFileInfo#getExecFile()
*/
public IBinaryExecutable getExecFile() {
return getBinaryFile();
}
public IBinaryExecutable getBinaryFile() {
return fBinaryFile;
} }
private void setExecFile( IFile file ) { private void setExecFile( IBinaryExecutable file ) {
fExecFile = file; fBinaryFile = file;
} }
private void setProject(IProject project) {
fProject = project;
}
public IProject getProject() {
return fProject;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IExecFileInfo#getGlobals() * @see org.eclipse.cdt.debug.core.model.IExecFileInfo#getGlobals()
*/ */
public IGlobalVariableDescriptor[] getGlobals() throws DebugException { public IGlobalVariableDescriptor[] getGlobals() throws DebugException {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
if ( getExecFile() != null && CoreModel.getDefault().isBinary( getExecFile() ) ) { IBinaryObject file = getBinaryFile();
ICElement cFile = CCorePlugin.getDefault().getCoreModel().create( getExecFile() ); if (file != null) {
if ( cFile instanceof IParent ) { list.addAll( getCFileGlobals( file ) );
list.addAll( getCFileGlobals( (IParent)cFile ) );
}
} }
return (IGlobalVariableDescriptor[])list.toArray( new IGlobalVariableDescriptor[list.size()] ); return (IGlobalVariableDescriptor[])list.toArray( new IGlobalVariableDescriptor[list.size()] );
} }
private List getCFileGlobals( IParent file ) throws DebugException { private List getCFileGlobals( IBinaryObject file ) throws DebugException {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
try { ISymbol[] symbols = file.getSymbols();
ICElement[] elements = file.getChildren(); for( int i = 0; i < symbols.length; ++i ) {
for( int i = 0; i < elements.length; ++i ) { if (symbols[i].getType() == ISymbol.VARIABLE) {
if ( elements[i] instanceof org.eclipse.cdt.core.model.IVariable ) { list.add( CVariableFactory.createGlobalVariableDescriptor( symbols[i] ) );
list.add( CVariableFactory.createGlobalVariableDescriptor( (org.eclipse.cdt.core.model.IVariable)elements[i] ) );
}
else if ( elements[i] instanceof org.eclipse.cdt.core.model.IParent ) {
list.addAll( getCFileGlobals( (org.eclipse.cdt.core.model.IParent)elements[i] ) );
}
} }
} }
catch( CModelException e ) {
requestFailed( CoreModelMessages.getString( "CDebugTarget.Unable_to_get_globals_1" ) + e.getMessage(), e ); //$NON-NLS-1$
}
return list; return list;
} }
@ -1834,12 +1843,11 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
public IAddressFactory getAddressFactory() { public IAddressFactory getAddressFactory() {
if ( fAddressFactory == null ) { if ( fAddressFactory == null ) {
if ( getExecFile() != null && CoreModel.getDefault().isBinary( getExecFile() ) ) { if ( getExecFile() != null && getProject() != null ) {
ICElement cFile = CCorePlugin.getDefault().getCoreModel().create( getExecFile() ); IBinaryObject file;
if ( cFile instanceof IBinary ) { file = getBinaryFile();
IBinaryParser.IBinaryObject obj; if (file != null) {
obj = (IBinaryParser.IBinaryObject)cFile.getAdapter(IBinaryParser.IBinaryObject.class); fAddressFactory = file.getAddressFactory();
fAddressFactory = obj.getAddressFactory();
} }
} }
} }

View file

@ -11,6 +11,9 @@
package org.eclipse.cdt.debug.internal.core.model; package org.eclipse.cdt.debug.internal.core.model;
import java.text.MessageFormat; import java.text.MessageFormat;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.core.IBinaryParser.ISymbol;
import org.eclipse.cdt.core.model.IBinaryModule; import org.eclipse.cdt.core.model.IBinaryModule;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
@ -58,6 +61,14 @@ public class CVariableFactory {
return createGlobalVariableDescriptor( var.getElementName(), path ); return createGlobalVariableDescriptor( var.getElementName(), path );
} }
public static IGlobalVariableDescriptor createGlobalVariableDescriptor(ISymbol symbol) {
IPath path = new Path( "" ); //$NON-NLS-1$
IBinaryObject parent = symbol.getBinarObject();
path = parent.getPath();
return createGlobalVariableDescriptor( symbol.getName(), path );
}
public static CGlobalVariable createGlobalVariable( CDebugElement parent, IGlobalVariableDescriptor descriptor, ICDIVariableObject cdiVariableObject ) { public static CGlobalVariable createGlobalVariable( CDebugElement parent, IGlobalVariableDescriptor descriptor, ICDIVariableObject cdiVariableObject ) {
return new CGlobalVariable( parent, descriptor, cdiVariableObject ); return new CGlobalVariable( parent, descriptor, cdiVariableObject );
} }

View file

@ -92,7 +92,7 @@ public class DisassemblyBlock implements IDisassemblyBlock, IAdaptable {
if ( d != null ) { if ( d != null ) {
IExecFileInfo info = (IExecFileInfo)d.getAdapter( IExecFileInfo.class ); IExecFileInfo info = (IExecFileInfo)d.getAdapter( IExecFileInfo.class );
if ( info != null && info.getExecFile() != null ) { if ( info != null && info.getExecFile() != null ) {
return info.getExecFile().getLocation().toOSString(); return info.getExecFile().getPath().toOSString();
} }
} }
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$

View file

@ -1,3 +1,10 @@
2004-10-18 David Inglis
Update to new ICDIDebugger interface deprecating old
Added seperate launch configuration for attaching to pid
* lots of files changed
2004-10-17 Alain Magloire 2004-10-17 Alain Magloire
Remove deprecated method in CDI adjust the implementation. Remove deprecated method in CDI adjust the implementation.
* src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java * src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java

View file

@ -11,8 +11,9 @@
pluginName=C/C++ Development Tools Launching Support pluginName=C/C++ Development Tools Launching Support
providerName=Eclipse.org providerName=Eclipse.org
LocalCDTLaunch.name= C/C++ Local LocalCDTLaunch.name=C/C++ Local Application
CoreFileCDTLaunch.name= C/C++ Postmortem debugger LocalAttachCDTLaunch.name=C/C++ Attach to Local Application
CoreFileCDTLaunch.name=C/C++ Postmortem debugger
CApplicationShortcut.label=Local C/C++ Application CApplicationShortcut.label=Local C/C++ Application
ContextualRunCApplication.label=Run Local C/C++ Application ContextualRunCApplication.label=Run Local C/C++ Application

View file

@ -32,42 +32,59 @@
point="org.eclipse.debug.core.launchConfigurationTypes"> point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType <launchConfigurationType
name="%LocalCDTLaunch.name" name="%LocalCDTLaunch.name"
delegate="org.eclipse.cdt.launch.internal.LocalCLaunchConfigurationDelegate" delegate="org.eclipse.cdt.launch.internal.LocalRunLaunchDelegate"
modes="run,debug" modes="run,debug"
public="true" public="true"
id="org.eclipse.cdt.launch.localCLaunch"> id="org.eclipse.cdt.launch.localRunLaunch">
</launchConfigurationType>
<launchConfigurationType
name="%LocalAttachCDTLaunch.name"
delegate="org.eclipse.cdt.launch.internal.LocalAttachLaunchDelegate"
modes="debug"
public="true"
id="org.eclipse.cdt.launch.localAttachLaunch">
</launchConfigurationType> </launchConfigurationType>
<launchConfigurationType <launchConfigurationType
name="%CoreFileCDTLaunch.name" name="%CoreFileCDTLaunch.name"
delegate="org.eclipse.cdt.launch.internal.CoreFileLaunchDelegate" delegate="org.eclipse.cdt.launch.internal.CoreFileLaunchDelegate"
modes="debug" modes="debug"
public="true" public="true"
id="org.eclipse.cdt.launch.coreFileCLaunch"> id="org.eclipse.cdt.launch.coreFileLaunch">
</launchConfigurationType> </launchConfigurationType>
</extension> </extension>
<extension <extension
point="org.eclipse.debug.ui.launchConfigurationTypeImages"> point="org.eclipse.debug.ui.launchConfigurationTypeImages">
<launchConfigurationTypeImage <launchConfigurationTypeImage
icon="icons/c_app.gif" icon="icons/c_app.gif"
configTypeID="org.eclipse.cdt.launch.localCLaunch" configTypeID="org.eclipse.cdt.launch.localRunLaunch"
id="org.eclipse.cdt.launch.localCLaunchImage"> id="org.eclipse.cdt.launch.localRunLaunchImage">
</launchConfigurationTypeImage> </launchConfigurationTypeImage>
<launchConfigurationTypeImage <launchConfigurationTypeImage
icon="icons/c_app.gif" icon="icons/c_app.gif"
configTypeID="org.eclipse.cdt.launch.coreFileCLaunch" configTypeID="org.eclipse.cdt.launch.localAttachLaunch"
id="org.eclipse.cdt.launch.coreFileCLaunchImage"> id="org.eclipse.cdt.launch.localAttachLaunchImage">
</launchConfigurationTypeImage>
<launchConfigurationTypeImage
icon="icons/c_app.gif"
configTypeID="org.eclipse.cdt.launch.coreFileLaunch"
id="org.eclipse.cdt.launch.coreFileLaunchImage">
</launchConfigurationTypeImage> </launchConfigurationTypeImage>
</extension> </extension>
<extension <extension
point="org.eclipse.debug.ui.launchConfigurationTabGroups"> point="org.eclipse.debug.ui.launchConfigurationTabGroups">
<launchConfigurationTabGroup <launchConfigurationTabGroup
type="org.eclipse.cdt.launch.localCLaunch" type="org.eclipse.cdt.launch.localRunLaunch"
class="org.eclipse.cdt.launch.internal.ui.LocalCLaunchConfigurationTabGroup" class="org.eclipse.cdt.launch.internal.ui.LocalRunLaunchConfigurationTabGroup"
id="org.eclipse.cdt.launch.localClaunchConfigurationTabGroup"> id="org.eclipse.cdt.launch.localRunLaunchTabGroup">
</launchConfigurationTabGroup> </launchConfigurationTabGroup>
<launchConfigurationTabGroup <launchConfigurationTabGroup
type="org.eclipse.cdt.launch.coreFileCLaunch" type="org.eclipse.cdt.launch.localAttachLaunch"
class="org.eclipse.cdt.launch.internal.ui.CoreFileCLaunchConfigurationTabGroup" class="org.eclipse.cdt.launch.internal.ui.LocalAttachLaunchConfigurationTabGroup"
id="org.eclipse.cdt.launch.localAttachLaunchTabGroup">
</launchConfigurationTabGroup>
<launchConfigurationTabGroup
type="org.eclipse.cdt.launch.coreFileLaunch"
class="org.eclipse.cdt.launch.internal.ui.CoreFileLaunchConfigurationTabGroup"
id="org.eclipse.cdt.launch.voreFileCLaunchTabGroup"> id="org.eclipse.cdt.launch.voreFileCLaunchTabGroup">
</launchConfigurationTabGroup> </launchConfigurationTabGroup>
</extension> </extension>

View file

@ -1,17 +1,16 @@
/********************************************************************** /*******************************************************************************
* Copyright (c) 2002 - 2004 QNX Software Systems and others. * Copyright (c) 2002 - 2004 QNX Software Systems and others. All rights
* All rights reserved. This program and the accompanying materials * reserved. This program and the accompanying materials are made available
* are made available under the terms of the Common Public License v1.0 * under the terms of the Common Public License v1.0 which accompanies this
* which accompanies this distribution, and is available at * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
* http://www.eclipse.org/legal/cpl-v10.html
* *
* Contributors: * Contributors: QNX Software Systems - Initial API and implementation
* QNX Software Systems - Initial API and implementation ******************************************************************************/
***********************************************************************/
package org.eclipse.cdt.launch; package org.eclipse.cdt.launch;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -26,12 +25,16 @@ import java.util.Properties;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.utils.spawner.EnvironmentReader; import org.eclipse.cdt.utils.spawner.EnvironmentReader;
import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IContainer;
@ -306,6 +309,24 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null); return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null);
} }
public static IPath getProgramPath(ILaunchConfiguration configuration) throws CoreException {
String path = getProgramName(configuration);
if (path == null) {
return null;
}
return new Path(path);
}
/**
* @param launch
* @param config
* @throws CoreException
* @deprecated
*/
protected void setSourceLocator(ILaunch launch, ILaunchConfiguration config) throws CoreException {
setDefaultSourceLocator(launch, config);
}
/** /**
* Assigns a default source locator to the given launch if a source locator * Assigns a default source locator to the given launch if a source locator
* has not yet been assigned to it, and the associated launch configuration * has not yet been assigned to it, and the associated launch configuration
@ -318,7 +339,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
* @exception CoreException * @exception CoreException
* if unable to set the source locator * if unable to set the source locator
*/ */
protected void setSourceLocator(ILaunch launch, ILaunchConfiguration configuration) throws CoreException { protected void setDefaultSourceLocator(ILaunch launch, ILaunchConfiguration configuration) throws CoreException {
// set default source locator if none specified // set default source locator if none specified
if (launch.getSourceLocator() == null) { if (launch.getSourceLocator() == null) {
IPersistableSourceLocator sourceLocator; IPersistableSourceLocator sourceLocator;
@ -326,7 +347,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
if (id == null) { if (id == null) {
ICProject cProject = getCProject(configuration); ICProject cProject = getCProject(configuration);
if (cProject == null) { if (cProject == null) {
abort(LaunchUIPlugin.getResourceString("Launch.common.Project_does_not_exist"), null, //$NON-NLS-1$ abort(LaunchMessages.getString("Launch.common.Project_does_not_exist"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
} }
sourceLocator = CDebugUIPlugin.createDefaultSourceLocator(); sourceLocator = CDebugUIPlugin.createDefaultSourceLocator();
@ -375,11 +396,13 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
ICDebugConfiguration dbgCfg = null; ICDebugConfiguration dbgCfg = null;
try { try {
dbgCfg = CDebugCorePlugin.getDefault().getDebugConfiguration( dbgCfg = CDebugCorePlugin.getDefault().getDebugConfiguration(
config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "")); //$NON-NLS-1$ config.getAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID,
"")); //$NON-NLS-1$
} catch (CoreException e) { } catch (CoreException e) {
IStatus status = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), IStatus status = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(),
ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED, ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED,
LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Debugger_not_installed"), //$NON-NLS-1$ LaunchMessages.getString("AbstractCLaunchDelegate.Debugger_not_installed"), //$NON-NLS-1$
e); e);
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status); IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
@ -411,45 +434,78 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
String format = "{0} ({1})"; //$NON-NLS-1$ String format = "{0} ({1})"; //$NON-NLS-1$
String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis())); String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
return MessageFormat.format(format, new String[]{ return MessageFormat.format(format, new String[]{
LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Debugger_Process"), timestamp}); //$NON-NLS-1$ LaunchMessages.getString("AbstractCLaunchDelegate.Debugger_Process"), timestamp}); //$NON-NLS-1$
}
/**
* @param config
* @return
* @throws CoreException
* @deprecated
*/
protected IFile getProgramFile(ILaunchConfiguration config) throws CoreException {
ICProject cproject = verifyCProject(config);
String fileName = getProgramName(config);
if (fileName == null) {
abort(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM);
}
IFile programPath = ((IProject)cproject.getResource()).getFile(fileName);
if (programPath == null || !programPath.exists() || !programPath.getLocation().toFile().exists()) {
abort(
LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException(
LaunchMessages.getFormattedString(
"AbstractCLaunchDelegate.PROGRAM_PATH_not_found", programPath.getLocation().toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
}
return programPath;
} }
protected ICProject verifyCProject(ILaunchConfiguration config) throws CoreException { protected ICProject verifyCProject(ILaunchConfiguration config) throws CoreException {
String name = getProjectName(config); String name = getProjectName(config);
if (name == null) { if (name == null) {
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.C_Project_not_specified"), null, //$NON-NLS-1$ abort(LaunchMessages.getString("AbstractCLaunchDelegate.C_Project_not_specified"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT); ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT);
} }
ICProject cproject = getCProject(config); ICProject cproject = getCProject(config);
if (cproject == null) { if (cproject == null) {
IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(name); IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
if (!proj.exists()) { if (!proj.exists()) {
abort(LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.Project_NAME_does_not_exist", name), null, //$NON-NLS-1$ abort(
LaunchMessages.getFormattedString("AbstractCLaunchDelegate.Project_NAME_does_not_exist", name), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
} else if (!proj.isOpen()) { } else if (!proj.isOpen()) {
abort(LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.Project_NAME_is_closed", name), null, //$NON-NLS-1$ abort(LaunchMessages.getFormattedString("AbstractCLaunchDelegate.Project_NAME_is_closed", name), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
} }
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Not_a_C_CPP_project"), null, //$NON-NLS-1$ abort(LaunchMessages.getString("AbstractCLaunchDelegate.Not_a_C_CPP_project"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
} }
return cproject; return cproject;
} }
protected IFile getProgramFile(ILaunchConfiguration config) throws CoreException { protected IPath verifyProgramPath(ILaunchConfiguration config) throws CoreException {
ICProject cproject = verifyCProject(config); ICProject cproject = verifyCProject(config);
String fileName = getProgramName(config); IPath programPath = getProgramPath(config);
if (fileName == null) { if (programPath == null) {
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$ abort(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM); ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM);
} }
if (!programPath.isAbsolute()) {
IFile programPath = ((IProject)cproject.getResource()).getFile(fileName); IFile wsProgramPath = cproject.getProject().getFile(programPath);
if (programPath == null || !programPath.exists() || !programPath.getLocation().toFile().exists()) { programPath = wsProgramPath.getLocation();
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Program_file_does_not_exist"), //$NON-NLS-1$ }
new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString( if (!programPath.toFile().exists()) {
"AbstractCLaunchDelegate.PROGRAM_PATH_not_found", programPath.getLocation().toOSString())), //$NON-NLS-1$ 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); ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
} }
return programPath; return programPath;
} }
@ -485,18 +541,22 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
if (dir.isDirectory()) { if (dir.isDirectory()) {
return dir; return dir;
} }
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$ abort(
new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString( LaunchMessages.getString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
"AbstractCLaunchDelegate.PROGRAM_PATH_not_found", path.toOSString())), //$NON-NLS-1$ new FileNotFoundException(
LaunchMessages.getFormattedString(
"AbstractCLaunchDelegate.PROGRAM_PATH_not_found", path.toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST); ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
} else { } else {
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path); IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
if (res instanceof IContainer && res.exists()) { if (res instanceof IContainer && res.exists()) {
return res.getLocation().toFile(); return res.getLocation().toFile();
} }
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$ abort(
new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString( LaunchMessages.getString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
"AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist", path.toOSString())), //$NON-NLS-1$ new FileNotFoundException(
LaunchMessages.getFormattedString(
"AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist", path.toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST); ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
} }
} }
@ -669,16 +729,16 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
if (orderedProjects != null) { if (orderedProjects != null) {
monitor.beginTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.building_projects"), //$NON-NLS-1$ monitor.beginTask(LaunchMessages.getString("AbstractCLaunchDelegate.building_projects"), //$NON-NLS-1$
orderedProjects.size() + 1); orderedProjects.size() + 1);
for (Iterator i = orderedProjects.iterator(); i.hasNext();) { for (Iterator i = orderedProjects.iterator(); i.hasNext();) {
IProject proj = (IProject)i.next(); IProject proj = (IProject)i.next();
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.building") + proj.getName()); //$NON-NLS-1$ monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.building") + proj.getName()); //$NON-NLS-1$
proj.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); proj.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
} }
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractLaunchConfigurationDelegate.building") + project.getName()); //$NON-NLS-1$ monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.building") + project.getName()); //$NON-NLS-1$
project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
} }
monitor.done(); monitor.done();
@ -701,15 +761,15 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
try { try {
boolean continueLaunch = true; boolean continueLaunch = true;
if (orderedProjects != null) { if (orderedProjects != null) {
monitor.beginTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.searching_for_errors"), //$NON-NLS-1$ monitor.beginTask(LaunchMessages.getString("AbstractCLaunchDelegate.searching_for_errors"), //$NON-NLS-1$
orderedProjects.size() + 1); orderedProjects.size() + 1);
boolean compileErrorsInProjs = false; boolean compileErrorsInProjs = false;
//check prerequisite projects for compile errors. //check prerequisite projects for compile errors.
for (Iterator i = orderedProjects.iterator(); i.hasNext();) { for (Iterator i = orderedProjects.iterator(); i.hasNext();) {
IProject proj = (IProject)i.next(); IProject proj = (IProject)i.next();
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.searching_for_errors_in") //$NON-NLS-1$ monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.searching_for_errors_in") //$NON-NLS-1$
+ proj.getName()); + proj.getName());
compileErrorsInProjs = existsErrors(proj); compileErrorsInProjs = existsErrors(proj);
if (compileErrorsInProjs) { if (compileErrorsInProjs) {
@ -719,7 +779,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
//check current project, if prerequite projects were ok //check current project, if prerequite projects were ok
if (!compileErrorsInProjs) { if (!compileErrorsInProjs) {
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.searching_for_errors_in") //$NON-NLS-1$ monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.searching_for_errors_in") //$NON-NLS-1$
+ project.getName()); + project.getName());
compileErrorsInProjs = existsErrors(project); compileErrorsInProjs = existsErrors(project);
} }
@ -768,7 +828,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
// build project list // build project list
if (monitor != null) { if (monitor != null) {
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.20")); //$NON-NLS-1$ monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.20")); //$NON-NLS-1$
} }
orderedProjects = null; orderedProjects = null;
ICProject cProject = getCProject(configuration); ICProject cProject = getCProject(configuration);
@ -782,4 +842,31 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
return super.preLaunchCheck(configuration, mode, monitor); return super.preLaunchCheck(configuration, mode, monitor);
} }
/**
* @param project
* @param exePath
* @return
* @throws CoreException
*/
protected IBinaryExecutable createBinary(ICProject project, IPath exePath) throws CoreException {
ICExtensionReference[] parserRef = CCorePlugin.getDefault().getBinaryParserExtensions(project.getProject());
for (int i = 0; i < parserRef.length; i++) {
try {
IBinaryParser parser = (IBinaryParser)parserRef[i].createExtension();
IBinaryExecutable exe = (IBinaryExecutable)parser.getBinary(exePath);
if (exe != null) {
return exe;
}
} catch (ClassCastException e) {
} catch (IOException e) {
}
}
IBinaryParser parser = CCorePlugin.getDefault().getDefaultBinaryParser();
try {
return (IBinaryExecutable)parser.getBinary(exePath);
} catch (IOException e) {
}
return null;
}
} }

View file

@ -24,11 +24,13 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate; import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.ui.CElementLabelProvider; import org.eclipse.cdt.ui.CElementLabelProvider;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor;
@ -73,7 +75,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
config.launch(mode, null); config.launch(mode, null);
} }
} catch (CoreException e) { } catch (CoreException e) {
LaunchUIPlugin.errorDialog(LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.LaunchFailed"), e.getStatus()); //$NON-NLS-1$ LaunchUIPlugin.errorDialog(LaunchMessages.getString("CApplicationLaunchShortcut.LaunchFailed"), e.getStatus()); //$NON-NLS-1$
} }
} }
@ -91,10 +93,10 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
candidateConfigs = new ArrayList(configs.length); candidateConfigs = new ArrayList(configs.length);
for (int i = 0; i < configs.length; i++) { for (int i = 0; i < configs.length; i++) {
ILaunchConfiguration config = configs[i]; ILaunchConfiguration config = configs[i];
String programName = AbstractCLaunchDelegate.getProgramName(config); IPath programPath = AbstractCLaunchDelegate.getProgramPath(config);
String projectName = AbstractCLaunchDelegate.getProjectName(config); String projectName = AbstractCLaunchDelegate.getProjectName(config);
String name = bin.getResource().getProjectRelativePath().toString(); IPath name = bin.getResource().getProjectRelativePath();
if (programName != null && programName.equals(name)) { if (programPath != null && programPath.equals(name)) {
if (projectName != null && projectName.equals(bin.getCProject().getProject().getName())) { if (projectName != null && projectName.equals(bin.getCProject().getProject().getName())) {
candidateConfigs.add(config); candidateConfigs.add(config);
} }
@ -228,16 +230,16 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
} }
protected String getDebugConfigDialogTitleString(ICDebugConfiguration [] configList, String mode) { protected String getDebugConfigDialogTitleString(ICDebugConfiguration [] configList, String mode) {
return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.LaunchDebugConfigSelection"); //$NON-NLS-1$ return LaunchMessages.getString("CApplicationLaunchShortcut.LaunchDebugConfigSelection"); //$NON-NLS-1$
} }
protected String getDebugConfigDialogMessageString(ICDebugConfiguration [] configList, String mode) { protected String getDebugConfigDialogMessageString(ICDebugConfiguration [] configList, String mode) {
if (mode.equals(ILaunchManager.DEBUG_MODE)) { if (mode.equals(ILaunchManager.DEBUG_MODE)) {
return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.ChooseConfigToDebug"); //$NON-NLS-1$ return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseConfigToDebug"); //$NON-NLS-1$
} else if (mode.equals(ILaunchManager.RUN_MODE)) { } else if (mode.equals(ILaunchManager.RUN_MODE)) {
return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.ChooseConfigToRun"); //$NON-NLS-1$ return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseConfigToRun"); //$NON-NLS-1$
} }
return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Invalid_launch_mode_1"); //$NON-NLS-1$ return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_1"); //$NON-NLS-1$
} }
@ -262,16 +264,16 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
} }
protected String getLaunchSelectionDialogTitleString(List configList, String mode) { protected String getLaunchSelectionDialogTitleString(List configList, String mode) {
return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.LaunchConfigSelection"); //$NON-NLS-1$ return LaunchMessages.getString("CApplicationLaunchShortcut.LaunchConfigSelection"); //$NON-NLS-1$
} }
protected String getLaunchSelectionDialogMessageString(List binList, String mode) { protected String getLaunchSelectionDialogMessageString(List binList, String mode) {
if (mode.equals(ILaunchManager.DEBUG_MODE)) { if (mode.equals(ILaunchManager.DEBUG_MODE)) {
return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.ChooseLaunchConfigToDebug"); //$NON-NLS-1$ return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLaunchConfigToDebug"); //$NON-NLS-1$
} else if (mode.equals(ILaunchManager.RUN_MODE)) { } else if (mode.equals(ILaunchManager.RUN_MODE)) {
return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.ChooseLaunchConfigToRun"); //$NON-NLS-1$ return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLaunchConfigToRun"); //$NON-NLS-1$
} }
return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Invalid_launch_mode_2"); //$NON-NLS-1$ return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_2"); //$NON-NLS-1$
} }
/** /**
@ -310,8 +312,8 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
dialog.setElements(binList.toArray()); dialog.setElements(binList.toArray());
dialog.setTitle(getBinarySelectionDialogTitleString(binList, mode)); //$NON-NLS-1$ dialog.setTitle(getBinarySelectionDialogTitleString(binList, mode)); //$NON-NLS-1$
dialog.setMessage(getBinarySelectionDialogMessageString(binList, mode)); //$NON-NLS-1$ dialog.setMessage(getBinarySelectionDialogMessageString(binList, mode)); //$NON-NLS-1$
dialog.setUpperListLabel(LaunchUIPlugin.getResourceString("Launch.common.BinariesColon")); //$NON-NLS-1$ dialog.setUpperListLabel(LaunchMessages.getString("Launch.common.BinariesColon")); //$NON-NLS-1$
dialog.setLowerListLabel(LaunchUIPlugin.getResourceString("Launch.common.QualifierColon")); //$NON-NLS-1$ dialog.setLowerListLabel(LaunchMessages.getString("Launch.common.QualifierColon")); //$NON-NLS-1$
dialog.setMultipleSelection(false); dialog.setMultipleSelection(false);
if (dialog.open() == Window.OK) { if (dialog.open() == Window.OK) {
return (IBinary) dialog.getFirstResult(); return (IBinary) dialog.getFirstResult();
@ -321,16 +323,16 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
} }
protected String getBinarySelectionDialogTitleString(List binList, String mode) { protected String getBinarySelectionDialogTitleString(List binList, String mode) {
return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.CLocalApplication"); //$NON-NLS-1$ return LaunchMessages.getString("CApplicationLaunchShortcut.CLocalApplication"); //$NON-NLS-1$
} }
protected String getBinarySelectionDialogMessageString(List binList, String mode) { protected String getBinarySelectionDialogMessageString(List binList, String mode) {
if (mode.equals(ILaunchManager.DEBUG_MODE)) { if (mode.equals(ILaunchManager.DEBUG_MODE)) {
return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.ChooseLocalAppToDebug"); //$NON-NLS-1$ return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLocalAppToDebug"); //$NON-NLS-1$
} else if (mode.equals(ILaunchManager.RUN_MODE)) { } else if (mode.equals(ILaunchManager.RUN_MODE)) {
return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.ChooseLocalAppToRun"); //$NON-NLS-1$ return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLocalAppToRun"); //$NON-NLS-1$
} }
return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Invalid_launch_mode_3"); //$NON-NLS-1$ return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_3"); //$NON-NLS-1$
} }
/** /**
@ -386,12 +388,12 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
} catch (InterruptedException e) { } catch (InterruptedException e) {
return; return;
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
MessageDialog.openError(getShell(), LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Application_Launcher"), e.getMessage()); //$NON-NLS-1$ MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), e.getMessage()); //$NON-NLS-1$
return; return;
} }
int count = results.size(); int count = results.size();
if (count == 0) { if (count == 0) {
MessageDialog.openError(getShell(), LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Application_Launcher"), LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Launch_failed_no_binaries")); //$NON-NLS-1$ //$NON-NLS-2$ MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_binaries")); //$NON-NLS-1$ //$NON-NLS-2$
} else if (count > 1) { } else if (count > 1) {
bin = chooseBinary(results, mode); bin = chooseBinary(results, mode);
} else { } else {
@ -402,7 +404,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
launch(bin, mode); launch(bin, mode);
} }
} else { } else {
MessageDialog.openError(getShell(), LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Application_Launcher"), LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Launch_failed_no_project_selected")); //$NON-NLS-1$ //$NON-NLS-2$ MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_project_selected")); //$NON-NLS-1$ //$NON-NLS-2$
} }
} }

View file

@ -1,15 +1,14 @@
/********************************************************************** /*******************************************************************************
* Copyright (c) 2002 - 2004 QNX Software Systems and others. * Copyright (c) 2002 - 2004 QNX Software Systems and others. All rights
* All rights reserved. This program and the accompanying materials * reserved. This program and the accompanying materials are made available
* are made available under the terms of the Common Public License v1.0 * under the terms of the Common Public License v1.0 which accompanies this
* which accompanies this distribution, and is available at * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
* http://www.eclipse.org/legal/cpl-v10.html
* *
* Contributors: * Contributors: QNX Software Systems - Initial API and implementation
* QNX Software Systems - Initial API and implementation ******************************************************************************/
***********************************************************************/
package org.eclipse.cdt.launch.internal; package org.eclipse.cdt.launch.internal;
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
@ -18,8 +17,8 @@ import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDISession; import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate; import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -27,9 +26,11 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IProcess;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.FileDialog;
@ -42,65 +43,75 @@ public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate {
if (monitor == null) { if (monitor == null) {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
} }
monitor.beginTask(LaunchMessages.getString("CoreFileLaunchDelegate.Launching_postmortem_debugger"), 10); //$NON-NLS-1$
monitor.beginTask(LaunchUIPlugin.getResourceString("CoreFileLaunchDelegate.Launching_postmortem_debugger"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
// check for cancellation // check for cancellation
if (monitor.isCanceled()) { if (monitor.isCanceled()) {
return; return;
} }
IFile exeFile = getProgramFile(config);
ICDebugConfiguration debugConfig = getDebugConfig(config);
ICDISession dsession = null;
ICProject cproject = getCProject(config);
IPath corefile = getCoreFilePath((IProject) cproject.getResource());
if (corefile == null) {
cancel(LaunchUIPlugin.getResourceString("CoreFileLaunchDelegate.No_Corefile_selected"), ICDTLaunchConfigurationConstants.ERR_NO_COREFILE); //$NON-NLS-1$
}
Process debugger = null;
IProcess debuggerProcess = null;
try { try {
dsession = debugConfig.getDebugger().createCoreSession(config, exeFile, corefile); monitor.worked(1);
debugger = dsession.getSessionProcess(); IPath exePath = verifyProgramPath(config);
} catch (CDIException e) { ICProject project = verifyCProject(config);
if (dsession != null) { IBinaryExecutable exeFile = createBinary(project, exePath);
ICDebugConfiguration debugConfig = getDebugConfig(config);
ICDISession dsession = null;
ICProject cproject = getCProject(config);
String path = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, (String)null);
IPath corefile;
if (path == null) {
corefile = promptForCoreFilePath((IProject)cproject.getResource());
if (corefile == null) {
cancel(LaunchMessages.getString("CoreFileLaunchDelegate.No_Corefile_selected"), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NO_COREFILE);
}
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, corefile.toString());
launch(wc, mode, launch, new SubProgressMonitor(monitor, 9));
return;
}
corefile = new Path(path);
dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile, new SubProgressMonitor(monitor, 8));
try {
// set the source locator
setDefaultSourceLocator(launch, config);
ICDITarget[] targets = dsession.getTargets();
for (int i = 0; i < targets.length; i++) {
Process process = targets[i].getProcess();
IProcess iprocess = null;
if (process != null) {
iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()));
}
CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i], renderTargetLabel(debugConfig), iprocess,
exeFile, false, false, false);
}
} catch (CoreException e) {
try { try {
dsession.terminate(); dsession.terminate();
} catch (CDIException ex) { } catch (CDIException cdi) {
// ignore
} }
throw e;
} }
abort(LaunchUIPlugin.getResourceString("CoreFileLaunchDelegate.Failed_Launching_CDI_Debugger"), e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$ } finally {
monitor.done();
} }
if ( debugger != null ) {
debuggerProcess = DebugPlugin.newProcess(launch, debugger, renderDebuggerProcessLabel());
}
// set the source locator
setSourceLocator(launch, config);
ICDITarget[] dTargets = dsession.getTargets();
for (int i = 0; i < dTargets.length; ++i) {
CDIDebugModel.newCoreFileDebugTarget(
launch,
dTargets[i],
renderTargetLabel(debugConfig),
debuggerProcess,
exeFile);
}
monitor.done();
} }
protected IPath getCoreFilePath(final IProject project) throws CoreException { protected IPath promptForCoreFilePath(final IProject project) throws CoreException {
final Shell shell = LaunchUIPlugin.getShell(); final Shell shell = LaunchUIPlugin.getShell();
final String res[] = { null }; final String res[] = {null};
if (shell == null) { if (shell == null) {
abort(LaunchUIPlugin.getResourceString("CoreFileLaunchDelegate.No_Shell_available_in_Launch"), null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$ abort(LaunchMessages.getString("CoreFileLaunchDelegate.No_Shell_available_in_Launch"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
} }
Display display = shell.getDisplay(); Display display = shell.getDisplay();
display.syncExec(new Runnable() { display.syncExec(new Runnable() {
public void run() { public void run() {
FileDialog dialog = new FileDialog(shell); FileDialog dialog = new FileDialog(shell);
dialog.setText(LaunchUIPlugin.getResourceString("CoreFileLaunchDelegate.Select_Corefile")); //$NON-NLS-1$ dialog.setText(LaunchMessages.getString("CoreFileLaunchDelegate.Select_Corefile")); //$NON-NLS-1$
String initPath = null; String initPath = null;
try { try {
@ -123,4 +134,14 @@ public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate {
public String getPluginID() { public String getPluginID() {
return LaunchUIPlugin.getUniqueIdentifier(); return LaunchUIPlugin.getUniqueIdentifier();
} }
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.launch.AbstractCLaunchConfigurationDelegate#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration,
* java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
*/
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
return true; // no pre launch check for core file
}
}

View file

@ -0,0 +1,197 @@
/*******************************************************************************
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Common Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.launch.internal;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IProcessInfo;
import org.eclipse.cdt.core.IProcessList;
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate {
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
* java.lang.String, org.eclipse.debug.core.ILaunch,
* org.eclipse.core.runtime.IProgressMonitor)
*/
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask(LaunchMessages.getString("LocalAttachLaunchDelegate.Attaching_to_Local_C_Application"), 10); //$NON-NLS-1$
// check for cancellation
if (monitor.isCanceled()) {
return;
}
try {
monitor.worked(1);
IPath exePath = verifyProgramPath(config);
ICProject project = verifyCProject(config);
IBinaryExecutable exeFile = createBinary(project, exePath);
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
ICDebugConfiguration debugConfig = getDebugConfig(config);
ICDISession dsession = null;
String debugMode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
//It may be that we have already been provided with a
// process id
if (config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_ATTACH_PROCESS_ID, -1) == -1) {
int pid = promptForProcessID(config);
if (pid == -1) {
cancel(LaunchMessages.getString("LocalAttachLaunchDelegate.No_Process_ID_selected"), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NO_PROCESSID);
}
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_ATTACH_PROCESS_ID, pid);
wc.launch(mode, new SubProgressMonitor(monitor, 9));
} else {
dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile,
new SubProgressMonitor(monitor, 8));
try {
// set the default source locator if required
setDefaultSourceLocator(launch, config);
ICDITarget[] targets = dsession.getTargets();
for (int i = 0; i < targets.length; i++) {
CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i],
renderTargetLabel(debugConfig), null, exeFile, true, true);
}
} catch (CoreException e) {
try {
dsession.terminate();
} catch (CDIException ex) {
// ignore
}
throw e;
}
}
}
}
} finally {
monitor.done();
}
}
protected int promptForProcessID(ILaunchConfiguration config) throws CoreException {
final Shell shell = LaunchUIPlugin.getShell();
final int pidResult[] = {-1};
if (shell == null) {
abort(LaunchMessages.getString("LocalAttachLaunchDelegate.No_Shell_available_in_Launch"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
Display display = shell.getDisplay();
display.syncExec(new Runnable() {
public void run() {
ILabelProvider provider = new LabelProvider() {
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
public String getText(Object element) {
IProcessInfo info = (IProcessInfo)element;
IPath path = new Path(info.getName());
return path.lastSegment() + " - " + info.getPid(); //$NON-NLS-1$
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
*/
public Image getImage(Object element) {
return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC);
}
};
ILabelProvider qprovider = new LabelProvider() {
public String getText(Object element) {
IProcessInfo info = (IProcessInfo)element;
return info.getName();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
*/
public Image getImage(Object element) {
return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC);
}
};
TwoPaneElementSelector dialog = new TwoPaneElementSelector(shell, provider, qprovider);
dialog.setTitle(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process")); //$NON-NLS-1$
dialog.setMessage(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$
IProcessList plist = null;
try {
plist = CCorePlugin.getDefault().getProcessList();
} catch (CoreException e) {
LaunchUIPlugin.errorDialog(
LaunchMessages.getString("LocalAttachLaunchDelegate.CDT_Launch_Error"), e.getStatus()); //$NON-NLS-1$
}
if (plist == null) {
MessageDialog.openError(
shell,
LaunchMessages.getString("LocalAttachLaunchDelegate.CDT_Launch_Error"), LaunchMessages.getString("LocalAttachLaunchDelegate.Platform_cannot_list_processes")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
dialog.setElements(plist.getProcessList());
if (dialog.open() == Window.OK) {
IProcessInfo info = (IProcessInfo)dialog.getFirstResult();
if (info != null) {
pidResult[0] = info.getPid();
}
}
}
});
return pidResult[0];
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.launch.AbstractCLaunchConfigurationDelegate#getPluginID()
*/
protected String getPluginID() {
return LaunchUIPlugin.getUniqueIdentifier();
}
}

View file

@ -1,291 +0,0 @@
/**********************************************************************
* Copyright (c) 2002 - 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.launch.internal;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Properties;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IProcessInfo;
import org.eclipse.cdt.core.IProcessList;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.utils.spawner.ProcessFactory;
import org.eclipse.core.resources.IFile;
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.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.Launching_Local_C_Application"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
// check for cancellation
if (monitor.isCanceled()) {
return;
}
IFile exeFile = getProgramFile(config);
String arguments[] = getProgramArgumentsArray(config);
ArrayList command = new ArrayList(1 + arguments.length);
command.add(exeFile.getLocation().toOSString());
command.addAll(Arrays.asList(arguments));
String[] commandArray = (String[]) command.toArray(new String[command.size()]);
// set the default source locator if required
setSourceLocator(launch, config);
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
IProcess debuggerProcess = null;
Process debugger;
ICDebugConfiguration debugConfig = getDebugConfig(config);
ICDISession dsession = null;
try {
String debugMode =
config.getAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
dsession = debugConfig.getDebugger().createLaunchSession(config, exeFile);
ICDIRuntimeOptions opt = dsession.getRuntimeOptions();
opt.setArguments(getProgramArgumentsArray(config));
File wd = getWorkingDirectory(config);
if (wd != null) {
opt.setWorkingDirectory(wd.getAbsolutePath());
}
opt.setEnvironment(expandEnvironment(config));
debugger = dsession.getSessionProcess();
if ( debugger != null ) {
debuggerProcess = DebugPlugin.newProcess(launch, debugger, renderDebuggerProcessLabel());
}
ICDITarget[] dtargets = dsession.getTargets();
for (int i = 0; i < dtargets.length; ++i) {
ICDITarget dtarget = dtargets[i];
Process process = dtarget.getProcess();
IProcess iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(commandArray[0]));
boolean stopInMain = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
CDIDebugModel.newDebugTarget(
launch,
dtarget,
renderTargetLabel(debugConfig),
iprocess,
debuggerProcess,
exeFile,
true,
false,
stopInMain);
}
} else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
int pid = getProcessID();
if (pid == -1) {
cancel(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.No_Process_ID_selected"), ICDTLaunchConfigurationConstants.ERR_NO_PROCESSID); //$NON-NLS-1$
}
dsession = debugConfig.getDebugger().createAttachSession(config, exeFile, pid);
debugger = dsession.getSessionProcess();
if ( debugger != null ) {
debuggerProcess = DebugPlugin.newProcess(launch, debugger, renderDebuggerProcessLabel());
launch.removeProcess(debuggerProcess);
}
ICDITarget[] dTargets = dsession.getTargets();
for (int i = 0; i < dTargets.length; ++i) {
CDIDebugModel.newAttachDebugTarget(
launch,
dTargets[i],
renderTargetLabel(debugConfig),
debuggerProcess,
exeFile);
}
}
} catch (CDIException e) {
if (dsession != null) {
try {
dsession.terminate();
} catch (CDIException ex) {
// ignore
}
}
abort(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.Failed_Launching_CDI_Debugger"), e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$
}
} else {
File wd = getWorkingDirectory(config);
if (wd == null) {
wd = new File(System.getProperty("user.home", ".")); //NON-NLS-1; //$NON-NLS-1$//$NON-NLS-2$
}
Process process = exec(commandArray, getEnvironmentProperty(config), wd);
DebugPlugin.newProcess(launch, process, renderProcessLabel(commandArray[0]));
}
monitor.done();
}
private int getProcessID() throws CoreException {
final Shell shell = LaunchUIPlugin.getShell();
final int pid[] = { -1 };
if (shell == null) {
abort(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.No_Shell_available_in_Launch"), null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$
}
Display display = shell.getDisplay();
display.syncExec(new Runnable() {
public void run() {
ILabelProvider provider = new LabelProvider() {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
public String getText(Object element) {
IProcessInfo info = (IProcessInfo)element;
IPath path = new Path(info.getName());
return path.lastSegment() + " - " + info.getPid(); //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
*/
public Image getImage(Object element) {
return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC);
}
};
ILabelProvider qprovider = new LabelProvider() {
public String getText(Object element) {
IProcessInfo info = (IProcessInfo) element;
return info.getName();
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
*/
public Image getImage(Object element) {
return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC);
}
};
TwoPaneElementSelector dialog = new TwoPaneElementSelector(shell, provider, qprovider);
dialog.setTitle(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.Select_Process")); //$NON-NLS-1$
dialog.setMessage(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$
IProcessList plist = null;
try {
plist = CCorePlugin.getDefault().getProcessList();
} catch (CoreException e) {
LaunchUIPlugin.errorDialog(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.CDT_Launch_Error"), e.getStatus()); //$NON-NLS-1$
}
if (plist == null) {
MessageDialog.openError(shell, LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.CDT_Launch_Error"), LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.Platform_cannot_list_processes")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
dialog.setElements(plist.getProcessList());
if (dialog.open() == Window.OK) {
IProcessInfo info = (IProcessInfo) dialog.getFirstResult();
if ( info != null ) {
pid[0] = info.getPid();
}
}
}
});
return pid[0];
}
/**
* Performs a runtime exec on the given command line in the context
* of the specified working directory, and returns
* the resulting process. If the current runtime does not support the
* specification of a working directory, the status handler for error code
* <code>ERR_WORKING_DIRECTORY_NOT_SUPPORTED</code> is queried to see if the
* exec should be re-executed without specifying a working directory.
*
* @param cmdLine the command line
* @param workingDirectory the working directory, or <code>null</code>
* @return the resulting process or <code>null</code> if the exec is
* cancelled
* @see Runtime
*/
protected Process exec(String[] cmdLine, Properties environ, File workingDirectory) throws CoreException {
Process p = null;
Properties props = getDefaultEnvironment();
props.putAll(expandEnvironment(environ));
String[] envp = null;
ArrayList envList = new ArrayList();
Enumeration names = props.propertyNames();
if (names != null) {
while (names.hasMoreElements()) {
String key = (String) names.nextElement();
envList.add(key + "=" + props.getProperty(key)); //$NON-NLS-1$
}
envp = (String[]) envList.toArray(new String[envList.size()]);
}
try {
if (workingDirectory == null) {
p = ProcessFactory.getFactory().exec(cmdLine, envp);
} else {
p = ProcessFactory.getFactory().exec(cmdLine, envp, workingDirectory);
}
} catch (IOException e) {
if (p != null) {
p.destroy();
}
abort(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.Error_starting_process"), e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$
} catch (NoSuchMethodError e) {
//attempting launches on 1.2.* - no ability to set working directory
IStatus status =
new Status(
IStatus.ERROR,
LaunchUIPlugin.getUniqueIdentifier(),
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_NOT_SUPPORTED,
LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.Does_not_support_working_dir"), //$NON-NLS-1$
e);
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
if (handler != null) {
Object result = handler.handleStatus(status, this);
if (result instanceof Boolean && ((Boolean) result).booleanValue()) {
p = exec(cmdLine, environ, null);
}
}
}
return p;
}
protected String getPluginID() {
return LaunchUIPlugin.getUniqueIdentifier();
}
}

View file

@ -0,0 +1,198 @@
/*******************************************************************************
* Copyright (c) 2002 - 2004 QNX Software Systems and others. All rights
* reserved. This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0 which accompanies this
* distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors: QNX Software Systems - Initial API and implementation
******************************************************************************/
package org.eclipse.cdt.launch.internal;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Properties;
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.utils.spawner.ProcessFactory;
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.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.debug.core.model.IProcess;
public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate {
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask(LaunchMessages.getString("LocalRunLaunchDelegate.Launching_Local_C_Application"), 10); //$NON-NLS-1$
// check for cancellation
if (monitor.isCanceled()) {
return;
}
try {
monitor.worked(1);
IPath exePath = verifyProgramPath(config);
ICProject project = verifyCProject(config);
IBinaryExecutable exeFile = createBinary(project, exePath);
String arguments[] = getProgramArgumentsArray(config);
// set the default source locator if required
setDefaultSourceLocator(launch, config);
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
ICDebugConfiguration debugConfig = getDebugConfig(config);
ICDISession dsession = null;
String debugMode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile, new SubProgressMonitor(monitor, 8));
try {
ICDIRuntimeOptions opt = dsession.getRuntimeOptions();
opt.setArguments(arguments);
File wd = getWorkingDirectory(config);
if (wd != null) {
opt.setWorkingDirectory(wd.getAbsolutePath());
}
opt.setEnvironment(expandEnvironment(config));
} catch (CDIException e) {
try {
dsession.terminate();
} catch (CDIException ex) {
// ignore
}
abort(LaunchMessages.getString("LocalRunLaunchDelegate.Failed_setting_runtime_option_though_debugger"), e, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
monitor.worked(1);
try {
boolean stopInMain = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
ICDITarget[] targets = dsession.getTargets();
for (int i = 0; i < targets.length; i++) {
Process process = targets[i].getProcess();
IProcess iprocess = null;
if (process != null) {
iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()));
}
CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i], renderTargetLabel(debugConfig),
iprocess, exeFile, true, false, stopInMain);
}
} catch (CoreException e) {
try {
dsession.terminate();
} catch (CDIException e1) {
// ignore
}
throw e;
}
}
} else {
File wd = getWorkingDirectory(config);
if (wd == null) {
wd = new File(System.getProperty("user.home", ".")); //$NON-NLS-1$ //$NON-NLS-2$
}
ArrayList command = new ArrayList(1 + arguments.length);
command.add(exePath.toOSString());
command.addAll(Arrays.asList(arguments));
String[] commandArray = (String[])command.toArray(new String[command.size()]);
monitor.worked(5);
Process process = exec(commandArray, getEnvironmentProperty(config), wd);
monitor.worked(3);
DebugPlugin.newProcess(launch, process, renderProcessLabel(commandArray[0]));
}
} finally {
monitor.done();
}
}
/**
* Performs a runtime exec on the given command line in the context of the
* specified working directory, and returns the resulting process. If the
* current runtime does not support the specification of a working
* directory, the status handler for error code
* <code>ERR_WORKING_DIRECTORY_NOT_SUPPORTED</code> is queried to see if
* the exec should be re-executed without specifying a working directory.
*
* @param cmdLine
* the command line
* @param workingDirectory
* the working directory, or <code>null</code>
* @return the resulting process or <code>null</code> if the exec is
* cancelled
* @see Runtime
*/
protected Process exec(String[] cmdLine, Properties environ, File workingDirectory) throws CoreException {
Process p = null;
Properties props = getDefaultEnvironment();
props.putAll(expandEnvironment(environ));
String[] envp = null;
ArrayList envList = new ArrayList();
Enumeration names = props.propertyNames();
if (names != null) {
while (names.hasMoreElements()) {
String key = (String)names.nextElement();
envList.add(key + "=" + props.getProperty(key)); //$NON-NLS-1$
}
envp = (String[])envList.toArray(new String[envList.size()]);
}
try {
if (workingDirectory == null) {
p = ProcessFactory.getFactory().exec(cmdLine, envp);
} else {
p = ProcessFactory.getFactory().exec(cmdLine, envp, workingDirectory);
}
} catch (IOException e) {
if (p != null) {
p.destroy();
}
abort(LaunchMessages.getString("LocalRunLaunchDelegate.Error_starting_process"), e, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
} catch (NoSuchMethodError e) {
//attempting launches on 1.2.* - no ability to set working
// directory
IStatus status = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(),
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_NOT_SUPPORTED,
LaunchMessages.getString("LocalRunLaunchDelegate.Does_not_support_working_dir"), //$NON-NLS-1$
e);
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
if (handler != null) {
Object result = handler.handleStatus(status, this);
if (result instanceof Boolean && ((Boolean)result).booleanValue()) {
p = exec(cmdLine, environ, null);
}
}
}
return p;
}
protected String getPluginID() {
return LaunchUIPlugin.getUniqueIdentifier();
}
}

View file

@ -1,13 +1,11 @@
/********************************************************************** /*******************************************************************************
* Copyright (c) 2002 - 2004 QNX Software Systems and others. * Copyright (c) 2002 - 2004 QNX Software Systems and others. All rights
* All rights reserved. This program and the accompanying materials * reserved. This program and the accompanying materials are made available
* are made available under the terms of the Common Public License v1.0 * under the terms of the Common Public License v1.0 which accompanies this
* which accompanies this distribution, and is available at * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
* http://www.eclipse.org/legal/cpl-v10.html
* *
* Contributors: * Contributors: QNX Software Systems - Initial API and implementation
* QNX Software Systems - Initial API and implementation ******************************************************************************/
***********************************************************************/
package org.eclipse.cdt.launch.internal.ui; package org.eclipse.cdt.launch.internal.ui;
import java.util.Map; import java.util.Map;
@ -20,9 +18,17 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab { public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
@ -34,6 +40,9 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
protected ILaunchConfigurationTab fDynamicTab; protected ILaunchConfigurationTab fDynamicTab;
protected Composite fDynamicTabHolder; protected Composite fDynamicTabHolder;
private boolean fInitDefaults; private boolean fInitDefaults;
private Combo fDCombo;
private boolean fIsInitializing = false;
private boolean fPageUpdated;
protected void setDebugConfig(ICDebugConfiguration config) { protected void setDebugConfig(ICDebugConfiguration config) {
fCurrentDebugConfig = config; fCurrentDebugConfig = config;
@ -65,7 +74,7 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
protected void setLaunchConfiguration(ILaunchConfiguration launchConfiguration) { protected void setLaunchConfiguration(ILaunchConfiguration launchConfiguration) {
fLaunchConfiguration = launchConfiguration; fLaunchConfiguration = launchConfiguration;
setLaunchConfigurationWorkingCopy( null ); setLaunchConfigurationWorkingCopy(null);
} }
protected ILaunchConfiguration getLaunchConfiguration() { protected ILaunchConfiguration getLaunchConfiguration() {
@ -77,13 +86,14 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
} }
/** /**
* Overridden here so that any error message in the dynamic UI gets returned. * Overridden here so that any error message in the dynamic UI gets
* returned.
* *
* @see ILaunchConfigurationTab#getErrorMessage() * @see ILaunchConfigurationTab#getErrorMessage()
*/ */
public String getErrorMessage() { public String getErrorMessage() {
ILaunchConfigurationTab tab = getDynamicTab(); ILaunchConfigurationTab tab = getDynamicTab();
if ((super.getErrorMessage() != null) || (tab == null)) { if ( (super.getErrorMessage() != null) || (tab == null)) {
return super.getErrorMessage(); return super.getErrorMessage();
} }
return tab.getErrorMessage(); return tab.getErrorMessage();
@ -101,11 +111,11 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
// remove any debug specfic args from the config // remove any debug specfic args from the config
if (wc == null) { if (wc == null) {
if (getLaunchConfiguration().isWorkingCopy()) { if (getLaunchConfiguration().isWorkingCopy()) {
wc = (ILaunchConfigurationWorkingCopy) getLaunchConfiguration(); wc = (ILaunchConfigurationWorkingCopy)getLaunchConfiguration();
} }
} }
if (wc != null) { if (wc != null) {
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map) null); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null);
} }
} else { } else {
if (wc == null) { if (wc == null) {
@ -150,7 +160,7 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
try { try {
tab = CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID()); tab = CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID());
} catch (CoreException e) { } catch (CoreException e) {
LaunchUIPlugin.errorDialog(LaunchUIPlugin.getResourceString("AbstractCDebuggerTab.ErrorLoadingDebuggerPage"), e.getStatus()); //$NON-NLS-1$ LaunchUIPlugin.errorDialog(LaunchMessages.getString("AbstractCDebuggerTab.ErrorLoadingDebuggerPage"), e.getStatus()); //$NON-NLS-1$
} }
setDynamicTab(tab); setDynamicTab(tab);
} }
@ -165,17 +175,15 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
getDynamicTabHolder().layout(true); getDynamicTabHolder().layout(true);
} }
abstract protected ICDebugConfiguration getConfigForCurrentDebugger();
abstract public void createControl(Composite parent); abstract public void createControl(Composite parent);
public void activated(ILaunchConfigurationWorkingCopy workingCopy) { public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
ILaunchConfigurationTab dynamicTab = getDynamicTab(); ILaunchConfigurationTab dynamicTab = getDynamicTab();
if (dynamicTab != null) { if (dynamicTab != null) {
dynamicTab.activated(workingCopy); dynamicTab.activated(workingCopy);
} }
} }
public void initializeFrom(ILaunchConfiguration config) { public void initializeFrom(ILaunchConfiguration config) {
setLaunchConfiguration(config); setLaunchConfiguration(config);
ILaunchConfigurationTab dynamicTab = getDynamicTab(); ILaunchConfigurationTab dynamicTab = getDynamicTab();
@ -189,7 +197,7 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, getDebugConfig().getID()); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, getDebugConfig().getID());
ILaunchConfigurationTab dynamicTab = getDynamicTab(); ILaunchConfigurationTab dynamicTab = getDynamicTab();
if (dynamicTab == null) { if (dynamicTab == null) {
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map) null); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null);
} else { } else {
dynamicTab.performApply(config); dynamicTab.performApply(config);
} }
@ -209,7 +217,7 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
setErrorMessage(null); setErrorMessage(null);
setMessage(null); setMessage(null);
if (getDebugConfig() == null) { if (getDebugConfig() == null) {
setErrorMessage(LaunchUIPlugin.getResourceString("AbstractCDebuggerTab.No_debugger_available")); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getString("AbstractCDebuggerTab.No_debugger_available")); //$NON-NLS-1$
return false; return false;
} }
@ -233,7 +241,88 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
} }
public String getName() { public String getName() {
return LaunchUIPlugin.getResourceString("AbstractCDebuggerTab.Debugger"); //$NON-NLS-1$ return LaunchMessages.getString("AbstractCDebuggerTab.Debugger"); //$NON-NLS-1$
} }
} protected void createDebuggerCombo(Composite parent, int colspan) {
Composite comboComp = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
comboComp.setLayout(layout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = colspan;
comboComp.setLayoutData(gd);
Label dlabel = new Label(comboComp, SWT.NONE);
dlabel.setText(LaunchMessages.getString("Launch.common.DebuggerColon")); //$NON-NLS-1$
fDCombo = new Combo(comboComp, SWT.READ_ONLY | SWT.DROP_DOWN);
fDCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fDCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (!isInitializing()) {
setInitializeDefault(true);
updateComboFromSelection();
}
}
});
}
protected void loadDebuggerCombo(ICDebugConfiguration[] debugConfigs, String current) {
fDCombo.removeAll();
for (int i = 0; i < debugConfigs.length; i++) {
fDCombo.add(debugConfigs[i].getName());
fDCombo.setData(Integer.toString(i), debugConfigs[i]);
}
fPageUpdated = false;
fDCombo.setText(current);
//The behaviour is undefined for if the callbacks should be triggered
// for this,
//so force page update if needed.
if (!fPageUpdated) {
updateComboFromSelection();
}
fPageUpdated = false;
getControl().getParent().layout(true);
}
protected void createDebuggerGroup(Composite parent, int colspan) {
Group debuggerGroup = new Group(parent, SWT.SHADOW_ETCHED_IN);
debuggerGroup.setText(LaunchMessages.getString("CDebuggerTab.Debugger_Options")); //$NON-NLS-1$
setDynamicTabHolder(debuggerGroup);
GridLayout tabHolderLayout = new GridLayout();
tabHolderLayout.marginHeight = 0;
tabHolderLayout.marginWidth = 0;
tabHolderLayout.numColumns = 1;
getDynamicTabHolder().setLayout(tabHolderLayout);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = colspan;
getDynamicTabHolder().setLayoutData(gd);
}
protected void updateComboFromSelection() {
fPageUpdated = true;
handleDebuggerChanged();
updateLaunchConfigurationDialog();
}
protected boolean isInitializing() {
return fIsInitializing;
}
protected void setInitializing(boolean isInitializing) {
fIsInitializing = isInitializing;
}
/**
* Return the class that implements <code>ILaunchConfigurationTab</code>
* that is registered against the debugger id of the currently selected
* debugger.
*/
protected ICDebugConfiguration getConfigForCurrentDebugger() {
int selectedIndex = fDCombo.getSelectionIndex();
return (ICDebugConfiguration)fDCombo.getData(Integer.toString(selectedIndex));
}
}

View file

@ -20,7 +20,7 @@ import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.debug.ui.ILaunchConfigurationTab;
public class CoreFileCLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup { public class CoreFileLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String) * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)

View file

@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Common Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.launch.internal.ui;
import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class LaunchMessages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.launch.internal.ui.LaunchMessages";//$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
private LaunchMessages() {
}
public static String getFormattedString(String key, String arg) {
return MessageFormat.format(getString(key), new String[]{arg});
}
public 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);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}

View file

@ -20,25 +20,27 @@ AbstractCLaunchDelegate.Project_NAME_is_closed=Project {0} is closed
AbstractCLaunchDelegate.PROGRAM_PATH_not_found={0} not found AbstractCLaunchDelegate.PROGRAM_PATH_not_found={0} not found
AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist={0} Does not exist. AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist={0} Does not exist.
AbstractCLaunchDelegate.Debugger_Process=Debugger Process AbstractCLaunchDelegate.Debugger_Process=Debugger Process
AbstractCLaunchConfigurationDelegate.building_projects=Building prerequisite project list AbstractCLaunchDelegate.building_projects=Building prerequisite project list
AbstractCLaunchConfigurationDelegate.building=Building AbstractCLaunchDelegate.building=Building
AbstractCLaunchConfigurationDelegate.searching_for_errors=Searching for compile errors AbstractCLaunchDelegate.searching_for_errors=Searching for compile errors
AbstractCLaunchConfigurationDelegate.searching_for_errors_in=Searching for compile errors in AbstractCLaunchDelegate.searching_for_errors_in=Searching for compile errors in
AbstractCLaunchDelegate.20=Building prerequisite project list
LocalCLaunchConfigurationDelegate.Launching_Local_C_Application=Launching Local C Application LocalRunLaunchDelegate.Launching_Local_C_Application=Launching Local C/C++ Application
LocalCLaunchConfigurationDelegate.No_Process_ID_selected=No Process ID selected LocalRunLaunchDelegate.Failed_setting_runtime_option_though_debugger=Failed to set program arguments, environemt or working directory.
LocalCLaunchConfigurationDelegate.Failed_Launching_CDI_Debugger=Failed Launching CDI Debugger LocalRunLaunchDelegate.Error_starting_process=Error starting process
LocalCLaunchConfigurationDelegate.No_Shell_available_in_Launch=No Shell available in Launch LocalRunLaunchDelegate.Does_not_support_working_dir=Eclipse runtime does not support working directory
LocalCLaunchConfigurationDelegate.Select_Process=Select Process
LocalCLaunchConfigurationDelegate.CDT_Launch_Error=CDT Launch Error LocalAttachLaunchDelegate.Attaching_to_Local_C_Application=Attaching to Local C/C++ Application
LocalCLaunchConfigurationDelegate.Platform_cannot_list_processes=Current platform does not support listing processes LocalAttachLaunchDelegate.No_Process_ID_selected=No Process ID selected
LocalCLaunchConfigurationDelegate.Error_starting_process=Error starting process LocalAttachLaunchDelegate.No_Shell_available_in_Launch=No Shell available in Launch
LocalCLaunchConfigurationDelegate.Does_not_support_working_dir=Eclipse runtime does not support working directory LocalAttachLaunchDelegate.Select_Process=Select Process
LocalCLaunchConfigurationDelegate.Select_Process_to_attach_debugger_to=Select a Process to attach debugger to: LocalAttachLaunchDelegate.Platform_cannot_list_processes=Current platform does not support listing processes
LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to=Select a Process to attach debugger to:
LocalAttachLaunchDelegate.CDT_Launch_Error=CDT Launch Error
CoreFileLaunchDelegate.Launching_postmortem_debugger=Launching postmortem debugger CoreFileLaunchDelegate.Launching_postmortem_debugger=Launching postmortem debugger
CoreFileLaunchDelegate.No_Corefile_selected=No Corefile selected CoreFileLaunchDelegate.No_Corefile_selected=No Corefile selected
CoreFileLaunchDelegate.Failed_Launching_CDI_Debugger=Failed Launching CDI Debugger
CoreFileLaunchDelegate.No_Shell_available_in_Launch=No Shell available in Launch CoreFileLaunchDelegate.No_Shell_available_in_Launch=No Shell available in Launch
CoreFileLaunchDelegate.Select_Corefile=Select Corefile CoreFileLaunchDelegate.Select_Corefile=Select Corefile
@ -67,9 +69,6 @@ LaunchUIPlugin.Error=Error
CSourceLookupTab.Source=Source CSourceLookupTab.Source=Source
CorefileDebuggerTab.Debugger_Options=Debugger Options
CorefileDebuggerTab.No_debugger_available=No debugger available
CMainTab.Project_required=Project required CMainTab.Project_required=Project required
CMainTab.Enter_project_before_searching_for_program=Project must first be entered before searching for a program CMainTab.Enter_project_before_searching_for_program=Project must first be entered before searching for a program
CMainTab.Program_Selection=Program Selection CMainTab.Program_Selection=Program Selection
@ -90,7 +89,6 @@ CMainTab.Search...=Searc&h...
CMainTab.Choose_program_to_run=Choose a &program to run: CMainTab.Choose_program_to_run=Choose a &program to run:
CMainTab.Choose_program_to_run_from_NAME=Choose a program to run from {0}: CMainTab.Choose_program_to_run_from_NAME=Choose a program to run from {0}:
CDebuggerTab.Attach_to_running_process=Attach to running process
CDebuggerTab.Advanced_Options_Dialog_Title=Advanced Options CDebuggerTab.Advanced_Options_Dialog_Title=Advanced Options
CDebuggerTab.Stop_at_main_on_startup=Stop at main() on startup CDebuggerTab.Stop_at_main_on_startup=Stop at main() on startup
CDebuggerTab.Automatically_track_values_of=Automatically track the values of CDebuggerTab.Automatically_track_values_of=Automatically track the values of
@ -101,6 +99,10 @@ CDebuggerTab.Variables=Variables
CDebuggerTab.Registers=Registers CDebuggerTab.Registers=Registers
CDebuggerTab.No_debugger_available=No debugger available CDebuggerTab.No_debugger_available=No debugger available
CDebuggerTab.CPU_is_not_supported=The CPU is not supported by selected debugger. CDebuggerTab.CPU_is_not_supported=The CPU is not supported by selected debugger.
CDebuggerTab.Platform_is_not_supported=The project platform is not supported by the selected debugger.
CoreFileDebuggerTab.No_debugger_available=No debugger available
CoreFileDebuggerTab.platform_is_not_supported=The project platform is not supported by the selected debugger.
CEnvironmentTab.Edit_Variable=Edit Variable CEnvironmentTab.Edit_Variable=Edit Variable
CEnvironmentTab.New_Variable=New Variable CEnvironmentTab.New_Variable=New Variable
@ -136,4 +138,4 @@ Launch.common.BinariesColon=Binaries:
Launch.common.QualifierColon=Qualifier: Launch.common.QualifierColon=Qualifier:
Launch.common.Browse_1=&Browse Launch.common.Browse_1=&Browse
Launch.common.Browse_2=B&rowse Launch.common.Browse_2=B&rowse
Launch.common.Project_does_not_exist=Project does not exist Launch.common.Project_does_not_exist=Project does not exist

View file

@ -1,19 +1,13 @@
/********************************************************************** /*******************************************************************************
* Copyright (c) 2002 - 2004 QNX Software Systems and others. * Copyright (c) 2002 - 2004 QNX Software Systems and others. All rights
* All rights reserved. This program and the accompanying materials * reserved. This program and the accompanying materials are made available
* are made available under the terms of the Common Public License v1.0 * under the terms of the Common Public License v1.0 which accompanies this
* which accompanies this distribution, and is available at * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
* http://www.eclipse.org/legal/cpl-v10.html
* *
* Contributors: * Contributors: QNX Software Systems - Initial API and implementation
* QNX Software Systems - Initial API and implementation ******************************************************************************/
***********************************************************************/
package org.eclipse.cdt.launch.internal.ui; package org.eclipse.cdt.launch.internal.ui;
import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate; import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -31,27 +25,12 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
public class LaunchUIPlugin extends AbstractUIPlugin public class LaunchUIPlugin extends AbstractUIPlugin implements IDebugEventSetListener {
implements
IDebugEventSetListener {
public static final String PLUGIN_ID = "org.eclipse.cdt.launch"; //$NON-NLS-1$ public static final String PLUGIN_ID = "org.eclipse.cdt.launch"; //$NON-NLS-1$
private static final String BUNDLE_NAME = "org.eclipse.cdt.launch.internal.ui.LaunchUIPluginResources";//$NON-NLS-1$
private static ResourceBundle resourceBundle = null;
// -------- static methods -------- // -------- static methods --------
static {
if (resourceBundle == null) {
// Acquire a reference to the .properties file for this plug-in
try {
resourceBundle = ResourceBundle.getBundle(BUNDLE_NAME);
} catch (MissingResourceException e) {
resourceBundle = null;
}
}
}
/** /**
* Launch UI plug-in instance * Launch UI plug-in instance
*/ */
@ -133,8 +112,7 @@ public class LaunchUIPlugin extends AbstractUIPlugin
* the error message to log * the error message to log
*/ */
public static void logErrorMessage(String message) { public static void logErrorMessage(String message) {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, message, null));
message, null));
} }
/** /**
@ -144,8 +122,7 @@ public class LaunchUIPlugin extends AbstractUIPlugin
* the exception to be logged * the exception to be logged
*/ */
public static void log(Throwable e) { public static void log(Throwable e) {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e.getMessage(), e)); //$NON-NLS-1$
.getMessage(), e)); //$NON-NLS-1$
} }
/** /**
@ -182,11 +159,7 @@ public class LaunchUIPlugin extends AbstractUIPlugin
log(status); log(status);
Shell shell = getActiveWorkbenchShell(); Shell shell = getActiveWorkbenchShell();
if (shell != null) { if (shell != null) {
ErrorDialog ErrorDialog.openError(shell, LaunchMessages.getString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$
.openError(
shell,
LaunchUIPlugin
.getResourceString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$
} }
} }
@ -194,13 +167,8 @@ public class LaunchUIPlugin extends AbstractUIPlugin
log(t); log(t);
Shell shell = getActiveWorkbenchShell(); Shell shell = getActiveWorkbenchShell();
if (shell != null) { if (shell != null) {
IStatus status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus status = new Status(IStatus.ERROR, getUniqueIdentifier(), 1, t.getMessage(), null); //$NON-NLS-1$
1, t.getMessage(), null); //$NON-NLS-1$ ErrorDialog.openError(shell, LaunchMessages.getString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$
ErrorDialog
.openError(
shell,
LaunchUIPlugin
.getResourceString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$
} }
} }
@ -237,17 +205,15 @@ public class LaunchUIPlugin extends AbstractUIPlugin
if (events[i].getKind() == DebugEvent.TERMINATE) { if (events[i].getKind() == DebugEvent.TERMINATE) {
Object o = events[i].getSource(); Object o = events[i].getSource();
if (o instanceof IProcess) { if (o instanceof IProcess) {
IProcess proc = (IProcess) o; IProcess proc = (IProcess)o;
ICProject cproject = null; ICProject cproject = null;
try { try {
cproject = AbstractCLaunchDelegate.getCProject(proc cproject = AbstractCLaunchDelegate.getCProject(proc.getLaunch().getLaunchConfiguration());
.getLaunch().getLaunchConfiguration());
} catch (CoreException e) { } catch (CoreException e) {
} }
if (cproject != null) { if (cproject != null) {
try { try {
cproject.getProject().refreshLocal( cproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
IResource.DEPTH_INFINITE, null);
} catch (CoreException e) { } catch (CoreException e) {
} }
} }
@ -255,38 +221,4 @@ public class LaunchUIPlugin extends AbstractUIPlugin
} }
} }
} }
/**
* Returns the plugin's resource bundle,
*/
public ResourceBundle getResourceBundle() {
return resourceBundle;
}
public static String getResourceString(String key) {
ResourceBundle bundle = LaunchUIPlugin.getDefault().getResourceBundle();
// No point trying if bundle is null as exceptions are costly
if (bundle != null) {
try {
return bundle.getString(key);
} catch (MissingResourceException e) {
return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
} catch (NullPointerException e) {
return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
// If we get here, then bundle is null.
return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
}
public static String getFormattedResourceString(String key, String arg) {
return MessageFormat.format(getResourceString(key), new String[]{arg});
}
public static String getFormattedResourceString(String key, String[] args) {
return MessageFormat.format(getResourceString(key), args);
}
} }

View file

@ -0,0 +1,35 @@
/**********************************************************************
* Copyright (c) 2002 - 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.launch.internal.ui;
import org.eclipse.cdt.launch.ui.CDebuggerTab;
import org.eclipse.cdt.launch.ui.CMainTab;
import org.eclipse.cdt.launch.ui.CSourceLookupTab;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
public class LocalAttachLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
*/
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
new CMainTab(),
new CDebuggerTab(true),
new CSourceLookupTab(),
new CommonTab()
};
setTabs(tabs);
}
}

View file

@ -20,7 +20,7 @@ import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.debug.ui.ILaunchConfigurationTab;
public class LocalCLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup { public class LocalRunLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String) * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
@ -30,7 +30,7 @@ public class LocalCLaunchConfigurationTabGroup extends AbstractLaunchConfigurati
new CMainTab(), new CMainTab(),
new CArgumentsTab(), new CArgumentsTab(),
new CEnvironmentTab(), new CEnvironmentTab(),
new CDebuggerTab(), new CDebuggerTab(false),
new CSourceLookupTab(), new CSourceLookupTab(),
new CommonTab() new CommonTab()
}; };

View file

@ -24,6 +24,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
@ -85,13 +86,13 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab {
setControl(workingDirComp); setControl(workingDirComp);
fWorkingDirLabel = new Label(workingDirComp, SWT.NONE); fWorkingDirLabel = new Label(workingDirComp, SWT.NONE);
fWorkingDirLabel.setText(LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Wor&king_directory")); //$NON-NLS-1$ fWorkingDirLabel.setText(LaunchMessages.getString("WorkingDirectoryBlock.Wor&king_directory")); //$NON-NLS-1$
gd = new GridData(); gd = new GridData();
gd.horizontalSpan = 3; gd.horizontalSpan = 3;
fWorkingDirLabel.setLayoutData(gd); fWorkingDirLabel.setLayoutData(gd);
fUseDefaultWorkingDirButton = new Button(workingDirComp,SWT.CHECK); fUseDefaultWorkingDirButton = new Button(workingDirComp,SWT.CHECK);
fUseDefaultWorkingDirButton.setText(LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Use_de&fault_working_directory")); //$NON-NLS-1$ fUseDefaultWorkingDirButton.setText(LaunchMessages.getString("WorkingDirectoryBlock.Use_de&fault_working_directory")); //$NON-NLS-1$
gd = new GridData(); gd = new GridData();
gd.horizontalSpan = 3; gd.horizontalSpan = 3;
fUseDefaultWorkingDirButton.setLayoutData(gd); fUseDefaultWorkingDirButton.setLayoutData(gd);
@ -101,7 +102,7 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab {
} }
}); });
fLocalDirButton = createRadioButton(workingDirComp, LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.&Local_directory")); //$NON-NLS-1$ fLocalDirButton = createRadioButton(workingDirComp, LaunchMessages.getString("WorkingDirectoryBlock.&Local_directory")); //$NON-NLS-1$
fLocalDirButton.addSelectionListener(new SelectionAdapter() { fLocalDirButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
handleLocationButtonSelected(); handleLocationButtonSelected();
@ -117,14 +118,14 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab {
} }
}); });
fWorkingDirBrowseButton = createPushButton(workingDirComp, LaunchUIPlugin.getResourceString("Launch.common.Browse_1"), null); //$NON-NLS-1$ fWorkingDirBrowseButton = createPushButton(workingDirComp, LaunchMessages.getString("Launch.common.Browse_1"), null); //$NON-NLS-1$
fWorkingDirBrowseButton.addSelectionListener(new SelectionAdapter() { fWorkingDirBrowseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
handleWorkingDirBrowseButtonSelected(); handleWorkingDirBrowseButtonSelected();
} }
}); });
fWorkspaceDirButton = createRadioButton(workingDirComp, LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Works&pace")); //$NON-NLS-1$ fWorkspaceDirButton = createRadioButton(workingDirComp, LaunchMessages.getString("WorkingDirectoryBlock.Works&pace")); //$NON-NLS-1$
fWorkspaceDirButton.addSelectionListener(new SelectionAdapter() { fWorkspaceDirButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
handleLocationButtonSelected(); handleLocationButtonSelected();
@ -140,7 +141,7 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab {
} }
}); });
fWorkspaceDirBrowseButton = createPushButton(workingDirComp, LaunchUIPlugin.getResourceString("Launch.common.Browse_2"), null); //$NON-NLS-1$ fWorkspaceDirBrowseButton = createPushButton(workingDirComp, LaunchMessages.getString("Launch.common.Browse_2"), null); //$NON-NLS-1$
fWorkspaceDirBrowseButton.addSelectionListener(new SelectionAdapter() { fWorkspaceDirBrowseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
handleWorkspaceDirBrowseButtonSelected(); handleWorkspaceDirBrowseButtonSelected();
@ -160,7 +161,7 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab {
*/ */
protected void handleWorkingDirBrowseButtonSelected() { protected void handleWorkingDirBrowseButtonSelected() {
DirectoryDialog dialog = new DirectoryDialog(getShell()); DirectoryDialog dialog = new DirectoryDialog(getShell());
dialog.setMessage(LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Select_&working_directory_for_launch_configuration")); //$NON-NLS-1$ dialog.setMessage(LaunchMessages.getString("WorkingDirectoryBlock.Select_&working_directory_for_launch_configuration")); //$NON-NLS-1$
String currentWorkingDir = fWorkingDirText.getText(); String currentWorkingDir = fWorkingDirText.getText();
if (!currentWorkingDir.trim().equals(EMPTY_STRING)) { if (!currentWorkingDir.trim().equals(EMPTY_STRING)) {
File path = new File(currentWorkingDir); File path = new File(currentWorkingDir);
@ -183,7 +184,7 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab {
ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(),
ResourcesPlugin.getWorkspace().getRoot(), ResourcesPlugin.getWorkspace().getRoot(),
false, false,
LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Select_&workspace_relative_working_directory")); //$NON-NLS-1$ LaunchMessages.getString("WorkingDirectoryBlock.Select_&workspace_relative_working_directory")); //$NON-NLS-1$
IContainer currentContainer = getContainer(); IContainer currentContainer = getContainer();
if (currentContainer != null) { if (currentContainer != null) {
@ -291,17 +292,17 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab {
if (workingDirPath.length() > 0) { if (workingDirPath.length() > 0) {
File dir = new File(workingDirPath); File dir = new File(workingDirPath);
if (!dir.exists()) { if (!dir.exists()) {
setErrorMessage(LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Working_directory_does_not_exist")); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getString("WorkingDirectoryBlock.Working_directory_does_not_exist")); //$NON-NLS-1$
return false; return false;
} }
if (!dir.isDirectory()) { if (!dir.isDirectory()) {
setErrorMessage(LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Working_directory_is_not_a_directory")); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getString("WorkingDirectoryBlock.Working_directory_is_not_a_directory")); //$NON-NLS-1$
return false; return false;
} }
} }
} else { } else {
if (getContainer() == null) { if (getContainer() == null) {
setErrorMessage(LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Project_or_folder_does_not_exist")); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getString("WorkingDirectoryBlock.Project_or_folder_does_not_exist")); //$NON-NLS-1$
return false; return false;
} }
} }
@ -345,7 +346,7 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab {
} }
handleUseDefaultWorkingDirButtonSelected(); handleUseDefaultWorkingDirButtonSelected();
} catch (CoreException e) { } catch (CoreException e) {
setErrorMessage(LaunchUIPlugin.getFormattedResourceString("Launch.common.Exception_occurred_reading_configuration_EXCEPTION", e.getStatus().getMessage())); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getFormattedString("Launch.common.Exception_occurred_reading_configuration_EXCEPTION", e.getStatus().getMessage())); //$NON-NLS-1$
LaunchUIPlugin.log(e); LaunchUIPlugin.log(e);
} }
} }
@ -384,7 +385,7 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab {
* @see ILaunchConfigurationTab#getName() * @see ILaunchConfigurationTab#getName()
*/ */
public String getName() { public String getName() {
return LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Working_Directory"); //$NON-NLS-1$ return LaunchMessages.getString("WorkingDirectoryBlock.Working_Directory"); //$NON-NLS-1$
} }
/** /**

View file

@ -12,12 +12,14 @@ package org.eclipse.cdt.launch.ui;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.launch.internal.ui.LaunchImages; import org.eclipse.cdt.launch.internal.ui.LaunchImages;
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.launch.internal.ui.WorkingDirectoryBlock; import org.eclipse.cdt.launch.internal.ui.WorkingDirectoryBlock;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
@ -63,7 +65,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
createVerticalSpacer(comp, 1); createVerticalSpacer(comp, 1);
fPrgmArgumentsLabel = new Label(comp, SWT.NONE); fPrgmArgumentsLabel = new Label(comp, SWT.NONE);
fPrgmArgumentsLabel.setText(LaunchUIPlugin.getResourceString("CArgumentsTab.C/C++_Program_Arguments")); //$NON-NLS-1$ fPrgmArgumentsLabel.setText(LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments")); //$NON-NLS-1$
fPrgmArgumentsText = new Text(comp, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); fPrgmArgumentsText = new Text(comp, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
gd = new GridData(GridData.FILL_HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 40; gd.heightHint = 40;
@ -111,7 +113,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
fWorkingDirectoryBlock.initializeFrom(configuration); fWorkingDirectoryBlock.initializeFrom(configuration);
} }
catch (CoreException e) { catch (CoreException e) {
setErrorMessage(LaunchUIPlugin.getFormattedResourceString("Launch.common.Exception_occurred_reading_configuration_EXCEPTION", e.getStatus().getMessage())); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getFormattedString("Launch.common.Exception_occurred_reading_configuration_EXCEPTION", e.getStatus().getMessage())); //$NON-NLS-1$
LaunchUIPlugin.log(e); LaunchUIPlugin.log(e);
} }
} }
@ -143,7 +145,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
* @see ILaunchConfigurationTab#getName() * @see ILaunchConfigurationTab#getName()
*/ */
public String getName() { public String getName() {
return LaunchUIPlugin.getResourceString("CArgumentsTab.Arguments"); //$NON-NLS-1$ return LaunchMessages.getString("CArgumentsTab.Arguments"); //$NON-NLS-1$
} }
/** /**

View file

@ -11,10 +11,13 @@
package org.eclipse.cdt.launch.ui; package org.eclipse.cdt.launch.ui;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
@ -22,25 +25,21 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.debug.internal.ui.PixelConverter; import org.eclipse.cdt.debug.internal.ui.PixelConverter;
import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab; import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.help.WorkbenchHelp;
@ -65,14 +64,14 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
protected Control createDialogArea( Composite parent ) { protected Control createDialogArea( Composite parent ) {
Composite composite = (Composite)super.createDialogArea( parent ); Composite composite = (Composite)super.createDialogArea( parent );
Group group = new Group( composite, SWT.NONE ); Group group = new Group( composite, SWT.NONE );
group.setText( LaunchUIPlugin.getResourceString( "CDebuggerTab.Automatically_track_values_of" ) ); //$NON-NLS-1$ group.setText( LaunchMessages.getString( "CDebuggerTab.Automatically_track_values_of" ) ); //$NON-NLS-1$
GridLayout layout = new GridLayout(); GridLayout layout = new GridLayout();
group.setLayout( layout ); group.setLayout( layout );
group.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); group.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
fVarBookKeeping = new Button( group, SWT.CHECK ); fVarBookKeeping = new Button( group, SWT.CHECK );
fVarBookKeeping.setText( LaunchUIPlugin.getResourceString( "CDebuggerTab.Variables" ) ); //$NON-NLS-1$ fVarBookKeeping.setText( LaunchMessages.getString( "CDebuggerTab.Variables" ) ); //$NON-NLS-1$
fRegBookKeeping = new Button( group, SWT.CHECK ); fRegBookKeeping = new Button( group, SWT.CHECK );
fRegBookKeeping.setText( LaunchUIPlugin.getResourceString( "CDebuggerTab.Registers" ) ); //$NON-NLS-1$ fRegBookKeeping.setText( LaunchMessages.getString( "CDebuggerTab.Registers" ) ); //$NON-NLS-1$
initialize(); initialize();
return composite; return composite;
} }
@ -104,21 +103,23 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
*/ */
protected void configureShell( Shell newShell ) { protected void configureShell( Shell newShell ) {
super.configureShell( newShell ); super.configureShell( newShell );
newShell.setText( LaunchUIPlugin.getResourceString( "CDebuggerTab.Advanced_Options_Dialog_Title" ) ); //$NON-NLS-1$ newShell.setText( LaunchMessages.getString( "CDebuggerTab.Advanced_Options_Dialog_Title" ) ); //$NON-NLS-1$
} }
} }
protected Combo fDCombo; final protected boolean fAttachMode;
protected Button fAdvancedButton; protected Button fAdvancedButton;
protected Button fStopInMain; protected Button fStopInMain;
protected Button fAttachButton; protected Button fAttachButton;
private Map fAdvancedAttributes = new HashMap( 5 ); private Map fAdvancedAttributes = new HashMap( 5 );
private boolean fPageUpdated; public CDebuggerTab(boolean attachMode) {
fAttachMode = attachMode;
private boolean fIsInitializing = false; }
public void createControl( Composite parent ) { public void createControl( Composite parent ) {
Composite comp = new Composite( parent, SWT.NONE ); Composite comp = new Composite( parent, SWT.NONE );
setControl( comp ); setControl( comp );
@ -130,16 +131,14 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
gd.grabExcessHorizontalSpace = true; gd.grabExcessHorizontalSpace = true;
comp.setLayoutData( gd ); comp.setLayoutData( gd );
createDebuggerCombo( comp ); createDebuggerCombo( comp, 1 );
createAttachButton( comp );
createOptionsComposite( comp ); createOptionsComposite( comp );
createDebuggerGroup( comp ); createDebuggerGroup( comp, 2 );
} }
protected void loadDebuggerComboBox( ILaunchConfiguration config, String selection ) { protected void loadDebuggerComboBox( ILaunchConfiguration config, String selection ) {
ICDebugConfiguration[] debugConfigs; ICDebugConfiguration[] debugConfigs;
String configPlatform = getPlatform( config ); String configPlatform = getPlatform( config );
fDCombo.removeAll();
debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations(); debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
Arrays.sort( debugConfigs, new Comparator() { Arrays.sort( debugConfigs, new Comparator() {
@ -149,48 +148,46 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
return ic1.getName().compareTo( ic2.getName() ); return ic1.getName().compareTo( ic2.getName() );
} }
} ); } );
int selndx = -1; List list = new ArrayList();
int x = 0; String mode;
if (fAttachMode) {
mode = ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH;
} else {
mode = ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN;
}
String defaultSelection = selection;
for( int i = 0; i < debugConfigs.length; i++ ) { for( int i = 0; i < debugConfigs.length; i++ ) {
if ( debugConfigs[i].supportsMode( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN ) || debugConfigs[i].supportsMode( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH ) ) { if ( debugConfigs[i].supportsMode( mode )) {
String debuggerPlatform = debugConfigs[i].getPlatform(); String debuggerPlatform = debugConfigs[i].getPlatform();
if ( validatePlatform( config, debugConfigs[i] ) ) { if ( validatePlatform( config, debugConfigs[i] ) ) {
fDCombo.add( debugConfigs[i].getName() ); list.add( debugConfigs[i] );
fDCombo.setData( Integer.toString( x ), debugConfigs[i] );
// select first exact matching debugger for platform or requested selection // select first exact matching debugger for platform or requested selection
if ( (selndx == -1 && debuggerPlatform.equalsIgnoreCase( configPlatform )) || selection.equals( debugConfigs[i].getID() ) ) { if ( (defaultSelection.equals("") && debuggerPlatform.equalsIgnoreCase( configPlatform ))) { //$NON-NLS-1$
selndx = x; defaultSelection = debugConfigs[i].getName();
} }
x++;
} }
} }
} }
// if no selection meaning nothing in config the force initdefault on tab // if no selection meaning nothing in config the force initdefault on tab
setInitializeDefault( selection.equals( "" ) ? true : false ); //$NON-NLS-1$ setInitializeDefault( selection.equals( "" ) ? true : false ); //$NON-NLS-1$
fPageUpdated = false; loadDebuggerCombo((ICDebugConfiguration[])list.toArray(new ICDebugConfiguration[list.size()]), defaultSelection);
fDCombo.select( selndx == -1 ? 0 : selndx );
//The behaviour is undefined for if the callbacks should be triggered for this,
//so force page update if needed.
if ( !fPageUpdated ) {
updateComboFromSelection();
}
fPageUpdated = false;
getControl().getParent().layout( true );
} }
protected void updateComboFromSelection() { protected void updateComboFromSelection() {
fPageUpdated = true; super.updateComboFromSelection();
handleDebuggerChanged(); initializeCommonControls( getLaunchConfiguration() );
initializeCommonControls( getLaunchConfigurationWorkingCopy() );
updateLaunchConfigurationDialog();
} }
public void setDefaults( ILaunchConfigurationWorkingCopy config ) { public void setDefaults( ILaunchConfigurationWorkingCopy config ) {
super.setDefaults( config ); super.setDefaults( config );
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT ); if (fAttachMode) {
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH );
} else {
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT );
}
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false ); config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false );
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, false ); config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, false );
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
} }
public void initializeFrom( ILaunchConfiguration config ) { public void initializeFrom( ILaunchConfiguration config ) {
@ -208,7 +205,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
public void performApply( ILaunchConfigurationWorkingCopy config ) { public void performApply( ILaunchConfigurationWorkingCopy config ) {
super.performApply( config ); super.performApply( config );
if ( fAttachButton.getSelection() ) { if ( fAttachMode ) {
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH ); config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH );
} }
else { else {
@ -223,23 +220,17 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
return false; return false;
} }
ICDebugConfiguration debugConfig = getDebugConfig(); ICDebugConfiguration debugConfig = getDebugConfig();
if ( debugConfig == null ) { String mode = fAttachMode ? ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH : ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN;
setErrorMessage( LaunchUIPlugin.getResourceString( "CDebuggerTab.No_debugger_available" ) ); //$NON-NLS-1$ if ( !debugConfig.supportsMode( mode ) ) {
setErrorMessage( MessageFormat.format( LaunchMessages.getString( "CDebuggerTab.Mode_not_supported" ), new String[] { mode } ) ); //$NON-NLS-1$
return false; return false;
} }
if ( fAttachButton != null ) {
String mode = ( fAttachButton.getSelection() ) ? ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH : ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN;
if ( !debugConfig.supportsMode( mode ) ) {
setErrorMessage( MessageFormat.format( LaunchUIPlugin.getResourceString( "CDebuggerTab.Mode_not_supported" ), new String[] { mode } ) ); //$NON-NLS-1$
return false;
}
}
if ( super.isValid( config ) == false ) { if ( super.isValid( config ) == false ) {
return false; return false;
} }
return true; return true;
} }
protected boolean validatePlatform( ILaunchConfiguration config, ICDebugConfiguration debugConfig ) { protected boolean validatePlatform( ILaunchConfiguration config, ICDebugConfiguration debugConfig ) {
String configPlatform = getPlatform( config ); String configPlatform = getPlatform( config );
String debuggerPlatform = debugConfig.getPlatform(); String debuggerPlatform = debugConfig.getPlatform();
@ -261,24 +252,20 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
protected boolean validateDebuggerConfig( ILaunchConfiguration config ) { protected boolean validateDebuggerConfig( ILaunchConfiguration config ) {
ICDebugConfiguration debugConfig = getDebugConfig(); ICDebugConfiguration debugConfig = getDebugConfig();
if ( debugConfig == null ) { if ( debugConfig == null ) {
setErrorMessage( LaunchUIPlugin.getResourceString( "CDebuggerTab.No_debugger_available" ) ); //$NON-NLS-1$ setErrorMessage( LaunchMessages.getString( "CDebuggerTab.No_debugger_available" ) ); //$NON-NLS-1$
return false; return false;
} }
if ( !validatePlatform( config, debugConfig ) || !validateCPU( config, debugConfig ) ) { if ( !validatePlatform( config, debugConfig ) ) {
setErrorMessage( LaunchUIPlugin.getResourceString( "CDebuggerTab.CPU_is_not_supported" ) ); //$NON-NLS-1$ setErrorMessage( LaunchMessages.getString( "CDebuggerTab.Platform_is_not_supported" ) ); //$NON-NLS-1$
return false;
}
if (!validateCPU( config, debugConfig ) ) {
setErrorMessage( LaunchMessages.getString( "CDebuggerTab.CPU_is_not_supported" ) ); //$NON-NLS-1$
return false; return false;
} }
return true; return true;
} }
/**
* Return the class that implements <code>ILaunchConfigurationTab</code> that is registered against the debugger id of the currently selected debugger.
*/
protected ICDebugConfiguration getConfigForCurrentDebugger() {
int selectedIndex = fDCombo.getSelectionIndex();
return (ICDebugConfiguration)fDCombo.getData( Integer.toString( selectedIndex ) );
}
/** /**
* @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog() * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog()
*/ */
@ -286,60 +273,26 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
super.updateLaunchConfigurationDialog(); super.updateLaunchConfigurationDialog();
} }
protected void createDebuggerCombo( Composite parent ) {
Composite comboComp = new Composite( parent, SWT.NONE );
GridLayout layout = new GridLayout( 2, false );
comboComp.setLayout( layout );
Label dlabel = new Label( comboComp, SWT.NONE );
dlabel.setText( LaunchUIPlugin.getResourceString( "Launch.common.DebuggerColon" ) ); //$NON-NLS-1$
fDCombo = new Combo( comboComp, SWT.DROP_DOWN | SWT.READ_ONLY );
fDCombo.addModifyListener( new ModifyListener() {
public void modifyText( ModifyEvent e ) {
if ( !isInitializing() ) {
setInitializeDefault( true );
updateComboFromSelection();
}
}
} );
}
protected void createAttachButton( Composite parent ) {
Composite attachComp = new Composite( parent, SWT.NONE );
GridLayout attachLayout = new GridLayout();
attachLayout.marginHeight = 0;
attachLayout.marginWidth = 0;
attachComp.setLayout( attachLayout );
fAttachButton = createCheckButton( attachComp, LaunchUIPlugin.getResourceString( "CDebuggerTab.Attach_to_running_process" ) ); //$NON-NLS-1$
fAttachButton.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
if ( !isInitializing() ) {
fStopInMain.setSelection( !fAttachButton.getSelection() );
fStopInMain.setEnabled( !fAttachButton.getSelection() );
updateLaunchConfigurationDialog();
}
}
} );
}
protected void createOptionsComposite( Composite parent ) { protected void createOptionsComposite( Composite parent ) {
Composite optionsComp = new Composite( parent, SWT.NONE ); Composite optionsComp = new Composite( parent, SWT.NONE );
GridLayout layout = new GridLayout( 2, true ); GridLayout layout = new GridLayout( 2, true );
optionsComp.setLayout( layout ); optionsComp.setLayout( layout );
optionsComp.setLayoutData( new GridData( GridData.FILL, GridData.CENTER, true, false, 2, 1 ) ); optionsComp.setLayoutData( new GridData( GridData.FILL, GridData.CENTER, true, false, 1, 1 ) );
fStopInMain = createCheckButton( optionsComp, LaunchUIPlugin.getResourceString( "CDebuggerTab.Stop_at_main_on_startup" ) ); //$NON-NLS-1$ if (fAttachMode == true) {
fStopInMain.addSelectionListener( new SelectionAdapter() { createVerticalSpacer(optionsComp, 1);
} else {
public void widgetSelected( SelectionEvent e ) { fStopInMain = createCheckButton( optionsComp, LaunchMessages.getString( "CDebuggerTab.Stop_at_main_on_startup" ) ); //$NON-NLS-1$
if ( !isInitializing() ) { fStopInMain.addSelectionListener( new SelectionAdapter() {
updateLaunchConfigurationDialog();
public void widgetSelected( SelectionEvent e ) {
if ( !isInitializing() ) {
updateLaunchConfigurationDialog();
}
} }
} } );
} ); }
fAdvancedButton = createPushButton( optionsComp, LaunchMessages.getString( "CDebuggerTab.Advanced" ), null ); //$NON-NLS-1$
fAdvancedButton = createPushButton( optionsComp, LaunchUIPlugin.getResourceString( "CDebuggerTab.Advanced" ), null ); //$NON-NLS-1$
GridData data = new GridData(); GridData data = new GridData();
data.horizontalAlignment = GridData.END; data.horizontalAlignment = GridData.END;
PixelConverter pc = new PixelConverter( parent ); PixelConverter pc = new PixelConverter( parent );
@ -354,20 +307,6 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
} ); } );
} }
protected void createDebuggerGroup( Composite parent ) {
Group debuggerGroup = new Group( parent, SWT.SHADOW_ETCHED_IN );
debuggerGroup.setText( LaunchUIPlugin.getResourceString( "CDebuggerTab.Debugger_Options" ) ); //$NON-NLS-1$
setDynamicTabHolder( debuggerGroup );
GridLayout tabHolderLayout = new GridLayout();
tabHolderLayout.marginHeight = 0;
tabHolderLayout.marginWidth = 0;
tabHolderLayout.numColumns = 1;
getDynamicTabHolder().setLayout( tabHolderLayout );
GridData gd = new GridData( GridData.FILL_BOTH );
gd.horizontalSpan = 2;
getDynamicTabHolder().setLayoutData( gd );
}
protected Map getAdvancedAttributes() { protected Map getAdvancedAttributes() {
return fAdvancedAttributes; return fAdvancedAttributes;
} }
@ -411,29 +350,16 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
} }
protected void initializeCommonControls( ILaunchConfiguration config ) { protected void initializeCommonControls( ILaunchConfiguration config ) {
ICDebugConfiguration debugConfig = getConfigForCurrentDebugger();
try { try {
String mode = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN ); if (!fAttachMode) {
fAttachButton.setEnabled( debugConfig != null && debugConfig.supportsMode( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH ) ); fStopInMain.setSelection( config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT ) );
if ( fAttachButton.isEnabled() ) }
fAttachButton.setSelection( mode.equals( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH ) );
fStopInMain.setEnabled( debugConfig != null && !fAttachButton.getSelection() );
if ( fStopInMain.isEnabled() )
fStopInMain.setSelection( ( fAttachButton.getSelection() ) ? false : config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT ) );
initializeAdvancedAttributes( config ); initializeAdvancedAttributes( config );
} }
catch( CoreException e ) { catch( CoreException e ) {
} }
} }
protected boolean isInitializing() {
return fIsInitializing;
}
private void setInitializing( boolean isInitializing ) {
fIsInitializing = isInitializing;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab#setInitializeDefault(boolean) * @see org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab#setInitializeDefault(boolean)
*/ */

View file

@ -20,10 +20,11 @@ import java.util.Properties;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.launch.internal.ui.LaunchImages; import org.eclipse.cdt.launch.internal.ui.LaunchImages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialog;
@ -131,7 +132,7 @@ public class CEnvironmentTab extends CLaunchConfigurationTab {
protected void configureShell(Shell shell) { protected void configureShell(Shell shell) {
super.configureShell(shell); super.configureShell(shell);
String title = (fEdit) ? LaunchUIPlugin.getResourceString("CEnvironmentTab.Edit_Variable") : LaunchUIPlugin.getResourceString("CEnvironmentTab.New_Variable"); //$NON-NLS-1$ //$NON-NLS-2$ String title = (fEdit) ? LaunchMessages.getString("CEnvironmentTab.Edit_Variable") : LaunchMessages.getString("CEnvironmentTab.New_Variable"); //$NON-NLS-1$ //$NON-NLS-2$
shell.setText(title); shell.setText(title);
} }
@ -149,14 +150,14 @@ public class CEnvironmentTab extends CLaunchConfigurationTab {
int fieldWidthHint = convertWidthInCharsToPixels(metrics, 50); int fieldWidthHint = convertWidthInCharsToPixels(metrics, 50);
Label label = new Label(composite, SWT.NONE); Label label = new Label(composite, SWT.NONE);
label.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.NameColon")); //$NON-NLS-1$ label.setText(LaunchMessages.getString("CEnvironmentTab.NameColon")); //$NON-NLS-1$
fTextName = new Text(composite, SWT.SINGLE | SWT.BORDER); fTextName = new Text(composite, SWT.SINGLE | SWT.BORDER);
GridData gd = new GridData(GridData.FILL_BOTH); GridData gd = new GridData(GridData.FILL_BOTH);
gd.grabExcessHorizontalSpace = true; gd.grabExcessHorizontalSpace = true;
gd.widthHint = fieldWidthHint; gd.widthHint = fieldWidthHint;
fTextName.setLayoutData(gd); fTextName.setLayoutData(gd);
label = new Label(composite, SWT.NONE); label = new Label(composite, SWT.NONE);
label.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.ValueColon")); //$NON-NLS-1$ label.setText(LaunchMessages.getString("CEnvironmentTab.ValueColon")); //$NON-NLS-1$
fTextValue = new Text(composite, SWT.SINGLE | SWT.BORDER); fTextValue = new Text(composite, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_BOTH); gd = new GridData(GridData.FILL_BOTH);
gd.grabExcessHorizontalSpace = true; gd.grabExcessHorizontalSpace = true;
@ -272,11 +273,11 @@ public class CEnvironmentTab extends CLaunchConfigurationTab {
table.setLinesVisible(true); table.setLinesVisible(true);
TableColumn column1 = new TableColumn(table, SWT.NULL); TableColumn column1 = new TableColumn(table, SWT.NULL);
column1.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.Name")); //$NON-NLS-1$ column1.setText(LaunchMessages.getString("CEnvironmentTab.Name")); //$NON-NLS-1$
tableLayout.addColumnData(new ColumnWeightData(30)); tableLayout.addColumnData(new ColumnWeightData(30));
TableColumn column2 = new TableColumn(table, SWT.NULL); TableColumn column2 = new TableColumn(table, SWT.NULL);
column2.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.Value")); //$NON-NLS-1$ column2.setText(LaunchMessages.getString("CEnvironmentTab.Value")); //$NON-NLS-1$
tableLayout.addColumnData(new ColumnWeightData(30)); tableLayout.addColumnData(new ColumnWeightData(30));
fVariableList.addDoubleClickListener(new IDoubleClickListener() { fVariableList.addDoubleClickListener(new IDoubleClickListener() {
@ -296,7 +297,7 @@ public class CEnvironmentTab extends CLaunchConfigurationTab {
composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
composite.setLayout(new GridLayout(1, true)); composite.setLayout(new GridLayout(1, true));
fBtnNew = new Button(composite, SWT.NONE); fBtnNew = new Button(composite, SWT.NONE);
fBtnNew.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.New...")); //$NON-NLS-1$ fBtnNew.setText(LaunchMessages.getString("CEnvironmentTab.New...")); //$NON-NLS-1$
fBtnNew.setLayoutData(new GridData(GridData.FILL_BOTH)); fBtnNew.setLayoutData(new GridData(GridData.FILL_BOTH));
fBtnNew.addSelectionListener(new SelectionAdapter() { fBtnNew.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
@ -304,7 +305,7 @@ public class CEnvironmentTab extends CLaunchConfigurationTab {
} }
}); });
fBtnImport = new Button(composite, SWT.NONE); fBtnImport = new Button(composite, SWT.NONE);
fBtnImport.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.Import...")); //$NON-NLS-1$ fBtnImport.setText(LaunchMessages.getString("CEnvironmentTab.Import...")); //$NON-NLS-1$
fBtnImport.setLayoutData(new GridData(GridData.FILL_BOTH)); fBtnImport.setLayoutData(new GridData(GridData.FILL_BOTH));
fBtnImport.addSelectionListener(new SelectionAdapter() { fBtnImport.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
@ -312,7 +313,7 @@ public class CEnvironmentTab extends CLaunchConfigurationTab {
} }
}); });
fBtnEdit = new Button(composite, SWT.NONE); fBtnEdit = new Button(composite, SWT.NONE);
fBtnEdit.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.Edit...")); //$NON-NLS-1$ fBtnEdit.setText(LaunchMessages.getString("CEnvironmentTab.Edit...")); //$NON-NLS-1$
fBtnEdit.setLayoutData(new GridData(GridData.FILL_BOTH)); fBtnEdit.setLayoutData(new GridData(GridData.FILL_BOTH));
fBtnEdit.addSelectionListener(new SelectionAdapter() { fBtnEdit.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
@ -320,7 +321,7 @@ public class CEnvironmentTab extends CLaunchConfigurationTab {
} }
}); });
fBtnRemove = new Button(composite, SWT.NONE); fBtnRemove = new Button(composite, SWT.NONE);
fBtnRemove.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.Remove")); //$NON-NLS-1$ fBtnRemove.setText(LaunchMessages.getString("CEnvironmentTab.Remove")); //$NON-NLS-1$
fBtnRemove.setLayoutData(new GridData(GridData.FILL_BOTH)); fBtnRemove.setLayoutData(new GridData(GridData.FILL_BOTH));
fBtnRemove.addSelectionListener(new SelectionAdapter() { fBtnRemove.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
@ -392,7 +393,7 @@ public class CEnvironmentTab extends CLaunchConfigurationTab {
if(fElements.getProperty(key) != null) { if(fElements.getProperty(key) != null) {
boolean overwrite; boolean overwrite;
overwrite = MessageDialog.openQuestion(getShell(), LaunchUIPlugin.getResourceString("CEnvironmentTab.Existing_Environment_Variable"), LaunchUIPlugin.getFormattedResourceString("CEnvironmentTab.Environment_variable_NAME_exists", key)); //$NON-NLS-1$ //$NON-NLS-2$ overwrite = MessageDialog.openQuestion(getShell(), LaunchMessages.getString("CEnvironmentTab.Existing_Environment_Variable"), LaunchMessages.getFormattedString("CEnvironmentTab.Environment_variable_NAME_exists", key)); //$NON-NLS-1$ //$NON-NLS-2$
if(!overwrite) { if(!overwrite) {
continue; continue;
} }
@ -461,7 +462,7 @@ public class CEnvironmentTab extends CLaunchConfigurationTab {
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
*/ */
public String getName() { public String getName() {
return LaunchUIPlugin.getResourceString("CEnvironmentTab.Environment"); //$NON-NLS-1$ return LaunchMessages.getString("CEnvironmentTab.Environment"); //$NON-NLS-1$
} }
/** /**

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.internal.ui.CPluginImages; import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
import org.eclipse.cdt.launch.internal.ui.LaunchImages; import org.eclipse.cdt.launch.internal.ui.LaunchImages;
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.ui.CElementImageDescriptor; import org.eclipse.cdt.ui.CElementImageDescriptor;
import org.eclipse.cdt.ui.CElementLabelProvider; import org.eclipse.cdt.ui.CElementLabelProvider;
@ -113,7 +114,7 @@ public class CMainTab extends CLaunchConfigurationTab {
projComp.setLayoutData(gd); projComp.setLayoutData(gd);
fProjLabel = new Label(projComp, SWT.NONE); fProjLabel = new Label(projComp, SWT.NONE);
fProjLabel.setText(LaunchUIPlugin.getResourceString("CMainTab.&ProjectColon")); //$NON-NLS-1$ fProjLabel.setText(LaunchMessages.getString("CMainTab.&ProjectColon")); //$NON-NLS-1$
gd = new GridData(); gd = new GridData();
gd.horizontalSpan = 2; gd.horizontalSpan = 2;
fProjLabel.setLayoutData(gd); fProjLabel.setLayoutData(gd);
@ -128,7 +129,7 @@ public class CMainTab extends CLaunchConfigurationTab {
} }
}); });
fProjButton = createPushButton(projComp, LaunchUIPlugin.getResourceString("Launch.common.Browse_1"), null); //$NON-NLS-1$ fProjButton = createPushButton(projComp, LaunchMessages.getString("Launch.common.Browse_1"), null); //$NON-NLS-1$
fProjButton.addSelectionListener(new SelectionAdapter() { fProjButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
@ -148,7 +149,7 @@ public class CMainTab extends CLaunchConfigurationTab {
gd = new GridData(GridData.FILL_HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL);
mainComp.setLayoutData(gd); mainComp.setLayoutData(gd);
fProgLabel = new Label(mainComp, SWT.NONE); fProgLabel = new Label(mainComp, SWT.NONE);
fProgLabel.setText(LaunchUIPlugin.getResourceString("CMainTab.C/C++_Application")); //$NON-NLS-1$ fProgLabel.setText(LaunchMessages.getString("CMainTab.C/C++_Application")); //$NON-NLS-1$
gd = new GridData(); gd = new GridData();
gd.horizontalSpan = 3; gd.horizontalSpan = 3;
fProgLabel.setLayoutData(gd); fProgLabel.setLayoutData(gd);
@ -162,7 +163,7 @@ public class CMainTab extends CLaunchConfigurationTab {
} }
}); });
fSearchButton = createPushButton(mainComp, LaunchUIPlugin.getResourceString("CMainTab.Search..."), null); //$NON-NLS-1$ fSearchButton = createPushButton(mainComp, LaunchMessages.getString("CMainTab.Search..."), null); //$NON-NLS-1$
fSearchButton.addSelectionListener(new SelectionAdapter() { fSearchButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
@ -172,7 +173,7 @@ public class CMainTab extends CLaunchConfigurationTab {
}); });
Button fBrowseForBinaryButton; Button fBrowseForBinaryButton;
fBrowseForBinaryButton = createPushButton(mainComp, LaunchUIPlugin.getResourceString("Launch.common.Browse_2"), null); //$NON-NLS-1$ fBrowseForBinaryButton = createPushButton(mainComp, LaunchMessages.getString("Launch.common.Browse_2"), null); //$NON-NLS-1$
fBrowseForBinaryButton.addSelectionListener(new SelectionAdapter() { fBrowseForBinaryButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
@ -228,8 +229,8 @@ public class CMainTab extends CLaunchConfigurationTab {
protected void handleSearchButtonSelected() { protected void handleSearchButtonSelected() {
if (getCProject() == null) { if (getCProject() == null) {
MessageDialog.openInformation(getShell(), LaunchUIPlugin.getResourceString("CMainTab.Project_required"), //$NON-NLS-1$ MessageDialog.openInformation(getShell(), LaunchMessages.getString("CMainTab.Project_required"), //$NON-NLS-1$
LaunchUIPlugin.getResourceString("CMainTab.Enter_project_before_searching_for_program")); //$NON-NLS-1$ LaunchMessages.getString("CMainTab.Enter_project_before_searching_for_program")); //$NON-NLS-1$
return; return;
} }
@ -284,10 +285,10 @@ public class CMainTab extends CLaunchConfigurationTab {
TwoPaneElementSelector dialog = new TwoPaneElementSelector(getShell(), programLabelProvider, qualifierLabelProvider); TwoPaneElementSelector dialog = new TwoPaneElementSelector(getShell(), programLabelProvider, qualifierLabelProvider);
dialog.setElements(getBinaryFiles(getCProject())); dialog.setElements(getBinaryFiles(getCProject()));
dialog.setMessage(LaunchUIPlugin.getResourceString("CMainTab.Choose_program_to_run")); //$NON-NLS-1$ dialog.setMessage(LaunchMessages.getString("CMainTab.Choose_program_to_run")); //$NON-NLS-1$
dialog.setTitle(LaunchUIPlugin.getResourceString("CMainTab.Program_Selection")); //$NON-NLS-1$ dialog.setTitle(LaunchMessages.getString("CMainTab.Program_Selection")); //$NON-NLS-1$
dialog.setUpperListLabel(LaunchUIPlugin.getResourceString("Launch.common.BinariesColon")); //$NON-NLS-1$ dialog.setUpperListLabel(LaunchMessages.getString("Launch.common.BinariesColon")); //$NON-NLS-1$
dialog.setLowerListLabel(LaunchUIPlugin.getResourceString("Launch.common.QualifierColon")); //$NON-NLS-1$ dialog.setLowerListLabel(LaunchMessages.getString("Launch.common.QualifierColon")); //$NON-NLS-1$
dialog.setMultipleSelection(false); dialog.setMultipleSelection(false);
//dialog.set //dialog.set
if (dialog.open() == Window.OK) { if (dialog.open() == Window.OK) {
@ -305,8 +306,8 @@ public class CMainTab extends CLaunchConfigurationTab {
protected void handleBinaryBrowseButtonSelected() { protected void handleBinaryBrowseButtonSelected() {
final ICProject cproject = getCProject(); final ICProject cproject = getCProject();
if (cproject == null) { if (cproject == null) {
MessageDialog.openInformation(getShell(), LaunchUIPlugin.getResourceString("CMainTab.Project_required"), //$NON-NLS-1$ MessageDialog.openInformation(getShell(), LaunchMessages.getString("CMainTab.Project_required"), //$NON-NLS-1$
LaunchUIPlugin.getResourceString("CMainTab.Enter_project_before_browsing_for_program")); //$NON-NLS-1$ LaunchMessages.getString("CMainTab.Enter_project_before_browsing_for_program")); //$NON-NLS-1$
return; return;
} }
@ -314,8 +315,8 @@ public class CMainTab extends CLaunchConfigurationTab {
WorkbenchLabelProvider labelProvider = new WorkbenchLabelProvider(); WorkbenchLabelProvider labelProvider = new WorkbenchLabelProvider();
WorkbenchContentProvider contentProvider = new WorkbenchContentProvider(); WorkbenchContentProvider contentProvider = new WorkbenchContentProvider();
dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, contentProvider); dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, contentProvider);
dialog.setTitle(LaunchUIPlugin.getResourceString("CMainTab.Program_selection")); //$NON-NLS-1$ dialog.setTitle(LaunchMessages.getString("CMainTab.Program_selection")); //$NON-NLS-1$
dialog.setMessage(LaunchUIPlugin.getFormattedResourceString( dialog.setMessage(LaunchMessages.getFormattedString(
"CMainTab.Choose_program_to_run_from_NAME", cproject.getResource().getName())); //$NON-NLS-1$ "CMainTab.Choose_program_to_run_from_NAME", cproject.getResource().getName())); //$NON-NLS-1$
dialog.setBlockOnOpen(true); dialog.setBlockOnOpen(true);
dialog.setAllowMultiple(false); dialog.setAllowMultiple(false);
@ -325,21 +326,21 @@ public class CMainTab extends CLaunchConfigurationTab {
public IStatus validate(Object[] selection) { public IStatus validate(Object[] selection) {
if (selection.length == 0 || ! (selection[0] instanceof IFile)) { if (selection.length == 0 || ! (selection[0] instanceof IFile)) {
return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1,
LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_file"), null); //$NON-NLS-1$ LaunchMessages.getString("CMainTab.Selection_must_be_file"), null); //$NON-NLS-1$
} }
try { try {
ICElement celement = cproject.findElement( ((IFile)selection[0]).getProjectRelativePath()); ICElement celement = cproject.findElement( ((IFile)selection[0]).getProjectRelativePath());
if (celement == null if (celement == null
|| (celement.getElementType() != ICElement.C_BINARY && celement.getElementType() != ICElement.C_ARCHIVE)) { || (celement.getElementType() != ICElement.C_BINARY && celement.getElementType() != ICElement.C_ARCHIVE)) {
return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1,
LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$ LaunchMessages.getString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
} }
return new Status(IStatus.OK, LaunchUIPlugin.getUniqueIdentifier(), IStatus.OK, return new Status(IStatus.OK, LaunchUIPlugin.getUniqueIdentifier(), IStatus.OK,
celement.getResource().getName(), null); celement.getResource().getName(), null);
} catch (Exception ex) { } catch (Exception ex) {
return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1, return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1,
LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$ LaunchMessages.getString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
} }
} }
}); });
@ -411,8 +412,8 @@ public class CMainTab extends CLaunchConfigurationTab {
ILabelProvider labelProvider = new CElementLabelProvider(); ILabelProvider labelProvider = new CElementLabelProvider();
ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider); ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
dialog.setTitle(LaunchUIPlugin.getResourceString("CMainTab.Project_Selection")); //$NON-NLS-1$ dialog.setTitle(LaunchMessages.getString("CMainTab.Project_Selection")); //$NON-NLS-1$
dialog.setMessage(LaunchUIPlugin.getResourceString("CMainTab.Choose_project_to_constrain_search_for_program")); //$NON-NLS-1$ dialog.setMessage(LaunchMessages.getString("CMainTab.Choose_project_to_constrain_search_for_program")); //$NON-NLS-1$
dialog.setElements(projects); dialog.setElements(projects);
ICProject cProject = getCProject(); ICProject cProject = getCProject();
@ -478,30 +479,30 @@ public class CMainTab extends CLaunchConfigurationTab {
String name = fProjText.getText().trim(); String name = fProjText.getText().trim();
if (name.length() == 0) { if (name.length() == 0) {
setErrorMessage(LaunchUIPlugin.getResourceString("CMainTab.Project_not_specified")); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getString("CMainTab.Project_not_specified")); //$NON-NLS-1$
return false; return false;
} }
if (!ResourcesPlugin.getWorkspace().getRoot().getProject(name).exists()) { if (!ResourcesPlugin.getWorkspace().getRoot().getProject(name).exists()) {
setErrorMessage(LaunchUIPlugin.getResourceString("Launch.common.Project_does_not_exist")); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getString("Launch.common.Project_does_not_exist")); //$NON-NLS-1$
return false; return false;
} }
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
name = fProgText.getText().trim(); name = fProgText.getText().trim();
if (name.length() == 0) { if (name.length() == 0) {
setErrorMessage(LaunchUIPlugin.getResourceString("CMainTab.Program_not_specified")); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getString("CMainTab.Program_not_specified")); //$NON-NLS-1$
return false; return false;
} }
if (name.equals(".") || name.equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$ if (name.equals(".") || name.equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$
setErrorMessage(LaunchUIPlugin.getResourceString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
return false; return false;
} }
if (!project.isOpen()) { if (!project.isOpen()) {
setErrorMessage(LaunchUIPlugin.getResourceString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$
return false; return false;
} }
if (!project.getFile(name).exists()) { if (!project.getFile(name).exists()) {
setErrorMessage(LaunchUIPlugin.getResourceString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
return false; return false;
} }
return true; return true;
@ -563,7 +564,7 @@ public class CMainTab extends CLaunchConfigurationTab {
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
*/ */
public String getName() { public String getName() {
return LaunchUIPlugin.getResourceString("CMainTab.Main"); //$NON-NLS-1$ return LaunchMessages.getString("CMainTab.Main"); //$NON-NLS-1$
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -14,7 +14,7 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.sourcelookup.SourceLookupBlock; import org.eclipse.cdt.debug.ui.sourcelookup.SourceLookupBlock;
import org.eclipse.cdt.launch.internal.ui.LaunchImages; import org.eclipse.cdt.launch.internal.ui.LaunchImages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -83,7 +83,7 @@ public class CSourceLookupTab extends CLaunchConfigurationTab
*/ */
public String getName() public String getName()
{ {
return LaunchUIPlugin.getResourceString("CSourceLookupTab.Source"); //$NON-NLS-1$ return LaunchMessages.getString("CSourceLookupTab.Source"); //$NON-NLS-1$
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -1,22 +1,26 @@
/********************************************************************** /*******************************************************************************
* Copyright (c) 2004 QNX Software Systems and others. * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* All rights reserved. This program and the accompanying materials * program and the accompanying materials are made available under the terms of
* are made available under the terms of the Common Public License v1.0 * the Common Public License v1.0 which accompanies this distribution, and is
* which accompanies this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v10.html
* http://www.eclipse.org/legal/cpl-v10.html *
* * Contributors: QNX Software Systems - Initial API and implementation
* Contributors: ******************************************************************************/
* QNX Software Systems - Initial API and implementation package org.eclipse.cdt.launch.ui;
***********************************************************************/
package org.eclipse.cdt.launch.ui;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor; import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab;
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.debug.ui.ILaunchConfigurationTab;
@ -25,100 +29,128 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.help.WorkbenchHelp;
public class CoreFileDebuggerTab extends CDebuggerTab { public class CoreFileDebuggerTab extends AbstractCDebuggerTab {
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
*/ */
public void createControl( Composite parent ) { public void createControl(Composite parent) {
Composite comp = new Composite( parent, SWT.NONE ); Composite comp = new Composite(parent, SWT.NONE);
setControl( comp ); setControl(comp);
WorkbenchHelp.setHelp( getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB ); WorkbenchHelp.setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB);
GridLayout topLayout = new GridLayout( 2, false ); GridLayout topLayout = new GridLayout(1, false);
comp.setLayout( topLayout ); comp.setLayout(topLayout);
createDebuggerCombo( comp ); createDebuggerCombo(comp, 1);
createDebuggerGroup( comp ); createDebuggerGroup(comp, 1);
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
*/ */
public void setDefaults( ILaunchConfigurationWorkingCopy config ) { public void setDefaults(ILaunchConfigurationWorkingCopy config) {
super.setDefaults( config ); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE ); ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE);
} }
/* (non-Javadoc) /*
* @see org.eclipse.cdt.launch.ui.CDebuggerTab#initializeCommonControls(org.eclipse.debug.core.ILaunchConfiguration) * (non-Javadoc)
*/ *
protected void initializeCommonControls( ILaunchConfiguration config ) {
// no common controls for this tab
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
*/ */
public void performApply( ILaunchConfigurationWorkingCopy config ) { public void performApply(ILaunchConfigurationWorkingCopy config) {
if ( getDebugConfig() != null ) { if (getDebugConfig() != null) {
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, getDebugConfig().getID() ); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, getDebugConfig().getID());
ILaunchConfigurationTab dynamicTab = getDynamicTab(); ILaunchConfigurationTab dynamicTab = getDynamicTab();
if ( dynamicTab == null ) { if (dynamicTab == null) {
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null ); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null);
} } else {
else { dynamicTab.performApply(config);
dynamicTab.performApply( config );
} }
} }
} }
protected void loadDebuggerComboBox( ILaunchConfiguration config, String selection ) { public void initializeFrom(ILaunchConfiguration config) {
fDCombo.removeAll(); setInitializing(true);
super.initializeFrom(config);
try {
String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
loadDebuggerComboBox(config, id);
} catch (CoreException e) {
}
setInitializing(false);
}
public boolean isValid(ILaunchConfiguration config) {
if (!validateDebuggerConfig(config)) {
return false;
}
if (super.isValid(config) == false) {
return false;
}
return true;
}
protected boolean validateDebuggerConfig(ILaunchConfiguration config) {
ICDebugConfiguration debugConfig = getDebugConfig();
if (debugConfig == null) {
setErrorMessage(LaunchMessages.getString("CoreFileDebuggerTab.No_debugger_available")); //$NON-NLS-1$
return false;
}
if (!validatePlatform(config, debugConfig)) {
setErrorMessage(LaunchMessages.getString("CoreFileDebuggerTab.platform_is_not_supported")); //$NON-NLS-1$
return false;
}
return true;
}
protected void loadDebuggerComboBox(ILaunchConfiguration config, String selection) {
ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations(); ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
String projectPlatform = getProjectPlatform( config ); String projectPlatform = getProjectPlatform(config);
int x = 0; String defaultSelection = null;
int selndx = -1; List list = new ArrayList();
for( int i = 0; i < debugConfigs.length; i++ ) { for (int i = 0; i < debugConfigs.length; i++) {
if ( debugConfigs[i].supportsMode( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE ) ) { if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
if ( validatePlatform( config, debugConfigs[i] ) ) { if (validatePlatform(config, debugConfigs[i])) {
fDCombo.add( debugConfigs[i].getName() ); list.add(debugConfigs[i]);
fDCombo.setData( Integer.toString( x ), debugConfigs[i] ); // select first exact matching debugger for platform or
// select first exact matching debugger for platform or requested selection // requested selection
String debuggerPlatform = debugConfigs[i].getPlatform(); String debuggerPlatform = debugConfigs[i].getPlatform();
if ( (selndx == -1 && debuggerPlatform.equalsIgnoreCase( projectPlatform )) || selection.equals( debugConfigs[i].getID() ) ) { if (defaultSelection == null && debuggerPlatform.equalsIgnoreCase(projectPlatform)) { //$NON-NLS-1$
selndx = x; defaultSelection = debugConfigs[i].getName();
} }
x++; }
if (selection.equals(debugConfigs[i].getID())) {
defaultSelection = debugConfigs[i].getName();
} }
} }
} }
// if no selection meaning nothing in config the force initdefault on tab // if no selection meaning nothing in config the force initdefault on
setInitializeDefault( selection.equals( "" ) ? true : false ); //$NON-NLS-1$ // tab
fDCombo.select( selndx == -1 ? 0 : selndx ); setInitializeDefault(selection.equals("") ? true : false); //$NON-NLS-1$
//The behaviour is undefined for if the callbacks should be triggered for this, loadDebuggerCombo((ICDebugConfiguration[])list.toArray(new ICDebugConfiguration[list.size()]), defaultSelection);
//so to avoid unnecessary confusion, we force an update.
handleDebuggerChanged();
getControl().getParent().layout( true );
} }
protected boolean validatePlatform( ILaunchConfiguration config, ICDebugConfiguration debugConfig ) { protected boolean validatePlatform(ILaunchConfiguration config, ICDebugConfiguration debugConfig) {
String projectPlatform = getProjectPlatform( config ); String projectPlatform = getProjectPlatform(config);
String debuggerPlatform = debugConfig.getPlatform(); String debuggerPlatform = debugConfig.getPlatform();
return ( debuggerPlatform.equals( "*" ) || debuggerPlatform.equalsIgnoreCase( projectPlatform ) ); //$NON-NLS-1$ return (projectPlatform.equals("*") || debuggerPlatform.equals("*") || debuggerPlatform.equalsIgnoreCase(projectPlatform)); //$NON-NLS-1$ //$NON-NLS-2$
} }
private String getProjectPlatform( ILaunchConfiguration config ) { private String getProjectPlatform(ILaunchConfiguration config) {
ICElement ce = getContext( config, null ); ICElement ce = getContext(config, null);
String projectPlatform = "*"; //$NON-NLS-1$ String projectPlatform = "*"; //$NON-NLS-1$
if ( ce != null ) { if (ce != null) {
try { try {
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription( ce.getCProject().getProject(), false ); ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(ce.getCProject().getProject(), false);
if ( descriptor != null ) { if (descriptor != null) {
projectPlatform = descriptor.getPlatform(); projectPlatform = descriptor.getPlatform();
} }
} } catch (Exception e) {
catch( Exception e ) {
} }
} }
return projectPlatform; return projectPlatform;
} }
} }