public static void ILDasmCmd(string args)
        {
            var 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(ilCode.IsIL);

            WriteOutput("code size: " + ilCode.Size);

            var 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);
                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]);
        }
Ejemplo n.º 2
0
        public static void ILDasmCmd(string args)
        {
            var 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(ilCode.IsIL);

            WriteOutput("code size: " + ilCode.Size);

            var 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);
                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]);
                }
            }
        }