protected override void RunTest(Program program, string outputFile) { var eventListener = new FakeDecompilerEventListener(); using (FileUnitTester fut = new FileUnitTester(outputFile)) { fut.TextWriter.WriteLine("// Before ///////"); DumpProgram(program, fut.TextWriter); SetupPreStages(program); aen.Transform(program); eqb.Build(program); var coll = new TypeCollector(program.TypeFactory, program.TypeStore, program, eventListener); coll.CollectTypes(); program.TypeStore.BuildEquivalenceClassDataTypes(program.TypeFactory); tvr.ReplaceTypeVariables(); trans.Transform(); ctn.RenameAllTypes(program.TypeStore); ter = new TypedExpressionRewriter(program, eventListener); try { ter.RewriteProgram(program); } catch (Exception ex) { fut.TextWriter.WriteLine("** Exception **"); fut.TextWriter.WriteLine(ex); } finally { fut.TextWriter.WriteLine("// After ///////"); DumpProgAndStore(program, fut); } } }
protected void RunStringTest(Program program, string expectedOutput) { var sw = new StringWriter(); var factory = program.TypeFactory; var store = program.TypeStore; var aen = new ExpressionNormalizer(program.Platform.PointerType); var eqb = new EquivalenceClassBuilder(factory, store, eventListener); var tyco = new TypeCollector(factory, store, program, eventListener); aen.Transform(program); eqb.Build(program); tyco.CollectTypes(); aen.Transform(program); eqb.Build(program); var coll = new TypeCollector(program.TypeFactory, program.TypeStore, program, eventListener); coll.CollectTypes(); program.TypeStore.Dump(); program.TypeStore.BuildEquivalenceClassDataTypes(program.TypeFactory); DumpProgAndStore(program, sw); Assert.AreEqual(expectedOutput, sw.ToString()); }
public void TrcoCmpMock() { ProgramBuilder mock = new ProgramBuilder(); mock.Add(new CmpMock()); Program program = mock.BuildProgram(); coll = CreateCollector(program); eqb.Build(program); coll.CollectProgramTraits(program); Verify(program, "Typing/TrcoCmpMock.txt"); }
protected override void RunTest(Program program, string outputFile) { FileUnitTester fut = null; try { fut = new FileUnitTester(outputFile); var factory = program.TypeFactory; var store = program.TypeStore; var aen = new ExpressionNormalizer(program.Platform.PointerType); var eqb = new EquivalenceClassBuilder(factory, store, eventListener); var tyco = new TypeCollector(factory, store, program, eventListener); aen.Transform(program); eqb.Build(program); tyco.CollectTypes(); if (buildEquivalenceClasses) { store.BuildEquivalenceClassDataTypes(factory); new TypeVariableReplacer(store).ReplaceTypeVariables(); } } catch (Exception ex) { fut.TextWriter.WriteLine(ex.Message); fut.TextWriter.WriteLine(ex.StackTrace); throw; } finally { DumpProgAndStore(program, fut.TextWriter); fut.AssertFilesEqual(); fut.Dispose(); } }
protected override void RunTest(Program prog, string outputFilename) { TypeFactory factory = new TypeFactory(); store = new TypeStore(); EquivalenceClassBuilder eqb = new EquivalenceClassBuilder(factory, store); eqb.Build(prog); DataTypeBuilder dtb = new DataTypeBuilder(factory, store, prog.Platform); TraitCollector trco = new TraitCollector(factory, store, dtb, prog); trco.CollectProgramTraits(prog); dtb.BuildEquivalenceClassDataTypes(); store.CopyClassDataTypesToTypeVariables(); TypeVariableReplacer tvr = new TypeVariableReplacer(store); tvr.ReplaceTypeVariables(); PtrPrimitiveReplacer ppr = new PtrPrimitiveReplacer(factory, store, prog); ppr.ReplaceAll(); Verify(prog, outputFilename); }
private void RunTest(Program program, string outputFile) { var listener = new FakeDecompilerEventListener(); EquivalenceClassBuilder eqb = new EquivalenceClassBuilder(factory, store, listener); DataTypeBuilder dtb = new DataTypeBuilder(factory, store, program.Platform); eqb.Build(program); TraitCollector trco = new TraitCollector(factory, store, dtb, program); trco.CollectProgramTraits(program); dtb.BuildEquivalenceClassDataTypes(); var tv = new TypeVariableReplacer(store); tv.ReplaceTypeVariables(); store.CopyClassDataTypesToTypeVariables(); var ppr = new PtrPrimitiveReplacer(factory, store, program); ppr.ReplaceAll(listener); var cpa = new ConstantPointerAnalysis(factory, store, program); cpa.FollowConstantPointers(); Verify(null, outputFile); }
protected override void RunTest(Program program, string outputFileName) { ExpressionNormalizer aen = new ExpressionNormalizer(program.Architecture.PointerType); aen.Transform(program); EquivalenceClassBuilder eq = new EquivalenceClassBuilder(factory, store); eq.Build(program); #if OLD DataTypeBuilder dtb = new DataTypeBuilder(factory, store, program.Architecture); TraitCollector coll = new TraitCollector(factory, store, dtb, program); coll.CollectProgramTraits(program); dtb.BuildEquivalenceClassDataTypes(); #else TypeCollector coll = new TypeCollector(factory, store, program); coll.CollectTypes(); store.BuildEquivalenceClassDataTypes(factory); #endif TypeVariableReplacer tvr = new TypeVariableReplacer(store); tvr.ReplaceTypeVariables(); TypeTransformer trans = new TypeTransformer(factory, store, program); trans.Transform(); using (FileUnitTester fut = new FileUnitTester(outputFileName)) { foreach (Procedure proc in program.Procedures.Values) { proc.Write(false, fut.TextWriter); fut.TextWriter.WriteLine(); } store.Write(fut.TextWriter); fut.AssertFilesEqual(); } }
protected override void RunTest(Program prog, string outputFile) { aen.Transform(prog); eqb.Build(prog); TypeCollector trco = new TypeCollector(factory, store, prog); trco.CollectTypes(); dtb.BuildEquivalenceClassDataTypes(); Verify(prog, outputFile); }
protected override void RunTest(Program program, string outputFile) { aen.Transform(program); eqb.Build(program); TypeCollector trco = new TypeCollector(factory, store, program, new FakeDecompilerEventListener()); trco.CollectTypes(); dtb.BuildEquivalenceClassDataTypes(); Verify(program, outputFile); }
protected override void RunTest(Program prog, string outputFilename) { eqb.Build(prog); trco = new TraitCollector(factory, store, dtb, prog); trco.CollectProgramTraits(prog); dtb.BuildEquivalenceClassDataTypes(); store.CopyClassDataTypesToTypeVariables(); TypeVariableReplacer tvr = new TypeVariableReplacer(store); tvr.ReplaceTypeVariables(); Verify(outputFilename); }
protected override void RunTest(Program program, string outputFileName) { var listener = new FakeDecompilerEventListener(); ExpressionNormalizer aen = new ExpressionNormalizer(program.Architecture.PointerType); aen.Transform(program); EquivalenceClassBuilder eq = new EquivalenceClassBuilder(factory, store, listener); eq.Build(program); #if OLD DataTypeBuilder dtb = new DataTypeBuilder(factory, store, program.Architecture); TraitCollector coll = new TraitCollector(factory, store, dtb, program); coll.CollectProgramTraits(program); sktore.BuildEquivalenceClassDataTypes(factory); #else TypeCollector coll = new TypeCollector(factory, store, program, listener); coll.CollectTypes(); store.BuildEquivalenceClassDataTypes(factory); #endif TypeVariableReplacer tvr = new TypeVariableReplacer(store); tvr.ReplaceTypeVariables(); Exception theEx = null; try { TypeTransformer trans = new TypeTransformer(factory, store, program); trans.Transform(); } catch (Exception ex) { theEx = ex; } using (FileUnitTester fut = new FileUnitTester(outputFileName)) { if (theEx != null) { fut.TextWriter.WriteLine(theEx.Message); fut.TextWriter.WriteLine(theEx.StackTrace); } foreach (Procedure proc in program.Procedures.Values) { proc.Write(false, fut.TextWriter); fut.TextWriter.WriteLine(); } store.Write(fut.TextWriter); fut.AssertFilesEqual(); } }
private void RunTestCore(Program program) { var listener = new FakeDecompilerEventListener(); var aen = new ExpressionNormalizer(program.Architecture.PointerType); aen.Transform(program); var eq = new EquivalenceClassBuilder(factory, store, listener); eq.Build(program); var coll = new TypeCollector(factory, store, program, listener); coll.CollectTypes(); store.BuildEquivalenceClassDataTypes(factory); var tvr = new TypeVariableReplacer(store); tvr.ReplaceTypeVariables(); var trans = new TypeTransformer(factory, store, program); trans.Transform(); }
private void RunTest(Program prog, string outputFile) { EquivalenceClassBuilder eqb = new EquivalenceClassBuilder(factory, store); DataTypeBuilder dtb = new DataTypeBuilder(factory, store, prog.Platform); eqb.Build(prog); TraitCollector trco = new TraitCollector(factory, store, dtb, prog); trco.CollectProgramTraits(prog); dtb.BuildEquivalenceClassDataTypes(); var tv = new TypeVariableReplacer(store); tv.ReplaceTypeVariables(); store.CopyClassDataTypesToTypeVariables(); var ppr = new PtrPrimitiveReplacer(factory, store, prog); ppr.ReplaceAll(); var dpa = new DerivedPointerAnalysis(factory, store, prog); dpa.FollowDerivedPointers(); Verify(null, outputFile); }