public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Fix sign extension bug with breg operation.
@ 2008-01-14 21:03 tthomas
  0 siblings, 0 replies; only message in thread
From: tthomas @ 2008-01-14 21:03 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  bf27254471f894469bfcb05e6e39dc3a879ce345 (commit)
      from  5f9911f885000327e51a4a5269ec3d1d3c42e3c4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit bf27254471f894469bfcb05e6e39dc3a879ce345
Author: Teresa Thomas <tthomas@redhat.com>
Date:   Mon Jan 14 15:47:51 2008 -0500

    Fix sign extension bug with breg operation.
    
    frysk-core/frysk/debuginfo/ChangeLog
    2008-01-14  Teresa Thomas  <tthomas@redhat.com>
    
    	* TestLocationExpression.java (testOverFlow): New.
    	* LocationExpression.java (decode): Mask out
    	sign extension for BREG locations.
    
    frysk-core/frysk/pkglibdir/ChangeLog
    2008-01-14  Teresa Thomas  <tthomas@redhat.com>
    
    	* funit-location.S: Set REG3 for tests.

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/debuginfo/ChangeLog               |    6 ++
 frysk-core/frysk/debuginfo/LocationExpression.java |   11 ++-
 .../frysk/debuginfo/TestLocationExpression.java    |   68 +++++++++++++-------
 frysk-core/frysk/pkglibdir/ChangeLog               |    4 +
 frysk-core/frysk/pkglibdir/funit-location.S        |    1 +
 5 files changed, 63 insertions(+), 27 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/debuginfo/ChangeLog b/frysk-core/frysk/debuginfo/ChangeLog
index 71c4418..375c6ad 100644
--- a/frysk-core/frysk/debuginfo/ChangeLog
+++ b/frysk-core/frysk/debuginfo/ChangeLog
@@ -1,3 +1,9 @@
+2008-01-14  Teresa Thomas  <tthomas@redhat.com>
+
+	* TestLocationExpression.java (testOverFlow): New.
+	* LocationExpression.java (decode): Mask out
+	sign extension for BREG locations.
+	
 2008-01-14  Nurdin Premji  <npremji@redhat.com>
 
 	* TypeEntry.java: Ran formatter.
diff --git a/frysk-core/frysk/debuginfo/LocationExpression.java b/frysk-core/frysk/debuginfo/LocationExpression.java
index ee88e06..70021ee 100644
--- a/frysk-core/frysk/debuginfo/LocationExpression.java
+++ b/frysk-core/frysk/debuginfo/LocationExpression.java
@@ -83,13 +83,16 @@ public class LocationExpression {
 	// pieces will contain the resulting location as a list of 
 	// MemoryPiece, RegisterPiece or UnavaiablePiece
 	ArrayList pieces = new ArrayList(); 
-
+	
+	long wordMask = (Config.getWordSize() == 32)?
+			         0xffffffffL : 0xffffffffffffffffL;
+	
 	if (nops == 0)
 	    if (die.getAttrBoolean(DwAt.LOCATION)) 
 		throw new VariableOptimizedOutException();  
 	    else 
 		throw new ValueUavailableException();
-
+	
 	for(int i = 0; i < nops; i++) {
 
 	    int operator = ((DwarfOp) ops.get(i)).operator;
@@ -206,7 +209,7 @@ public class LocationExpression {
 	    case DwOp.BREG31_:
 		register = registerMap.getRegister(operator - DwOp.BREG0_);
 		long regval = frame.getRegister(register);
-		stack.addFirst(new Long(operand1 + regval));
+		stack.addFirst(new Long((regval + operand1) & wordMask));
 		break;
 
 	    case DwOp.REGX_:
@@ -217,7 +220,7 @@ public class LocationExpression {
 	    case DwOp.BREGX_:
 		register = registerMap.getRegister((int)operand1);
 		regval = frame.getRegister(register);
-		stack.addFirst(new Long(operand2 + regval));
+		stack.addFirst(new Long((operand2 + regval) & wordMask));
 		break;
 
 	    case DwOp.ADDR_:
diff --git a/frysk-core/frysk/debuginfo/TestLocationExpression.java b/frysk-core/frysk/debuginfo/TestLocationExpression.java
index 4393145..fab2328 100644
--- a/frysk-core/frysk/debuginfo/TestLocationExpression.java
+++ b/frysk-core/frysk/debuginfo/TestLocationExpression.java
@@ -84,7 +84,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.DUP_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)989, 12));
+	expectedLoc.add(new MemoryPiece((long)989, 4));
 	
 	checkLocExpected(ops, expectedLoc, 2);
     }
@@ -102,7 +102,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.BREGX_, dwarfReg1.intValue(), 2, 0) );
 		
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)989, 12));
+	expectedLoc.add(new MemoryPiece((long)989, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
@@ -146,7 +146,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.MUL_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)60, 12));
+	expectedLoc.add(new MemoryPiece((long)60, 4));
 	
 	checkLocExpected(ops, expectedLoc, 3);
     }
@@ -165,7 +165,7 @@ public class TestLocationExpression
 	
 	// Created expected result list
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)17, 12));
+	expectedLoc.add(new MemoryPiece((long)17, 4));
 	
 	checkLocExpected(ops, expectedLoc, 2);
     }
@@ -178,7 +178,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.DIV_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)3, 12));
+	expectedLoc.add(new MemoryPiece((long)3, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
@@ -191,7 +191,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.MOD_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)1, 12));
+	expectedLoc.add(new MemoryPiece((long)1, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
@@ -204,7 +204,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.DROP_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)30, 12));
+	expectedLoc.add(new MemoryPiece((long)30, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
@@ -217,7 +217,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.SWAP_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)12, 12));
+	expectedLoc.add(new MemoryPiece((long)12, 4));
 	
 	checkLocExpected(ops, expectedLoc, 2);
     }  
@@ -231,7 +231,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.ROT_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)7, 12));
+	expectedLoc.add(new MemoryPiece((long)7, 4));
 	
 	checkLocExpected(ops, expectedLoc, 3);
     }  
@@ -243,7 +243,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.ABS_, 0, 0, 0) );
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)5, 12));
+	expectedLoc.add(new MemoryPiece((long)5, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
@@ -255,7 +255,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.NEG_, 0, 0, 0) );
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)-5, 12));
+	expectedLoc.add(new MemoryPiece((long)-5, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
@@ -267,7 +267,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.NOT_, 0, 0, 0) );
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)-6, 12));
+	expectedLoc.add(new MemoryPiece((long)-6, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
@@ -280,7 +280,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.AND_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)0, 12));
+	expectedLoc.add(new MemoryPiece((long)0, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
@@ -294,7 +294,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.OR_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)7, 12));
+	expectedLoc.add(new MemoryPiece((long)7, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
@@ -308,7 +308,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.SHL_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)72, 12));
+	expectedLoc.add(new MemoryPiece((long)72, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
@@ -322,7 +322,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.SHR_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)3, 12));
+	expectedLoc.add(new MemoryPiece((long)3, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
@@ -336,7 +336,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.SHRA_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)-7, 12));
+	expectedLoc.add(new MemoryPiece((long)-7, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
@@ -350,7 +350,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.XOR_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)7, 12));
+	expectedLoc.add(new MemoryPiece((long)7, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
@@ -364,7 +364,7 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.LE_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)1, 12));
+	expectedLoc.add(new MemoryPiece((long)1, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
@@ -378,11 +378,33 @@ public class TestLocationExpression
 	ops.add( new DwarfOp(DwOp.GE_, 0, 0, 0) ) ;
 	
 	List expectedLoc = new ArrayList();
-	expectedLoc.add(new MemoryPiece((long)0, 12));
+	expectedLoc.add(new MemoryPiece((long)0, 4));
 	
 	checkLocExpected(ops, expectedLoc, 1);
     }
        
+    public void testOverFlow()
+    {
+    	if (unresolvedOnPPC(4964))
+    		return;
+    	List ops = new ArrayList();
+
+    	Task task = getStoppedTask();
+    	ISA isa = task.getISA();
+
+    	if (isa == ISA.IA32) {
+    		ops.add( new DwarfOp(DwOp.BREG2_, -4, 0, 0) ); // Value in register edx plus 4
+    	} else if (isa == ISA.X8664) {
+    		ops.add( new DwarfOp(DwOp.BREG1_, -4, 0, 0) ); // Value in register rdx plus 4
+    	} else {
+    		throw new RuntimeException("unknown isa: " + isa);
+    	}  
+
+    	List expectedLoc = new ArrayList();
+    	expectedLoc.add(new MemoryPiece((long)0x12345674, 4));
+
+    	checkLocExpected(ops, expectedLoc, 1);
+    }
     /**
      * Function that creates Dwarf stack and checks its values
      * 
@@ -397,7 +419,7 @@ public class TestLocationExpression
 	Frame frame = StackFactory.createFrame(task);
 	
 	LocationExpression locExp = new LocationExpression(die);
-	List loc = locExp.decode(frame, ops,12);  
+	List loc = locExp.decode(frame, ops, 4);  
 	
 	assertEquals ("Stack size", stackSize, locExp.getStackSize());
 	compareLocations (loc, expectedLoc);
@@ -423,9 +445,9 @@ public class TestLocationExpression
 		    // Note: equals() overridden for the pieces.
 		    isEqual = o.equals(oExpect);
 
-		    if (o instanceof MemoryPiece)
+		    if (o instanceof MemoryPiece) 
 			assertEquals ("Memory", ((MemoryPiece)oExpect).getMemory(), 
-				      ((MemoryPiece)o).getMemory());		  
+				      ((MemoryPiece)o).getMemory());
 
 		    else if (o instanceof RegisterPiece)  	
 			assertEquals ("Register", ((RegisterPiece)oExpect).getRegister(), 
diff --git a/frysk-core/frysk/pkglibdir/ChangeLog b/frysk-core/frysk/pkglibdir/ChangeLog
index 4b1f933..746ddea 100644
--- a/frysk-core/frysk/pkglibdir/ChangeLog
+++ b/frysk-core/frysk/pkglibdir/ChangeLog
@@ -1,3 +1,7 @@
+2008-01-14  Teresa Thomas  <tthomas@redhat.com>
+
+	* funit-location.S: Set REG3 for tests.
+
 2007-01-04  Nurdin Premji  <npremji@redhat.com>
 	* funit-complex-class.cxx: New
 	* funit-complex-struct.cxx: New
diff --git a/frysk-core/frysk/pkglibdir/funit-location.S b/frysk-core/frysk/pkglibdir/funit-location.S
index cf188c2..4083138 100644
--- a/frysk-core/frysk/pkglibdir/funit-location.S
+++ b/frysk-core/frysk/pkglibdir/funit-location.S
@@ -44,6 +44,7 @@ MAIN_PROLOGUE(0)
 
 LOAD_IMMED_WORD (REG0, 0)
 LOAD_IMMED_WORD (REG1, 987)
+LOAD_IMMED_WORD (REG3, 0x12345678)
 
 LOAD_IMMED_WORD (REG2, memory)
 


hooks/post-receive
--
frysk system monitor/debugger


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-01-14 21:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-14 21:03 [SCM] master: Fix sign extension bug with breg operation tthomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).