Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Proposed CDT 1.2 patches 3/3

CDT 1-2 patch: 3/3

3. Different versions of gdb seem to vary greatly in their ability at retrieving
   the full target register set. This is a gdb bug: gdb/MI will list a
   register as available, but then  subsequently report an error while
   querying the value of the register.  When this happens, the register
   pane will be empty.

   The proposed patch is to catch the exception, and display the partial
   partial register set.

Ashish.
#!/bin/bash
--- ./precious/old/CRegisterGroup.java	2003-10-22 19:40:41.000000000 -0400
+++ ./precious/new/CRegisterGroup.java	2003-10-22 19:40:41.000000000 -0400
@@ -93,16 +93,29 @@
 	private ICDIRegister[] getCDIRegisters() throws DebugException
 	{
 		ICDIRegister[] results = new ICDIRegister[fRegisterObjects.length];
+		int i=0;
 		try
 		{
-			for ( int i = 0; i < fRegisterObjects.length; ++i )
+			for ( i = 0; i < fRegisterObjects.length; ++i )
 			{
 				results[i] = ((CDebugTarget)getDebugTarget()).getCDISession().getRegisterManager().createRegister( fRegisterObjects[i] );
 			}
 		}
 		catch( CDIException e )
 		{
-			targetRequestFailed( e.getMessage(), null );
+			//gdb's success in retrieving the full register set appears to vary significantly between revisions of gdb
+			//and different target architectures. In case gdb fails to provide a register after listing it as available,
+			//we need to make at least a partial  register set available if possible.
+			//Throw an exception only if no registers were found, otherwise simply log the message and return the
+			// registers found.
+			if (i >0) {
+				CDebugCorePlugin.log(e);
+				ICDIRegister[] partialResults = new ICDIRegister[i];
+				System.arraycopy(results,0,partialResults,0,i);
+				return partialResults;
+			}else {
+				targetRequestFailed( e.getMessage(), null );
+			}
 		}
 		return results;
 	}



Back to the top