Package proguard.evaluation.util
Class DebugPrinter
- java.lang.Object
-
- proguard.evaluation.util.DebugPrinter
-
- All Implemented Interfaces:
PartialEvaluatorStateTracker
public class DebugPrinter extends java.lang.Object implements PartialEvaluatorStateTracker
-
-
Constructor Summary
Constructors Constructor Description DebugPrinter(boolean printDebugInfo, boolean printDebugResults)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterInstructionEvaluation(Clazz clazz, Method method, int instructionOffset, Instruction instruction, TracedVariables variablesAfter, TracedStack stackAfter, BasicBranchUnit branchUnit, InstructionOffsetValue branchTarget)The instruction is evaluated and branching information is obtained.voiddefinitiveBranch(Clazz clazz, Method method, int instructionOffset, Instruction instruction, TracedVariables variablesAfter, TracedStack stackAfter, InstructionOffsetValue branchTargets)The instruction causes a definitive branch.voidendSubroutine(Clazz clazz, Method method, TracedVariables variablesAfter, TracedStack stackAfter, int subroutineStart, int subroutineEnd)The evaluation and generalization of the subroutine is done, the partial evaluator moves on.voidevaluationResults(Clazz clazz, Method method, CodeAttribute codeAttribute, PartialEvaluator evaluator)Partial evaluator is done evaluating the code attribute.voidgeneralizeInstructionBlock(Clazz clazz, Method method, int instructionOffset, Instruction instruction, TracedVariables variablesBefore, TracedStack stackBefore, int evaluationCount)The instruction has been seen a certain number of times and the evaluator deems it time to start generalizing the instruction.voidgeneralizeSubroutine(Clazz clazz, Method method, TracedVariables startVariables, TracedStack startStack, int subroutineStart, int subroutineEnd)The partial evaluator will start generalizing the results of the evaluated subroutine.voidinstructionBlockDone(Clazz clazz, Method method, CodeAttribute codeAttribute, TracedVariables startVariables, TracedStack startStack, int startOffset)An instruction block has been evaluated.voidregisterAlternativeBranch(Clazz clazz, Method method, int fromInstructionOffset, Instruction fromInstruction, TracedVariables variablesAfter, TracedStack stackAfter, int branchIndex, int branchTargetCount, int offset)The evaluator detects multiple branches need to be evaluated.voidregisterException(Clazz clazz, Method method, CodeAttribute codeAttribute, PartialEvaluator evaluator, java.lang.Throwable cause)An exception has been thrown while evaluating the current code attribute.voidregisterExceptionHandler(Clazz clazz, Method method, int startPC, int endPC, ExceptionInfo info)Partial evaluator starts evaluating a specific exception handler.voidregisterSubroutineReturn(Clazz clazz, Method method, int returnOffset, TracedVariables returnVariables, TracedStack returnStack)The current instruction was RET and the partial evaluator pushes the return address to the branch stack of the calling partial evaluator.voidregisterUnusedExceptionHandler(Clazz clazz, Method method, int startPC, int endPC, ExceptionInfo info)Partial evaluator detects that the evaluation of the exception handler over a certain range is not needed.voidskipInstructionBlock(Clazz clazz, Method method, int instructionOffset, Instruction instruction, TracedVariables variablesBefore, TracedStack stackBefore, int evaluationCount)The instruction within this instruction block has been seen with the those variables and this stack, and thus it is not needed to evaluate this block any further.voidstartBranchCodeBlockEvaluation(java.util.List<PartialEvaluator.InstructionBlock> branchStack)Evaluation of the first general block has been done.voidstartCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, Variables parameters)The partial evaluator starts with the evaluation of a code block.voidstartExceptionHandlingForBlock(Clazz clazz, Method method, int startOffset, int endOffset)Partial evaluator starts evaluating the exceptions handlers that catch over a certain instruction range.voidstartInstructionBlock(Clazz clazz, Method method, CodeAttribute codeAttribute, TracedVariables startVariables, TracedStack startStack, int startOffset)Partial evaluator starts evaluating an instruction block, specified by an instruction range within the code attribute and the variables and stack it would start with.voidstartInstructionEvaluation(Clazz clazz, Method method, int instructionOffset, Instruction instruction, TracedVariables variablesBefore, TracedStack stackBefore, int evaluationCount)The partial evaluator will forward the evaluation of the instruction.voidstartSubroutine(Clazz clazz, Method method, TracedVariables startVariables, TracedStack startStack, int subroutineStart, int subroutineEnd)The current instruction was JSR or JSR_W and the partial evaluator starts with the evaluation of the subroutine.
-
-
-
Method Detail
-
startCodeAttribute
public void startCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, Variables parameters)
Description copied from interface:PartialEvaluatorStateTrackerThe partial evaluator starts with the evaluation of a code block.- Specified by:
startCodeAttributein interfacePartialEvaluatorStateTracker
-
registerException
public void registerException(Clazz clazz, Method method, CodeAttribute codeAttribute, PartialEvaluator evaluator, java.lang.Throwable cause)
Description copied from interface:PartialEvaluatorStateTrackerAn exception has been thrown while evaluating the current code attribute.- Specified by:
registerExceptionin interfacePartialEvaluatorStateTracker
-
startExceptionHandlingForBlock
public void startExceptionHandlingForBlock(Clazz clazz, Method method, int startOffset, int endOffset)
Description copied from interface:PartialEvaluatorStateTrackerPartial evaluator starts evaluating the exceptions handlers that catch over a certain instruction range.- Specified by:
startExceptionHandlingForBlockin interfacePartialEvaluatorStateTracker
-
registerExceptionHandler
public void registerExceptionHandler(Clazz clazz, Method method, int startPC, int endPC, ExceptionInfo info)
Description copied from interface:PartialEvaluatorStateTrackerPartial evaluator starts evaluating a specific exception handler.- Specified by:
registerExceptionHandlerin interfacePartialEvaluatorStateTracker
-
registerUnusedExceptionHandler
public void registerUnusedExceptionHandler(Clazz clazz, Method method, int startPC, int endPC, ExceptionInfo info)
Description copied from interface:PartialEvaluatorStateTrackerPartial evaluator detects that the evaluation of the exception handler over a certain range is not needed. For example when the exceptionType can not be thrown from with the instruction range.- Specified by:
registerUnusedExceptionHandlerin interfacePartialEvaluatorStateTracker
-
evaluationResults
public void evaluationResults(Clazz clazz, Method method, CodeAttribute codeAttribute, PartialEvaluator evaluator)
Description copied from interface:PartialEvaluatorStateTrackerPartial evaluator is done evaluating the code attribute. You can extract the results straight from the evaluator.- Specified by:
evaluationResultsin interfacePartialEvaluatorStateTracker
-
startInstructionBlock
public void startInstructionBlock(Clazz clazz, Method method, CodeAttribute codeAttribute, TracedVariables startVariables, TracedStack startStack, int startOffset)
Description copied from interface:PartialEvaluatorStateTrackerPartial evaluator starts evaluating an instruction block, specified by an instruction range within the code attribute and the variables and stack it would start with.- Specified by:
startInstructionBlockin interfacePartialEvaluatorStateTracker
-
startBranchCodeBlockEvaluation
public void startBranchCodeBlockEvaluation(java.util.List<PartialEvaluator.InstructionBlock> branchStack)
Description copied from interface:PartialEvaluatorStateTrackerEvaluation of the first general block has been done. The evaluator now starts evaluating the blocks generated by branch instructions and will do this in a stack like behaviour.- Specified by:
startBranchCodeBlockEvaluationin interfacePartialEvaluatorStateTracker
-
instructionBlockDone
public void instructionBlockDone(Clazz clazz, Method method, CodeAttribute codeAttribute, TracedVariables startVariables, TracedStack startStack, int startOffset)
Description copied from interface:PartialEvaluatorStateTrackerAn instruction block has been evaluated.- Specified by:
instructionBlockDonein interfacePartialEvaluatorStateTracker
-
skipInstructionBlock
public void skipInstructionBlock(Clazz clazz, Method method, int instructionOffset, Instruction instruction, TracedVariables variablesBefore, TracedStack stackBefore, int evaluationCount)
Description copied from interface:PartialEvaluatorStateTrackerThe instruction within this instruction block has been seen with the those variables and this stack, and thus it is not needed to evaluate this block any further.- Specified by:
skipInstructionBlockin interfacePartialEvaluatorStateTracker
-
generalizeInstructionBlock
public void generalizeInstructionBlock(Clazz clazz, Method method, int instructionOffset, Instruction instruction, TracedVariables variablesBefore, TracedStack stackBefore, int evaluationCount)
Description copied from interface:PartialEvaluatorStateTrackerThe instruction has been seen a certain number of times and the evaluator deems it time to start generalizing the instruction.- Specified by:
generalizeInstructionBlockin interfacePartialEvaluatorStateTracker
-
startInstructionEvaluation
public void startInstructionEvaluation(Clazz clazz, Method method, int instructionOffset, Instruction instruction, TracedVariables variablesBefore, TracedStack stackBefore, int evaluationCount)
Description copied from interface:PartialEvaluatorStateTrackerThe partial evaluator will forward the evaluation of the instruction. An exception right after this state is likely.- Specified by:
startInstructionEvaluationin interfacePartialEvaluatorStateTracker
-
afterInstructionEvaluation
public void afterInstructionEvaluation(Clazz clazz, Method method, int instructionOffset, Instruction instruction, TracedVariables variablesAfter, TracedStack stackAfter, BasicBranchUnit branchUnit, InstructionOffsetValue branchTarget)
Description copied from interface:PartialEvaluatorStateTrackerThe instruction is evaluated and branching information is obtained.- Specified by:
afterInstructionEvaluationin interfacePartialEvaluatorStateTracker
-
definitiveBranch
public void definitiveBranch(Clazz clazz, Method method, int instructionOffset, Instruction instruction, TracedVariables variablesAfter, TracedStack stackAfter, InstructionOffsetValue branchTargets)
Description copied from interface:PartialEvaluatorStateTrackerThe instruction causes a definitive branch. This means the partial evaluator discovered a jump is used and is sure what the next instruction will be. This next instruction will be evaluated next and within the same instructionBlock evaluation.- Specified by:
definitiveBranchin interfacePartialEvaluatorStateTracker
-
registerAlternativeBranch
public void registerAlternativeBranch(Clazz clazz, Method method, int fromInstructionOffset, Instruction fromInstruction, TracedVariables variablesAfter, TracedStack stackAfter, int branchIndex, int branchTargetCount, int offset)
Description copied from interface:PartialEvaluatorStateTrackerThe evaluator detects multiple branches need to be evaluated. It adds these block evaluations to a stack of blocks that still need to be evaluated. After all branches have been registered, the evaluator exits the evaluation of the current instruction block.- Specified by:
registerAlternativeBranchin interfacePartialEvaluatorStateTracker
-
startSubroutine
public void startSubroutine(Clazz clazz, Method method, TracedVariables startVariables, TracedStack startStack, int subroutineStart, int subroutineEnd)
Description copied from interface:PartialEvaluatorStateTrackerThe current instruction was JSR or JSR_W and the partial evaluator starts with the evaluation of the subroutine.- Specified by:
startSubroutinein interfacePartialEvaluatorStateTracker
-
registerSubroutineReturn
public void registerSubroutineReturn(Clazz clazz, Method method, int returnOffset, TracedVariables returnVariables, TracedStack returnStack)
Description copied from interface:PartialEvaluatorStateTrackerThe current instruction was RET and the partial evaluator pushes the return address to the branch stack of the calling partial evaluator.- Specified by:
registerSubroutineReturnin interfacePartialEvaluatorStateTracker
-
generalizeSubroutine
public void generalizeSubroutine(Clazz clazz, Method method, TracedVariables startVariables, TracedStack startStack, int subroutineStart, int subroutineEnd)
Description copied from interface:PartialEvaluatorStateTrackerThe partial evaluator will start generalizing the results of the evaluated subroutine.- Specified by:
generalizeSubroutinein interfacePartialEvaluatorStateTracker
-
endSubroutine
public void endSubroutine(Clazz clazz, Method method, TracedVariables variablesAfter, TracedStack stackAfter, int subroutineStart, int subroutineEnd)
Description copied from interface:PartialEvaluatorStateTrackerThe evaluation and generalization of the subroutine is done, the partial evaluator moves on.- Specified by:
endSubroutinein interfacePartialEvaluatorStateTracker
-
-