Exemplo n.º 1
0
        public override bool Analyze(IEnumerable <ResolvedMethod <Node> > starts)
        {
            var initialState     = new UnknownEntity();
            var emptyInvocation  = new OperationEdge <Node>(0, new NopStatement(), 0);
            var initialStackData = new MyStackData(emptyInvocation, initialState, false);

            var pdvm = (MyPdvm)InternalSimulation.Pdvm;

            pdvm.SetForcedExecutor(InternalSimulation.ForceExecute);

            var contexts = starts.Select(
                start => InternalSimulation.Load(start.Start, initialState, initialStackData)).ToList();

            InternalSimulation.Run();

            return(true);
        }
Exemplo n.º 2
0
        public override IEnumerable <IEnumerable <Statement> > Analyze(IEnumerable <ResolvedMethod <Node> > starts)
        {
            var initialContexts = new List <PdaExtractingContext <GssNode <TStackSymbol, EmptyGssData>, OperationEdge <Node> > >();
            var finalContexts   = new List <PdaExtractingContext <GssNode <TStackSymbol, EmptyGssData>, OperationEdge <Node> > >();

            foreach (var start in starts)
            {
                var context = InternalSimulation.Load(start.EntryPoint, InitialState, InitialStackSymbol);
                initialContexts.Add(context);
            }

            var pdvm = (ILProcessingPDVM <TState, TStackSymbol>)InternalSimulation.Pdvm;

            pdvm.OnFinishEvent += context => finalContexts.Add(context);

            InternalSimulation.Run();

            var finalContextSet = finalContexts.ToHashSet();
            var results         = new List <IEnumerable <Statement> >();

            foreach (var initialContext in initialContexts)
            {
                PdaContextDecoder.ExtractWords(
                    initialContext,
                    context => finalContextSet.Contains(context),
                    0,
                    word =>
                {
                    results.Add(word.Select(symbol => symbol?.Statement));
                    return(true);
                },
                    _ => { });
            }

            return(results.Select(FormatTrace));
        }
Exemplo n.º 3
0
 public void FinishAnalysis()
 {
     InternalSimulation.ExecuteAllQueuedActions();
 }