mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Bug 41725: I can't set a breakpoint in a function where I used attach source.
Bug 45514: Breakpoints made is assembly view do not show in C view.
This commit is contained in:
parent
865d770780
commit
288e94d28e
15 changed files with 402 additions and 56 deletions
|
@ -1,3 +1,15 @@
|
|||
2005-06-29 Mikhail Khodjaiants
|
||||
Bug 41725: I can't set a breakpoint in a function where I used attach source.
|
||||
Bug 45514: Breakpoints made is assembly view do not show in C view.
|
||||
* CDIDebugModel.java
|
||||
* IAsmSourceLine.java
|
||||
* ICBreakpoint.java
|
||||
* IDisassemblyBlock.java
|
||||
* CBreakpointManager.java
|
||||
* CBreakpoint.java
|
||||
* AsmSourceLine.java
|
||||
* DisassemblyBlock.java
|
||||
|
||||
2005-06-28 Mikhail Khodjaiants
|
||||
Bug 101188: Breakpoints don't work with MingW gdb.
|
||||
Use "toPortableString" instead of "toOsString" when setting the source search paths.
|
||||
|
|
|
@ -174,6 +174,7 @@ public class CDIDebugModel {
|
|||
* given source handle, at the given address. The marker associated with the
|
||||
* breakpoint will be created on the specified resource.
|
||||
*
|
||||
* @param module the module name the breakpoint is set in
|
||||
* @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
|
||||
|
@ -189,17 +190,44 @@ public class CDIDebugModel {
|
|||
* failure.</li>
|
||||
* </ul>
|
||||
*/
|
||||
public static ICAddressBreakpoint createAddressBreakpoint( String sourceHandle, IResource resource, IAddress address, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
|
||||
public static ICAddressBreakpoint createAddressBreakpoint( String module, String sourceHandle, IResource resource, IAddress address, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
|
||||
return createAddressBreakpoint( module, sourceHandle, resource, -1, address, enabled, ignoreCount, condition, register );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns an address breakpoint for the source defined by the
|
||||
* given source handle, at the given address. The marker associated with the
|
||||
* breakpoint will be created on the specified resource.
|
||||
*
|
||||
* @param module the module name the breakpoint is set in
|
||||
* @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 in the source file
|
||||
* @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 module, String sourceHandle, IResource resource, int lineNumber, 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.CHAR_START, new Integer( -1 ) );
|
||||
attributes.put( IMarker.CHAR_END, new Integer( -1 ) );
|
||||
attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
|
||||
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 );
|
||||
attributes.put( ICBreakpoint.MODULE, module );
|
||||
return new CAddressBreakpoint( resource, attributes, register );
|
||||
}
|
||||
|
||||
|
|
|
@ -21,4 +21,11 @@ public interface IAsmSourceLine {
|
|||
* @return the array of the disassembly instructions associated with this source line
|
||||
*/
|
||||
IAsmInstruction[] getInstructions();
|
||||
|
||||
/**
|
||||
* Returns the number of this line in the source file
|
||||
*
|
||||
* @return the line number
|
||||
*/
|
||||
int getLineNumber();
|
||||
}
|
||||
|
|
|
@ -54,12 +54,21 @@ public interface ICBreakpoint extends IBreakpoint {
|
|||
public static final String THREAD_ID = "org.eclipse.cdt.debug.core.threadId"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Breakpoint attribute storing a source handle this breakpoint
|
||||
* Breakpoint attribute storing the source handle of the file this breakpoint
|
||||
* is set in (value <code>"org.eclipse.cdt.debug.core.sourceHandle"</code>).
|
||||
* This attribute is a <code>String</code>.
|
||||
*/
|
||||
public static final String SOURCE_HANDLE = "org.eclipse.cdt.debug.core.sourceHandle"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Breakpoint attribute storing the module name this breakpoint
|
||||
* is set in (value <code>"org.eclipse.cdt.debug.core.module"</code>).
|
||||
* This attribute is a <code>String</code>.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public static final String MODULE = "org.eclipse.cdt.debug.core.module"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Returns whether this breakpoint is installed in at least one debug
|
||||
* target.
|
||||
|
@ -134,6 +143,24 @@ public interface ICBreakpoint extends IBreakpoint {
|
|||
*/
|
||||
public void setThreadId( String threadId ) throws CoreException;
|
||||
|
||||
/**
|
||||
* Returns the module name this breakpoint is set in.
|
||||
*
|
||||
* @return the module name
|
||||
* @exception CoreException if unable to access the property on this breakpoint's
|
||||
* underlying marker
|
||||
*/
|
||||
public String getModule() throws CoreException;
|
||||
|
||||
/**
|
||||
* Sets the module name of this breakpoint.
|
||||
*
|
||||
* @param module the module name
|
||||
* @exception CoreException if unable to access the property on this breakpoint's
|
||||
* underlying marker
|
||||
*/
|
||||
public void setModule( String module ) throws CoreException;
|
||||
|
||||
/**
|
||||
* Returns the source handle this breakpoint is set in.
|
||||
*
|
||||
|
|
|
@ -30,6 +30,15 @@ public interface IDisassemblyBlock {
|
|||
*/
|
||||
String getModuleFile();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the source element (<code>IFile</code> or <code>File></code>)
|
||||
* of the source file associated with this segment or null if no source file is associated.
|
||||
*
|
||||
* @return the source element
|
||||
*/
|
||||
Object getSourceElement();
|
||||
|
||||
/**
|
||||
* Returns whether this block contains given stack frame.
|
||||
*
|
||||
|
|
|
@ -253,8 +253,17 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
|
|||
}
|
||||
|
||||
public boolean supportsAddressBreakpoint( ICAddressBreakpoint breakpoint ) {
|
||||
String module = null;
|
||||
try {
|
||||
return ( getExecFilePath().toOSString().equals( breakpoint.getSourceHandle() ) );
|
||||
module = breakpoint.getModule();
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
}
|
||||
if ( module != null )
|
||||
return getExecFilePath().toOSString().equals( module );
|
||||
// supporting old breakpoints (> 3.0)
|
||||
try {
|
||||
return getExecFilePath().toOSString().equals( breakpoint.getSourceHandle() );
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
}
|
||||
|
@ -435,9 +444,9 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
|
|||
if ( breakpoint instanceof ICLineBreakpoint ) {
|
||||
ICDILocator locator = cdiBreakpoint.getLocator();
|
||||
if ( locator != null ) {
|
||||
BigInteger address = locator.getAddress();
|
||||
IAddress address = getDebugTarget().getAddressFactory().createAddress( locator.getAddress() );
|
||||
if ( address != null ) {
|
||||
((ICLineBreakpoint)breakpoint).setAddress( address.toString() );
|
||||
((ICLineBreakpoint)breakpoint).setAddress( address.toHexAddressString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -578,12 +587,10 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
|
|||
final boolean enabled = breakpoint.isEnabled();
|
||||
final ICDITarget cdiTarget = getCDITarget();
|
||||
String address = breakpoint.getAddress();
|
||||
if ( address.startsWith( "0x" ) ) { //$NON-NLS-1$
|
||||
final ICDIAddressLocation location = cdiTarget.createAddressLocation( new BigInteger ( breakpoint.getAddress().substring( 2 ), 16 ) );
|
||||
final ICDIAddressLocation location = cdiTarget.createAddressLocation( new BigInteger ( ( address.startsWith( "0x" ) ) ? address.substring( 2 ) : address, 16 ) ); //$NON-NLS-1$
|
||||
final ICDICondition condition = createCondition( breakpoint );
|
||||
setLocationBreakpointOnTarget( breakpoint, cdiTarget, location, condition, enabled );
|
||||
}
|
||||
}
|
||||
|
||||
private void setLineBreakpoint( ICLineBreakpoint breakpoint ) throws CDIException, CoreException {
|
||||
boolean enabled = breakpoint.isEnabled();
|
||||
|
@ -648,16 +655,11 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
|
|||
ICLineBreakpoint breakpoint = null;
|
||||
try {
|
||||
ICDILocator location = cdiBreakpoint.getLocator();
|
||||
if ( !isEmpty( location.getFile() ) ) {
|
||||
ISourceLocator locator = getSourceLocator();
|
||||
if ( locator instanceof ICSourceLocator || locator instanceof CSourceLookupDirector ) {
|
||||
String sourceHandle = location.getFile();
|
||||
String file = location.getFile();
|
||||
if ( !isEmpty( file ) ) {
|
||||
Object sourceElement = getSourceElement( file );
|
||||
String sourceHandle = file;
|
||||
IResource resource = getProject();
|
||||
Object sourceElement = null;
|
||||
if ( locator instanceof ICSourceLocator )
|
||||
sourceElement = ((ICSourceLocator)locator).findSourceElement( location.getFile() );
|
||||
else
|
||||
sourceElement = ((CSourceLookupDirector)locator).getSourceElement( location.getFile() );
|
||||
if ( sourceElement instanceof IFile || sourceElement instanceof IStorage ) {
|
||||
sourceHandle = ( sourceElement instanceof IFile ) ? ((IFile)sourceElement).getLocation().toOSString() : ((IStorage)sourceElement).getFullPath().toOSString();
|
||||
resource = ( sourceElement instanceof IFile ) ? (IResource)sourceElement : ResourcesPlugin.getWorkspace().getRoot();
|
||||
|
@ -670,7 +672,6 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
|
|||
// breakpoint = createAddressBreakpoint( cdiBreakpoint );
|
||||
// }
|
||||
}
|
||||
}
|
||||
else if ( !isEmpty( location.getFunction() ) ) {
|
||||
breakpoint = createFunctionBreakpoint( cdiBreakpoint );
|
||||
}
|
||||
|
@ -728,7 +729,8 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
|
|||
String sourceHandle = execFile.toOSString();
|
||||
IAddress address = getDebugTarget().getAddressFactory().createAddress( cdiBreakpoint.getLocator().getAddress() );
|
||||
ICAddressBreakpoint breakpoint = CDIDebugModel.createAddressBreakpoint( sourceHandle,
|
||||
getProject(),
|
||||
sourceHandle,
|
||||
ResourcesPlugin.getWorkspace().getRoot(),
|
||||
address,
|
||||
cdiBreakpoint.isEnabled(),
|
||||
cdiBreakpoint.getCondition().getIgnoreCount(),
|
||||
|
@ -874,4 +876,16 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
|
|||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
private Object getSourceElement( String file ) {
|
||||
Object sourceElement = null;
|
||||
ISourceLocator locator = getSourceLocator();
|
||||
if ( locator instanceof ICSourceLocator || locator instanceof CSourceLookupDirector ) {
|
||||
if ( locator instanceof ICSourceLocator )
|
||||
sourceElement = ((ICSourceLocator)locator).findSourceElement( file );
|
||||
else
|
||||
sourceElement = ((CSourceLookupDirector)locator).getSourceElement( file );
|
||||
}
|
||||
return sourceElement;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -351,4 +351,18 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, ID
|
|||
DebugPlugin.getDefault().getBreakpointManager().fireBreakpointChanged( this );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#getModule()
|
||||
*/
|
||||
public String getModule() throws CoreException {
|
||||
return ensureMarker().getAttribute( MODULE, null );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#setModule(java.lang.String)
|
||||
*/
|
||||
public void setModule( String module ) throws CoreException {
|
||||
setAttribute( MODULE, module );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,17 +24,34 @@ public class AsmSourceLine implements IAsmSourceLine {
|
|||
|
||||
private IAsmInstruction[] fInstructions = null;
|
||||
|
||||
private int fLineNumber;
|
||||
|
||||
/**
|
||||
* Constructor for AsmSourceLine.
|
||||
*/
|
||||
public AsmSourceLine( IAddressFactory factory, String text, ICDIInstruction[] cdiInstructions ) {
|
||||
this( factory, text, -1, cdiInstructions );
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AsmSourceLine.
|
||||
*/
|
||||
public AsmSourceLine( IAddressFactory factory, String text, int lineNumber, ICDIInstruction[] cdiInstructions ) {
|
||||
fText = text;
|
||||
fLineNumber = lineNumber;
|
||||
fInstructions = new IAsmInstruction[cdiInstructions.length];
|
||||
for ( int i = 0; i < fInstructions.length; ++i ) {
|
||||
fInstructions[i] = new AsmInstruction( factory, cdiInstructions[i] );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.IAsmSourceLine#getLineNumber()
|
||||
*/
|
||||
public int getLineNumber() {
|
||||
return fLineNumber;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.IAsmSourceLine#getInstructions()
|
||||
*/
|
||||
|
|
|
@ -40,6 +40,8 @@ public class DisassemblyBlock implements IDisassemblyBlock, IAdaptable {
|
|||
|
||||
private IDisassembly fDisassembly;
|
||||
|
||||
private Object fSourceElement;
|
||||
|
||||
private IAsmSourceLine[] fSourceLines;
|
||||
|
||||
private IAddress fStartAddress = null;
|
||||
|
@ -57,23 +59,31 @@ public class DisassemblyBlock implements IDisassemblyBlock, IAdaptable {
|
|||
|
||||
public static DisassemblyBlock create( IDisassembly disassembly, ICDIMixedInstruction[] instructions ) {
|
||||
DisassemblyBlock block = new DisassemblyBlock( disassembly );
|
||||
block.setMixedMode( true );
|
||||
ISourceLocator locator = disassembly.getDebugTarget().getLaunch().getSourceLocator();
|
||||
IAddressFactory factory = ((CDebugTarget)disassembly.getDebugTarget()).getAddressFactory();
|
||||
block.setSourceLines( createSourceLines( factory, locator, instructions ) );
|
||||
block.initializeAddresses();
|
||||
block.initialize( factory, locator, instructions );
|
||||
return block;
|
||||
}
|
||||
|
||||
public static DisassemblyBlock create( IDisassembly disassembly, ICDIInstruction[] instructions ) {
|
||||
DisassemblyBlock block = new DisassemblyBlock( disassembly );
|
||||
IAddressFactory factory = ((CDebugTarget)disassembly.getDebugTarget()).getAddressFactory();
|
||||
block.setMixedMode( false );
|
||||
block.setSourceLines( createSourceLines( factory, instructions ) );
|
||||
block.initializeAddresses();
|
||||
block.initialize( factory, instructions );
|
||||
return block;
|
||||
}
|
||||
|
||||
private void initialize( IAddressFactory factory, ICDIInstruction[] instructions ) {
|
||||
setMixedMode( false );
|
||||
createSourceLines( factory, instructions );
|
||||
initializeAddresses();
|
||||
}
|
||||
|
||||
private void initialize( IAddressFactory factory, ISourceLocator locator, ICDIMixedInstruction[] mi ) {
|
||||
setMixedMode( true );
|
||||
createSourceLines( factory, locator, mi );
|
||||
initializeAddresses();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.IDisassemblyBlock#getDisassembly()
|
||||
*/
|
||||
|
@ -95,6 +105,13 @@ public class DisassemblyBlock implements IDisassemblyBlock, IAdaptable {
|
|||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.IDisassemblyBlock#getSourceElement()
|
||||
*/
|
||||
public Object getSourceElement() {
|
||||
return fSourceElement;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.IDisassemblyBlock#contains(org.eclipse.cdt.debug.core.model.ICStackFrame)
|
||||
*/
|
||||
|
@ -133,7 +150,7 @@ public class DisassemblyBlock implements IDisassemblyBlock, IAdaptable {
|
|||
public void dispose() {
|
||||
}
|
||||
|
||||
private static IAsmSourceLine[] createSourceLines( IAddressFactory factory, ISourceLocator locator, ICDIMixedInstruction[] mi ) {
|
||||
private void createSourceLines( IAddressFactory factory, ISourceLocator locator, ICDIMixedInstruction[] mi ) {
|
||||
IAsmSourceLine[] result = new IAsmSourceLine[mi.length];
|
||||
LineNumberReader reader = null;
|
||||
if ( result.length > 0 && locator != null ) {
|
||||
|
@ -145,6 +162,7 @@ public class DisassemblyBlock implements IDisassemblyBlock, IAdaptable {
|
|||
if ( locator instanceof ICSourceLocator ) {
|
||||
element = ((ICSourceLocator)locator).findSourceElement( fileName );
|
||||
}
|
||||
fSourceElement = element;
|
||||
File file= null;
|
||||
if ( element instanceof IFile ) {
|
||||
file = ((IFile)element).getLocation().toFile();
|
||||
|
@ -162,8 +180,8 @@ public class DisassemblyBlock implements IDisassemblyBlock, IAdaptable {
|
|||
}
|
||||
for ( int i = 0; i < result.length; ++i ) {
|
||||
String text = null;
|
||||
if ( reader != null ) {
|
||||
int lineNumber = mi[i].getLineNumber();
|
||||
if ( reader != null ) {
|
||||
while( reader.getLineNumber() + 1 < lineNumber ) {
|
||||
try {
|
||||
reader.readLine();
|
||||
|
@ -179,13 +197,13 @@ public class DisassemblyBlock implements IDisassemblyBlock, IAdaptable {
|
|||
}
|
||||
}
|
||||
}
|
||||
result[i] = new AsmSourceLine( factory, text, mi[i].getInstructions() );
|
||||
result[i] = new AsmSourceLine( factory, text, lineNumber, mi[i].getInstructions() );
|
||||
}
|
||||
return result;
|
||||
fSourceLines = result;
|
||||
}
|
||||
|
||||
private static IAsmSourceLine[] createSourceLines( IAddressFactory factory, ICDIInstruction[] instructions ) {
|
||||
return new IAsmSourceLine[] { new AsmSourceLine( factory, "", instructions ) }; //$NON-NLS-1$
|
||||
private void createSourceLines( IAddressFactory factory, ICDIInstruction[] instructions ) {
|
||||
fSourceLines = new IAsmSourceLine[] { new AsmSourceLine( factory, "", instructions ) }; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private void initializeAddresses() {
|
||||
|
@ -202,8 +220,4 @@ public class DisassemblyBlock implements IDisassemblyBlock, IAdaptable {
|
|||
private void setMixedMode( boolean mixedMode ) {
|
||||
this.fMixedMode = mixedMode;
|
||||
}
|
||||
|
||||
private void setSourceLines( IAsmSourceLine[] sourceLines ) {
|
||||
this.fSourceLines = sourceLines;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
2005-06-29 Mikhail Khodjaiants
|
||||
Bug 41725: I can't set a breakpoint in a function where I used attach source.
|
||||
Bug 45514: Breakpoints made is assembly view do not show in C view.
|
||||
+ DebugMarkerAnnotationModel.java
|
||||
+ DebugMarkerAnnotationModelFactory.java
|
||||
* ToggleBreakpointAdapter.java
|
||||
* DisassemblyEditorInput.java
|
||||
* plugin.xml
|
||||
|
||||
2005-06-29 Mikhail Khodjaiants
|
||||
Removed unused imports.
|
||||
* CBreapointWorkbencAdapterFactory.java
|
||||
|
|
|
@ -1240,5 +1240,11 @@
|
|||
icon="icons/obj16/folder_obj.gif"
|
||||
id="org.eclipse.cdt.debug.ui.containerPresentation.directory"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.filebuffers.annotationModelCreation">
|
||||
<factory
|
||||
class="org.eclipse.cdt.debug.internal.ui.DebugMarkerAnnotationModelFactory"
|
||||
contentTypeId="org.eclipse.cdt.core.cSource"/>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/**********************************************************************
|
||||
* 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.ui;
|
||||
|
||||
import java.io.File;
|
||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IMarkerDelta;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.IBreakpointsListener;
|
||||
import org.eclipse.debug.core.model.IBreakpoint;
|
||||
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
|
||||
|
||||
public class DebugMarkerAnnotationModel extends AbstractMarkerAnnotationModel implements IBreakpointsListener {
|
||||
|
||||
private File fFile;
|
||||
|
||||
public DebugMarkerAnnotationModel( File file ) {
|
||||
super();
|
||||
fFile = file;
|
||||
}
|
||||
|
||||
protected IMarker[] retrieveMarkers() throws CoreException {
|
||||
IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints( CDIDebugModel.getPluginIdentifier() );
|
||||
IMarker[] markers = new IMarker[breakpoints.length];
|
||||
for ( int i = 0; i < markers.length; ++i ) {
|
||||
markers[i] = breakpoints[i].getMarker();
|
||||
}
|
||||
return markers;
|
||||
}
|
||||
|
||||
protected void deleteMarkers( IMarker[] markers ) throws CoreException {
|
||||
}
|
||||
|
||||
protected void listenToMarkerChanges( boolean listen ) {
|
||||
if ( listen )
|
||||
DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener( this );
|
||||
else
|
||||
DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener( this );
|
||||
}
|
||||
|
||||
protected boolean isAcceptable( IMarker marker ) {
|
||||
IBreakpoint b = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint( marker );
|
||||
if ( b != null ) {
|
||||
return isAcceptable( b );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected File getFile() {
|
||||
return fFile;
|
||||
}
|
||||
|
||||
public void breakpointsAdded( IBreakpoint[] breakpoints ) {
|
||||
for ( int i = 0; i < breakpoints.length; ++i ) {
|
||||
if ( isAcceptable( breakpoints[i] ) ) {
|
||||
addMarkerAnnotation( breakpoints[i].getMarker() );
|
||||
fireModelChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void breakpointsRemoved( IBreakpoint[] breakpoints, IMarkerDelta[] deltas ) {
|
||||
for ( int i = 0; i < breakpoints.length; ++i ) {
|
||||
if ( isAcceptable( breakpoints[i] ) ) {
|
||||
removeMarkerAnnotation( breakpoints[i].getMarker() );
|
||||
fireModelChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void breakpointsChanged( IBreakpoint[] breakpoints, IMarkerDelta[] deltas ) {
|
||||
for ( int i = 0; i < breakpoints.length; ++i ) {
|
||||
if ( isAcceptable( breakpoints[i] ) ) {
|
||||
modifyMarkerAnnotation( breakpoints[i].getMarker() );
|
||||
fireModelChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isAcceptable( IBreakpoint b ) {
|
||||
if ( b instanceof ICBreakpoint ) {
|
||||
try {
|
||||
String handle = ((ICBreakpoint)b).getSourceHandle();
|
||||
File file = new File( handle );
|
||||
return file.equals( getFile() );
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/**********************************************************************
|
||||
* 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.ui;
|
||||
|
||||
import java.io.File;
|
||||
import org.eclipse.core.filebuffers.FileBuffers;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.jface.text.source.IAnnotationModel;
|
||||
import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModelFactory;
|
||||
|
||||
public class DebugMarkerAnnotationModelFactory extends ResourceMarkerAnnotationModelFactory {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.texteditor.ResourceMarkerAnnotationModelFactory#createAnnotationModel(org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
public IAnnotationModel createAnnotationModel( IPath location ) {
|
||||
IFile file = FileBuffers.getWorkspaceFileAtLocation( location );
|
||||
if ( file != null ) {
|
||||
return super.createAnnotationModel( location );
|
||||
}
|
||||
File osFile = new File( location.toOSString() );
|
||||
if ( osFile.exists() ) {
|
||||
return new DebugMarkerAnnotationModel( osFile );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -33,7 +33,9 @@ import org.eclipse.core.resources.IFile;
|
|||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
|
||||
|
@ -125,10 +127,13 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
|
|||
DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
|
||||
}
|
||||
else {
|
||||
IResource resource = ResourcesPlugin.getWorkspace().getRoot();
|
||||
String module = ((DisassemblyEditorInput)input).getModuleFile();
|
||||
IResource resource = getAddressBreakpointResource( ((DisassemblyEditorInput)input).getSourceFile() );
|
||||
String sourceHandle = getSourceHandle( input );
|
||||
CDIDebugModel.createAddressBreakpoint( sourceHandle,
|
||||
CDIDebugModel.createAddressBreakpoint( module,
|
||||
sourceHandle,
|
||||
resource,
|
||||
((DisassemblyEditorInput)input).getSourceLine( lineNumber ),
|
||||
address,
|
||||
true,
|
||||
0,
|
||||
|
@ -314,6 +319,10 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
|
|||
return ((IStorageEditorInput)input).getStorage().getFullPath().toOSString();
|
||||
}
|
||||
if ( input instanceof DisassemblyEditorInput ) {
|
||||
String sourceFile = ((DisassemblyEditorInput)input).getSourceFile();
|
||||
if ( sourceFile != null ) {
|
||||
return sourceFile;
|
||||
}
|
||||
return ((DisassemblyEditorInput)input).getModuleFile();
|
||||
}
|
||||
return ""; //$NON-NLS-1$
|
||||
|
@ -465,4 +474,14 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
|
|||
true );
|
||||
}
|
||||
}
|
||||
|
||||
private IResource getAddressBreakpointResource( String fileName ) {
|
||||
IPath path = new Path( fileName );
|
||||
if ( path.isValidPath( fileName ) ) {
|
||||
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation( path );
|
||||
if ( files.length > 0 )
|
||||
return files[0];
|
||||
}
|
||||
return ResourcesPlugin.getWorkspace().getRoot();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
|||
import org.eclipse.cdt.debug.core.model.ICStackFrame;
|
||||
import org.eclipse.cdt.debug.core.model.IDisassembly;
|
||||
import org.eclipse.cdt.debug.core.model.IDisassemblyBlock;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
|
@ -186,6 +188,34 @@ public class DisassemblyEditorInput implements IEditorInput {
|
|||
return ( fBlock != null ) ? fBlock.getModuleFile() : null;
|
||||
}
|
||||
|
||||
public String getSourceFile() {
|
||||
if ( fBlock != null ) {
|
||||
Object element = fBlock.getSourceElement();
|
||||
if ( element instanceof IFile ) {
|
||||
return ((IFile)element).getLocation().toOSString();
|
||||
}
|
||||
else if ( element instanceof IStorage ) {
|
||||
return ((IStorage)element).getFullPath().toOSString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getSourceLine( int instrNumber ) {
|
||||
if ( fBlock != null ) {
|
||||
IAsmSourceLine[] sl = fBlock.getSourceLines();
|
||||
int current = 0;
|
||||
for ( int i = 0; i < sl.length; ++i ) {
|
||||
++current;
|
||||
IAsmInstruction[] ins = sl[i].getInstructions();
|
||||
if ( instrNumber >= current && instrNumber <= current + ins.length )
|
||||
return sl[i].getLineNumber();
|
||||
current += ins.length;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static DisassemblyEditorInput create( ICStackFrame frame ) throws DebugException {
|
||||
DisassemblyEditorInput input = null;
|
||||
ICDebugTarget target = ((ICDebugTarget)frame.getDebugTarget());
|
||||
|
|
Loading…
Add table
Reference in a new issue