public static void ILDasmCmd(string args) { // Provides disassembly of IL opcodes. ArgParser ap = new ArgParser(args); if (ap.Count > 1) { WriteError("Wrong # of arguments."); return; } MDbgFrame functionFrame = null; MDbgFunction function = null; if (ap.Exists(0)) { function = Debugger.Processes.Active.ResolveFunctionNameFromScope(ap.AsString(0)); if (function == null) { throw new MDbgShellException("no such function."); } } else { functionFrame = Debugger.Processes.Active.Threads.Active.CurrentFrame; function = functionFrame.Function; } CorCode ilCode = function.CorFunction.ILCode; //CorMetadataImport importer = functionFrame.Function.Module.Importer; Debug.Assert(true == ilCode.IsIL); WriteOutput("code size: " + ilCode.Size); ILVirtualDocument doc = new ILVirtualDocument(function); int currentLine; if (functionFrame != null) { // we have frame and therefore we should show current location uint ip; CorDebugMappingResult mappingResult; functionFrame.CorFrame.GetIP(out ip, out mappingResult); WriteOutput("current IL-IP: " + ip); WriteOutput("mapping: " + mappingResult.ToString()); WriteOutput("URL: " + doc.Path); currentLine = doc.Ip2LineNo((int)ip); } else { // no current IP. currentLine = -1; } for (int i = 0; i < doc.Count; i++) { if (i == currentLine) { WriteOutput("* " + doc[i]); } else { WriteOutput(" " + doc[i]); } } }
public static void ILDasmCmd(string args) { // Provides disassembly of IL opcodes. ArgParser ap = new ArgParser(args); if (ap.Count > 1) { WriteError("Wrong # of arguments."); return; } MDbgFrame functionFrame = null; MDbgFunction function = null; if (ap.Exists(0)) { function = Debugger.Processes.Active.ResolveFunctionNameFromScope(ap.AsString(0)); if (function == null) throw new MDbgShellException("no such function."); } else { functionFrame = Debugger.Processes.Active.Threads.Active.CurrentFrame; function = functionFrame.Function; } CorCode ilCode = function.CorFunction.ILCode; //CorMetadataImport importer = functionFrame.Function.Module.Importer; Debug.Assert(true == ilCode.IsIL); WriteOutput("code size: " + ilCode.Size); ILVirtualDocument doc = new ILVirtualDocument(function); int currentLine; if (functionFrame != null) { // we have frame and therefore we should show current location uint ip; CorDebugMappingResult mappingResult; functionFrame.CorFrame.GetIP(out ip, out mappingResult); WriteOutput("current IL-IP: " + ip); WriteOutput("mapping: " + mappingResult.ToString()); WriteOutput("URL: " + doc.Path); currentLine = doc.Ip2LineNo((int)ip); } else { // no current IP. currentLine = -1; } for (int i = 0; i < doc.Count; i++) if (i == currentLine) WriteOutput("* " + doc[i]); else WriteOutput(" " + doc[i]); }