Example #1
0
        /// <summary>
        /// Loads the current method's C# code (if it isn't plugged).
        /// </summary>
        private void LoadCurrentMethodCS()
        {
            if(CurrentILOpInfo != null)
            {
                string methodSig = CurrentMethod.MethodSignature;
                string[] reversedSig = Kernel.Compiler.Utils.ReverseMethodSignature(methodSig);

                string SymbolName = reversedSig[1];
                string MethodName = reversedSig[2];

                try
                {
                    currentCSSymbol= ThePDBDumpManager.Symbols[SymbolName];
                    //TODO - Choosing First here is wrong as one function name can be overridden.
                    //       We need to fix this so we can properly identify which override we are 
                    //       executing.
                    currentCSMethod = (from methods in currentCSSymbol.Methods
                                       where methods.FunctionName == MethodName
                                       select methods).First();
                    currentCSLine = null;

                    for (int i = 0; i < currentCSMethod.Lines.Count; i++)
                    {
                        PDB_LineInfo testLine = currentCSMethod.Lines[i];
                        if(CurrentILOpInfo.Position >= testLine.ILStartNum &&
                            CurrentILOpInfo.Position <= testLine.ILEndNum)
                        {
                            currentCSLine = testLine;
                            break;
                        }
                    }
                }
                catch
                {
                    currentCSLine = null;
                    currentCSSymbol = null;
                    currentCSMethod = null;
                }
            }
            else
            {
                currentCSLine = null;
                currentCSSymbol = null;
                currentCSMethod = null;
            }
        }
Example #2
0
        /// <summary>
        /// Reads the specified dump file.
        /// </summary>
        /// <param name="aDumpPath">The dump file to read.</param>
        private void Read(string aDumpPath)
        {
            string[] Lines = File.ReadAllLines(aDumpPath);
            string currSectionKey = null;
            List<string> currSectionText = new List<string>();
            for(int i = 0; i < Lines.Length; i++)
            {
                string cLine = Lines[i];
                if(cLine.StartsWith("***"))
                {
                    if(currSectionKey != null)
                    {
                        SectionsData.Add(currSectionKey, currSectionText);
                    }
                    currSectionKey = cLine.Substring(4).Trim();
                    currSectionText = new List<string>();
                }
                else if (!string.IsNullOrEmpty(cLine))
                {
                    currSectionText.Add(cLine);
                }
            }
            if (currSectionKey != null)
            {
                SectionsData.Add(currSectionKey, currSectionText);
            }


            List<PDB_MethodInfo> AllMethodInfos = new List<PDB_MethodInfo>();

            List<string> SymbolsData = SectionsData["SYMBOLS"];
            string currSymbolKey = null;
            List<string> currSymbolText = new List<string>();
            for(int i = 0; i < SymbolsData.Count; i++)
            {
                string cLine = SymbolsData[i];
                if (cLine.StartsWith("**"))
                {
                    if (currSymbolKey != null)
                    {
                        PDB_SymbolInfo newInf = new PDB_SymbolInfo(currSymbolText);
                        AllMethodInfos.AddRange(newInf.Methods);
                        Symbols.Add(currSymbolKey, newInf);
                    }
                    currSymbolKey = cLine.Substring(11).Trim();
                    currSymbolText = new List<string>();
                }
                else if (!string.IsNullOrEmpty(cLine))
                {
                    currSymbolText.Add(cLine);
                }
            }
            if (currSymbolKey != null)
            {
                PDB_SymbolInfo newInf = new PDB_SymbolInfo(currSymbolText);
                AllMethodInfos.AddRange(newInf.Methods);
                Symbols.Add(currSymbolKey, newInf);
            }


            List<string> LinesData = SectionsData["LINES"];
            string currLineKey = null;
            List<string> currLinesText = new List<string>();
            for (int i = 0; i < LinesData.Count; i++)
            {
                string cLine = LinesData[i];
                if (cLine.StartsWith("**"))
                {
                    if (currLineKey != null)
                    {
                        string DumpStartAddressStr = currLinesText[0].Trim().Split(' ')[3].Substring(1, 8);
                        int DumpStartAddress = int.Parse(DumpStartAddressStr, System.Globalization.NumberStyles.HexNumber);
                        PDB_MethodInfo TheMethodInfo = (from infs in AllMethodInfos
                                                        where (infs.DumpStartAddress == DumpStartAddress &&
                                                        infs.FunctionName == currLineKey)
                                                        select infs).First();
                        TheMethodInfo.ParseLines(currLinesText);
                    }
                    currLineKey = cLine.Substring(3).Trim();
                    currLinesText = new List<string>();
                }
                else if(!string.IsNullOrEmpty(cLine))
                {
                    currLinesText.Add(cLine);
                }
            }
            if (currLineKey != null)
            {
                string DumpStartAddressStr = currLinesText[0].Trim().Split(' ')[3].Substring(1, 8);
                int DumpStartAddress = int.Parse(DumpStartAddressStr, System.Globalization.NumberStyles.HexNumber);
                PDB_MethodInfo TheMethodInfo = (from infs in AllMethodInfos
                                                where (infs.DumpStartAddress == DumpStartAddress &&
                                                infs.FunctionName == currLineKey)
                                                select infs).First();
                TheMethodInfo.ParseLines(currLinesText);
            }
        }
Example #3
0
        /// <summary>
        /// Sends a request for the brwak address.
        /// </summary>
        public void GetBreakAddress()
        {
            currentMethod = null;
            currentMethodASM = null;
            currentNearestLabels = null;
            currentNearestMethodBasedLabel = null;
            if (currentILOpInfo != null)
            {
                lastILOpInfo = currentILOpInfo;
            }
            currentILOpInfo = null;
            arguments = null;
            locals = null;
            currentCSLine = null;
            currentCSMethod = null;
            currentCSSymbol = null;

            TheSerial.Write((byte)DebugCommands.GetBreakAddress);
            WaitForCommand();
        }