Added support of the 'Add Global Variables' action of the Expressions
view.
Index:
ChangeLog
===================================================================
RCS
file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v
retrieving revision
1.46
diff -u -r1.46 ChangeLog
--- ChangeLog 4 Nov 2002 01:40:24
-0000 1.46
+++ ChangeLog 5 Nov 2002 20:15:30 -0000
@@ -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
Added support of the formatting actions of the Memory
view.
* IFormattedMemoryBlock.java
Index:
src/org/eclipse/cdt/debug/core/IExecFileInfo.java
===================================================================
RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IExecFileInfo.java,v
retrieving
revision 1.1
diff -u -r1.1 IExecFileInfo.java
---
src/org/eclipse/cdt/debug/core/IExecFileInfo.java 1 Nov 2002 23:17:17
-0000 1.1
+++ src/org/eclipse/cdt/debug/core/IExecFileInfo.java 5
Nov 2002 20:15:30 -0000
@@ -3,6 +3,7 @@
* All Rights
Reserved.
*
*/
+
package
org.eclipse.cdt.debug.core;
/**
@@ -13,4 +14,6
@@
public interface IExecFileInfo
{
public
boolean isLittleEndian();
+
+ public IGlobalVariable[]
getGlobals();
}
Index:
src/org/eclipse/cdt/debug/core/IGlobalVariable.java
===================================================================
RCS
file: src/org/eclipse/cdt/debug/core/IGlobalVariable.java
diff -N
src/org/eclipse/cdt/debug/core/IGlobalVariable.java
--- /dev/null 1 Jan
1970 00:00:00 -0000
+++
src/org/eclipse/cdt/debug/core/IGlobalVariable.java 5 Nov 2002 20:15:30
-0000
@@ -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();
+}
Index:
src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
===================================================================
RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java,v
retrieving
revision 1.53
diff -u -r1.53 CDebugTarget.java
---
src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java 4 Nov 2002
01:40:24 -0000 1.53
+++
src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java 5 Nov 2002
20:15:31 -0000
@@ -13,6 +13,7 @@
import
org.eclipse.cdt.core.CCorePlugin;
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.core.model.ICFile;
import
org.eclipse.cdt.debug.core.CDebugCorePlugin;
import
org.eclipse.cdt.debug.core.CDebugModel;
@@ -26,6 +27,7 @@
import
org.eclipse.cdt.debug.core.IExecFileInfo;
import
org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
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.IRunToLine;
import
org.eclipse.cdt.debug.core.IState;
@@ -2009,5 +2011,64
@@
private void setExecFile( IFile 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;
+
}
+
};
}
}