Beispiel #1
0
        static void processSimple(string filename)
        {
            var folder = BuildFolder(filename);

            var lines =
                SimpleLine
                .FromFile(filename)
                .OrderBy(x => x.Address);

            var groups = LineGroup.MakeGroups(lines);

            var missing = SourceProcessing.GetMissingOutput(groups, (x) => x.ToString());

            File.WriteAllLines(Path.Combine(folder, "with-missing.txt"), missing);

            var bytecodes = SourceProcessing.GetBadBytecodeConversions(lines);

            File.WriteAllLines(Path.Combine(folder, "bad-bytecode-conversions.txt"), bytecodes);

            var allraw = SourceProcessing.GetAllRaw(lines, (x) => x.ToString());

            File.WriteAllLines(Path.Combine(folder, "all-raw.txt"), allraw);

            var allrawOps = SourceProcessing.GetAllRaw(lines, (x) => x.ToLongString());

            File.WriteAllLines(Path.Combine(folder, "all-raw-with-ops.txt"), allrawOps);

            // Code with labels and line breaks
            var labeled = SourceProcessing.LabelCode(allraw);

            File.WriteAllLines(Path.Combine(folder, "code-labeled.txt"), labeled);
        }
Beispiel #2
0
        static void processBSNES(string filename)
        {
            var lines  = File.ReadAllLines(filename);
            var folder = Path.Combine(Path.GetDirectoryName(filename), $"{Path.GetFileNameWithoutExtension(filename)} {DateTime.Now.ToString("yyyy-MM-dd hh-mm-ss")}");

            Directory.CreateDirectory(folder);

            // Raw input
            File.WriteAllLines(Path.Combine(folder, "raw.txt"), lines);

            // Simple, just code & address ordered
            var code =
                lines
                .Where(x => !string.IsNullOrEmpty(x))
                .Select(x => x.Substring(0, 20).Trim())
                .Distinct()
                .OrderBy(x => x)
                .ToList();

            File.WriteAllLines(Path.Combine(folder, "code.txt"), code);

            // Code with labels and line breaks
            var labeled = SourceProcessing.LabelCode(code);

            File.WriteAllLines(Path.Combine(folder, "code-labeled.txt"), labeled);

            // Address/instruction usage counts
            Regex getAddress = new Regex(@"^.{7}(...).{11}\[([0-9a-f]{6})\].*$");
            var   addresses  =
                lines
                .Where(x => getAddress.IsMatch(x))
                .Select(x => getAddress.Match(x))
                .Select(x => $"{x.Groups[2].Value} {x.Groups[1].Value}")
                .GroupBy(x => x)
                .Select(x => $"{x.Key} {x.Count()}")
                .OrderBy(x => x)
                .ToList();

            File.WriteAllLines(Path.Combine(folder, "address-usage.txt"), addresses);

            // Jump targets
            Regex targetsRegex     = new Regex(@"^([a-f0-9]{6}) (jsr|jrl|jmp|jml)(.{11})\[([0-9a-f]{6})\].*$", RegexOptions.Compiled);
            Regex containsIndirect = new Regex(@",|\[|\(", RegexOptions.Compiled);
            var   targets          =
                lines
                .Where(x => targetsRegex.IsMatch(x))
                .Select(x => targetsRegex.Match(x))
                .Where(x => containsIndirect.IsMatch(x.Groups[3].Value))
                .Select(x => $"{x.Groups[1].Value} {x.Groups[2].Value}{x.Groups[3].Value}[{x.Groups[4].Value}]")
                .GroupBy(x => x)
                .Select(x => $"{x.Key} - {x.Count()}")
                .OrderBy(x => x)
                .ToList();

            File.WriteAllLines(Path.Combine(folder, "jump-targets.txt"), targets);
        }
Beispiel #3
0
 /// <summary>
 /// Запускает обработку файла, инициирует и проводит тестирование
 /// </summary>
 private void StartProcessing()
 {
     try
     {
         SourceProcessing processing = new SourceProcessing(FileName);
         SourceProcessing.ReaderBinaryFile();
         GetDeviceInfo   infoDev             = new GetDeviceInfo(SourceProcessing.getArrayInventoryNumber());
         DirectDimension processingDimension = new DirectDimension(SourceProcessing.RawStructDevice);
         Testing         initTest            = new Testing(SourceProcessing.RawStructDevice, infoDev.XmlDeviceExport);
         initTest.StartTest();
         //DataBaseConnect DBC = new DataBaseConnect(GetConnectionString.getStringConnectionData());
         //DBC.InsertDataDevice(initTest.TestResultDataStruct);
         Reporting report = new Reporting(initTest.TestResultDataStruct);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.StackTrace, e.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #4
0
        static void processMesen(string filename)
        {
            var rawlines = File.ReadAllLines(filename);
            //var folder = Path.Combine(Path.GetDirectoryName(filename), $"{Path.GetFileNameWithoutExtension(filename)} {DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss")}");
            var folder = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename));

            Directory.CreateDirectory(folder);

            // Raw input
            File.WriteAllLines(Path.Combine(folder, "raw.txt"), rawlines);

            // Parse lines into usable form
            var lines = MesenLine.ConvertTrace(rawlines.ToList());

            var notMesen =
                rawlines
                .Where(x => !string.IsNullOrEmpty(x) && !MesenLine.IsA(x));

            File.WriteAllLines(Path.Combine(folder, "not-mesen.txt"), notMesen);
            notMesen = null;
            rawlines = null;

            // Simple, just code & address ordered
            var code =
                lines
                .Select(x => $"{x.Address} {x.Op} {x.Parameters}".Trim())
                .Distinct()
                .OrderBy(x => x)
                .ToList();

            File.WriteAllLines(Path.Combine(folder, "code.txt"), code);

            // Code with labels and line breaks
            var labeled = SourceProcessing.LabelCode(code);

            File.WriteAllLines(Path.Combine(folder, "code-labeled.txt"), labeled);
            code    = null;
            labeled = null;

            // Address/instruction usage counts
            var addresses =
                lines
                .Where(x => !string.IsNullOrEmpty(x.Target))
                .Select(x => $"{x.Target} {x.Op}");

            GroupCountAndWriteFile(addresses, Path.Combine(folder, "address-usage.txt"));
            addresses = null;

            // Code instruction counts
            var codeAddresses =
                lines
                .Select(x => x.Address);

            GroupCountAndWriteFile(codeAddresses, Path.Combine(folder, "code-address-counts.txt"));
            codeAddresses = null;

            // Move counts
            var moves =
                lines
                .Where(x => x.Op == "mvn" || x.Op == "mvp")
                .Select(x => $"{getMoveAddresses(x)} {x.Op}");

            GroupCountAndWriteFile(moves, Path.Combine(folder, "moves.txt"));
            moves = null;

            // Move counts - source
            moves =
                lines
                .Where(x => x.Op == "mvn" || x.Op == "mvp")
                .Select(x => $"{getMoveAddresses(x).Split(' ')[0]} {x.Op}");
            GroupCountAndWriteFile(moves, Path.Combine(folder, "moves-source.txt"));
            moves = null;

            // Move counts - destination
            moves =
                lines
                .Where(x => x.Op == "mvn" || x.Op == "mvp")
                .Select(x => $"{getMoveAddresses(x).Split(' ')[2]} {x.Op}");
            GroupCountAndWriteFile(moves, Path.Combine(folder, "moves-destination.txt"));
            moves = null;

            // Move counts - both
            moves =
                lines
                .Where(x => x.Op == "mvn" || x.Op == "mvp")
                .Select(x => $"{getMoveAddresses(x).Split(' ')[0]} {x.Op}")
                .Concat(
                    lines
                    .Where(x => x.Op == "mvn" || x.Op == "mvp")
                    .Select(x => $"{getMoveAddresses(x).Split(' ')[2]} {x.Op}")
                    );
            GroupCountAndWriteFile(moves, Path.Combine(folder, "moves-both.txt"));
            moves = null;


            // With missing sections
            var olines = Line.ToLines(lines);
            var groups = LineGroup.MakeGroups(olines);

            olines = null;
            var missing = SourceProcessing.GetMissingOutput(groups, (x) => x.ToString());

            File.WriteAllLines(Path.Combine(folder, "with-missing.txt"), missing);
            missing = null;
            groups  = null;

            // Jump targets
            Regex targetsRegex     = new Regex(@"^(?:jsr|jrl|jmp|jml)$", RegexOptions.Compiled);
            Regex containsIndirect = new Regex(@",|\[|\(", RegexOptions.Compiled);
            var   targets          =
                lines
                .Where(x => targetsRegex.IsMatch(x.Op) && containsIndirect.IsMatch(x.Parameters))
                .Select(x => $"{x.Address} {x.Op} {x.Parameters} [{x.Target}]");

            GroupCountAndWriteFile(targets, Path.Combine(folder, "jump-targets.txt"));
            targets = null;

            // Wrong bytecode conversions
            var wrong =
                lines
                .Where(x => x.BytecodeOriginal != x.Bytecode)
                .Select(x => $"{x.Op} {x.Parameters}   log={x.BytecodeOriginal}  computed={x.Bytecode}")
                .ToList();

            File.WriteAllLines(Path.Combine(folder, "wrong-bytecode.txt"), wrong);
            wrong = null;
            lines = null;

            var f = 8;
        }