1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Moved the extraction of the stop symbol to the launch.

This commit is contained in:
Mikhail Khodjaiants 2006-03-27 20:34:02 +00:00
parent 6d80cc5d00
commit 1018fe85a9
6 changed files with 103 additions and 7 deletions

View file

@ -1,3 +1,8 @@
2006-03-27 Mikhail Khodjaiants
Moved the extraction of the stop symbol to the launch.
* CDIDebugModel.java
* CDebugTarget.java
2006-03-06 Mikhail Khodjaiants
Fix for Bug 93777: Postmortem and Local launch need a default preference for selected debugger.
* CDebugCorePlugin.java

View file

@ -65,6 +65,43 @@ public class CDIDebugModel {
return CDebugCorePlugin.getUniqueIdentifier();
}
/**
* Creates and returns a debug target for the given CDI target, with the specified name, and associates it with the given process for console I/O. The debug
* target is added to the given launch.
*
* @param launch the launch the new debug target will be contained in
* @param project the project to use to persist breakpoints.
* @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 debuggeeProcess the process to associate with the debug target, which will be returned from <code>IDebugTarget.getProcess</code>
* @param file the executable to debug.
* @param allowTerminate allow terminate().
* @param allowDisconnect allow disconnect().
* @param stopSymbol place temporary breakpoint at <code>stopSymbol</code>, ignore if <code>null</code> or empty.
* @param resumeTarget resume target.
* @return a debug target
* @throws DebugException
* @since 3.1
*/
public static IDebugTarget newDebugTarget( final ILaunch launch, final IProject project, final ICDITarget cdiTarget, final String name, final IProcess debuggeeProcess, final IBinaryObject file, final boolean allowTerminate, final boolean allowDisconnect, final String stopSymbol, final boolean resumeTarget ) throws DebugException {
final IDebugTarget[] target = new IDebugTarget[1];
IWorkspaceRunnable r = new IWorkspaceRunnable() {
public void run( IProgressMonitor m ) throws CoreException {
target[0] = new CDebugTarget( launch, project, cdiTarget, name, debuggeeProcess, file, allowTerminate, allowDisconnect );
((CDebugTarget)target[0]).start( stopSymbol, resumeTarget );
}
};
try {
ResourcesPlugin.getWorkspace().run( r, null );
}
catch( CoreException e ) {
CDebugCorePlugin.log( e );
throw new DebugException( e.getStatus() );
}
return target[0];
}
/**
* Creates and returns a debug target for the given CDI target, with the specified name, and associates it with the given process for console I/O. The debug
* target is added to the given launch.
@ -81,14 +118,18 @@ public class CDIDebugModel {
* @param resumeTarget resume target.
* @return a debug target
* @throws DebugException
* @deprecated
*/
public static IDebugTarget newDebugTarget( final ILaunch launch, final IProject project, final ICDITarget cdiTarget, final String name, final IProcess debuggeeProcess, final IBinaryObject file, final boolean allowTerminate, final boolean allowDisconnect, final boolean stopInMain, final boolean resumeTarget ) throws DebugException {
final IDebugTarget[] target = new IDebugTarget[1];
IWorkspaceRunnable r = new IWorkspaceRunnable() {
public void run( IProgressMonitor m ) throws CoreException {
String stopSymbol = null;
if ( stopInMain )
stopSymbol = launch.getLaunchConfiguration().getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT );
target[0] = new CDebugTarget( launch, project, cdiTarget, name, debuggeeProcess, file, allowTerminate, allowDisconnect );
((CDebugTarget)target[0]).start( stopInMain, resumeTarget );
((CDebugTarget)target[0]).start( stopSymbol, resumeTarget );
}
};
try {
@ -118,7 +159,7 @@ public class CDIDebugModel {
* @throws DebugException
*/
public static IDebugTarget newDebugTarget( ILaunch launch, IProject project, ICDITarget cdiTarget, final String name, IProcess debuggeeProcess, IBinaryObject file, boolean allowTerminate, boolean allowDisconnect, boolean resumeTarget ) throws DebugException {
return newDebugTarget( launch, project, cdiTarget, name, debuggeeProcess, file, allowTerminate, allowDisconnect, false, resumeTarget );
return newDebugTarget( launch, project, cdiTarget, name, debuggeeProcess, file, allowTerminate, allowDisconnect, null, resumeTarget );
}
/**
@ -454,7 +495,10 @@ public class CDIDebugModel {
*/
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, true );
String stopSymbol = null;
if ( stopInMain )
stopSymbol = launch.getLaunchConfiguration().getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT );
return newDebugTarget( launch, file.getProject(), target, name, iprocess, exeFile, allowTerminate, allowDisconnect, stopSymbol, true );
}
/**

View file

@ -270,11 +270,32 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
}
public void start( boolean stopInMain, boolean resume ) throws DebugException {
String stopSymbol = null;
try {
if ( stopInMain )
stopSymbol = getLaunch().getLaunchConfiguration().getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT );
}
catch( CoreException e ) {
throw new DebugException( e.getStatus() );
}
ICDITargetConfiguration config = getConfiguration();
if ( config.supportsBreakpoints() ) {
getBreakpointManager().setInitialBreakpoints();
if ( stopInMain ) {
stopInMain();
if ( stopSymbol != null && stopSymbol.length() != 0 ) {
stopAtSymbol( stopSymbol );
}
}
if ( config.supportsResume() && resume ) {
resume();
}
}
public void start( String stopSymbol, boolean resume ) throws DebugException {
ICDITargetConfiguration config = getConfiguration();
if ( config.supportsBreakpoints() ) {
getBreakpointManager().setInitialBreakpoints();
if ( stopSymbol != null && stopSymbol.length() != 0 ) {
stopAtSymbol( stopSymbol );
}
}
if ( config.supportsResume() && resume ) {
@ -1699,6 +1720,21 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
getBreakpointManager().skipBreakpoints( enabled );
}
protected void stopAtSymbol( String stopSymbol ) throws DebugException {
try {
ICDILocation location = getCDITarget().createFunctionLocation( "", stopSymbol ); //$NON-NLS-1$
setInternalTemporaryBreakpoint( location );
}
catch( CoreException e ) {
String message = MessageFormat.format( 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 );
if ( !CDebugUtils.question( newStatus, this ) ) {
terminate();
throw new DebugException( new Status( IStatus.OK, e.getStatus().getPlugin(), e.getStatus().getCode(), e.getStatus().getMessage(), null ) );
}
}
}
protected void stopInMain() throws DebugException {
String mainSymbol = new String( ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT );
try {

View file

@ -1,3 +1,8 @@
2006-03-27 Mikhail Khodjaiants
Moved the extraction of the stop symbol to the launch.
* LocalCDILaunchDelegate.java
* LocalRunLaunchDelegate.java
2006-03-15 Mikhail Khodjaiants
Reversing previous changes. The existing "verifyProgramPath" method can be used.
* AbstractCLaunchDelegate.java

View file

@ -142,6 +142,9 @@ public class LocalCDILaunchDelegate extends AbstractCLaunchDelegate {
monitor.worked( 1 );
boolean stopInMain = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false );
String stopSymbol = null;
if ( stopInMain )
stopSymbol = launch.getLaunchConfiguration().getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT );
ICDITarget[] targets = dsession.getTargets();
for( int i = 0; i < targets.length; i++ ) {
Process process = targets[i].getProcess();
@ -149,7 +152,7 @@ public class LocalCDILaunchDelegate extends AbstractCLaunchDelegate {
if ( process != null ) {
iprocess = DebugPlugin.newProcess( launch, process, renderProcessLabel( exePath.toOSString() ), getDefaultProcessMap() );
}
CDIDebugModel.newDebugTarget( launch, project.getProject(), targets[i], renderTargetLabel( debugConfig ), iprocess, exeFile, true, false, stopInMain, true );
CDIDebugModel.newDebugTarget( launch, project.getProject(), targets[i], renderTargetLabel( debugConfig ), iprocess, exeFile, true, false, stopSymbol, true );
}
}
catch( CoreException e ) {

View file

@ -96,6 +96,9 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate {
monitor.worked(1);
boolean stopInMain = config
.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
String stopSymbol = null;
if ( stopInMain )
stopSymbol = launch.getLaunchConfiguration().getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT );
ICDITarget[] targets = dsession.getTargets();
for (int i = 0; i < targets.length; i++) {
@ -105,7 +108,7 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate {
iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()), getDefaultProcessMap());
}
CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i], renderTargetLabel(debugConfig),
iprocess, exeFile, true, false, stopInMain, true);
iprocess, exeFile, true, false, stopSymbol, true);
}
} catch (CoreException e) {
try {