Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Fix for 40108 and Related Issues...


Hi,

This is a fix for 40108. That part of the fix is pretty straight forward.

It's also a fix for the performance issues when you use the memoryview in a mode other than hex. Turns out that the reason that takes so long is that CDebugTarget.isLittleEndian is amazingly heavyweight. On the assumption that once you've got a target, the endianness is not going to change, the endianness value is now cached after first determination in CDebugTarget. This makes an amazing difference in performance.

It could be that this caching should really pushed down yet another level or two, but I was not sure if it was the model call that was creating the problem and CDebugTarget is where the model call is made.

These changes without the performance fix make the memory view really annoying because the byteswizzle part of the fix requires a call to isLittleEndian. These changes were made against 1.2.1.

Thanks!
-Chris
songer@xxxxxxxxxxxxx
director of platform engineering
voice: 408 327 7341 fax: 408 986 8919
diff -r -u xide/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java xide_compare/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
--- xide/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java	Fri Jan 16 20:25:13 2004
+++ xide_compare/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java	Wed Feb  4 10:09:18 2004
@@ -266,6 +266,12 @@
 
 	private RunningInfo fRunningInfo = null;
 	
+	/** do we know the endianness? */
+	protected boolean fKnowEndianness = false;
+	
+	/** what is the endianness, only valid if fKnowEndianness == true */
+	protected boolean fIsLittleEndian;
+	
 	/**
 	 * Constructor for CDebugTarget.
 	 * @param target
@@ -1908,12 +1914,17 @@
 	 */
 	public boolean isLittleEndian()
 	{
+		if( fKnowEndianness )
+			return fIsLittleEndian;
+		
 		if ( getExecFile() != null && CoreModel.getDefault().isBinary( getExecFile() ) )
 		{
 			ICElement cFile = CCorePlugin.getDefault().getCoreModel().create( getExecFile() );
 			if ( cFile instanceof IBinary )
 			{
-				((IBinary)cFile).isLittleEndian();
+				fKnowEndianness = true;
+				fIsLittleEndian = ((IBinary)cFile).isLittleEndian(); 
+				return fIsLittleEndian;
 			}
 		}
 		return true;
diff -r -u xide/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java xide_compare/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java
--- xide/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java	Fri Jan 16 20:25:21 2004
+++ xide_compare/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java	Wed Feb  4 10:09:18 2004
@@ -425,7 +425,7 @@
 		switch( getDataFormat() )
 		{
 			case IFormattedMemoryBlock.MEMORY_FORMAT_HEX:
-				return item;
+				return convertToHex(getWordSize(), item);
 			case IFormattedMemoryBlock.MEMORY_FORMAT_SIGNED_DECIMAL:
 				return convertToDecimal( getWordSize(), item, true );
 			case IFormattedMemoryBlock.MEMORY_FORMAT_UNSIGNED_DECIMAL:
@@ -457,6 +457,26 @@
 		return 0;
 	}
 	
+	/**
+	 * Performs endianness swap (in a brainless, but right most of the time) fashion.
+	 * @param item
+	 * @return
+	 */
+	private String convertToHex( int wordsize, String item )
+	{
+		if( !getMemoryBlock().isLittleEndian() || wordsize == IFormattedMemoryBlock.MEMORY_SIZE_BYTE )
+			return item;
+
+		String ret = "";
+		int length = item.length();
+		for( int i = length - 2 ; i >= 0 ; i-=2 )
+		{
+			ret = ret + item.substring(i, i+2); 
+		}
+		 
+		return ret;
+	}
+	
 	private String convertToDecimal( int wordSize, String item, boolean signed )
 	{
 		String result = "";

Back to the top