示例#1
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="PC"></param>
		public void Trace(uint PC)
		{
			if (MipsDisassembler == null) MipsDisassembler = new MipsDisassembler();
			var Result = MipsDisassembler.Disassemble(PC, (Instruction)Memory.Read4(PC));
			Console.WriteLine("  Trace: PC:0x{0:X8} : DATA:0x{1:X8} : {2}", PC, Memory.Read4(PC), Result);
		}
示例#2
0
		private void UpdateText()
		{
			if (PcListBox.SelectedItem != null)
			{
				var PCItem = (PCItem)PcListBox.SelectedItem;
				var MethodCacheInfo = CpuProcessor.MethodCache.GetForPC(PCItem.PC);
				var MinPC = MethodCacheInfo.MinPC;
				var MaxPC = MethodCacheInfo.MaxPC;
				var Memory = CpuProcessor.Memory;
				AstNodeStm Node = null;
				if (MethodCacheInfo.AstTree != null) Node = MethodCacheInfo.AstTree.Optimize(CpuProcessor);

				var OutString = "";
				switch (LanguageComboBox.SelectedItem.ToString())
				{
					case "C#":
						if (Node != null)
						{
							OutString = Node.ToCSharpString().Replace("CpuThreadState.", "");
						}
						break;
					case "IL":
						if (Node != null)
						{
							OutString = Node.ToILString<Action<CpuThreadState>>();
						}
						break;
					case "Ast":
						if (Node != null)
						{
							OutString = AstSerializer.SerializeAsXml(Node);
						}
						break;
					case "Mips":
						{
							var MipsDisassembler = new MipsDisassembler();
							try
							{
								for (uint PC = MinPC; PC <= MaxPC; PC += 4)
								{
									var Instruction = Memory.ReadSafe<Instruction>(PC);					
									var Result = MipsDisassembler.Disassemble(PC, Instruction);
									OutString += String.Format("0x{0:X8}: {1}\r\n", PC, Result.ToString());
								}
							}
							catch (Exception Exception)
							{
								Console.Error.WriteLine(Exception);
							}
						}
						break;
					default:
						break;
				}

				ViewTextBox.Text = OutString.Replace("\n", "\r\n");
			}
		}
 private AstNodeStm ProcessGeneratedInstruction(MipsDisassembler.Result Disasm, AstNodeStm AstNodeStm)
 {
     var PC = Disasm.InstructionPC;
     return ast.Statements(
     #if DEBUG_TRACE_INSTRUCTIONS
         ast.DebugWrite(String.Format("0x{0:X8}: {1}", PC, Disasm)),
     #endif
         AstNodeStm
     );
 }
 public AstNodeStmPspInstruction(MipsDisassembler.Result DisassembledResult, AstNodeStm Statement)
 {
     this.DisassembledResult = DisassembledResult;
     this.Statement = Statement;
 }
示例#5
0
        private void UpdateText()
        {
            if (PcListBox.SelectedItem != null)
            {
                var PCItem = (PCItem)PcListBox.SelectedItem;
                var MethodCacheInfo = PCItem.MethodCacheInfo;
                var MinPC = MethodCacheInfo.MinPC;
                var MaxPC = MethodCacheInfo.MaxPC;
                var Memory = CpuProcessor.Memory;
                AstNodeStm Node = null;
                if (MethodCacheInfo.AstTree != null) Node = MethodCacheInfo.AstTree.Optimize(CpuProcessor);

                var InfoLines = new List<string>();

                InfoLines.Add(String.Format("Name: {0}", MethodCacheInfo.Name));
                InfoLines.Add(String.Format("TotalInstructions: {0}", MethodCacheInfo.TotalInstructions));
                InfoLines.Add(String.Format("DisableOptimizations: {0}", MethodCacheInfo.DynarecFunction.DisableOptimizations));

                InfoLines.Add(String.Format("EntryPC: 0x{0:X8}", MethodCacheInfo.EntryPC));
                InfoLines.Add(String.Format("MinPC: 0x{0:X8}", MethodCacheInfo.MinPC));
                InfoLines.Add(String.Format("MaxPC: 0x{0:X8}", MethodCacheInfo.MaxPC));
                InfoLines.Add(String.Format("TimeAnalyzeBranches: {0}", MethodCacheInfo.DynarecFunction.TimeAnalyzeBranches.TotalMilliseconds));
                InfoLines.Add(String.Format("TimeGenerateAst: {0}", MethodCacheInfo.DynarecFunction.TimeGenerateAst.TotalMilliseconds));
                InfoLines.Add(String.Format("TimeOptimize: {0}", MethodCacheInfo.DynarecFunction.TimeOptimize.TotalMilliseconds));
                InfoLines.Add(String.Format("TimeGenerateIL: {0}", MethodCacheInfo.DynarecFunction.TimeGenerateIL.TotalMilliseconds));
                InfoLines.Add(String.Format("TimeCreateDelegate: {0}", MethodCacheInfo.DynarecFunction.TimeCreateDelegate.TotalMilliseconds));
                InfoLines.Add(String.Format("TimeLinking: {0}", MethodCacheInfo.DynarecFunction.TimeLinking.TotalMilliseconds));
                InfoLines.Add(String.Format("TimeTotal: {0}", MethodCacheInfo.DynarecFunction.TimeTotal.TotalMilliseconds));

                InfoLines.Add(String.Format(""));
                foreach (var Item in MethodCacheInfo.DynarecFunction.InstructionStats.OrderBy(Pair => Pair.Value))
                {
                    InfoLines.Add(String.Format("{0}: {1}", Item.Key, Item.Value));
                }

                InfoTextBox.Text = String.Join("\r\n", InfoLines);

                var OutString = "";
                switch (LanguageComboBox.SelectedItem.ToString())
                {
                    case "C#":
                        if (Node != null)
                        {
                            OutString = Node.ToCSharpString().Replace("CpuThreadState.", "");
                        }
                        break;
                    case "IL":
                        if (Node != null)
                        {
                            OutString = Node.ToILString<Action<CpuThreadState>>();
                        }
                        break;
                    case "Ast":
                        if (Node != null)
                        {
                            OutString = AstSerializer.SerializeAsXml(Node);
                        }
                        break;
                    case "Mips":
                        {
                            var MipsDisassembler = new MipsDisassembler();
                            try
                            {
                                for (uint PC = MinPC; PC <= MaxPC; PC += 4)
                                {
                                    var Instruction = Memory.ReadSafe<Instruction>(PC);
                                    var Result = MipsDisassembler.Disassemble(PC, Instruction);
                                    OutString += String.Format("0x{0:X8}: {1}\r\n", PC, Result.ToString());
                                }
                            }
                            catch (Exception Exception)
                            {
                                Console.Error.WriteLine(Exception);
                            }
                        }
                        break;
                    default:
                        break;
                }

                ViewTextBox.Text = OutString.Replace("\n", "\r\n");
            }
        }