From: <mic...@us...> - 2007-05-17 19:20:16
|
Revision: 121 http://svn.sourceforge.net/pearcolator/?rev=121&view=rev Author: michael_baer Date: 2007-05-17 12:20:02 -0700 (Thu, 17 May 2007) Log Message: ----------- - Fixed in the generation of ARM_Laziness instances - Added a command line option to debug the resolution of branches Modified Paths: -------------- src/org/binarytranslator/DBT_Options.java src/org/binarytranslator/arch/arm/decoder/ARM2IR.java src/org/binarytranslator/arch/arm/decoder/ARM_Laziness.java src/org/binarytranslator/generic/decoder/AbstractCodeTranslator.java Modified: src/org/binarytranslator/DBT_Options.java =================================================================== --- src/org/binarytranslator/DBT_Options.java 2007-05-17 16:31:37 UTC (rev 120) +++ src/org/binarytranslator/DBT_Options.java 2007-05-17 19:20:02 UTC (rev 121) @@ -105,9 +105,9 @@ public static boolean debugInstr = true; /** - * In PPC2IR, print information about lazy resolution... + * Print information about the lazy resolution of branch addresses... */ - public final static boolean debugLazy = false; + public static boolean debugBranchResolution = true; /** * In PPC2IR, print cfg. @@ -213,6 +213,8 @@ debugInstr = Boolean.parseBoolean(value); } else if (arg.equalsIgnoreCase("-X:dbt:debugRuntime")) { debugRuntime = Boolean.parseBoolean(value); + } else if (arg.equalsIgnoreCase("-X:dbt:debugBranchResolution")) { + debugBranchResolution = Boolean.parseBoolean(value); } else if (arg.equalsIgnoreCase("-X:dbt:debugSyscall")) { debugSyscall = Boolean.parseBoolean(value); } else if (arg.equalsIgnoreCase("-X:dbt:debugSyscallMore")) { Modified: src/org/binarytranslator/arch/arm/decoder/ARM2IR.java =================================================================== --- src/org/binarytranslator/arch/arm/decoder/ARM2IR.java 2007-05-17 16:31:37 UTC (rev 120) +++ src/org/binarytranslator/arch/arm/decoder/ARM2IR.java 2007-05-17 19:20:02 UTC (rev 121) @@ -376,20 +376,6 @@ } /** - * Prints the given BasicBlock and the <code>count</code> blocks following it in code order. - * @param block - * @param count - */ - public void printNextBlocks(OPT_BasicBlock block, int count) { - do - { - block.printExtended(); - block = block.nextBasicBlockInCodeOrder(); - } - while (block != null && count-- > 0); - } - - /** * Adds code to the current block that will rotate <code>rotatedOperand</code> by * <code>rotation</code> and stores the rotated integer into <code>result</code>. * @param result Modified: src/org/binarytranslator/arch/arm/decoder/ARM_Laziness.java =================================================================== --- src/org/binarytranslator/arch/arm/decoder/ARM_Laziness.java 2007-05-17 16:31:37 UTC (rev 120) +++ src/org/binarytranslator/arch/arm/decoder/ARM_Laziness.java 2007-05-17 19:20:02 UTC (rev 121) @@ -4,22 +4,39 @@ public class ARM_Laziness extends Laziness { + final class ARM_LazinessKey extends Key { + private final int pc; + + public int hashCode() { + return pc; + } + + public boolean equals(Object o) { + return ((o instanceof ARM_LazinessKey) && ((ARM_LazinessKey) o).pc == pc); + } + + ARM_LazinessKey(int pc) { + this.pc = pc; + } + + public String toString() { + return "0x" + Integer.toHexString(pc); + } + } + @Override public Object clone() { - // TODO Auto-generated method stub - return null; + return new ARM_Laziness(); } @Override public boolean equivalent(Laziness other) { - // TODO Auto-generated method stub - return false; + return other instanceof ARM_Laziness; } @Override public Key makeKey(int pc) { - // TODO Auto-generated method stub - return null; + return new ARM_LazinessKey(pc); } } Modified: src/org/binarytranslator/generic/decoder/AbstractCodeTranslator.java =================================================================== --- src/org/binarytranslator/generic/decoder/AbstractCodeTranslator.java 2007-05-17 16:31:37 UTC (rev 120) +++ src/org/binarytranslator/generic/decoder/AbstractCodeTranslator.java 2007-05-17 19:20:02 UTC (rev 121) @@ -238,7 +238,7 @@ do { resolveGoto(); resolveIfCmp(); - } while (((unresolvedGoto.size() == 0) && (unresolvedIfCmp.size() == 0)) == false); + } while ((unresolvedGoto.size() != 0) || (unresolvedIfCmp.size() != 0)); } else { resolveGoto(); resolveIfCmp(); @@ -304,6 +304,7 @@ setReturnValueResolveLazinessAndBranchToFinish(lazy, new OPT_IntConstantOperand(pc)); } + break; } @@ -594,6 +595,10 @@ OPT_BasicBlock target = findMapping(targetPC, targetLaziness); if (target != null) { + + if (DBT_Options.debugBranchResolution) + System.out.println(String.format("Found precompiled mapping for pc 0x%x: %s", targetPC, target)); + jump = Goto.create(GOTO, target.makeJumpTarget()); getCurrentBlock().insertOut(target); } @@ -622,18 +627,17 @@ OPT_BasicBlock targetBB = resolveJumpTarget(targetPc, lazyStateAtJump); - if (DBT_Options.debugLazy) { + if (DBT_Options.debugBranchResolution) { report("Resolving goto " + lazyStateAtJump.makeKey(targetPc) + " " + targetBB); } // Fix up instruction Goto.setTarget(gotoInstr, targetBB.makeJumpTarget()); - gotoInstr.getBasicBlock().deleteNormalOut(); gotoInstr.getBasicBlock().insertOut(targetBB); if (DBT.VerifyAssertions) DBT._assert(gotoInstr.getBasicBlock().getNumberOfNormalOut() == 1); - if (DBT_Options.debugLazy) { + if (DBT_Options.debugBranchResolution) { report("Properly resolving goto in block " + gotoInstr.getBasicBlock() + " to " + lazyStateAtJump.makeKey(targetPc) + " " + targetBB); @@ -661,6 +665,7 @@ //In Single instruction mode, the target block just ends the trace if (currentBlock.getNumberOfRealInstructions() != 0) { currentBlock = createBlockAfterCurrentNotInCFG(); + System.out.println("Resolving branch to next block."); } targetBB = currentBlock; @@ -1332,6 +1337,22 @@ return gc.temps.makeTemp(type); } + /** + * Prints the given BasicBlock and the <code>count</code> blocks following it in code order. + * @param block + * The basic block that shall be printed. + * @param count + * The number of blocks following <code>block</code> that shall be printed. + */ + public void printNextBlocks(OPT_BasicBlock block, int count) { + do + { + block.printExtended(); + block = block.nextBasicBlockInCodeOrder(); + } + while (block != null && count-- > 0); + } + /** Report some debug output */ protected abstract void report(String str); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |