Esempio n. 1
0
        internal AD7DisassemblyStream(enum_DISASSEMBLY_STREAM_SCOPE scope, IDebugCodeContext2 pCodeContext)
        {
            _scope = scope;
            AD7MemoryAddress addr = pCodeContext as AD7MemoryAddress;

            _addr = addr.Address;
        }
Esempio n. 2
0
        public int Seek(enum_SEEK_START dwSeekStart, IDebugCodeContext2 pCodeContext, ulong uCodeLocationId, long iInstructions)
        {
            if (dwSeekStart == enum_SEEK_START.SEEK_START_CODECONTEXT)
            {
                AD7MemoryAddress addr = pCodeContext as AD7MemoryAddress;
                _addr = addr.Address;
            }
            else if (dwSeekStart == enum_SEEK_START.SEEK_START_CODELOCID)
            {
                _addr = (uint)uCodeLocationId;
            }

            if (iInstructions != 0)
            {
                DebuggedProcess process = DebuggedProcess.g_Process;
                IEnumerable <DisasmInstruction> instructions = null;
                process.WorkerThread.RunOperation(async() =>
                {
                    instructions = await process.Disassembly.FetchInstructions(_addr, (int)iInstructions);
                });
                if (instructions == null)
                {
                    return(Constants.E_FAIL);
                }
                _addr = instructions.ElementAt(0).Addr;
            }
            return(Constants.S_OK);
        }
Esempio n. 3
0
 public int GetCodeContext(out IDebugCodeContext2 codeContext)
 {
     codeContext = this.codeContext.Value;
     return(codeContext != null
         ? VSConstants.S_OK
         : VSConstants.E_FAIL);
 }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    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;
      }
    }
        public void SetUp()
        {
            _codeContextFactory     = Substitute.For <DebugCodeContext.Factory>();
            _documentContextFactory = Substitute.For <DebugDocumentContext.Factory>();

            _mockTarget      = Substitute.For <RemoteTarget>();
            _mockCodeContext = Substitute.For <IDebugCodeContext2>();
            // Mock the address getters. Unfortunately this has to be done on both
            // the IDebugCodeContext2 and IDebugMemoryContext2 interfaces.
            Action <CONTEXT_INFO[]> setContextInfo = infos =>
            {
                infos[0].bstrAddress = GetHexString(_testAddress);
                infos[0].dwFields    = enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS;
            };

            ((IDebugMemoryContext2)_mockCodeContext)
            .GetInfo(Arg.Any <enum_CONTEXT_INFO_FIELDS>(), Arg.Do(setContextInfo))
            .Returns(VSConstants.S_OK);
            _mockCodeContext.GetInfo(Arg.Any <enum_CONTEXT_INFO_FIELDS>(), Arg.Do(setContextInfo))
            .Returns(VSConstants.S_OK);

            _disassemblyStream = (DebugDisassemblyStream) new DebugDisassemblyStream
                                 .Factory(_codeContextFactory, _documentContextFactory)
                                 .Create(_testScope, _mockCodeContext, _mockTarget);
        }
Esempio n. 6
0
 public int GetDisassemblyStream(enum_DISASSEMBLY_STREAM_SCOPE dwScope, IDebugCodeContext2 pCodeContext,
                                 out IDebugDisassemblyStream2 ppDisassemblyStream)
 {
     DebugHelper.TraceEnteringMethod();
     ppDisassemblyStream = null;
     return(VSConstants.E_NOTIMPL);
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int EnumCodePaths(string pszHint, IDebugCodeContext2 pStart, IDebugStackFrame2 pFrame, int fSource, out IEnumCodePaths2 ppEnum, out IDebugCodeContext2 ppSafety)
        {
            //
            // Enumerates the code paths of this program.
            //

            LoggingUtils.PrintFunction();

            ppEnum = null;

            ppSafety = null;

            try
            {
                if (AttachedEngine == null)
                {
                    throw new InvalidOperationException();
                }

                LoggingUtils.RequireOk(AttachedEngine.NativeDebugger.NativeProgram.EnumCodePaths(pszHint, pStart, pFrame, fSource, out ppEnum, out ppSafety));

                //LoggingUtils.RequireOk (AttachedEngine.JavaDebugger.JavaProgram.EnumCodePaths (pszHint, pStart, pFrame, fSource, out ppEnum, out ppSafety));

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

                return(Constants.E_FAIL);
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int GetDisassemblyStream(enum_DISASSEMBLY_STREAM_SCOPE dwScope, IDebugCodeContext2 pCodeContext, out IDebugDisassemblyStream2 ppDisassemblyStream)
        {
            //
            // Gets the disassembly stream for this program or part of this program.
            //

            LoggingUtils.PrintFunction();

            ppDisassemblyStream = null;

            try
            {
                if (AttachedEngine == null)
                {
                    throw new InvalidOperationException();
                }

                LoggingUtils.RequireOk(AttachedEngine.NativeDebugger.NativeProgram.GetDisassemblyStream(dwScope, pCodeContext, out ppDisassemblyStream));

                //LoggingUtils.RequireOk (AttachedEngine.JavaDebugger.JavaProgram.GetDisassemblyStream (dwScope, pCodeContext, out ppDisassemblyStream));

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

                return(Constants.E_FAIL);
            }
        }
        public int GetCodeContext(ulong codeLocationId, out IDebugCodeContext2 codeContext)
        {
            // The codeContext is used, among other things, to link assembly instructions and
            // source code. The "Go To Source Code" functionality in disassembly view needs this
            // to be properly implemented.
            IDebugDocumentContext2 documentContext = null;

            if (_lineEntryCache.TryGetValue(codeLocationId, out LineEntryInfo lineEntry))
            {
                documentContext = _documentContextFactory.Create(lineEntry);
            }
            else
            {
                SbAddress address = _target.ResolveLoadAddress(codeLocationId);
                if (address != null)
                {
                    lineEntry       = address.GetLineEntry();
                    documentContext = _documentContextFactory.Create(lineEntry);
                }
            }

            string AddressToFuncName() =>
            _target.ResolveLoadAddress(codeLocationId)?.GetFunction()?.GetName() ??
            _codeContextName;

            codeContext = _codeContextFactory.Create(codeLocationId,
                                                     new Lazy <string>(AddressToFuncName),
                                                     documentContext, Guid.Empty);
            return(VSConstants.S_OK);
        }
Esempio n. 10
0
 public int /*IDebugProgram3*/ GetDisassemblyStream(
     enum_DISASSEMBLY_STREAM_SCOPE dwScope,
     IDebugCodeContext2 pCodeContext,
     out IDebugDisassemblyStream2 ppDisassemblyStream)
 {
     throw new NotImplementedException();
 }
 public void SetUp()
 {
     _mockDocumentContext      = Substitute.For <IDebugDocumentContext2>();
     _mockMemoryContextFactory = Substitute.For <DebugMemoryContext.Factory>();
     _codeContext = new DebugCodeContext.Factory(_mockMemoryContextFactory)
                    .Create(_testPc, _testName, _mockDocumentContext, Guid.Empty);
 }
Esempio n. 12
0
 public int GetDisassemblyStream(
     enum_DISASSEMBLY_STREAM_SCOPE scope, IDebugCodeContext2 codeContext,
     out IDebugDisassemblyStream2 disassemblyStream)
 {
     disassemblyStream = null;
     return(VSConstants.E_NOTIMPL);
 }
Esempio n. 13
0
        public int GetCodeLocationId(IDebugCodeContext2 pCodeContext, out ulong puCodeLocationId)
        {
            AD7MemoryAddress addr = pCodeContext as AD7MemoryAddress;

            puCodeLocationId = addr.Address;
            return(Constants.S_OK);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        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);
            }
        }
Esempio n. 15
0
        public int Seek(enum_SEEK_START dwSeekStart, IDebugCodeContext2 pCodeContext, ulong uCodeLocationId, long iInstructions)
        {
            if (dwSeekStart == enum_SEEK_START.SEEK_START_CODECONTEXT)
            {
                AD7MemoryAddress addr = pCodeContext as AD7MemoryAddress;
                _addr = addr.Address;
            }
            else if (dwSeekStart == enum_SEEK_START.SEEK_START_CODELOCID)
            {
                _addr = (uint)uCodeLocationId;
            }

            //if (iInstructions != 0)
            //{
            //    IEnumerable<DisasmInstruction> instructions = null;
            //    _engine.DebuggedProcess.WorkerThread.RunOperation(async () =>
            //    {
            //        instructions = await _engine.DebuggedProcess.Disassembly.FetchInstructions(_addr, (int)iInstructions);
            //    });
            //    if (instructions == null)
            //    {
            //        return VSConstants.E_FAIL;
            //    }
            //    _addr = instructions.ElementAt(0).Addr;
            //}
            return(VSConstants.S_OK);
        }
Esempio n. 16
0
 public int EnumCodePaths(string pszHint, IDebugCodeContext2 pStart, IDebugStackFrame2 pFrame, int fSource,
                          out IEnumCodePaths2 ppEnum, out IDebugCodeContext2 ppSafety)
 {
     ppEnum   = null;
     ppSafety = null;
     return(VSConstants.E_NOTIMPL);
 }
Esempio n. 17
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int GetCodeLocationId(IDebugCodeContext2 pCodeContext, out ulong puCodeLocationId)
        {
            //
            // Returns a code location identifier for a particular code context.
            //

            LoggingUtils.PrintFunction();

            try
            {
                CONTEXT_INFO [] contextInfoArray = new CONTEXT_INFO [1];

                LoggingUtils.RequireOk(pCodeContext.GetInfo(enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE, contextInfoArray));

                if (contextInfoArray [0].bstrAddressAbsolute.StartsWith("0x"))
                {
                    puCodeLocationId = ulong.Parse(contextInfoArray [0].bstrAddressAbsolute.Substring(2), NumberStyles.HexNumber);
                }
                else
                {
                    puCodeLocationId = ulong.Parse(contextInfoArray [0].bstrAddressAbsolute, NumberStyles.HexNumber);
                }

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

                puCodeLocationId = 0ul;

                return(Constants.E_FAIL);
            }
        }
Esempio n. 18
0
        // Sets the next statement to the given stack frame and code context.
        int IDebugThread2.SetNextStatement(IDebugStackFrame2 stackFrame, IDebugCodeContext2 codeContext)
        {
            // CLRDBG TODO: This implementation should be changed to call an MI command
            ulong         addr  = ((AD7MemoryAddress)codeContext).Address;
            AD7StackFrame frame = ((AD7StackFrame)stackFrame);

            if (frame.ThreadContext.Level != 0 || frame.Thread != this || !frame.ThreadContext.pc.HasValue || _engine.DebuggedProcess.MICommandFactory.Mode == MIMode.Clrdbg)
            {
                return(Constants.S_FALSE);
            }
            string toFunc   = EngineUtils.GetAddressDescription(_engine.DebuggedProcess, addr);
            string fromFunc = EngineUtils.GetAddressDescription(_engine.DebuggedProcess, frame.ThreadContext.pc.Value);

            if (toFunc != fromFunc)
            {
                return(Constants.S_FALSE);
            }
            string result = frame.EvaluateExpression("$pc=" + EngineUtils.AsAddr(addr));

            if (result != null)
            {
                _engine.DebuggedProcess.ThreadCache.MarkDirty();
                return(Constants.S_OK);
            }
            return(Constants.S_FALSE);
        }
Esempio n. 19
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);
            }
        }
        public int GetCodeLocationId(IDebugCodeContext2 pCodeContext, out ulong puCodeLocationId)
        {
            var location = ((DebugCodeContext)pCodeContext).Location;

            puCodeLocationId = location.Index;
            return(VSConstants.S_OK);
        }
Esempio n. 21
0
 public int EnumCodePaths(string pszHint, IDebugCodeContext2 pStart, IDebugStackFrame2 pFrame, int fSource, out IEnumCodePaths2 ppEnum, out IDebugCodeContext2 ppSafety)
 {
     DLog.Debug(DContext.VSDebuggerComCall, "IDebugProgram2.EnumCodePaths");
     ppEnum   = null;
     ppSafety = null;
     return(VSConstants.E_NOTIMPL);
 }
 public virtual IDebugDisassemblyStream2 Create(enum_DISASSEMBLY_STREAM_SCOPE scope,
                                                IDebugCodeContext2 codeContext,
                                                RemoteTarget target)
 {
     return(new DebugDisassemblyStream(_codeContextFactory, _documentContextFactory,
                                       scope, codeContext, target));
 }
Esempio n. 23
0
        public int CanSetNextStatement(IDebugStackFrame2 pStackFrame, IDebugCodeContext2 pCodeContext)
        {
            DLog.Debug(DContext.VSDebuggerComCall, "IDebugThread2.CanSetNextStatement");

            var stack = (DebugStackFrame)pStackFrame;
            var ctx = (DebugCodeContext)pCodeContext;

            if (stack == null || ctx == null)
                return VSConstants.E_FAIL;

            if (ctx.Location.Equals(stack.Location))
                return VSConstants.S_OK;

            if (!ctx.Location.IsSameMethod(stack.Location))
                return HResults.E_CANNOT_SETIP_TO_DIFFERENT_FUNCTION;

            // for now, only allow to set the position above the current position.
            if(ctx.Location.Index >= stack.Location.Index)
                return VSConstants.E_FAIL;

            // don't check existence of special code, so that we can produce a warning
            // below.

            //var loc = stack.GetDocumentLocationAsync().Await(DalvikProcess.VmTimeout);
            //if (loc.Document == null)
            //    return VSConstants.E_FAIL;

            return VSConstants.S_OK;
        }
Esempio n. 24
0
 internal AD7DisassemblyStream(AD7Engine engine, enum_DISASSEMBLY_STREAM_SCOPE scope, IDebugCodeContext2 pCodeContext)
 {
     _engine = engine;
     _scope = scope;
     AD7MemoryAddress addr = pCodeContext as AD7MemoryAddress;
     _addr = addr.Address;
 }
Esempio n. 25
0
 /// <summary>
 ///     EnumCodePaths is used for the step-into specific feature -- right click on the current statment and decide which
 ///     function to step into. This is not something that the SampleEngine supports.
 /// </summary>
 /// <param name="hint">The hint.</param>
 /// <param name="start">The start.</param>
 /// <param name="frame">The frame.</param>
 /// <param name="fSource">The f source.</param>
 /// <param name="pathEnum">The path enum.</param>
 /// <param name="safetyContext">The safety context.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 public int EnumCodePaths(string hint, IDebugCodeContext2 start, IDebugStackFrame2 frame, int fSource,
                          out IEnumCodePaths2 pathEnum, out IDebugCodeContext2 safetyContext)
 {
     pathEnum      = null;
     safetyContext = null;
     return(E_NOTIMPL);
 }
Esempio n. 26
0
        // Sets the next statement to the given stack frame and code context.
        int IDebugThread2.SetNextStatement(IDebugStackFrame2 stackFrame, IDebugCodeContext2 codeContext)
        {
            ulong         addr  = ((AD7MemoryAddress)codeContext).Address;
            AD7StackFrame frame = ((AD7StackFrame)stackFrame);

            if (frame.ThreadContext.Level != 0 || frame.Thread != this || !frame.ThreadContext.pc.HasValue)
            {
                return(Constants.S_FALSE);
            }
            string toFunc   = EngineUtils.GetAddressDescription(_engine.DebuggedProcess, addr);
            string fromFunc = EngineUtils.GetAddressDescription(_engine.DebuggedProcess, frame.ThreadContext.pc.Value);

            if (toFunc != fromFunc)
            {
                return(Constants.S_FALSE);
            }
            string result = frame.EvaluateExpression("$pc=" + EngineUtils.AsAddr(addr, _engine.DebuggedProcess.Is64BitArch));

            if (result != null)
            {
                _engine.DebuggedProcess.ThreadCache.MarkDirty();
                return(Constants.S_OK);
            }
            return(Constants.S_FALSE);
        }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public CLangDebuggeeDisassemblyStream (CLangDebugger debugger, enum_DISASSEMBLY_STREAM_SCOPE streamScope, IDebugCodeContext2 codeContext)
    {
      m_debugger = debugger;

      m_streamScope = streamScope;

      m_codeContext = codeContext as DebuggeeCodeContext;
    }
Esempio n. 28
0
 /// <summary>
 /// Gets the disassembly stream for this program or a part of this program.
 /// </summary>
 /// <param name="dwScope"> Specifies a value from the DISASSEMBLY_STREAM_SCOPE enumeration that defines the scope of the disassembly stream.</param>
 /// <param name="pCodeContext">An IDebugCodeContext2 object that represents the position of where to start the disassembly stream.</param>
 /// <param name="ppDisassemblyStream">Returns an IDebugDisassemblyStream2 object that represents the disassembly stream.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code. Returns E_DISASM_NOTSUPPORTED if disassembly is not supported for this particular architecture.</returns>
 /// <remarks>
 /// If the dwScopes parameter has the DSS_HUGE flag of the DISASSEMBLY_STREAM_SCOPE enumeration set, then the disassembly is expected to return a large number of disassembly instructions, for example, for an entire file or module. If the DSS_HUGE flag is not set, then the disassembly is expected to be confined to a small region, typically that of a single function.
 /// </remarks>
 public virtual int GetDisassemblyStream(enum_DISASSEMBLY_STREAM_SCOPE dwScope,
                                         IDebugCodeContext2 pCodeContext,
                                         out IDebugDisassemblyStream2 ppDisassemblyStream)
 {
     Logger.Debug(string.Empty);
     ppDisassemblyStream = null;
     return(VSConstants.E_NOTIMPL);
 }
Esempio n. 29
0
 public int GetDisassemblyStream(
     enum_DISASSEMBLY_STREAM_SCOPE scope, IDebugCodeContext2 codeContext,
     out IDebugDisassemblyStream2 disassemblyStream)
 {
     disassemblyStream = _debugDisassemblyStreamFactory.Create(
         scope, codeContext, _lldbTarget);
     return(VSConstants.S_OK);
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int GetDisassemblyStream(enum_DISASSEMBLY_STREAM_SCOPE dwScope, IDebugCodeContext2 pCodeContext, out IDebugDisassemblyStream2 ppDisassemblyStream)
        {
            LoggingUtils.PrintFunction();

            ppDisassemblyStream = null;

            return(Constants.E_NOTIMPL);
        }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public int GetDisassemblyStream (enum_DISASSEMBLY_STREAM_SCOPE dwScope, IDebugCodeContext2 pCodeContext, out IDebugDisassemblyStream2 ppDisassemblyStream)
    {
      LoggingUtils.PrintFunction ();

      ppDisassemblyStream = new CLangDebuggeeDisassemblyStream (m_debugger, dwScope, pCodeContext);

      return Constants.S_OK;
    }
Esempio n. 32
0
 public int EnumCodePaths(
     string hint, IDebugCodeContext2 start, IDebugStackFrame2 frame, int source,
     out IEnumCodePaths2 pathsEnum, out IDebugCodeContext2 safety)
 {
     pathsEnum = null;
     safety    = null;
     return(VSConstants.E_NOTIMPL);
 }
        /// <summary>
        /// Returns a code context object corresponding to a specified code location identifier.
        /// </summary>
        /// <param name="uCodeLocationId">
        /// [in] Specifies the code location identifier. See the Remarks section for the
        /// IDebugDisassemblyStream2.GetCodeLocationId method for a description of a code location identifier.
        /// </param>
        /// <param name="ppCodeContext">[out] Returns an IDebugCodeContext2 object that represents the associated code context.</param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
        /// <remarks>
        /// The code location identifier can be returned from a call to the IDebugDisassemblyStream2.GetCurrentLocation
        /// method and can appear in the DisassemblyData structure.
        /// 
        /// To convert a code context into a code location identifier, call the IDebugDisassemblyStream2.GetCodeLocationId
        /// method.
        /// </remarks>
        public int GetCodeContext(ulong uCodeLocationId, out IDebugCodeContext2 ppCodeContext)
        {
            ppCodeContext = null;
            if (uCodeLocationId > (uint)_bytecode.Length)
                return VSConstants.E_INVALIDARG;

            ppCodeContext = new JavaDebugCodeContext(_executionContext.Program, _executionContext.Location.GetMethod().GetLocationOfCodeIndex((long)uCodeLocationId));
            return VSConstants.S_OK;
        }
Esempio n. 34
0
 public int /*IDebugProgram3*/ EnumCodePaths(string pszHint,
                                             IDebugCodeContext2 pStart,
                                             IDebugStackFrame2 pFrame,
                                             int fSource,
                                             out IEnumCodePaths2 ppEnum,
                                             out IDebugCodeContext2 ppSafety)
 {
     throw new NotImplementedException();
 }
Esempio n. 35
0
 DebugBreakpointResolution(IDebugCodeContext2 codeContext, IDebugProgram2 program)
 {
     _codeContext           = codeContext;
     _program               = program;
     _location.bpType       = (uint)enum_BP_TYPE.BPT_CODE;
     _location.unionmember1 =
         System.Runtime.InteropServices.Marshal.GetComInterfaceForObject(
             codeContext, typeof(IDebugCodeContext2));
 }
        public BreakpointResolutionLocationCode(BP_RESOLUTION_LOCATION location, bool releaseComObjects)
        {
            if (location.bpType != (uint)enum_BP_TYPE.BPT_CODE)
                throw new ArgumentException();

            try
            {
                if (location.unionmember1 != IntPtr.Zero)
                    _codeContext = Marshal.GetObjectForIUnknown(location.unionmember1) as IDebugCodeContext2;
            }
            finally
            {
                if (releaseComObjects && location.unionmember1 != IntPtr.Zero)
                    Marshal.Release(location.unionmember1);
            }
        }
        public BreakpointLocationCodeContext(BP_LOCATION location, bool releaseComObjects)
        {
            Contract.Requires<ArgumentException>((enum_BP_LOCATION_TYPE)location.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_CODE_CONTEXT);

            try
            {
                if (location.unionmember1 != IntPtr.Zero)
                    _codeContext = Marshal.GetObjectForIUnknown(location.unionmember2) as IDebugCodeContext2;
            }
            finally
            {
                if (releaseComObjects)
                {
                    if (location.unionmember1 != IntPtr.Zero)
                        Marshal.Release(location.unionmember1);
                }
            }
        }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public override int SetNextStatement (IDebugStackFrame2 stackFrame, IDebugCodeContext2 codeContext)
    {
      // 
      // Sets the next statement to the given stack frame and code context.
      // 

      LoggingUtils.PrintFunction ();

      try
      {
        throw new NotImplementedException ();

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

        return Constants.E_FAIL;
      }
    }
Esempio n. 39
0
        public int GetCodeContext(ulong uCodeLocationId, out IDebugCodeContext2 ppCodeContext)
        {
            ppCodeContext = null;

            if (_method == null)
                return HResults.E_DISASM_NOTAVAILABLE;

            var location = _loc.Location.GetAtIndex((uint)uCodeLocationId);
            var ctx = new DebugCodeContext(location);

            // try to set source code.
            var source = _method.FindSourceCode((int)uCodeLocationId);
            if(source != null)
            {
                var docLoc = new DocumentLocation(location, source, _loc.ReferenceType, _loc.Method, _method.TypeEntry, _method.MethodEntry);
                ctx.DocumentContext = new DebugDocumentContext(docLoc, ctx);
            }

            ppCodeContext = ctx;
            return VSConstants.S_OK;
        }
Esempio n. 40
0
 // Determines whether the next statement can be set to the given stack frame and code context.
 int IDebugThread2.CanSetNextStatement(IDebugStackFrame2 stackFrame, IDebugCodeContext2 codeContext)
 {
     // CLRDBG TODO: This implementation should be changed to compare the method token
     ulong addr = ((AD7MemoryAddress)codeContext).Address;
     AD7StackFrame frame = ((AD7StackFrame)stackFrame);
     if (frame.ThreadContext.Level != 0 || frame.Thread != this || !frame.ThreadContext.pc.HasValue || _engine.DebuggedProcess.MICommandFactory.Mode == MIMode.Clrdbg)
     {
         return Constants.S_FALSE;
     }
     if (addr == frame.ThreadContext.pc)
     {
         return Constants.S_OK;
     }
     string toFunc = EngineUtils.GetAddressDescription(_engine.DebuggedProcess, addr);
     string fromFunc = EngineUtils.GetAddressDescription(_engine.DebuggedProcess, frame.ThreadContext.pc.Value);
     if (toFunc != fromFunc)
     {
         return Constants.S_FALSE;
     }
     return Constants.S_OK;
 }
 int Microsoft.VisualStudio.Debugger.Interop.IDebugProgram2.GetDisassemblyStream(uint dwScope, IDebugCodeContext2 pCodeContext, out IDebugDisassemblyStream2 ppDisassemblyStream)
 {
     ppDisassemblyStream = null;
     return Utility.COM_HResults.S_OK;
 }
Esempio n. 42
0
 /// <summary>
 /// Gets the disassembly stream for this program or a part of this program.
 /// The sample engine does not support dissassembly so it returns E_NOTIMPL
 /// </summary>
 /// <param name="dwScope"> Specifies a value from the DISASSEMBLY_STREAM_SCOPE enumeration that defines the scope of the 
 /// disassembly stream.</param>
 /// <param name="codeContext"> An object that represents the position of where to start the disassembly stream. </param>
 /// <param name="disassemblyStream"> Returns an IDebugDisassemblyStream2 object that represents the disassembly stream. </param>
 /// <returns> VSConstants.E_NOTIMPL. </returns>
 public int GetDisassemblyStream(enum_DISASSEMBLY_STREAM_SCOPE dwScope, IDebugCodeContext2 codeContext, out IDebugDisassemblyStream2 disassemblyStream)
 {
     disassemblyStream = null;
     return VSConstants.E_NOTIMPL;
 }
Esempio n. 43
0
 public int SetNextStatement(IDebugStackFrame2 pStackFrame, IDebugCodeContext2 pCodeContext)
 {
     return VSConstants.S_FALSE;
 }
Esempio n. 44
0
 public int GetCodeContext(out IDebugCodeContext2 ppCodeCxt)
 {
     DLog.Debug(DContext.VSDebuggerComCall, "DebugStackFrame.GetCodeContext");
     ppCodeCxt = GetDocumentContext().CodeContext;
     return VSConstants.S_OK;
 }
 /// <summary>
 /// Returns the next set of elements from the enumeration.
 /// </summary>
 /// <param name="celt">The number of elements to retrieve. Also specifies the maximum size of the rgelt array.</param>
 /// <param name="rgelt">Array of IDebugCodeContext2 elements to be filled in.</param>
 /// <param name="pceltFetched">Returns the number of elements actually returned in rgelt.</param>
 /// <returns>If successful, returns S_OK. Returns S_FALSE if fewer than the requested number of elements could be returned; otherwise, returns an error code.</returns>
 public virtual int Next( uint celt, IDebugCodeContext2[] rgelt, ref uint pceltFetched )
 {
     Logger.Debug( string.Empty );
     return VSConstants.E_NOTIMPL;
 }
Esempio n. 46
0
 // EnumCodePaths is used for the step-into specific feature -- right click on the current statment and decide which
 // function to step into. This is not something that the SampleEngine supports.
 public int EnumCodePaths(string hint, IDebugCodeContext2 start, IDebugStackFrame2 frame, int fSource, out IEnumCodePaths2 pathEnum, out IDebugCodeContext2 safetyContext)
 {
     pathEnum = null;
     safetyContext = null;
     return Constants.E_NOTIMPL;
 }
Esempio n. 47
0
 public int EnumCodePaths(IDebugThread2 pThread, IDebugCodeContext2 pStart, /*enum_STEPUNIT*/uint stepUnit, out IEnumDebugCodePaths90 ppEnum)
 {
     throw new NotImplementedException();
 }
Esempio n. 48
0
 int IDebugThread2.CanSetNextStatement(IDebugStackFrame2 pStackFrame, IDebugCodeContext2 pCodeContext) {
     ThrowIfDisposed();
     return VSConstants.S_FALSE;
 }
Esempio n. 49
0
 int IDebugThread2.SetNextStatement(IDebugStackFrame2 pStackFrame, IDebugCodeContext2 pCodeContext) {
     return VSConstants.E_NOTIMPL;
 }
Esempio n. 50
0
 public int GetDisassemblyStream(enum_DISASSEMBLY_STREAM_SCOPE dwScope, IDebugCodeContext2 pCodeContext, out IDebugDisassemblyStream2 ppDisassemblyStream) {
     throw new NotImplementedException();
 }
Esempio n. 51
0
 public int EnumCodePaths(string pszHint, IDebugCodeContext2 pStart, IDebugStackFrame2 pFrame, int fSource, out IEnumCodePaths2 ppEnum, out IDebugCodeContext2 ppSafety) {
     throw new NotImplementedException();
 }
 // Determines whether the next statement can be set to the given stack frame and code context.
 // NOTE: VS2013 and earlier do not use the result to disable the "set next statement" command
 int IDebugThread2.CanSetNextStatement(IDebugStackFrame2 stackFrame, IDebugCodeContext2 codeContext) {
     throw new NotSupportedException("Set Next Statement is not supported by Node.js.");
 }
Esempio n. 53
0
 int IDebugThread2.CanSetNextStatement(IDebugStackFrame2 pStackFrame, IDebugCodeContext2 pCodeContext)
 {
     return VSConstants.S_OK;
 }
Esempio n. 54
0
        // Gets the code context for this stack frame. The code context represents the current instruction pointer in this stack frame.
        int IDebugStackFrame2.GetCodeContext(out IDebugCodeContext2 memoryAddress)
        {
            memoryAddress = _codeCxt;
            if (memoryAddress == null)
            {
                return Constants.E_FAIL; // annotated frame
            }

            return Constants.S_OK;
        }
Esempio n. 55
0
 int IDebugProgram3.EnumCodePaths(string pszHint, IDebugCodeContext2 pStart, IDebugStackFrame2 pFrame, int fSource, out IEnumCodePaths2 ppEnum, out IDebugCodeContext2 ppSafety)
 {
     throw new NotSupportedException("This method has been replaced by IDebugProgramEnhancedStep90.EnumCodePaths.");
 }
Esempio n. 56
0
 // Sets the next statement to the given stack frame and code context.
 int IDebugThread2.SetNextStatement(IDebugStackFrame2 stackFrame, IDebugCodeContext2 codeContext)
 {
     // CLRDBG TODO: This implementation should be changed to call an MI command
     ulong addr = ((AD7MemoryAddress)codeContext).Address;
     AD7StackFrame frame = ((AD7StackFrame)stackFrame);
     if (frame.ThreadContext.Level != 0 || frame.Thread != this || !frame.ThreadContext.pc.HasValue || _engine.DebuggedProcess.MICommandFactory.Mode == MIMode.Clrdbg)
     {
         return Constants.S_FALSE;
     }
     string toFunc = EngineUtils.GetAddressDescription(_engine.DebuggedProcess, addr);
     string fromFunc = EngineUtils.GetAddressDescription(_engine.DebuggedProcess, frame.ThreadContext.pc.Value);
     if (toFunc != fromFunc)
     {
         return Constants.S_FALSE;
     }
     string result = frame.EvaluateExpression("$pc=" + EngineUtils.AsAddr(addr));
     if (result != null)
     {
         _engine.DebuggedProcess.ThreadCache.MarkDirty();
         return Constants.S_OK;
     }
     return Constants.S_FALSE;
 }
Esempio n. 57
0
        public int GetDisassemblyStream(enum_DISASSEMBLY_STREAM_SCOPE dwScope, IDebugCodeContext2 pCodeContext, out IDebugDisassemblyStream2 ppDisassemblyStream)
        {
            ppDisassemblyStream = null;

            if (pCodeContext == null)
                throw new ArgumentNullException("pCodeContext");

            JavaDebugCodeContext codeContext = pCodeContext as JavaDebugCodeContext;
            if (codeContext == null)
                return VSConstants.E_INVALIDARG;

            ppDisassemblyStream = new JavaDebugDisassemblyStream(codeContext);
            return VSConstants.S_OK;
        }
Esempio n. 58
0
 public int GetCodeContext(out IDebugCodeContext2 ppCodeCxt)
 {
     ppCodeCxt = docContext;
     return VSConstants.S_OK;
 }
Esempio n. 59
0
 // The debugger calls this when it needs to obtain the IDebugDisassemblyStream2 for a particular code-context.
 // The sample engine does not support dissassembly so it returns E_NOTIMPL
 // In order for this to be called, the Disassembly capability must be set in the registry for this Engine
 public int GetDisassemblyStream(enum_DISASSEMBLY_STREAM_SCOPE dwScope, IDebugCodeContext2 codeContext, out IDebugDisassemblyStream2 disassemblyStream)
 {
     disassemblyStream = new AD7DisassemblyStream(this, dwScope, codeContext);
     return Constants.S_OK;
 }
Esempio n. 60
0
 public int EnumCodePaths(string pszHint, IDebugCodeContext2 pStart, IDebugStackFrame2 pFrame, int fSource,
     out IEnumCodePaths2 ppEnum, out IDebugCodeContext2 ppSafety)
 {
     ppEnum = null;
     ppSafety = null;
     return VSConstants.E_NOTIMPL;
 }