Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] new method: IBinary.isLittleEndian()

2002-10-25 Alain Magloire

	The debugger needs to know the endian of a binary.  For example
	int the memory view, to do format.

	* model/.../model/IBinary (isLittleEndian): New method
	returns the endian.
	* model/.../internal/core/model/Binary.java (isLittleEndian): New method.
	* model/.../internal/core/model/BinaryInfo.java (isLittleEndian): New
	method implemented by calling Elf.
	* utils/.../utils/elf/Elf.java (Elf.Attribute.isLittleEndian): New
	method return the endian.



Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.10
diff -u -r1.10 ChangeLog
--- ChangeLog	23 Oct 2002 18:22:20 -0000	1.10
+++ ChangeLog	25 Oct 2002 18:37:10 -0000
@@ -1,3 +1,16 @@
+2002-10-25 Alain Magloire
+
+	The debugger needs to know the endian of a binary.  For example
+	int the memory view, to do format.
+
+	* model/.../model/IBinary (isLittleEndian): New method
+	returns the endian.
+	* model/.../internal/core/model/Binary.java (isLittleEndian): New method.
+	* model/.../internal/core/model/BinaryInfo.java (isLittleEndian): New
+	method implemented by calling Elf.
+	* utils/.../utils/elf/Elf.java (Elf.Attribute.isLittleEndian): New
+	method return the endian.
+
 2002-10-23 Alain Magloire
 
 	* src/.../core/resource/ACBuilder.java (mapMarkerSeverity):
Index: model/org/eclipse/cdt/core/model/IBinary.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IBinary.java,v
retrieving revision 1.1
diff -u -r1.1 IBinary.java
--- model/org/eclipse/cdt/core/model/IBinary.java	26 Jun 2002 20:37:14 -0000	1.1
+++ model/org/eclipse/cdt/core/model/IBinary.java	25 Oct 2002 18:37:10 -0000
@@ -32,4 +32,7 @@
 	public long getData();
 
 	public long getBSS();
+	
+	public boolean isLittleEndian();
+
 }
Index: model/org/eclipse/cdt/internal/core/model/Binary.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java,v
retrieving revision 1.1
diff -u -r1.1 Binary.java
--- model/org/eclipse/cdt/internal/core/model/Binary.java	26 Jun 2002 20:37:14 -0000	1.1
+++ model/org/eclipse/cdt/internal/core/model/Binary.java	25 Oct 2002 18:37:10 -0000
@@ -74,7 +74,15 @@
 		return ((BinaryInfo)getElementInfo()).getSoname();
 	}
 
+	/**
+	 * @see org.eclipse.cdt.core.model.IBinary#isLittleEndian()
+	 */
+	public boolean isLittleEndian() {
+		return  ((BinaryInfo)getElementInfo()).isLittleEndian();
+	}
+
 	public CElementInfo createElementInfo() {
 		return new BinaryInfo(this);
 	}
+
 }
Index: model/org/eclipse/cdt/internal/core/model/BinaryInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryInfo.java,v
retrieving revision 1.1
diff -u -r1.1 BinaryInfo.java
--- model/org/eclipse/cdt/internal/core/model/BinaryInfo.java	26 Jun 2002 20:37:14 -0000	1.1
+++ model/org/eclipse/cdt/internal/core/model/BinaryInfo.java	25 Oct 2002 18:37:10 -0000
@@ -114,6 +114,14 @@
 		return soname;
 	}
 
+	public boolean isLittleEndian() {
+		init();
+		if (attribute != null) {
+			return attribute.isLittleEndian();
+		}
+		return false;
+	}
+	
 	private void addFunction(Elf.Symbol [] symbol, boolean external) {
 		for (int i = 0; i < symbol.length; i++) {
 			ICElement parent = getElement();
@@ -244,6 +252,7 @@
 
 			sizes = helper.getSizes();
 			soname = helper.getSoname();
+			
 			attribute = helper.getElf().getAttributes();
 			helper.dispose();
 		} catch (IOException e) {
Index: utils/org/eclipse/cdt/utils/elf/Elf.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java,v
retrieving revision 1.3
diff -u -r1.3 Elf.java
--- utils/org/eclipse/cdt/utils/elf/Elf.java	9 Oct 2002 12:40:43 -0000	1.3
+++ utils/org/eclipse/cdt/utils/elf/Elf.java	25 Oct 2002 18:37:11 -0000
@@ -590,6 +590,7 @@
 		String cpu;
 		int type;
 		boolean bDebug;
+		boolean isle;
 
 		public String getCPU() {
 			return cpu;
@@ -602,6 +603,10 @@
 		public boolean hasDebug() {
 			return bDebug;
 		}
+
+		public boolean isLittleEndian() {
+			return isle;
+		}
 	}
 
 
@@ -649,13 +654,15 @@
 			default:
 				attrib.cpu = "none";
 		}
-		if ( !bSkipElfData) {
+		if (!bSkipElfData) {
 			switch (ehdr.e_ident[Elf.ELFhdr.EI_DATA]) {
 				case Elf.ELFhdr.ELFDATA2LSB :
 					attrib.cpu+= "le";
+					attrib.isle = true;
 					break;
 				case Elf.ELFhdr.ELFDATA2MSB :
 					attrib.cpu += "be";
+					attrib.isle = false;
 					break;
 			}
 		}



Back to the top