1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Added support of the 'Add Global Variables' action of the Expressions view.

This commit is contained in:
Mikhail Khodjaiants 2002-11-05 20:16:15 +00:00
parent fd2f3b9004
commit 21a42a700d
4 changed files with 89 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2002-11-05 Mikhail Khodjaiants
Added support of the 'Add Global Variables' action of the Expressions view.
* IExecFileInfo.java
* IGlobalVariable.java
* CDebugTarget.java
2002-11-03 Mikhail Khodjaiants 2002-11-03 Mikhail Khodjaiants
Added support of the formatting actions of the Memory view. Added support of the formatting actions of the Memory view.
* IFormattedMemoryBlock.java * IFormattedMemoryBlock.java

View file

@ -3,6 +3,7 @@
* All Rights Reserved. * All Rights Reserved.
* *
*/ */
package org.eclipse.cdt.debug.core; package org.eclipse.cdt.debug.core;
/** /**
@ -13,4 +14,6 @@ package org.eclipse.cdt.debug.core;
public interface IExecFileInfo public interface IExecFileInfo
{ {
public boolean isLittleEndian(); public boolean isLittleEndian();
public IGlobalVariable[] getGlobals();
} }

View file

@ -0,0 +1,19 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.core;
import org.eclipse.core.runtime.IPath;
/**
* Enter type comment.
*
* @since: Nov 4, 2002
*/
public interface IGlobalVariable
{
String getName();
IPath getPath();
}

View file

@ -13,6 +13,7 @@ import java.util.List;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICFile; import org.eclipse.cdt.core.model.ICFile;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugModel; import org.eclipse.cdt.debug.core.CDebugModel;
@ -26,6 +27,7 @@ import org.eclipse.cdt.debug.core.IDebuggerProcessSupport;
import org.eclipse.cdt.debug.core.IExecFileInfo; import org.eclipse.cdt.debug.core.IExecFileInfo;
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock; import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval; import org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval;
import org.eclipse.cdt.debug.core.IGlobalVariable;
import org.eclipse.cdt.debug.core.IRestart; import org.eclipse.cdt.debug.core.IRestart;
import org.eclipse.cdt.debug.core.IRunToLine; import org.eclipse.cdt.debug.core.IRunToLine;
import org.eclipse.cdt.debug.core.IState; import org.eclipse.cdt.debug.core.IState;
@ -2010,4 +2012,63 @@ public class CDebugTarget extends CDebugElement
{ {
fExecFile = file; fExecFile = file;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IExecFileInfo#getGlobals()
*/
public IGlobalVariable[] getGlobals()
{
ArrayList list = new ArrayList();
if ( getExecFile() != null && CoreModel.isBinary( getExecFile() ) )
{
ICFile cFile = CCorePlugin.getDefault().getCoreModel().create( getExecFile() );
if ( cFile instanceof IBinary )
{
list.addAll( getCFileGlobals( cFile ) );
}
}
return (IGlobalVariable[])list.toArray( new IGlobalVariable[list.size()] );
}
private List getCFileGlobals( ICFile file )
{
ArrayList list = new ArrayList();
ICElement[] elements = file.getChildren();
for ( int i = 0; i < elements.length; ++i )
{
if ( elements[i] instanceof org.eclipse.cdt.core.model.IVariable )
{
list.add( createGlobalVariable( (org.eclipse.cdt.core.model.IVariable)elements[i] ) );
}
else if ( elements[i] instanceof org.eclipse.cdt.core.model.ICFile )
{
list.addAll( getCFileGlobals( (org.eclipse.cdt.core.model.ICFile)elements[i] ) );
}
}
return list;
}
private IGlobalVariable createGlobalVariable( final org.eclipse.cdt.core.model.IVariable var )
{
return new IGlobalVariable()
{
public String getName()
{
return var.getElementName();
}
public IPath getPath()
{
IPath path = null;
if ( var.getParent() != null && var.getParent() instanceof ICFile )
{
if ( !(var.getParent() instanceof IBinary) )
{
path = ((ICFile)var.getParent()).getFile().getLocation();
}
}
return path;
}
};
}
} }