////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int EnumCodeContexts(out IEnumDebugCodeContexts2 enumCodeContexts)
        {
            //
            // Retrieves a list of all code contexts associated with this document context.
            //

            LoggingUtils.PrintFunction();

            try
            {
                IDebugCodeContext2 [] codeContexts;

                if (m_codeContext != null)
                {
                    codeContexts = new IDebugCodeContext2 [] { m_codeContext };
                }
                else
                {
                    codeContexts = new IDebugCodeContext2 [0];
                }

                enumCodeContexts = new DebuggeeCodeContext.Enumerator(codeContexts);

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

                enumCodeContexts = null;

                return(Constants.E_FAIL);
            }
        }
예제 #2
0
        // Retrieves a list of all code contexts associated with this document context.
        // The engine sample only supports one code context per document context and 
        // the code contexts are always memory addresses.
        int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
        {
            ppEnumCodeCxts = null;

            if (_codeContext == null)
            {
                return Constants.E_FAIL;
            }

            try
            {
                AD7MemoryAddress[] codeContexts = new AD7MemoryAddress[1];
                codeContexts[0] = _codeContext;
                ppEnumCodeCxts = new AD7CodeContextEnum(codeContexts);
                return Constants.S_OK;
            }
            catch (MIException e)
            {
                return e.HResult;
            }
            catch (Exception e)
            {
                return EngineUtils.UnexpectedException(e);
            }
        }
예제 #3
0
 // Retrieves a list of all code contexts associated with this document context.
 // The engine sample only supports one code context per document context and
 // the code contexts are always memory addresses.
 int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     var codeContexts = new AD7MemoryAddress[1];
     codeContexts[0] = _codeContext;
     ppEnumCodeCxts = new AD7CodeContextEnum(codeContexts);
     return VSConstants.S_OK;
 }
예제 #4
0
        // Retrieves a list of all code contexts associated with this document context.
        // The engine sample only supports one code context per document context and
        // the code contexts are always memory addresses.
        int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
        {
            ppEnumCodeCxts = null;

            if (_codeContext == null)
            {
                return(Constants.E_FAIL);
            }

            try
            {
                AD7MemoryAddress[] codeContexts = new AD7MemoryAddress[1];
                codeContexts[0] = _codeContext;
                ppEnumCodeCxts  = new AD7CodeContextEnum(codeContexts);
                return(Constants.S_OK);
            }
            catch (MIException e)
            {
                return(e.HResult);
            }
            catch (Exception e)
            {
                return(EngineUtils.UnexpectedException(e));
            }
        }
예제 #5
0
        public int EnumCodeContexts(
            IDebugDocumentPosition2 docPos, out IEnumDebugCodeContexts2 contextsEnum)
        {
            contextsEnum = null;
            var startPositions = new TEXT_POSITION[1];
            var result         = docPos.GetRange(startPositions, null);

            if (result != VSConstants.S_OK)
            {
                Trace.WriteLine("Error: Unable to retrieve starting position.");
                return(result);
            }
            string fileName;

            docPos.GetFileName(out fileName);
            var codeContexts = new List <IDebugCodeContext2>();

            // TODO: Find a less hacky way of doing this
            var tempBreakpoint = _lldbTarget.BreakpointCreateByLocation(fileName,
                                                                        startPositions[0].dwLine + 1);

            if (tempBreakpoint == null)
            {
                Trace.WriteLine("Error: Failed to set temporary breakpoint used to map document " +
                                "position to code contexts.");
                return(VSConstants.E_FAIL);
            }
            try
            {
                var numLocations = tempBreakpoint.GetNumLocations();
                for (uint i = 0; i < numLocations; ++i)
                {
                    var location = tempBreakpoint.GetLocationAtIndex(i);
                    var address  = location.GetAddress();
                    if (address != null)
                    {
                        var codeContext = _codeContextFactory.Create(
                            address.GetLoadAddress(_lldbTarget),
                            address.GetFunction().GetName(),
                            _documentContextFactory.Create(address.GetLineEntry()),
                            Guid.Empty);
                        codeContexts.Add(codeContext);
                    }
                    else
                    {
                        Trace.WriteLine("Warning: Failed to obtain address for code context " +
                                        "from temporary breakpoint location. Code context skipped.");
                    }
                }
            }
            finally
            {
                _lldbTarget.BreakpointDelete(tempBreakpoint.GetId());
                tempBreakpoint = null;
            }

            contextsEnum = _codeContextEnumFactory.Create(codeContexts);
            return(VSConstants.S_OK);
        }
예제 #6
0
        // Retrieves a list of all code contexts associated with this document context.
        // The engine sample only supports one code context per document context and
        // the code contexts are always memory addresses.
        int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
        {
            var codeContexts = new AD7MemoryAddress[1];

            codeContexts[0] = _codeContext;
            ppEnumCodeCxts  = new AD7CodeContextEnum(codeContexts);
            return(VSConstants.S_OK);
        }
예제 #7
0
        public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
        {
            TextPositionInfo posInfo = new TextPositionInfo(pDocPos);

            MonoDocumentContext docCtx    = new MonoDocumentContext(posInfo, null);
            MonoMemoryContext   memoryCtx = new MonoMemoryContext(docCtx, 0);

            ppEnum = new MonoCodeContextEnumerator(new IDebugCodeContext2[] { memoryCtx });

            return(S_OK);
        }
예제 #8
0
        // Enumerates the code contexts for a given position in a source file.
        public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
        {
            string filename;

            pDocPos.GetFileName(out filename);
            TEXT_POSITION[] beginning = new TEXT_POSITION[1], end = new TEXT_POSITION[1];

            pDocPos.GetRange(beginning, end);

            ppEnum = new AD7CodeContextEnum(new[] { new AD7MemoryAddress(this, filename, (uint)beginning[0].dwLine) });
            return(VSConstants.S_OK);
        }
예제 #9
0
 // Retrieves a list of all code contexts associated with this document context.
 // The engine sample only supports one code context per document context and
 // the code contexts are always memory addresses.
 int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = null;
     try
     {
         return(VSConstants.S_OK);
     }
     catch (Exception e)
     {
         return(EngineUtils.UnexpectedException(e));
     }
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
        {
            //
            // Enumerates the code contexts for a given position in a source file.
            //

            LoggingUtils.PrintFunction();

            ppEnum = null;

            try
            {
                List <IDebugCodeContext2> codeContexts = new List <IDebugCodeContext2> ();

                uint count;

                {
                    LoggingUtils.RequireOk(AttachedEngine.NativeDebugger.NativeProgram.EnumCodeContexts(pDocPos, out ppEnum));

                    LoggingUtils.RequireOk(ppEnum.GetCount(out count));

                    IDebugCodeContext2 [] codeContextArray = new IDebugCodeContext2 [count];

                    LoggingUtils.RequireOk(ppEnum.Next(count, codeContextArray, ref count));

                    codeContexts.AddRange(codeContextArray);
                }

#if false
                {
                    LoggingUtils.RequireOk(AttachedEngine.JavaDebugger.JavaProgram.EnumCodeContexts(pDocPos, out ppEnum));

                    LoggingUtils.RequireOk(ppEnum.GetCount(out count));

                    IDebugCodeContext2 [] codeContextArray = new IDebugCodeContext2 [count];

                    LoggingUtils.RequireOk(ppEnum.Next(count, codeContextArray, ref count));

                    codeContexts.AddRange(codeContextArray);
                }
#endif

                ppEnum = new DebuggeeCodeContext.Enumerator(codeContexts);

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

                return(Constants.E_FAIL);
            }
        }
예제 #11
0
 // Retrieves a list of all code contexts associated with this document context.
 // The engine sample only supports one code context per document context and 
 // the code contexts are always memory addresses.
 int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = null;
     try
     {
         return VSConstants.S_OK;
     }
     catch (Exception e)
     {
         return EngineUtils.UnexpectedException(e);
     }
 }
예제 #12
0
        public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
        {
            TEXT_POSITION[] startPosition;
            TEXT_POSITION[] endPosition;
            var             documentName = breakpointManager.Engine.GetLocationInfo(pDocPos, out startPosition, out endPosition);

            var textPosition = new TEXT_POSITION {
                dwLine = startPosition[0].dwLine + 1
            };
            var documentContext = new MonoDocumentContext(documentName, textPosition, textPosition, null);

            ppEnum = new MonoCodeContextEnum(new[] { new MonoMemoryAddress(this, 0, documentContext) });
            return(VSConstants.S_OK);
        }
예제 #13
0
 // Retrieves a list of all code contexts associated with this document context.
 // The engine sample only supports one code context per document context and
 // the code contexts are always memory addresses.
 int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = null;
     try
     {
         AD7MemoryAddress[] codeContexts = new AD7MemoryAddress[1];
         codeContexts[0] = m_codeContext;
         ppEnumCodeCxts = new AD7CodeContextEnum(codeContexts);
         return VSConstants.S_OK;
     }
     catch (Exception e)
     {
         return EngineUtils.UnexpectedException(e);
     }
 }
예제 #14
0
 /// <summary>
 /// Retrieves a list of all code contexts associated with this document context. The VSNDK Debug Engine only supports one code context per document
 /// context and the code contexts are always memory addresses. (http://msdn.microsoft.com/en-us/library/bb146273.aspx)
 /// </summary>
 /// <param name="ppEnumCodeCxts"> Returns an IEnumDebugCodeContexts2 object that contains a list of code contexts. </param>
 /// <returns> If successful, returns S_OK; otherwise, returns an error code. </returns>
 int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = null;
     try
     {
         AD7MemoryAddress[] codeContexts = new AD7MemoryAddress[1];
         codeContexts[0] = m_codeContext;
         ppEnumCodeCxts  = new AD7CodeContextEnum(codeContexts);
         return(VSConstants.S_OK);
     }
     catch (Exception e)
     {
         return(EngineUtils.UnexpectedException(e));
     }
 }
        /// <summary>
        /// Retrieves a list of the code contexts for a given position in a source file.
        /// </summary>
        /// <param name="pDocPos">An IDebugDocumentPosition2 object representing an abstract position in a source file known to the IDE.</param>
        /// <param name="ppEnum">Returns an IEnumDebugCodeContexts2 object that contains a list of the code contexts.</param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
        /// <remarks>
        /// This method allows the session debug manager (SDM) or IDE to map a source file position into a code
        /// position. More than one code context is returned if the source generates multiple blocks of code (for
        /// example, C++ templates).
        /// </remarks>
        public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
        {
            if (pDocPos == null)
            {
                throw new ArgumentNullException("pDocPos");
            }

            string fileName   = pDocPos.GetFileName();
            int    lineNumber = pDocPos.GetRange().iStartLine + 1;

            List <IDebugCodeContext2>      codeContexts = new List <IDebugCodeContext2>();
            IEnumerable <JavaDebugProgram> programs     = DebugEngine.Programs.ToArray();

            foreach (var program in programs)
            {
                if (!program.IsLoaded)
                {
                    continue;
                }

                IVirtualMachine virtualMachine = program.VirtualMachine;
                ReadOnlyCollection <IReferenceType> classes = virtualMachine.GetAllClasses();
                foreach (var @class in classes)
                {
                    if ([email protected]())
                    {
                        continue;
                    }

                    ReadOnlyCollection <ILocation> locations = @class.GetLocationsOfLine(@class.GetDefaultStratum(), Path.GetFileName(fileName), lineNumber);
                    ILocation bindLocation = locations.OrderBy(i => i.GetCodeIndex()).FirstOrDefault();
                    if (bindLocation != null)
                    {
                        codeContexts.Add(new JavaDebugCodeContext(this, bindLocation));
                    }
                }
            }

            if (codeContexts.Count == 0)
            {
                ppEnum = null;
                return(VSConstants.E_FAIL);
            }

            ppEnum = new EnumDebugCodeContexts(codeContexts);
            return(VSConstants.S_OK);
        }
예제 #16
0
        int IDebugProgram2.EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
        {
            ThrowIfDisposed();

            string fileName;

            Marshal.ThrowExceptionForHR(pDocPos.GetFileName(out fileName));

            var start = new TEXT_POSITION[1];
            var end   = new TEXT_POSITION[1];

            Marshal.ThrowExceptionForHR(pDocPos.GetRange(start, end));

            var addr = new AD7MemoryAddress(this, fileName, (int)start[0].dwLine);

            ppEnum = new AD7CodeContextEnum(new[] { addr });
            return(VSConstants.S_OK);
        }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public int EnumCodeContexts (IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
    {
      // 
      // Enumerates the code contexts for a given position in a source file.
      // 

      LoggingUtils.PrintFunction ();

      try
      {
        string fileName;

        TEXT_POSITION [] startPos = new TEXT_POSITION [1];

        TEXT_POSITION [] endPos = new TEXT_POSITION [1];

        LoggingUtils.RequireOk (pDocPos.GetFileName (out fileName));

        LoggingUtils.RequireOk (pDocPos.GetRange (startPos, endPos));

        DebuggeeDocumentContext documentContext = new DebuggeeDocumentContext (m_debugger.Engine, fileName, startPos [0], endPos [0]);

        CLangDebuggeeCodeContext codeContext = CLangDebuggeeCodeContext.GetCodeContextForDocumentContext (m_debugger, documentContext);

        if (codeContext == null)
        {
          throw new InvalidOperationException ("Failed evaluating code-context for location.");
        }

        CLangDebuggeeCodeContext [] codeContexts = new CLangDebuggeeCodeContext [] { codeContext };

        ppEnum = new DebuggeeCodeContext.Enumerator (codeContexts);

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

        ppEnum = null;

        return Constants.E_FAIL;
      }
    }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
        {
            //
            // Enumerates the code contexts for a given position in a source file.
            //

            LoggingUtils.PrintFunction();

            try
            {
                string fileName;

                TEXT_POSITION [] startPos = new TEXT_POSITION [1];

                TEXT_POSITION [] endPos = new TEXT_POSITION [1];

                LoggingUtils.RequireOk(pDocPos.GetFileName(out fileName));

                LoggingUtils.RequireOk(pDocPos.GetRange(startPos, endPos));

                string location = string.Format("\"{0}:{1}\"", fileName, startPos [0].dwLine + 1);

                DebuggeeCodeContext codeContext = m_debugger.GetCodeContextForLocation(location);

                if (codeContext == null)
                {
                    throw new InvalidOperationException("Failed evaluating code-context for location.");
                }

                DebuggeeCodeContext [] codeContexts = new DebuggeeCodeContext [] { codeContext };

                ppEnum = new DebuggeeCodeContext.Enumerator(codeContexts);

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

                ppEnum = null;

                return(Constants.E_FAIL);
            }
        }
예제 #19
0
 /// <summary>
 ///     Retrieves a list of all code contexts associated with this document context.
 /// </summary>
 /// <param name="ppEnumCodeCxts">The enumerator.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 public int EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = null;
     try
     {
         var codeContexts = new IDebugCodeContext2[1];
         codeContexts[0] = _address;
         ppEnumCodeCxts  = new MonoCodeContextEnumerator(codeContexts);
         return(S_OK);
     }
     catch (ComponentException e)
     {
         return(e.HResult);
     }
     catch (Exception e)
     {
         return(EngineUtils.UnexpectedException(e));
     }
 }
        // Token: 0x06000043 RID: 67 RVA: 0x00002FE4 File Offset: 0x000011E4
        int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
        {
            ppEnumCodeCxts = null;
            int result;

            try
            {
                ppEnumCodeCxts = new AD7CodeContextEnum(new AD7MemoryAddress[]
                {
                    this.m_codeContext
                });
                result = 0;
            }
            catch (Exception e)
            {
                result = Utils.UnexpectedException(e);
            }
            return(result);
        }
예제 #21
0
 public int EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = null;
     try
     {
         var codeContexts = new MonoMemoryAddress[1];
         codeContexts[0] = address;
         ppEnumCodeCxts  = new MonoCodeContextEnum(codeContexts);
         return(VSConstants.S_OK);
     }
     catch (ComponentException e)
     {
         return(e.HResult);
     }
     catch (Exception e)
     {
         return(EngineUtils.UnexpectedException(e));
     }
 }
예제 #22
0
 // Retrieves a list of all code contexts associated with this document context.
 // The engine sample only supports one code context per document context and 
 // the code contexts are always memory addresses.
 int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = null;
     //try
     //{
     //    AD7MemoryAddress[] codeContexts = new AD7MemoryAddress[1];
     //    codeContexts[0] = _codeContext;
     //    ppEnumCodeCxts = new AD7CodeContextEnum(codeContexts);
     //    return Constants.S_OK;
     //}
     //catch (MIException e)
     //{
     //    return e.HResult;
     //}
     //catch (Exception e)
     //{
     //    return EngineUtils.UnexpectedException(e);
     //}
     return VSConstants.S_FALSE;
 }
예제 #23
0
 // Retrieves a list of all code contexts associated with this document context.
 // The engine sample only supports one code context per document context and
 // the code contexts are always memory addresses.
 int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = null;
     //try
     //{
     //    AD7MemoryAddress[] codeContexts = new AD7MemoryAddress[1];
     //    codeContexts[0] = _codeContext;
     //    ppEnumCodeCxts = new AD7CodeContextEnum(codeContexts);
     //    return Constants.S_OK;
     //}
     //catch (MIException e)
     //{
     //    return e.HResult;
     //}
     //catch (Exception e)
     //{
     //    return EngineUtils.UnexpectedException(e);
     //}
     return(VSConstants.S_FALSE);
 }
 // Retrieves a list of all code contexts associated with this document context.
 int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = null;
     try
     {
         XamarinMemoryAddress[] codeContexts = new XamarinMemoryAddress[1];
         codeContexts[0] = _codeContext;
         ppEnumCodeCxts  = new XamarinCodeContextEnum(codeContexts);
         return(VisualStudioExtensionConstants.S_OK);
     }
     catch (ComponentException e)
     {
         return(e.HResult);
     }
     catch (Exception e)
     {
         NLogService.Logger.Error(e);
         return(VisualStudioExtensionConstants.S_FALSE);
     }
 }
예제 #25
0
        // Enumerates the code contexts for a given position in a source file.
        public int EnumCodeContexts(IDebugDocumentPosition2 docPosition, out IEnumDebugCodeContexts2 ppEnum)
        {
            string documentName;

            EngineUtils.CheckOk(docPosition.GetFileName(out documentName));

            // Get the location in the document
            TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
            TEXT_POSITION[] endPosition   = new TEXT_POSITION[1];
            EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));
            List <IDebugCodeContext2> codeContexts = new List <IDebugCodeContext2>();

            List <ulong> addresses = null;
            uint         line      = startPosition[0].dwLine + 1;

            _debuggedProcess.WorkerThread.RunOperation(async() =>
            {
                addresses = await DebuggedProcess.StartAddressesForLine(documentName, line);
            });

            if (addresses != null && addresses.Count > 0)
            {
                foreach (var a in addresses)
                {
                    var           codeCxt = new AD7MemoryAddress(this, a, null);
                    TEXT_POSITION pos;
                    pos.dwLine   = line;
                    pos.dwColumn = 0;
                    MITextPosition textPosition = new MITextPosition(documentName, pos, pos);
                    codeCxt.SetDocumentContext(new AD7DocumentContext(textPosition, codeCxt, this.DebuggedProcess));
                    codeContexts.Add(codeCxt);
                }
                if (codeContexts.Count > 0)
                {
                    ppEnum = new AD7CodeContextEnum(codeContexts.ToArray());
                    return(Constants.S_OK);
                }
            }
            ppEnum = null;
            return(Constants.E_FAIL);
        }
예제 #26
0
파일: AD7Engine.cs 프로젝트: e42s/VSLua
 // Enumerates the code contexts for a given position in a source file.
 public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
 {
     ppEnum = null;
     return VSConstants.E_NOTIMPL;
 }
예제 #27
0
 /// <summary>
 /// Retrieves a list of all code contexts associated with this document context.
 /// </summary>
 /// <param name="ppEnumCodeCxts">Returns an IEnumDebugCodeContexts2 object that contains a list of code contexts.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 /// <remarks>A single document context can generate multiple code contexts when the document is using templates or include files.</remarks>
 public virtual int EnumCodeContexts( out IEnumDebugCodeContexts2 ppEnumCodeCxts )
 {
     ppEnumCodeCxts = null;
     return VSConstants.E_NOTIMPL;
 }
예제 #28
0
 /// <summary>
 /// Returns a copy of the current enumeration as a separate object.
 /// </summary>
 /// <param name="ppEnum">Returns a copy of this enumeration as a separate object.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 /// <remarks>The copy of the enumeration has the same state as the original at the time this method is called. However, the copy's and the original's states are separate and can be changed individually.</remarks>
 public virtual int Clone( out IEnumDebugCodeContexts2 ppEnum )
 {
     Logger.Debug( string.Empty );
     ppEnum = null;
     return VSConstants.E_NOTIMPL;
 }
예제 #29
0
        // Enumerates the code contexts for a given position in a source file.
        public int EnumCodeContexts(IDebugDocumentPosition2 docPosition, out IEnumDebugCodeContexts2 ppEnum)
        {
            string documentName;
            EngineUtils.CheckOk(docPosition.GetFileName(out documentName));

            // Get the location in the document
            TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
            TEXT_POSITION[] endPosition = new TEXT_POSITION[1];
            EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));
            List<IDebugCodeContext2> codeContexts = new List<IDebugCodeContext2>();

            List<ulong> addresses = null;
            uint line = startPosition[0].dwLine + 1;
            _debuggedProcess.WorkerThread.RunOperation(async () =>
            {
                addresses = await DebuggedProcess.StartAddressesForLine(documentName, line);
            });

            if (addresses != null && addresses.Count > 0)
            {
                foreach (var a in addresses)
                {
                    var codeCxt = new AD7MemoryAddress(this, a, null);
                    TEXT_POSITION pos;
                    pos.dwLine = line;
                    pos.dwColumn = 0;
                    MITextPosition textPosition = new MITextPosition(documentName, pos, pos);
                    codeCxt.SetDocumentContext(new AD7DocumentContext(textPosition, codeCxt, this.DebuggedProcess));
                    codeContexts.Add(codeCxt);
                }
                if (codeContexts.Count > 0)
                {
                    ppEnum = new AD7CodeContextEnum(codeContexts.ToArray());
                    return Constants.S_OK;
                }
            }
            ppEnum = null;
            return Constants.E_FAIL;
        }
예제 #30
0
파일: AD7Engine.cs 프로젝트: Microsoft/RTVS
 int IDebugProgram3.EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum) {
     return IDebugProgram2.EnumCodeContexts(pDocPos, out ppEnum);
 }
예제 #31
0
 public int Clone(out IEnumDebugCodeContexts2 ppEnum)
 {
     ppEnum = null;
     return VSConstants.E_NOTIMPL;
 }
예제 #32
0
        public int EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
        {
            ppEnumCodeCxts = new MonoCodeContextEnumerator(new IDebugCodeContext2[] { _memory });

            return(S_OK);
        }
예제 #33
0
 public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
 {
     DebugHelper.TraceEnteringMethod();
     ppEnum = null;
     return(VSConstants.E_NOTIMPL);
 }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public int EnumCodeContexts (out IEnumDebugCodeContexts2 enumCodeContexts)
    {
      // 
      // Retrieves a list of all code contexts associated with this document context.
      // 

      LoggingUtils.PrintFunction ();

      try
      {
        IDebugCodeContext2 [] codeContexts;
        
        if (m_codeContext != null)
        {
          codeContexts = new IDebugCodeContext2 [] { m_codeContext };
        }
        else
        {
          codeContexts = new IDebugCodeContext2 [0];
        }

        enumCodeContexts = new DebuggeeCodeContext.Enumerator (codeContexts);

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

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

        enumCodeContexts = null;

        return Constants.E_FAIL;
      }
    }
 int IEnumDebugCodeContexts2.Clone(out IEnumDebugCodeContexts2 ppEnum)
 {
   Debug.WriteLine("AD7DocumentContext: Clone");
   throw new NotImplementedException();
 }
예제 #36
0
 int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts) {
     ppEnumCodeCxts = new AD7CodeContextEnum(new[] { Address });
     return VSConstants.S_OK;
 }
예제 #37
0
 public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
 {
     DLog.Debug(DContext.VSDebuggerComCall, "IDebugProgram2.EnumCodeContexts");
     throw new NotImplementedException();
 }
 int IDebugProgram2.EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
 {
   Debug.WriteLine("AD7ProgramNode: Entering EnumCodeContexts");
   throw new NotImplementedException();
 }
예제 #39
0
 // Retrieves a list of all code contexts associated with this document context.
 // The engine sample only supports one code context per document context and
 // the code contexts are always memory addresses.
 int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = null;
     return Constants.S_FALSE;
 }
 int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
   Debug.WriteLine("AD7DocumentContext: EnumCodeContexts");
   ppEnumCodeCxts = this;
   return VSConstants.S_OK;
 }
예제 #41
0
 /// <summary>
 /// Retrieves a list of the code contexts for a given position in a source file. Not implemented. 
 /// (http://msdn.microsoft.com/en-us/library/bb145902.aspx)
 /// </summary>
 /// <param name="pDocPos"> An object representing an abstract position in a source file known to the IDE. </param>
 /// <param name="ppEnum"> Returns an IEnumDebugCodeContexts2 object that contains a list of the code contexts. </param>
 /// <returns> Not implemented. </returns>
 public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
 {
     throw new Exception("The method or operation is not implemented.");
 }
 public int EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = null;
     return VSConstants.E_FAIL;
 }
예제 #43
0
 public int EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     Log.Debug("ScriptDocumentContext: EnumCodeContexts");
     ppEnumCodeCxts = this;
     return VSConstants.S_OK;
 }
예제 #44
0
 // Enumerates the code contexts for a given position in a source file.
 public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
 {
     throw new NotImplementedException();
 }
예제 #45
0
 public int EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = new CodeContextEnum(CodeContext != null ? new[] { CodeContext } : Enumerable.Empty<IDebugCodeContext2>());
     return VSConstants.S_OK;
 }
예제 #46
0
 public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum) {
     throw new NotImplementedException();
 }
예제 #47
0
        // Enumerates the code contexts for a given position in a source file.
        public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum) {
            DebugWriteCommand("EnumCodeContexts");

            string filename;
            pDocPos.GetFileName(out filename);
            TEXT_POSITION[] beginning = new TEXT_POSITION[1], end = new TEXT_POSITION[1];

            pDocPos.GetRange(beginning, end);

            ppEnum = new AD7CodeContextEnum(new[] { new AD7MemoryAddress(this, filename, (int)beginning[0].dwLine, (int)beginning[0].dwColumn) });
            return VSConstants.S_OK;
        }
 public int EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     throw new NotImplementedException();
 }
예제 #49
0
 public int EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = new CodeContextEnum(CodeContext != null ? new[] { CodeContext } : Enumerable.Empty <IDebugCodeContext2>());
     return(VSConstants.S_OK);
 }
예제 #50
0
        // Enumerates the code contexts for a given position in a source file.
        public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
        {
            if (_mixedMode) {
                ppEnum = null;
                return VSConstants.E_NOTIMPL;
            }

            string filename;
            pDocPos.GetFileName(out filename);
            TEXT_POSITION[] beginning = new TEXT_POSITION[1], end = new TEXT_POSITION[1];

            pDocPos.GetRange(beginning, end);

            ppEnum = new AD7CodeContextEnum(new[] { new AD7MemoryAddress(this, filename, (uint)beginning[0].dwLine) });
            return VSConstants.S_OK;
        }
 int Microsoft.VisualStudio.Debugger.Interop.IDebugProgram2.EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
 {
     ppEnum = null;
     return Utility.COM_HResults.S_OK;
 }
예제 #52
0
        public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
        {
            DLog.Debug(DContext.VSDebuggerComCall, "IDebugProgram2.EnumCodeContexts");

            ppEnum = null;

            string fileName;
            if (ErrorHandler.Failed(pDocPos.GetFileName(out fileName)))
                return VSConstants.E_INVALIDARG;
            var beginPosition = new TEXT_POSITION[1];
            var endPosition = new TEXT_POSITION[1];
            if (ErrorHandler.Failed(pDocPos.GetRange(beginPosition, endPosition)))
                return VSConstants.E_INVALIDARG;

            // Search matching document
            var doc = MapFile.FindDocument(fileName);
            if (doc == null)
                throw new ArgumentException("Unknown document " + fileName);

            DLog.Debug(DContext.VSDebuggerComCall, "document {0} positions {1}/{2} - {3}/{4}", fileName, (int)beginPosition[0].dwLine, (int)beginPosition[0].dwColumn, (int)endPosition[0].dwLine, (int)endPosition[0].dwColumn);

            // Search positions
            var documentPositions = doc.FindAll((int)beginPosition[0].dwLine + 1, (int)beginPosition[0].dwColumn + 1, (int)endPosition[0].dwLine + 1, (int)endPosition[0].dwColumn + 1)
                                       .ToList();

            if (documentPositions.Count == 0)
            {
                DLog.Debug(DContext.VSDebuggerComCall, "found nothing.");
                return VSConstants.E_FAIL;
            }

            List<DebugCodeContext> list = new List<DebugCodeContext>();

            foreach (var pos in documentPositions)
            {
                var loc = GetLocationFromPositionAsync(pos).Await(VmTimeout);
                if (loc == null)
                    continue;

                // only find one location per method.
                if(list.Any(c=>c.Location.IsSameMethod(loc.Location)))
                    continue;

                var ctx = new DebugCodeContext(loc.Location);
                ctx.DocumentContext = new DebugDocumentContext(loc, ctx);

                DLog.Debug(DContext.VSDebuggerComCall, "found {0}: {1}", loc.Description, loc.Location);
                list.Add(ctx);
            }

            DLog.Debug(DContext.VSDebuggerComCall, "done.");
            if (list.Count == 0)
                return VSConstants.E_FAIL;

            ppEnum = new CodeContextEnum(list);
            return VSConstants.S_OK;
        }
예제 #53
0
 // Enumerates the code contexts for a given position in a source file.
 public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #54
0
 public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
 {
     ppEnum = null;
     return(VSConstants.E_NOTIMPL);
 }
예제 #55
0
 /// <summary>
 /// Retrieves a list of all code contexts associated with this document context.
 /// </summary>
 /// <param name="ppEnumCodeCxts">Returns an IEnumDebugCodeContexts2 object that contains a list of code contexts.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 /// <remarks>A single document context can generate multiple code contexts when the document is using templates or include files.</remarks>
 public virtual int EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = null;
     return(VSConstants.E_NOTIMPL);
 }
예제 #56
0
        /// <summary>
        /// Retrieves a list of the code contexts for a given position in a source file.
        /// </summary>
        /// <param name="pDocPos">An IDebugDocumentPosition2 object representing an abstract position in a source file known to the IDE.</param>
        /// <param name="ppEnum">Returns an IEnumDebugCodeContexts2 object that contains a list of the code contexts.</param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
        /// <remarks>
        /// This method allows the session debug manager (SDM) or IDE to map a source file position into a code
        /// position. More than one code context is returned if the source generates multiple blocks of code (for
        /// example, C++ templates).
        /// </remarks>
        public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
        {
            if (pDocPos == null)
                throw new ArgumentNullException("pDocPos");

            string fileName = pDocPos.GetFileName();
            int lineNumber = pDocPos.GetRange().iStartLine + 1;

            List<IDebugCodeContext2> codeContexts = new List<IDebugCodeContext2>();
            IEnumerable<JavaDebugProgram> programs = DebugEngine.Programs.ToArray();
            foreach (var program in programs)
            {
                if (!program.IsLoaded)
                    continue;

                IVirtualMachine virtualMachine = program.VirtualMachine;
                ReadOnlyCollection<IReferenceType> classes = virtualMachine.GetAllClasses();
                foreach (var @class in classes)
                {
                    if ([email protected]())
                        continue;

                    ReadOnlyCollection<ILocation> locations = @class.GetLocationsOfLine(@class.GetDefaultStratum(), Path.GetFileName(fileName), lineNumber);
                    ILocation bindLocation = locations.OrderBy(i => i.GetCodeIndex()).FirstOrDefault();
                    if (bindLocation != null)
                        codeContexts.Add(new JavaDebugCodeContext(this, bindLocation));
                }
            }

            if (codeContexts.Count == 0)
            {
                ppEnum = null;
                return VSConstants.E_FAIL;
            }

            ppEnum = new EnumDebugCodeContexts(codeContexts);
            return VSConstants.S_OK;
        }
예제 #57
0
 /// <summary>
 /// Returns a copy of the current enumeration as a separate object.
 /// </summary>
 /// <param name="ppEnum">Returns a copy of this enumeration as a separate object.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 /// <remarks>The copy of the enumeration has the same state as the original at the time this method is called. However, the copy's and the original's states are separate and can be changed individually.</remarks>
 public virtual int Clone(out IEnumDebugCodeContexts2 ppEnum)
 {
     Logger.Debug(string.Empty);
     ppEnum = null;
     return(VSConstants.E_NOTIMPL);
 }
예제 #58
0
 // Retrieves a list of all code contexts associated with this document context.
 // The engine only supports one code context per document context.
 int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
 {
     ppEnumCodeCxts = new AD7DebugCodeContextEnum(new IDebugCodeContext2[] { this });
     return(VSConstants.S_OK);
 }
예제 #59
0
파일: AD7Engine.cs 프로젝트: Microsoft/RTVS
        int IDebugProgram2.EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum) {
            ThrowIfDisposed();

            string fileName;
            Marshal.ThrowExceptionForHR(pDocPos.GetFileName(out fileName));

            var start = new TEXT_POSITION[1];
            var end = new TEXT_POSITION[1];
            Marshal.ThrowExceptionForHR(pDocPos.GetRange(start, end));

            var addr = new AD7MemoryAddress(this, fileName, (int)start[0].dwLine);
            ppEnum = new AD7CodeContextEnum(new[] { addr });
            return VSConstants.S_OK;
        }