private static Translator GetTranslater(ClrRuntime runtime, AddressPrinter addressPrinter) { return(new IntelTranslator { SymbolResolver = (Instruction instruction, long address, ref long offset) => { var addr = (ulong)address; var buffer = new StringWriter(); addressPrinter.Print(buffer, addr); var operand = instruction.Operands.Length > 0 ? instruction.Operands[0] : null; if (operand?.PtrOffset == 0) { return buffer.ToString(); } var method = runtime.GetMethodByAddress(addr); if (method != null) { buffer.Write(" ("); buffer.Write(method.GetFullSignature()); buffer.Write(")"); } return buffer.ToString(); } }); }
private static void PrintInstruction(TextWriter writer, Instruction instruction, AddressPrinter addressPrinter, int bytesColumnWidth, Translator translater) { // address addressPrinter.Print(writer, instruction.Offset); writer.Write(" "); // bytes foreach (var b in instruction.Bytes) { writer.Write(b.ToString("x2")); } for (var i = instruction.Bytes.Length * 2; i < bytesColumnWidth; i++) { writer.Write(' '); } // asm writer.WriteLine(translater.Translate(instruction)); }