Ejemplo n.º 1
0
        public void BlockCloner_CloneCall()
        {
            var call   = new CallInstruction(new ProcedureConstant(arch.PointerType, procCalling), new CallSite(0, 0));
            var cloner = new BlockCloner(null, procCalling, callgraph);
            var block  = new Block(procCalling, "test");

            cloner.Statement = new Statement(42, call, block);
            var newCall = (CallInstruction)call.Accept(cloner);

            Assert.AreEqual(call.Callee, newCall.Callee);
            Assert.AreEqual(1, callgraph.CallerStatements(procCalling).Count(), "Should've added a call to the callgraph");
        }
Ejemplo n.º 2
0
        public void TrcoIcall()
        {
            ProcedureBuilder m     = new ProcedureBuilder();
            Identifier       pfn   = m.Local32("pfn");
            Expression       l     = m.Mem(PrimitiveType.Word32, pfn);
            CallInstruction  icall = new CallInstruction(l, new CallSite(0, 0));

            coll = CreateCollector();
            icall.Accept(eqb);
            icall.Accept(coll);
            StringWriter sw = new StringWriter();

            handler.Traits.Write(sw);
            string exp =
                "T_1 (in pfn : word32)" + nl +
                "\ttrait_primitive(word32)" + nl +
                "\ttrait_mem(T_2, 0)" + nl +
                "T_2 (in Mem0[pfn:word32] : word32)" + nl +
                "\ttrait_primitive((ptr32 code))" + nl +
                "\ttrait_primitive(word32)" + nl;

            Assert.AreEqual(exp, sw.ToString());
        }
Ejemplo n.º 3
0
        public void BlockCloner_CloneCall()
        {
            var call   = new CallInstruction(new ProcedureConstant(arch.PointerType, procCalling), new CallSite(0, 0));
            var block  = new Block(procCalling, procCalling.EntryAddress, "test");
            var stmOld = new Statement(42, call, block);

            callgraph.AddEdge(stmOld, procCalling);

            var cloner = new BlockCloner(null, procCalling, callgraph);

            cloner.Statement    = stmOld;
            cloner.StatementNew = new Statement(42, null, block);
            var newCall = (CallInstruction)call.Accept(cloner);

            cloner.StatementNew.Instruction = newCall;
            Assert.AreEqual(call.Callee, newCall.Callee);
            Assert.AreEqual(2, callgraph.CallerStatements(procCalling).Count(), "Should've added a call to the callgraph");
            Assert.AreEqual(1, callgraph.Callees(cloner.Statement).Count());
            Assert.AreEqual(1, callgraph.Callees(cloner.StatementNew).Count());
        }
Ejemplo n.º 4
0
 public void BlockCloner_CloneCall()
 {
     var call = new CallInstruction(new ProcedureConstant(arch.PointerType, procCalling), new CallSite(0, 0));
     var cloner = new BlockCloner(null, procCalling, callgraph);
     var block = new Block(procCalling, "test");
     cloner.Statement = new Statement(42, call, block);
     var newCall = (CallInstruction) call.Accept(cloner);
     Assert.AreEqual(call.Callee, newCall.Callee);
     Assert.AreEqual(1, callgraph.CallerStatements(procCalling).Count(), "Should've added a call to the callgraph");
 }
Ejemplo n.º 5
0
		public void TrcoIcall()
		{
			ProcedureBuilder m = new ProcedureBuilder();
			Identifier pfn = m.Local32("pfn");
			Expression l = m.Load(PrimitiveType.Word32, pfn);
			CallInstruction icall = new CallInstruction(l, new CallSite(0, 0));

            coll = CreateCollector();
			icall.Accept(eqb);
			icall.Accept(coll);
			StringWriter sw = new StringWriter();
			handler.Traits.Write(sw);
            string exp =
                "T_1 (in pfn : word32)" + nl +
                "\ttrait_primitive(word32)" + nl +
                "\ttrait_mem(T_2, 0)" + nl +
                "T_2 (in Mem0[pfn:word32] : word32)" + nl +
                "\ttrait_primitive((ptr code))" + nl +
                "\ttrait_primitive(word32)" + nl;
            Console.WriteLine(sw.ToString());
			Assert.AreEqual(exp, sw.ToString());
		}