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

Update disassembly when source locator is changed.

This commit is contained in:
Mikhail Khodjaiants 2004-05-14 20:12:32 +00:00
parent bab1a0f7cf
commit 855b524f20
3 changed files with 115 additions and 94 deletions

View file

@ -1,3 +1,8 @@
2004-05-14 Mikhail Khodjaiants
Update disassembly when source locator is changed.
* Disassembly.java
* CSourceManager.java
2004-05-13 Mikhail Khodjaiants 2004-05-13 Mikhail Khodjaiants
Changed the format of the disassembly error messages. Changed the format of the disassembly error messages.
* Disassembly.java * Disassembly.java

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.model.IDisassembly; import org.eclipse.cdt.debug.core.model.IDisassembly;
import org.eclipse.cdt.debug.core.model.IDisassemblyBlock; import org.eclipse.cdt.debug.core.model.IDisassemblyBlock;
import org.eclipse.cdt.debug.core.model.IExecFileInfo; import org.eclipse.cdt.debug.core.model.IExecFileInfo;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
/** /**
@ -133,4 +134,13 @@ public class Disassembly extends CDebugElement implements IDisassembly {
return getDebugTarget().getAdapter( adapter ); return getDebugTarget().getAdapter( adapter );
return super.getAdapter( adapter ); return super.getAdapter( adapter );
} }
public void reset() {
for ( int i = 0; i < fBlocks.length; ++i )
if ( fBlocks[i] != null ) {
fBlocks[i].dispose();
fBlocks[i] = null;
}
fireChangeEvent( DebugEvent.CONTENT );
}
} }

View file

@ -1,23 +1,26 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * 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.sourcelookup; package org.eclipse.cdt.debug.internal.core.sourcelookup;
import java.util.ArrayList;
import java.util.Arrays;
import org.eclipse.cdt.debug.core.model.IStackFrameInfo; import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
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.Disassembly;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
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;
import org.eclipse.debug.core.DebugException;
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.model.IPersistableSourceLocator; import org.eclipse.debug.core.model.IPersistableSourceLocator;
@ -26,106 +29,115 @@ import org.eclipse.debug.core.model.IStackFrame;
/** /**
* Locates sources for a C/C++ debug session. * Locates sources for a C/C++ debug session.
*
* @since: Oct 8, 2002
*/ */
public class CSourceManager implements ICSourceLocator, public class CSourceManager implements ICSourceLocator, IPersistableSourceLocator, IAdaptable {
IPersistableSourceLocator,
IAdaptable
{
private ISourceLocator fSourceLocator = null; private ISourceLocator fSourceLocator = null;
private ILaunch fLaunch = null; private ILaunch fLaunch = null;
private CDebugTarget fDebugTarget = null; private CDebugTarget fDebugTarget = null;
/** /**
* Constructor for CSourceManager. * Constructor for CSourceManager.
*/ */
public CSourceManager( ISourceLocator sourceLocator ) public CSourceManager( ISourceLocator sourceLocator ) {
{
setSourceLocator( sourceLocator ); setSourceLocator( sourceLocator );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getLineNumber(IStackFrameInfo) * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getLineNumber(IStackFrameInfo)
*/ */
public int getLineNumber( IStackFrame frame ) public int getLineNumber( IStackFrame frame ) {
{ if ( getCSourceLocator() != null ) {
if ( getCSourceLocator() != null )
{
return getCSourceLocator().getLineNumber( frame ); return getCSourceLocator().getLineNumber( frame );
} }
IStackFrameInfo info = (IStackFrameInfo)frame.getAdapter( IStackFrameInfo.class ); IStackFrameInfo info = (IStackFrameInfo)frame.getAdapter( IStackFrameInfo.class );
if ( info != null ) if ( info != null ) {
{
return info.getFrameLineNumber(); return info.getFrameLineNumber();
} }
return 0; return 0;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getSourceLocations() * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getSourceLocations()
*/ */
public ICSourceLocation[] getSourceLocations() public ICSourceLocation[] getSourceLocations() {
{ return (getCSourceLocator() != null) ? getCSourceLocator().getSourceLocations() : new ICSourceLocation[0];
return ( getCSourceLocator() != null ) ? getCSourceLocator().getSourceLocations() : new ICSourceLocation[0];
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#setSourceLocations(ICSourceLocation[]) * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#setSourceLocations(ICSourceLocation[])
*/ */
public void setSourceLocations( ICSourceLocation[] locations ) public void setSourceLocations( ICSourceLocation[] locations ) {
{ if ( getCSourceLocator() != null ) {
if ( getCSourceLocator() != null )
{
getCSourceLocator().setSourceLocations( locations ); getCSourceLocator().setSourceLocations( locations );
CDebugTarget target = getDebugTarget();
if ( target != null ) {
Disassembly d = null;
try {
d = (Disassembly)target.getDisassembly();
}
catch( DebugException e ) {
}
if ( d != null ) {
d.reset();
}
}
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#contains(IResource) * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#contains(IResource)
*/ */
public boolean contains( IResource resource ) public boolean contains( IResource resource ) {
{ return (getCSourceLocator() != null) ? getCSourceLocator().contains( resource ) : false;
return ( getCSourceLocator() != null ) ? getCSourceLocator().contains( resource ) : false;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
*/ */
public Object getAdapter( Class adapter ) public Object getAdapter( Class adapter ) {
{
if ( adapter.equals( CSourceManager.class ) ) if ( adapter.equals( CSourceManager.class ) )
return this; return this;
if ( adapter.equals( ICSourceLocator.class ) ) if ( adapter.equals( ICSourceLocator.class ) )
return this; return this;
if ( adapter.equals( IPersistableSourceLocator.class ) ) if ( adapter.equals( IPersistableSourceLocator.class ) )
return this; return this;
if ( adapter.equals( IResourceChangeListener.class ) && if ( adapter.equals( IResourceChangeListener.class ) && fSourceLocator instanceof IResourceChangeListener )
fSourceLocator instanceof IResourceChangeListener )
return fSourceLocator; return fSourceLocator;
return null; return null;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(IStackFrame) * @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(IStackFrame)
*/ */
public Object getSourceElement( IStackFrame stackFrame ) public Object getSourceElement( IStackFrame stackFrame ) {
{
Object result = null; Object result = null;
if ( getSourceLocator() != null ) if ( getSourceLocator() != null )
result = getSourceLocator().getSourceElement( stackFrame ); result = getSourceLocator().getSourceElement( stackFrame );
return result; return result;
} }
protected ICSourceLocator getCSourceLocator() protected ICSourceLocator getCSourceLocator() {
{
if ( getSourceLocator() instanceof ICSourceLocator ) if ( getSourceLocator() instanceof ICSourceLocator )
return (ICSourceLocator)getSourceLocator(); return (ICSourceLocator)getSourceLocator();
return null; return null;
} }
protected ISourceLocator getSourceLocator() protected ISourceLocator getSourceLocator() {
{
if ( fSourceLocator != null ) if ( fSourceLocator != null )
return fSourceLocator; return fSourceLocator;
else if ( fLaunch != null ) else if ( fLaunch != null )
@ -133,98 +145,92 @@ public class CSourceManager implements ICSourceLocator,
return null; return null;
} }
protected void setSourceLocator( ISourceLocator sl ) private void setSourceLocator( ISourceLocator sl ) {
{
fSourceLocator = sl; fSourceLocator = sl;
} }
public void addSourceLocation( ICSourceLocation location ) /*
{ * (non-Javadoc)
ICSourceLocation[] locations = getSourceLocations(); *
ArrayList list = new ArrayList( Arrays.asList( locations ) );
list.add( location );
setSourceLocations( (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] ) );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#findSourceElement(String) * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#findSourceElement(String)
*/ */
public Object findSourceElement( String fileName ) public Object findSourceElement( String fileName ) {
{ if ( getCSourceLocator() != null ) {
if ( getCSourceLocator() != null )
{
return getCSourceLocator().findSourceElement( fileName ); return getCSourceLocator().findSourceElement( fileName );
} }
return null; return null;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento() * @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento()
*/ */
public String getMemento() throws CoreException public String getMemento() throws CoreException {
{
if ( getPersistableSourceLocator() != null ) if ( getPersistableSourceLocator() != null )
return getPersistableSourceLocator().getMemento(); return getPersistableSourceLocator().getMemento();
return null; return null;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeDefaults(org.eclipse.debug.core.ILaunchConfiguration) * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeDefaults(org.eclipse.debug.core.ILaunchConfiguration)
*/ */
public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException {
{
if ( getPersistableSourceLocator() != null ) if ( getPersistableSourceLocator() != null )
getPersistableSourceLocator().initializeDefaults( configuration ); getPersistableSourceLocator().initializeDefaults( configuration );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeFromMemento(java.lang.String) * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeFromMemento(java.lang.String)
*/ */
public void initializeFromMemento( String memento ) throws CoreException public void initializeFromMemento( String memento ) throws CoreException {
{
if ( getPersistableSourceLocator() != null ) if ( getPersistableSourceLocator() != null )
getPersistableSourceLocator().initializeFromMemento( memento ); getPersistableSourceLocator().initializeFromMemento( memento );
} }
private IPersistableSourceLocator getPersistableSourceLocator() private IPersistableSourceLocator getPersistableSourceLocator() {
{
if ( fSourceLocator instanceof IPersistableSourceLocator ) if ( fSourceLocator instanceof IPersistableSourceLocator )
return (IPersistableSourceLocator)fSourceLocator; return (IPersistableSourceLocator)fSourceLocator;
return null; return null;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getProject() * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getProject()
*/ */
public IProject getProject() public IProject getProject() {
{ return (getCSourceLocator() != null) ? getCSourceLocator().getProject() : null;
return ( getCSourceLocator() != null ) ? getCSourceLocator().getProject() : null;
} }
public void setDebugTarget( CDebugTarget target ) public void setDebugTarget( CDebugTarget target ) {
{
fDebugTarget = target; fDebugTarget = target;
} }
protected CDebugTarget getDebugTarget() protected CDebugTarget getDebugTarget() {
{
return fDebugTarget; return fDebugTarget;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#setSearchForDuplicateFiles(boolean) * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#setSearchForDuplicateFiles(boolean)
*/ */
public void setSearchForDuplicateFiles( boolean search ) public void setSearchForDuplicateFiles( boolean search ) {
{
if ( getCSourceLocator() != null ) if ( getCSourceLocator() != null )
getCSourceLocator().setSearchForDuplicateFiles( search ); getCSourceLocator().setSearchForDuplicateFiles( search );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#searchForDuplicateFiles() * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#searchForDuplicateFiles()
*/ */
public boolean searchForDuplicateFiles() public boolean searchForDuplicateFiles() {
{ return (getCSourceLocator() != null) ? getCSourceLocator().searchForDuplicateFiles() : false;
return ( getCSourceLocator() != null ) ? getCSourceLocator().searchForDuplicateFiles() : false;
} }
} }