1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

Bug 82264: Enhance the Shared Libraries view. Core support for the Modules view.

This commit is contained in:
Mikhail Khodjaiants 2005-02-07 22:49:42 +00:00
parent 74a096a516
commit 461f0b0ef0
7 changed files with 560 additions and 2 deletions

View file

@ -1,3 +1,13 @@
2005-02-07 Mikhail Khodjaiants
Bug 82264: Enhance the Shared Libraries view.
Core support for the Modules view.
* ICDebugTarget.java
* ICModule.java: new
* CoreModelMessages.properties
* CDebugTarget.java
* CModule.java: new
* CModuleManager.java: new
2005-02-03 Mikhail Khodjaiants
Fix for bug 84187: "Toggle Watchpoint" and "Toggle Method Breakpoint" don't work with C editor.
ICWatchpoint should extend ILineBreakpoint to allow watchpoints to be shown in editors.

View file

@ -92,4 +92,28 @@ public interface ICDebugTarget extends IDebugTarget,
* @return whether this target is a post mortem type
*/
public boolean isPostMortem();
/**
* Returns whether there are modules currently loaded in this debug target.
*
* @return whether there are modules currently loaded in this debug target
*
* @throws DebugException
*/
public boolean hasModules() throws DebugException;
/**
* Returns the array of the currently loaded modules.
*
* @return the array of the currently loaded modules
* @throws DebugException if this method fails. Reasons include:
*/
public ICModule[] getModules() throws DebugException;
/**
* Load symbols for all currently loaded modules.
*
* @throws DebugException if this method fails. Reasons include:
*/
public void loadSymbolsForAllModules() throws DebugException;
}

View file

@ -0,0 +1,126 @@
/**********************************************************************
* 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.model;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.core.runtime.IPath;
import org.eclipse.debug.core.DebugException;
/**
* Represents a module in the process being debugged.
*/
public interface ICModule extends ICDebugElement {
/**
* Type constant which identifies executables.
*/
public static final int EXECUTABLE = 1;
/**
* Type constant which identifies shared libraries.
*/
public static final int SHARED_LIBRARY = 2;
/**
* Type constant which identifies core files.
*/
public static final int CORE = 3;
/**
* Returns the type of this module.
* The returned value will be one of <code>EXECUTABLE</code>,
* <code>SHARED_LIBRARY</code>, <code>CORE</code>.
*
* @return the type of this module
*/
public int getType();
/**
* Returns the name of this module.
*
* @return the name of this module
*/
public String getName();
/**
* Returns the image name of this module. The name may or may not
* contain a full path.
*
* @return the image name of this module
*/
public IPath getImageName();
/**
* Returns the full path of the file from which symbols to be loaded.
*
* @return the full path of the file from which symbols to be loaded
*/
public IPath getSymbolsFileName();
/**
* Associate the specified file as a symbol provider for this module.
* If <code>null</code> is passed as a file name the internal symbols
* search mechanism will be used.
*
* @param symbolsFile the symbol provider for this module.
*/
public void setSymbolsFileName( IPath symbolsFile );
/**
* Returns the base address of this module.
*
* @return the base address of this module
*/
public IAddress getBaseAddress();
/**
* Returns the size of this module.
*
* @return the size of this module
*/
public long getSize();
/**
* Returns whether the symbols of this module are read.
*
* @return whether the symbols of this module are read
*/
public boolean areSymbolsLoaded();
/**
* Loads the module symbols from the specified file.
*
* @throws DebugException if this method fails. Reasons include:
*/
public void loadSymbols() throws DebugException;
/**
* Returns the name of the platform.
*
* @return the name of the platform
*/
public String getPlatform();
/**
* Returns whether this module is little endian.
*
* @return whether this module is little endian
*/
public boolean isLittleEndian();
/**
* Returns the address factory associated with this module.
*
* @return the address factory
*/
public IAddressFactory getAddressFactory();
}

View file

@ -66,6 +66,7 @@ import org.eclipse.cdt.debug.core.model.ICDebugElementStatus;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICModule;
import org.eclipse.cdt.debug.core.model.ICSharedLibrary;
import org.eclipse.cdt.debug.core.model.ICSignal;
import org.eclipse.cdt.debug.core.model.IDebuggerProcessSupport;
@ -162,6 +163,11 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
*/
private CSharedLibraryManager fSharedLibraryManager;
/**
* The module manager for this target.
*/
private CModuleManager fModuleManager;
/**
* The signal manager for this target.
*/
@ -230,6 +236,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
setThreadList( new ArrayList( 5 ) );
createDisassembly();
setSharedLibraryManager( new CSharedLibraryManager( this ) );
setModuleManager( new CModuleManager( this ) );
setSignalManager( new CSignalManager( this ) );
setRegisterManager( new CRegisterManager( this ) );
setBreakpointManager( new CBreakpointManager( this ) );
@ -248,6 +255,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
initializeBreakpoints();
initializeRegisters();
initializeSourceManager();
initializeModuleManager();
getLaunch().addDebugTarget( this );
fireEventSet( (DebugEvent[])debugEvents.toArray( new DebugEvent[debugEvents.size()] ) );
}
@ -327,6 +335,10 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
}
}
protected void initializeModuleManager() {
getModuleManager().addModules( new ICModule[] { CModule.createExecutable( this, getExecFile().getPath() ) } );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IDebugTarget#getProcess()
*/
@ -797,8 +809,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
return this;
if ( adapter.equals( CBreakpointManager.class ) )
return getBreakpointManager();
if ( adapter.equals( ICSharedLibraryManager.class ) )
return getSharedLibraryManager();
if ( adapter.equals( CSignalManager.class ) )
return getSignalManager();
if ( adapter.equals( ICRegisterManager.class ) )
@ -831,6 +841,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
}
if ( source instanceof ICDISharedLibrary ) {
getSharedLibraryManager().sharedLibraryLoaded( (ICDISharedLibrary)source );
getModuleManager().sharedLibraryLoaded( (ICDISharedLibrary)source );
}
}
else if ( event instanceof ICDISuspendedEvent ) {
@ -854,6 +865,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
}
if ( source instanceof ICDISharedLibrary ) {
getSharedLibraryManager().sharedLibraryUnloaded( (ICDISharedLibrary)source );
getModuleManager().sharedLibraryUnloaded( (ICDISharedLibrary)source );
}
}
else if ( event instanceof ICDIDisconnectedEvent ) {
@ -971,6 +983,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
saveGlobalVariables();
disposeGlobalVariableManager();
disposeSharedLibraryManager();
disposeModuleManager();
disposeSignalManager();
disposeRegisterManager();
disposeDisassembly();
@ -1399,6 +1412,19 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
fSharedLibraryManager.dispose();
}
protected void setModuleManager( CModuleManager mm ) {
fModuleManager = mm;
}
protected CModuleManager getModuleManager() {
return fModuleManager;
}
protected void disposeModuleManager() {
fModuleManager.dispose();
fModuleManager = null;
}
protected void setSignalManager( CSignalManager sm ) {
fSignalManager = sm;
}
@ -1781,6 +1807,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
private void handleSymbolsLoaded( ICDISharedLibrary library ) {
getSharedLibraryManager().symbolsLoaded( library );
getModuleManager().symbolsLoaded( library );
}
public ICGlobalVariable createGlobalVariable( IGlobalVariableDescriptor info ) throws DebugException {
@ -1793,4 +1820,28 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
}
return CVariableFactory.createGlobalVariable( this, info, vo );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICDebugTarget#hasModules()
*/
public boolean hasModules() throws DebugException {
CModuleManager mm = getModuleManager();
return ( mm != null ) ? mm.hasModules() : false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICDebugTarget#getModules()
*/
public ICModule[] getModules() throws DebugException {
CModuleManager mm = getModuleManager();
return ( mm != null ) ? mm.getModules() : new ICModule[0];
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICDebugTarget#loadSymbolsForAllModules()
*/
public void loadSymbolsForAllModules() throws DebugException {
CModuleManager mm = getModuleManager();
mm.loadSymbolsForAll();
}
}

View file

@ -0,0 +1,198 @@
/**********************************************************************
* 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.model;
import java.math.BigInteger;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
import org.eclipse.cdt.debug.core.model.ICModule;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugException;
/**
* The CDI based implementation of <code>ICModule</code>.
*/
public class CModule extends CDebugElement implements ICModule {
private int fType = 0;
private ICElement fCElement;
private ICDIObject fCDIObject;
private IPath fImageName;
private IPath fSymbolsFileName;
public static CModule createExecutable( CDebugTarget target, IPath path ) {
// TODO Add support for executables to CDI.
return new CModule( EXECUTABLE, target, path );
}
public static CModule createSharedLibrary( CDebugTarget target, ICDISharedLibrary lib ) {
return new CModule( SHARED_LIBRARY, target, lib );
}
public static CModule createCore( CDebugTarget target, IPath path ) {
// TODO Add support for core file to CDI.
return new CModule( CORE, target, path );
}
/**
* Constructor for CModule.
*/
private CModule( int type, CDebugTarget target, IPath path ) {
super( target );
fType = type;
fCElement = CoreModel.getDefault().create( path );
fCDIObject = null;
fImageName = path;
fSymbolsFileName = path;
}
/**
* Constructor for CModule.
*/
private CModule( int type, CDebugTarget target, ICDIObject cdiObject ) {
super( target );
fType = type;
if ( cdiObject instanceof ICDISharedLibrary ) {
fCElement = CoreModel.getDefault().create( new Path( ((ICDISharedLibrary)cdiObject).getFileName() ) );
}
fCDIObject = cdiObject;
fImageName = ( ( cdiObject instanceof ICDISharedLibrary ) ) ? new Path( ((ICDISharedLibrary)cdiObject).getFileName() ) : new Path( CoreModelMessages.getString( "CModule.0" ) ); //$NON-NLS-1$
fSymbolsFileName = fImageName;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICModule#getType()
*/
public int getType() {
return fType;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICModule#getName()
*/
public String getName() {
return fImageName.lastSegment().toString();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICModule#getImageName()
*/
public IPath getImageName() {
return fImageName;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICModule#getSymbolsFileName()
*/
public IPath getSymbolsFileName() {
return fSymbolsFileName;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICModule#setSymbolsFileName(org.eclipse.core.runtime.IPath)
*/
public void setSymbolsFileName( IPath symbolsFile ) {
fSymbolsFileName = symbolsFile;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICModule#getBaseAddress()
*/
public IAddress getBaseAddress() {
return ( fCDIObject instanceof ICDISharedLibrary ) ? getAddressFactory().createAddress( ((ICDISharedLibrary)fCDIObject).getStartAddress() ) : getAddressFactory().getZero();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICModule#getSize()
*/
public long getSize() {
long result = 0;
if ( fCDIObject instanceof ICDISharedLibrary ) {
BigInteger start = ((ICDISharedLibrary)fCDIObject).getStartAddress();
BigInteger end = ((ICDISharedLibrary)fCDIObject).getEndAddress();
if ( end.compareTo( start ) > 0 )
result = end.subtract( start ).longValue();
}
return result;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICModule#areSymbolsLoaded()
*/
public boolean areSymbolsLoaded() {
return ( fCElement instanceof IBinary ) ? ((IBinary)fCElement).hasDebug() :
( ( fCDIObject instanceof ICDISharedLibrary ) ? ((ICDISharedLibrary)fCDIObject).areSymbolsLoaded() : false );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICModule#loadSymbols()
*/
public void loadSymbols() throws DebugException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICModule#getPlatform()
*/
public String getPlatform() {
return ( fCElement instanceof IBinary ) ? ((IBinary)fCElement).getCPU() : CoreModelMessages.getString( "CModule.1" ); //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICModule#isLittleEndian()
*/
public boolean isLittleEndian() {
return ( fCElement instanceof IBinary ) ? ((IBinary)fCElement).isLittleEndian() : ((CDebugTarget)getDebugTarget()).isLittleEndian();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICModule#getAddressFactory()
*/
public IAddressFactory getAddressFactory() {
return ((CDebugTarget)getDebugTarget()).getAddressFactory();
}
public void dispose() {
}
public boolean equals( ICDIObject cdiObject ) {
return ( fCDIObject != null ) ? fCDIObject.equals( cdiObject ) : false;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter( Class adapter ) {
if ( ICElement.class.equals( adapter ) ) {
return getCElement();
}
if ( IBinary.class.equals( adapter ) && getCElement() instanceof IBinary ) {
return (IBinary)getCElement();
}
return super.getAdapter( adapter );
}
protected ICElement getCElement() {
return fCElement;
}
}

View file

@ -0,0 +1,145 @@
/**********************************************************************
* 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.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
import org.eclipse.cdt.debug.core.model.ICModule;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
/**
* Manages the modules loaded on this debug target.
*/
public class CModuleManager {
/**
* The debug target associated with this manager.
*/
private CDebugTarget fDebugTarget;
/**
* The collection of the shared libraries loaded on this target.
*/
private ArrayList fModules;
/**
* Constructor for CModuleManager.
*/
public CModuleManager( CDebugTarget target ) {
fDebugTarget = target;
fModules = new ArrayList( 5 );
}
public boolean hasModules() {
return !fModules.isEmpty();
}
public ICModule[] getModules() {
return (ICModule[])fModules.toArray( new ICModule[fModules.size()] );
}
public void loadSymbolsForAll() throws DebugException {
MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, CoreModelMessages.getString( "CModuleManager.0" ), null ); //$NON-NLS-1$
Iterator it = fModules.iterator();
while( it.hasNext() ) {
ICModule module = (ICModule)it.next();
try {
module.loadSymbols();
}
catch( DebugException e ) {
ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e ) );
}
}
if ( !ms.isOK() ) {
throw new DebugException( ms );
}
}
public void loadSymbols( ICModule[] modules ) throws DebugException {
MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, CoreModelMessages.getString( "CModuleManager.1" ), null ); //$NON-NLS-1$
for ( int i = 0; i < modules.length; ++i ) {
try {
modules[i].loadSymbols();
}
catch( DebugException e ) {
ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e ) );
}
}
if ( !ms.isOK() ) {
throw new DebugException( ms );
}
}
public void dispose() {
Iterator it = fModules.iterator();
while( it.hasNext() ) {
((CModule)it.next()).dispose();
}
fModules.clear();
}
protected CDebugTarget getDebugTarget() {
return fDebugTarget;
}
protected void addModules( ICModule[] modules ) {
fModules.addAll( Arrays.asList( modules ) );
}
protected void removeModules( ICModule[] modules ) {
fModules.removeAll( Arrays.asList( modules ) );
}
public void sharedLibraryLoaded( ICDISharedLibrary cdiLibrary ) {
CModule library = CModule.createSharedLibrary( getDebugTarget(), cdiLibrary );
synchronized( fModules ) {
fModules.add( library );
}
library.fireCreationEvent();
}
public void sharedLibraryUnloaded( ICDISharedLibrary cdiLibrary ) {
CModule library = find( cdiLibrary );
if ( library != null ) {
synchronized( fModules ) {
fModules.remove( library );
}
library.dispose();
library.fireTerminateEvent();
}
}
public void symbolsLoaded( ICDIObject cdiObject ) {
CModule module = find( cdiObject );
if ( module != null ) {
module.fireChangeEvent( DebugEvent.STATE );
}
}
private CModule find( ICDIObject cdiObject ) {
Iterator it = fModules.iterator();
while( it.hasNext() ) {
CModule module = (CModule)it.next();
if ( module.equals( cdiObject ) )
return module;
}
return null;
}
}

View file

@ -27,3 +27,7 @@ CVariable.5=Type is not available.
CIndexedValue.0=Index out of bounds.
CIndexedValue.1=Index out of bounds.
CIndexedValue.2=Specified range out of bounds.
CModule.0=Unknown
CModule.1=Unknown
CModuleManager.0=Error loading symbols.
CModuleManager.1=Error loading symbols.