From f58a8c96eeca7b481e9d58f6aed095487298863c Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Fri, 1 Nov 2002 17:15:50 +0000 Subject: [PATCH] Replaced the 'IProject' argument by 'IFile' in the debug target factory methods. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 5 + .../eclipse/cdt/debug/core/CDebugModel.java | 160 +++++++++++++++++- .../internal/core/model/CDebugTarget.java | 38 +++++ 3 files changed, 200 insertions(+), 3 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index f200e36a7dd..7da83e682be 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,8 @@ +2002-10-31 Mikhail Khodjaiants + Replaced the 'IProject' argument by 'IFile' in the debug target factory methods. + * CDebugModel.java + * CDebugTarget.java + 2002-10-31 Mikhail Khodjaiants Fixed the synchronization bug. * CFormattedMemoryBlock.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java index b418901c1ed..d15174983b8 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java @@ -25,6 +25,7 @@ import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint; 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.CFormattedMemoryBlock; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -91,6 +92,7 @@ public class CDebugModel * @param stopInMain whether to set a temporary breakpoint in main. * @return a debug target */ +/* public static IDebugTarget newDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, @@ -141,7 +143,7 @@ public class CDebugModel return target[0]; } - +*/ public static IDebugTarget newDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, @@ -194,6 +196,58 @@ public class CDebugModel return target[0]; } + 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 + { + final IDebugTarget[] target = new IDebugTarget[1]; + + IWorkspaceRunnable r = new IWorkspaceRunnable() + { + public void run( IProgressMonitor m ) + { + target[0] = new CDebugTarget( launch, + ICDebugTargetType.TARGET_TYPE_LOCAL_RUN, + cdiTarget, + name, + debuggeeProcess, + debuggerProcess, + file, + allowTerminate, + allowDisconnect ); + } + }; + try + { + ResourcesPlugin.getWorkspace().run( r, null ); + } + catch( CoreException e ) + { + CDebugCorePlugin.log( e ); + throw new DebugException( e.getStatus() ); + } + + ICDIConfiguration config = cdiTarget.getSession().getConfiguration(); + + if ( config.supportsBreakpoints() && stopInMain ) + { + stopInMain( (CDebugTarget)target[0] ); + } + + if ( config.supportsResume() ) + { + target[0].resume(); + } + + return target[0]; + } +/* public static IDebugTarget newAttachDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, @@ -242,7 +296,7 @@ public class CDebugModel return target[0]; } - +*/ public static IDebugTarget newAttachDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, @@ -293,6 +347,56 @@ public class CDebugModel return target[0]; } + 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 ) + { + target[0] = new CDebugTarget( launch, + ICDebugTargetType.TARGET_TYPE_LOCAL_ATTACH, + cdiTarget, + name, + null, + debuggerProcess, + file, + false, + true ); + } + }; + try + { + ResourcesPlugin.getWorkspace().run( r, null ); + } + catch( CoreException e ) + { + CDebugCorePlugin.log( e ); + throw new DebugException( e.getStatus() ); + } + + ((CDebugTarget)target[0]).handleDebugEvent( new ICDISuspendedEvent() + { + public ICDISessionObject getReason() + { + return null; + } + + public ICDIObject getSource() + { + return cdiTarget; + } + + } ); + + return target[0]; + } +/* public static IDebugTarget newCoreFileDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, @@ -341,7 +445,7 @@ public class CDebugModel return target[0]; } - +*/ public static IDebugTarget newCoreFileDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, @@ -392,6 +496,56 @@ public class CDebugModel return target[0]; } + public static IDebugTarget newCoreFileDebugTarget( 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 ) + { + target[0] = new CDebugTarget( launch, + ICDebugTargetType.TARGET_TYPE_LOCAL_CORE_DUMP, + cdiTarget, + name, + null, + debuggerProcess, + file, + true, + false ); + } + }; + try + { + ResourcesPlugin.getWorkspace().run( r, null ); + } + catch( CoreException e ) + { + CDebugCorePlugin.log( e ); + throw new DebugException( e.getStatus() ); + } + + ((CDebugTarget)target[0]).handleDebugEvent( new ICDISuspendedEvent() + { + public ICDISessionObject getReason() + { + return null; + } + + public ICDIObject getSource() + { + return cdiTarget; + } + + } ); + + return target[0]; + } + /** * Returns a C/C++ line breakpoint that is already registered with the breakpoint * manager for a file with the given name at the given line number. diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java index 34a3d0d481d..71ec5efb93f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java @@ -63,6 +63,7 @@ import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint; import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLocator; import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceManager; import org.eclipse.cdt.debug.internal.core.sourcelookup.DisassemblyManager; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarkerDelta; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -251,6 +252,43 @@ public class CDebugTarget extends CDebugElement getCDISession().getEventManager().addEventListener( this ); } + /** + * Constructor for CDebugTarget. + * @param target + */ + public CDebugTarget( ILaunch launch, + int targetType, + ICDITarget cdiTarget, + String name, + IProcess debuggeeProcess, + IProcess debuggerProcess, + IFile file, + boolean allowsTerminate, + boolean allowsDisconnect ) + { + super( null ); + setLaunch( launch ); + setTargetType( targetType ); + setDebugTarget( this ); + setName( name ); + setProcesses( debuggeeProcess, debuggerProcess ); + setCDITarget( cdiTarget ); + setBreakpoints( new HashMap( 5 ) ); + setTemporaryBreakpoints( new ArrayList() ); + if ( file != null ) + { + getLaunch().setSourceLocator( createSourceLocator( file.getProject() ) ); + } + setConfiguration( cdiTarget.getSession().getConfiguration() ); + fSupportsTerminate = allowsTerminate & getConfiguration().supportsTerminate(); + fSupportsDisconnect = allowsDisconnect & getConfiguration().supportsDisconnect(); + setThreadList( new ArrayList( 5 ) ); + initialize(); + DebugPlugin.getDefault().getLaunchManager().addLaunchListener( this ); + DebugPlugin.getDefault().getExpressionManager().addExpressionListener( this ); + getCDISession().getEventManager().addEventListener( this ); + } + /** * Initialize state from the underlying debug session. *