/// <summary> /// Visits the specified not criterion. /// </summary> /// <param name="notCriterion">The not criterion.</param> /// <returns>FramePredicateExpression.</returns> public object Visit(NotCriterion notCriterion) { var exp = (FramePredicateExpression)notCriterion.Criterion.Accept(this); var candidateExpr = exp.Parameters[0]; var body = Expression.Not(exp.Body); return(Expression.Lambda <Func <FrameEntity, bool> >(body, candidateExpr)); }
public void Find_Matching_Frames_Complex() { var frameAccess = new FrameAccess(); var builder = new ContextFactoryBuilder(); builder.WithFrame(new FrameEntity { PosHi = 0, PosLo = 0, ThreadId = 1, Rax = ((ulong)1).ToHexString() }).WithFrame(new FrameEntity { PosHi = 0, PosLo = 0, ThreadId = 2, Rax = ((ulong)2).ToHexString() }).WithFrame(new FrameEntity { PosHi = 1, PosLo = 0, ThreadId = 2, Rax = ((ulong)2).ToHexString() }).WithFrame(new FrameEntity { PosHi = 1, PosLo = 1, ThreadId = 2, Rax = ((ulong)1).ToHexString(), Rbx = ((ulong)2).ToHexString() }); frameAccess.ContextFactory = builder.Build(); var rax = new RegisterEqualsCriterion(Register.Rax, ((ulong)1).ToHexString()); var rbx = new RegisterEqualsCriterion(Register.Rbx, ((ulong)2).ToHexString()); var and = new AndCriterion(new[] { rax, rbx }); var or = new OrCriterion(new[] { rax, rbx }); var not = new NotCriterion(rax); var all = new OrCriterion(new ICriterion[] { not, rax }); var none = new AndCriterion(new ICriterion[] { not, rax }); var andAll = new AndCriterion(new ICriterion[] { and, all }); var andResults = frameAccess.Search("", and); var orResults = frameAccess.Search("", or); var notResults = frameAccess.Search("", not); var allResults = frameAccess.Search("", all); var noneResults = frameAccess.Search("", none); var andAllResults = frameAccess.Search("", andAll); andResults.Single().RegisterSet.Rax.Should().Be(1); andResults.Single().RegisterSet.Rbx.Should().Be(2); orResults.Should().HaveCount(2); notResults.Should().HaveCount(2); allResults.Should().HaveCount(4); noneResults.Should().HaveCount(0); andAllResults.Should().HaveCount(1); }
public void Find_Matching_Frames_By_Register_values() { var frameAccess = new FrameAccess(); var builder = new ContextFactoryBuilder(); builder.WithFrame(new FrameEntity { PosHi = 0, PosLo = 0, ThreadId = 1, Rax = ((ulong)0).ToHexString(), Rbx = ((ulong)1).ToHexString(), Rcx = ((ulong)2).ToHexString(), Rdx = ((ulong)3).ToHexString() }).WithFrame(new FrameEntity { PosHi = 0, PosLo = 0, ThreadId = 2, Rax = ((ulong)0).ToHexString(), Rbx = ((ulong)2).ToHexString(), Rcx = ((ulong)4).ToHexString(), Rdx = ((ulong)6).ToHexString() }).WithFrame(new FrameEntity { PosHi = 1, PosLo = 0, ThreadId = 2 }).WithFrame(new FrameEntity { PosHi = 1, PosLo = 1, ThreadId = 2, Rax = ((ulong)0).ToHexString(), Rbx = ((ulong)1).ToHexString(), Rcx = ((ulong)2).ToHexString(), Rdx = ((ulong)3).ToHexString() }); frameAccess.ContextFactory = builder.Build(); var between = new RegisterBetweenCriterion(Register.Rax, ((ulong)0).ToHexString(), ((ulong)2).ToHexString()); var notBetween = new NotCriterion(between); var betweenResults = frameAccess.Search("", between); var notBetweenResults = frameAccess.Search("", notBetween); betweenResults.Should().HaveCount(3); notBetweenResults.Should().HaveCount(1); }