コード例 #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int GetCodeContext(ulong uCodeLocationId, out IDebugCodeContext2 ppCodeContext)
        {
            //
            // Returns a code context object corresponding to a specified code location identifier.
            //

            LoggingUtils.PrintFunction();

            try
            {
                string location = string.Format("0x{0:X8}", uCodeLocationId);

                ppCodeContext = CLangDebuggeeCodeContext.GetCodeContextForLocation(m_debugger, location);

                if (ppCodeContext == null)
                {
                    throw new InvalidOperationException();
                }

                return(Constants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                ppCodeContext = null;

                return(Constants.E_FAIL);
            }
        }
コード例 #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public override int GetMemoryContext(out IDebugMemoryContext2 memoryContext)
        {
            //
            // Returns the memory context for a property value.
            //

            LoggingUtils.PrintFunction();

            memoryContext = null;

            try
            {
                //
                // Pick out a memory address from a pool of potential strings.
                //
                //   This is mainly to support GDB reporting symbols like:
                //
                //   {void (JNIEnv *, jclass)} 0xb3e66c84 <Java_com_example_hellogdbserver_HelloGdbServer_invokeCrash>
                //

                string [] expressionPool = { m_expression, m_gdbVariable.Value };

                string pattern = "(?<address>0x[A-Za-z0-9]+)";

                Regex regExMatcher = new Regex(pattern, RegexOptions.IgnoreCase);

                foreach (string expression in expressionPool)
                {
                    Match regExLineMatch = regExMatcher.Match(expression);

                    if (regExLineMatch.Success)
                    {
                        string address = regExLineMatch.Result("${address}");

                        memoryContext = CLangDebuggeeCodeContext.GetCodeContextForLocation(m_debugger, address);

                        break;
                    }
                }

                if (memoryContext == null)
                {
                    return(Constants.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT);
                }

                return(Constants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                return(Constants.E_FAIL);
            }
        }
コード例 #3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private void GetInfoFromCurrentLevel(MiResultValueTuple frameTuple)
        {
            LoggingUtils.PrintFunction();

            try
            {
                if (frameTuple == null)
                {
                    throw new ArgumentNullException("frameTuple");
                }

                if (frameTuple.HasField("level"))
                {
                    m_stackLevel = frameTuple ["level"] [0].GetUnsignedInt();
                }

                //
                // Discover the function or shared library location.
                //

                if (frameTuple.HasField("addr"))
                {
                    m_locationAddress = new DebuggeeAddress(frameTuple ["addr"] [0].GetString());
                }
                else
                {
                    m_locationAddress = new DebuggeeAddress("0x0");
                }

                if (frameTuple.HasField("func"))
                {
                    m_locationFunction = frameTuple ["func"] [0].GetString();
                }
                else
                {
                    m_locationFunction = "??";
                }

                m_locationIsSymbolicated = !(m_locationFunction.Equals("??"));

                if (frameTuple.HasField("from"))
                {
                    m_locationModule = Path.GetFileName(frameTuple ["from"] [0].GetString());
                }
                else
                {
                    m_locationModule = string.Empty;
                }

                //
                // Generate code and document contexts for this frame location.
                //

                if (frameTuple.HasField("fullname") && frameTuple.HasField("line"))
                {
                    //
                    // If the symbol table isn't yet loaded, we'll need to specify exactly the location of this stack frame.
                    //

                    TEXT_POSITION [] textPositions = new TEXT_POSITION [2];

                    textPositions [0].dwLine = frameTuple ["line"] [0].GetUnsignedInt() - 1;

                    textPositions [0].dwColumn = 0;

                    textPositions [1].dwLine = textPositions [0].dwLine;

                    textPositions [1].dwColumn = textPositions [0].dwColumn;

                    string filename = PathUtils.ConvertPathCygwinToWindows(frameTuple ["fullname"] [0].GetString());

                    m_documentContext = new DebuggeeDocumentContext(m_debugger.Engine, filename, textPositions [0], textPositions [1]);

                    m_codeContext = CLangDebuggeeCodeContext.GetCodeContextForLocation(m_debugger, m_locationAddress.ToString());

                    if (m_codeContext == null)
                    {
                        throw new InvalidOperationException();
                    }
                }
                else
                {
                    m_codeContext = CLangDebuggeeCodeContext.GetCodeContextForLocation(m_debugger, m_locationAddress.ToString());

                    m_documentContext = (m_codeContext != null) ? m_codeContext.DocumentContext : null;
                }
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);
            }
        }