Пример #1
0
        /// <summary>Instanciate the <see cref="DebugConnector"/> that will handle communications
        /// between this debug engine hosted process and the emulation environment used to run the
        /// debugged Cosmos kernel. Actual connector to be instanciated is discovered from Cosmos
        /// project properties.</summary>
        private void CreateDebugConnector()
        {
            mDbgConnector = null;

            string xPort  = mDebugInfo[BuildProperties.VisualStudioDebugPortString];
            var    xParts = (null == xPort) ? null : xPort.Split(' ');

            if ((null == xParts) || (2 > xParts.Length))
            {
                throw new Exception(string.Format(
                                        "The '{0}' Cosmos project file property is either ill-formed or missing.",
                                        BuildProperties.VisualStudioDebugPortString));
            }
            string xPortType  = xParts[0].ToLower();
            string xPortParam = xParts[1].ToLower();

            OutputText("Starting debug connector.");
            if (xPortType == "pipe:")
            {
                mDbgConnector = new Cosmos.Debug.Common.DebugConnectorPipeServer(xPortParam);
            }
            else if (xPortType == "serial:")
            {
                mDbgConnector = new Cosmos.Debug.Common.DebugConnectorSerial(xPortParam);
            }

            if (mDbgConnector == null)
            {
                throw new Exception("No debug connector found.");
            }
            mDbgConnector.SetConnectionHandler(DebugConnectorConnected);
            mDbgConnector.CmdBreak                   += new Action <UInt32>(DbgCmdBreak);
            mDbgConnector.CmdTrace                   += new Action <UInt32>(DbgCmdTrace);
            mDbgConnector.CmdText                    += new Action <string>(DbgCmdText);
            mDbgConnector.CmdStarted                 += new Action(DbgCmdStarted);
            mDbgConnector.OnDebugMsg                 += new Action <string>(DebugMsg);
            mDbgConnector.ConnectionLost             += new Action <Exception>(DbgConnector_ConnectionLost);
            mDbgConnector.CmdRegisters               += new Action <byte[]>(DbgCmdRegisters);
            mDbgConnector.CmdFrame                   += new Action <byte[]>(DbgCmdFrame);
            mDbgConnector.CmdStack                   += new Action <byte[]>(DbgCmdStack);
            mDbgConnector.CmdPong                    += new Action <byte[]>(DbgCmdPong);
            mDbgConnector.CmdStackCorruptionOccurred += DbgCmdStackCorruptionOccurred;
            mDbgConnector.CmdNullReferenceOccurred   += DbgCmdNullReferenceOccurred;
            mDbgConnector.CmdMessageBox              += DbgCmdMessageBox;
        }
Пример #2
0
        /// <summary>Instanciate the <see cref="DebugConnector"/> that will handle communications
        /// between this debug engine hosted process and the emulation environment used to run the
        /// debugged Cosmos kernel. Actual connector to be instanciated is discovered from Cosmos
        /// project properties.</summary>
        private void CreateDebugConnector()
        {
            mDbgConnector = null;

            string xPort = mDebugInfo[BuildPropertyNames.VisualStudioDebugPortString];

            // using (var xDebug = new StreamWriter(@"e:\debug.info", false))
            // {
            //     foreach (var xItem in mDebugInfo.AllKeys)
            //     {
            //         xDebug.WriteLine("{0}: '{1}'", xItem, mDebugInfo[xItem]);
            //     }
            //     xDebug.Flush();
            // }

            if (String.IsNullOrWhiteSpace(xPort))
            {
                xPort = mDebugInfo[BuildPropertyNames.CosmosDebugPortString];
            }

            var xParts = (null == xPort) ? null : xPort.Split(' ');

            if ((null == xParts) || (2 > xParts.Length))
            {
                throw new Exception(string.Format("Unable to parse VS debug port: '{0}'", xPort));
                //throw new Exception(string.Format(
                //    "The '{0}' Cosmos project file property is either ill-formed or missing.",
                //    BuildProperties.VisualStudioDebugPortString));
            }
            string xPortType  = xParts[0].ToLower();
            string xPortParam = xParts[1].ToLower();

            var xLaunch = mDebugInfo[BuildPropertyNames.LaunchString];

            OutputText("Starting debug connector.");
            switch (xPortType)
            {
            case "pipe:":
                mDbgConnector = new Cosmos.Debug.Common.DebugConnectorPipeServer(xPortParam);
                break;

            case "serial:":
                if (xLaunch == "IntelEdison")
                {
                    mDbgConnector = new Cosmos.Debug.Common.DebugConnectorEdison(xPortParam, Path.ChangeExtension(mDebugInfo["ISOFile"], ".bin"));
                }
                else
                {
                    mDbgConnector = new Cosmos.Debug.Common.DebugConnectorSerial(xPortParam);
                }
                break;

            default:
                throw new Exception("No debug connector found for port type '" + xPortType + "'");
            }
            mDbgConnector.SetConnectionHandler(DebugConnectorConnected);
            mDbgConnector.CmdBreak                   += new Action <UInt32>(DbgCmdBreak);
            mDbgConnector.CmdTrace                   += new Action <UInt32>(DbgCmdTrace);
            mDbgConnector.CmdText                    += new Action <string>(DbgCmdText);
            mDbgConnector.CmdSimpleNumber            += new Action <uint>(DbgCmdSimpleNumber);
            mDbgConnector.CmdKernelPanic             += new Action <uint>(DbgCmdKernelPanic);
            mDbgConnector.CmdSimpleLongNumber        += new Action <ulong>(DbgCmdSimpleLongNumber);
            mDbgConnector.CmdComplexNumber           += new Action <float>(DbgCmdComplexNumber);
            mDbgConnector.CmdComplexLongNumber       += new Action <double>(DbgCmdComplexLongNumber);
            mDbgConnector.CmdStarted                 += new Action(DbgCmdStarted);
            mDbgConnector.OnDebugMsg                 += new Action <string>(DebugMsg);
            mDbgConnector.ConnectionLost             += new Action <Exception>(DbgConnector_ConnectionLost);
            mDbgConnector.CmdRegisters               += new Action <byte[]>(DbgCmdRegisters);
            mDbgConnector.CmdFrame                   += new Action <byte[]>(DbgCmdFrame);
            mDbgConnector.CmdStack                   += new Action <byte[]>(DbgCmdStack);
            mDbgConnector.CmdPong                    += new Action <byte[]>(DbgCmdPong);
            mDbgConnector.CmdStackCorruptionOccurred += DbgCmdStackCorruptionOccurred;
            mDbgConnector.CmdStackOverflowOccurred   += DbgCmdStackOverflowOccurred;
            mDbgConnector.CmdNullReferenceOccurred   += DbgCmdNullReferenceOccurred;
            mDbgConnector.CmdMessageBox              += DbgCmdMessageBox;
            mDbgConnector.CmdChannel                 += DbgCmdChannel;
        }