public void Creation() { CallGraph g = new CallGraph(); var arch = MockRepository.GenerateStub <IProcessorArchitecture>(); arch.Replay(); Procedure p1 = new Procedure(arch, "p1000", Address.Ptr32(0x1000), null); Procedure p2 = new Procedure(arch, "p2000", Address.Ptr32(0x2000), null); Procedure p3 = new Procedure(arch, "p3000", Address.Ptr32(0x3000), null); Procedure p4 = new Procedure(arch, "p4000", Address.Ptr32(0x4000), null); var pc2 = new ProcedureConstant(PrimitiveType.Ptr32, p2); var pc3 = new ProcedureConstant(PrimitiveType.Ptr32, p3); var pc4 = new ProcedureConstant(PrimitiveType.Ptr32, p4); Statement s11 = new Statement(0, CreateCall(pc2), p1.EntryBlock); Statement s12 = new Statement(0, CreateCall(pc2), p1.EntryBlock); Statement s13 = new Statement(0, CreateCall(pc3), p1.EntryBlock); p1.EntryBlock.Statements.Add(s11); p1.EntryBlock.Statements.Add(s12); p1.EntryBlock.Statements.Add(s13); Statement s21 = new Statement(0, CreateCall(pc3), p2.EntryBlock); Statement s22 = new Statement(0, CreateCall(pc4), p2.EntryBlock); p2.EntryBlock.Statements.Add(s21); p2.EntryBlock.Statements.Add(s22); Statement s31 = new Statement(0, CreateCall(pc4), p3.EntryBlock); p3.EntryBlock.Statements.Add(s31); Statement s41 = new Statement(0, CreateCall(pc4), p4.EntryBlock); g.AddEntryPoint(p1); g.AddEdge(s11, p2); g.AddEdge(s12, p2); g.AddEdge(s13, p3); g.AddEdge(s21, p3); g.AddEdge(s22, p4); g.AddEdge(s31, p4); g.AddEdge(s41, p4); // recursion! //$TODO: need Count // Assert.IsTrue(g.Callees(p1).Count == 3); // Assert.IsTrue(g.CallerStatements(p4).Count == 3); }
public void Creation() { CallGraph g = new CallGraph(); Procedure p1 = new Procedure("p1000", null); Procedure p2 = new Procedure("p2000", null); Procedure p3 = new Procedure("p3000", null); Procedure p4 = new Procedure("p4000", null); var pc1 = new ProcedureConstant(PrimitiveType.Pointer32, p1); var pc2 = new ProcedureConstant(PrimitiveType.Pointer32, p2); var pc3 = new ProcedureConstant(PrimitiveType.Pointer32, p3); var pc4 = new ProcedureConstant(PrimitiveType.Pointer32, p4); Statement s11 = new Statement(0, CreateCall(pc2), p1.EntryBlock); Statement s12 = new Statement(0, CreateCall(pc2), p1.EntryBlock); Statement s13 = new Statement(0, CreateCall(pc3), p1.EntryBlock); p1.EntryBlock.Statements.Add(s11); p1.EntryBlock.Statements.Add(s12); p1.EntryBlock.Statements.Add(s13); Statement s21 = new Statement(0, CreateCall(pc3), p2.EntryBlock); Statement s22 = new Statement(0, CreateCall(pc4), p2.EntryBlock); p2.EntryBlock.Statements.Add(s21); p2.EntryBlock.Statements.Add(s22); Statement s31 = new Statement(0, CreateCall(pc4), p3.EntryBlock); p3.EntryBlock.Statements.Add(s31); Statement s41 = new Statement(0, CreateCall(pc4), p4.EntryBlock); g.AddEntryPoint(p1); g.AddEdge(s11, p2); g.AddEdge(s12, p2); g.AddEdge(s13, p3); g.AddEdge(s21, p3); g.AddEdge(s22, p4); g.AddEdge(s31, p4); g.AddEdge(s41, p4); // recursion! //$TODO: need Count // Assert.IsTrue(g.Callees(p1).Count == 3); // Assert.IsTrue(g.CallerStatements(p4).Count == 3); }
public void Creation() { CallGraph g = new CallGraph(); Procedure p1 = new Procedure("p1000", null); Procedure p2 = new Procedure("p2000", null); Procedure p3 = new Procedure("p3000", null); Procedure p4 = new Procedure("p4000", null); var pc1 = new ProcedureConstant(PrimitiveType.Pointer32, p1); var pc2 = new ProcedureConstant(PrimitiveType.Pointer32, p2); var pc3 = new ProcedureConstant(PrimitiveType.Pointer32, p3); var pc4 = new ProcedureConstant(PrimitiveType.Pointer32, p4); Statement s11 = new Statement(0, CreateCall(pc2), p1.EntryBlock); Statement s12 = new Statement(0, CreateCall(pc2), p1.EntryBlock); Statement s13 = new Statement(0, CreateCall(pc3), p1.EntryBlock); p1.EntryBlock.Statements.Add(s11); p1.EntryBlock.Statements.Add(s12); p1.EntryBlock.Statements.Add(s13); Statement s21 = new Statement(0, CreateCall(pc3), p2.EntryBlock); Statement s22 = new Statement(0, CreateCall(pc4), p2.EntryBlock); p2.EntryBlock.Statements.Add(s21); p2.EntryBlock.Statements.Add(s22); Statement s31 = new Statement(0, CreateCall(pc4), p3.EntryBlock); p3.EntryBlock.Statements.Add(s31); Statement s41 = new Statement(0, CreateCall(pc4), p4.EntryBlock); g.AddEntryPoint(p1); g.AddEdge(s11, p2); g.AddEdge(s12, p2); g.AddEdge(s13, p3); g.AddEdge(s21, p3); g.AddEdge(s22, p4); g.AddEdge(s31, p4); g.AddEdge(s41, p4); // recursion! //$TODO: need Count // Assert.IsTrue(g.Callees(p1).Count == 3); // Assert.IsTrue(g.CallerStatements(p4).Count == 3); }