Exemplo n.º 1
0
        private static void _doGUIFaultSim(MyConfig simConfig, IBinInfo binInfo, IFaultModel[] faultModels, IEnumerable <TraceRange> glitchRange)
        {
            Console.WriteLine("Starting simulation... This will take several minutes.");

            // Good / Bad simulation
            _doFaultSimTrace(simConfig, binInfo, glitchRange, out var correctSignTraceData, out var wrongSignTraceData);

            Console.Out.Write($"{correctSignTraceData.AmountInstuctionsExecuted}/{correctSignTraceData.AmountUniqueInstuctionsExecuted} " +
                              $"{wrongSignTraceData.AmountInstuctionsExecuted}/{wrongSignTraceData.AmountUniqueInstuctionsExecuted}");

            var totalRuns = 0ul;

            foreach (var faultModel in faultModels)
            {
                totalRuns += faultModel.CountUniqueFaults(wrongSignTraceData);
            }

            Console.Out.WriteLine(" " + faultModels.Length + "/" + totalRuns);
            Console.Error.WriteLine(totalRuns);

            simConfig.UseAltData = true;

            var faultSim = new FaultSimulator(simConfig);

            faultSim.OnGlitchSimulationCompleted += (runs, eng, result) => {
                Console.Error.WriteLine($"{result.Fault.FaultModel.Name}::{result.Result}::{result.Fault.FaultAddress:x8}::" +
                                        $"{result.Fault.ToString()}::{(result.Result == Result.Exception?result.Exception.Message:"")}");

                return(false);
            };

            faultSim.RunSimulation(faultModels, wrongSignTraceData);

            Environment.Exit(0);
        }
Exemplo n.º 2
0
        private static void _doTUIFaultSim(MyConfig simConfig, IBinInfo binInfo, IFaultModel[] faultModels, IEnumerable <TraceRange> glitchRange)
        {
            Console.WriteLine("Starting simulation... This will take several minutes.");

            // Good / Bad simulation
            _doFaultSimTrace(simConfig, binInfo, glitchRange, out var correctSignTraceData, out var wrongSignTraceData);

            simConfig.UseAltData = true;

            var faultSim = new FaultSimulator(simConfig);

            faultSim.OnGlitchSimulationCompleted += (runs, eng, result) => {
                if (result.Result == Result.Completed)
                {
                    Console.WriteLine($"{result.Fault.FaultModel.Name} {result.Fault.ToString()} {binInfo.Symbolize(result.Fault.FaultAddress)}");
                }

                return(false);
            };

            faultSim.RunSimulation(faultModels, wrongSignTraceData);

            Environment.Exit(0);
        }