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

    public int ReadAt (IDebugMemoryContext2 pStartContext, uint dwCount, byte [] rgbMemory, out uint pdwRead, ref uint pdwUnreadable)
    {
      // 
      // Reads a sequence of bytes, starting at a given location.
      // 

      LoggingUtils.PrintFunction ();

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

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

        string command = string.Format ("-data-read-memory-bytes {0} {1}", contextInfoArray [0].bstrAddressAbsolute, dwCount);

        MiResultRecord resultRecord = m_debugger.GdbClient.SendSyncCommand (command);

        MiResultRecord.RequireOk (resultRecord, command);

        MiResultValueList memoryStreamList = (MiResultValueList) resultRecord ["memory"] [0];

        for (int s = 0; s < memoryStreamList.Values.Count; ++s)
        {
          if (!memoryStreamList [s].HasField ("contents"))
          {
            throw new InvalidOperationException ("-data-read-memory-bytes result missing 'contents' field");
          }

          string hexValue = memoryStreamList [s] ["contents"] [0].GetString ();

          if ((hexValue.Length / 2) != dwCount)
          {
            throw new InvalidOperationException ();
          }

          for (int i = 0; i < dwCount; ++i)
          {
            rgbMemory [i] = byte.Parse (hexValue.Substring (i * 2, 2), NumberStyles.HexNumber);
          }
        }

        pdwRead = dwCount;

        pdwUnreadable = 0;

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

        pdwRead = 0;

        pdwUnreadable = dwCount;

        return Constants.E_FAIL;
      }
    }
 /// <summary>
 /// Compares the memory context to each context in the given array in the manner indicated by compare flags, returning an index of the first context that matches.
 /// </summary>
 /// <param name="Compare">A value from the CONTEXT_COMPARE enumeration that determines the type of comparison.</param>
 /// <param name="rgpMemoryContextSet">An array of references to the IDebugMemoryContext2 objects to compare against.</param>
 /// <param name="dwMemoryContextSetLen">The number of contexts in the rgpMemoryContextSet array.</param>
 /// <param name="pdwMemoryContext">Returns the index of the first memory context that satisfies the comparison.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code. Returns E_COMPARE_CANNOT_COMPARE if the two contexts cannot be compared.</returns>
 /// <remarks>A debug engine (DE) does not have to support all types of comparisons, but it must support at least CONTEXT_EQUAL, CONTEXT_LESS_THAN, CONTEXT_GREATER_THAN and CONTEXT_SAME_SCOPE.</remarks>
 public virtual int Compare( enum_CONTEXT_COMPARE Compare,
     IDebugMemoryContext2[] rgpMemoryContextSet,
     uint dwMemoryContextSetLen,
     out uint pdwMemoryContext)
 {
     Logger.Debug( string.Empty );
     pdwMemoryContext = 0;
     return VSConstants.E_NOTIMPL;
 }
Example #3
0
        public int Compare(enum_CONTEXT_COMPARE Compare, IDebugMemoryContext2[] rgpMemoryContextSet, uint dwMemoryContextSetLen, out uint pdwMemoryContext)
        {
            for(int i = 0; i < dwMemoryContextSetLen; ++i)
            {
                pdwMemoryContext = (uint)i;
                var other = rgpMemoryContextSet[i] as DebugCodeContext;
                if (other == null)
                    return HResults.E_COMPARE_CANNOT_COMPARE;

                var isSameMethod = Equals(Location.Class, other.Location.Class) && Equals(Location.Method, other.Location.Method);

                switch (Compare)
                {
                    case enum_CONTEXT_COMPARE.CONTEXT_EQUAL:
                        if (location.Equals(other.Location))
                            return VSConstants.S_OK;
                        break;
                    case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN:
                        if (!isSameMethod) return HResults.E_COMPARE_CANNOT_COMPARE;

                        if(Location.CompareTo(other.Location) > 0)
                            return VSConstants.S_OK;
                        break;
                    case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN_OR_EQUAL:
                        if (!isSameMethod) return HResults.E_COMPARE_CANNOT_COMPARE;
                        if (Location.CompareTo(other.Location) >= 0)
                            return VSConstants.S_OK;
                        break;
                    case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN:
                        if (!isSameMethod) return HResults.E_COMPARE_CANNOT_COMPARE;
                        if (Location.CompareTo(other.Location) < 0)
                            return VSConstants.S_OK;
                        break;
                    case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN_OR_EQUAL:
                        if (!isSameMethod) return HResults.E_COMPARE_CANNOT_COMPARE;
                        if (Location.CompareTo(other.Location) <= 0)
                            return VSConstants.S_OK;
                        break;
                    case enum_CONTEXT_COMPARE.CONTEXT_SAME_PROCESS:
                    case enum_CONTEXT_COMPARE.CONTEXT_SAME_MODULE:
                        return VSConstants.S_OK;
                    case enum_CONTEXT_COMPARE.CONTEXT_SAME_FUNCTION:
                        if(isSameMethod)
                            return VSConstants.S_OK;
                        break;
                    case enum_CONTEXT_COMPARE.CONTEXT_SAME_SCOPE:
                        // TODO: analyze scopes.
                        if(isSameMethod)
                            return VSConstants.S_OK;
                        break;
                }
            }

            pdwMemoryContext = (uint)0;
            return VSConstants.S_FALSE;
        }
Example #4
0
        int IDebugMemoryContext2.Compare(enum_CONTEXT_COMPARE Compare, IDebugMemoryContext2[] rgpMemoryContextSet, uint dwMemoryContextSetLen, out uint pdwMemoryContext) {
            pdwMemoryContext = 0;

            for (int i = 0; i < rgpMemoryContextSet.Length; ++i) {
                var other = rgpMemoryContextSet[i] as AD7MemoryAddress;
                if (other == null || other.Engine != Engine) {
                    continue;
                }

                bool match = false;
                switch (Compare) {
                    case enum_CONTEXT_COMPARE.CONTEXT_EQUAL:
                        match = (LineNumber == other.LineNumber);
                        break;
                    case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN:
                        match = (LineNumber < other.LineNumber);
                        break;
                    case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN_OR_EQUAL:
                        match = (LineNumber <= other.LineNumber);
                        break;
                    case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN:
                        match = (LineNumber > other.LineNumber);
                        break;
                    case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN_OR_EQUAL:
                        match = (LineNumber >= other.LineNumber);
                        break;
                    case enum_CONTEXT_COMPARE.CONTEXT_SAME_PROCESS:
                        match = true;
                        break;
                    case enum_CONTEXT_COMPARE.CONTEXT_SAME_MODULE:
                        match = (FileName == other.FileName);
                        break;
                    case enum_CONTEXT_COMPARE.CONTEXT_SAME_FUNCTION:
                    case enum_CONTEXT_COMPARE.CONTEXT_SAME_SCOPE:
                        match = (LineNumber == other.LineNumber && FileName == other.FileName);
                        break;
                    default:
                        return VSConstants.E_NOTIMPL;
                }

                if (match) {
                    pdwMemoryContext = (uint)i;
                    return VSConstants.S_OK;
                }
            }

            return VSConstants.S_FALSE;
        }
 // Adds a specified value to the current context's address to create a new context.
 public int Add(ulong dwCount, out IDebugMemoryContext2 newAddress)
 {
     newAddress = new AD7MemoryAddress(_engine, (uint)dwCount + _address, null);
     return(VSConstants.S_OK);
 }
Example #6
0
 // Token: 0x060000B0 RID: 176 RVA: 0x00003B0F File Offset: 0x00001D0F
 public int Add(ulong dwCount, out IDebugMemoryContext2 newAddress)
 {
     newAddress = new AD7MemoryAddress(this.m_engine, (ulong)((uint)dwCount) + this.m_address);
     return(0);
 }
Example #7
0
 int IDebugProperty3.GetMemoryContext(out IDebugMemoryContext2 ppMemory) {
     return IDebugProperty2.GetMemoryContext(out ppMemory);
 }
Example #8
0
 // Subtracts a specified value from the current context's address to create a new context.
 public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     ppMemCxt = new AD7MemoryAddress(_engine, _address - (uint)dwCount, null);
     return Constants.S_OK;
 }
Example #9
0
 /// <summary>
 /// Returns the memory context for a property value. (http://msdn.microsoft.com/en-ca/library/bb147028.aspx)
 /// Not implemented. 
 /// </summary>
 /// <param name="ppMemory"> Returns the IDebugMemoryContext2 object that represents the memory associated with this property. </param>
 /// <returns> Not implemented. </returns>
 public int GetMemoryContext(out IDebugMemoryContext2 ppMemory)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Example #10
0
 int IDebugMemoryContext2.Add(ulong dwCount, out IDebugMemoryContext2 ppMemCxt) {
     ppMemCxt = new AD7MemoryAddress(Engine, FileName, LineNumber + (int)dwCount);
     return VSConstants.S_OK;
 }
 public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     throw new NotImplementedException();
 }
Example #12
0
 int IDebugProperty3.GetMemoryContext(out IDebugMemoryContext2 ppMemory)
 {
     return(IDebugProperty2.GetMemoryContext(out ppMemory));
 }
Example #13
0
 // Subtracts a specified value from the current context's address to create a new context.
 public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     ppMemCxt = new AD7MemoryAddress(_engine, _filename, (uint)dwCount - _lineNo);
     return(VSConstants.S_OK);
 }
Example #14
0
 int IDebugCodeContext2.Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     return(IDebugMemoryContext2.Subtract(dwCount, out ppMemCxt));
 }
Example #15
0
 int IDebugMemoryContext2.Add(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     ppMemCxt = new AD7MemoryAddress(Engine, FileName, LineNumber + (int)dwCount);
     return(VSConstants.S_OK);
 }
Example #16
0
 int IDebugCodeContext2.GetName(out string pbstrName)
 {
     return(IDebugMemoryContext2.GetName(out pbstrName));
 }
Example #17
0
 int IDebugCodeContext2.GetInfo(enum_CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO[] pinfo)
 {
     return(IDebugMemoryContext2.GetInfo(dwFields, pinfo));
 }
Example #18
0
 int IDebugCodeContext2.Compare(enum_CONTEXT_COMPARE Compare, IDebugMemoryContext2[] rgpMemoryContextSet, uint dwMemoryContextSetLen, out uint pdwMemoryContext)
 {
     return(IDebugMemoryContext2.Compare(Compare, rgpMemoryContextSet, dwMemoryContextSetLen, out pdwMemoryContext));
 }
        // Compares the memory context to each context in the given array in the manner indicated by compare flags, 
        // returning an index of the first context that matches.
        public int Compare(enum_CONTEXT_COMPARE uContextCompare, IDebugMemoryContext2[] compareToItems, uint compareToLength, out uint foundIndex)
        {
            foundIndex = uint.MaxValue;

            try
            {
                enum_CONTEXT_COMPARE contextCompare = (enum_CONTEXT_COMPARE)uContextCompare;

                for (uint c = 0; c < compareToLength; c++)
                {
                    AD7MemoryAddress compareTo = compareToItems[c] as AD7MemoryAddress;
                    if (compareTo == null)
                    {
                        continue;
                    }

                    if (!AD7Engine.ReferenceEquals(this.m_engine, compareTo.m_engine))
                    {
                        continue;
                    }

                    bool result;

                    switch (contextCompare)
                    {
                        case enum_CONTEXT_COMPARE.CONTEXT_EQUAL:
                            result = (this.m_address == compareTo.m_address);
                            break;

                        case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN:
                            result = (this.m_address < compareTo.m_address);
                            break;

                        case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN:
                            result = (this.m_address > compareTo.m_address);
                            break;

                        case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN_OR_EQUAL:
                            result = (this.m_address <= compareTo.m_address);
                            break;

                        case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN_OR_EQUAL:
                            result = (this.m_address >= compareTo.m_address);
                            break;

                        // The sample debug engine doesn't understand scopes or functions
                        case enum_CONTEXT_COMPARE.CONTEXT_SAME_SCOPE:
                        case enum_CONTEXT_COMPARE.CONTEXT_SAME_FUNCTION:
                            result = (this.m_address == compareTo.m_address);
                            break;

                        case enum_CONTEXT_COMPARE.CONTEXT_SAME_MODULE:
                            result = (this.m_address == compareTo.m_address);
                            if (result == false)
                            {
                                //DebuggedModule module = m_engine.DebuggedProcess.ResolveAddress(m_address);

                                //if (module != null)
                                //{
                                //    result = (compareTo.m_address >= module.BaseAddress) &&
                                //        (compareTo.m_address < module.BaseAddress + module.Size);
                                //}
                            }
                            break;

                        case enum_CONTEXT_COMPARE.CONTEXT_SAME_PROCESS:
                            result = true;
                            break;

                        default:
                            // A new comparison was invented that we don't support
                            return VSConstants.E_NOTIMPL;
                    }

                    if (result)
                    {
                        foundIndex = c;
                        return VSConstants.S_OK;
                    }
                }

                return VSConstants.S_FALSE;
            }
            //catch (ComponentException e)
            //{
            //    return e.HResult;
            //}
            catch (Exception e)
            {
                return EngineUtils.UnexpectedException(e);
            }
        }
Example #20
0
 // Subtracts a specified value from the current context's address to create a new context.
 public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     ppMemCxt = new AD7MemoryAddress(m_engine, (uint)dwCount - m_address);
     return(EngineConstants.S_OK);
 }
Example #21
0
 int IDebugCodeContext2.Compare(enum_CONTEXT_COMPARE Compare, IDebugMemoryContext2[] rgpMemoryContextSet, uint dwMemoryContextSetLen, out uint pdwMemoryContext) {
     return IDebugMemoryContext2.Compare(Compare, rgpMemoryContextSet, dwMemoryContextSetLen, out pdwMemoryContext);
 }
Example #22
0
 // Adds a specified value to the current context's address to create a new context.
 public int Add(ulong dwCount, out IDebugMemoryContext2 newAddress)
 {
     newAddress = new AD7MemoryAddress(m_engine, (uint)dwCount + m_address);
     return(EngineConstants.S_OK);
 }
Example #23
0
 // Adds a specified value to the current context's address to create a new context.
 public int Add(ulong dwCount, out IDebugMemoryContext2 newAddress)
 {
     newAddress = new AD7MemoryAddress(this._engine, this._frame, this._fileName, this._line + (int)dwCount, this._column);
     return(VSConstants.S_OK);
 }
Example #24
0
 // Get a memory context for this property within the memory bytes returned by GetMemoryBytes
 public void GetMemoryContext(out IDebugMemoryContext2 ppMemory)
 {
     throw new Exception("Not Implemented Yet");
 }
 public int Compare(enum_CONTEXT_COMPARE Compare, IDebugMemoryContext2[] rgpMemoryContextSet, uint dwMemoryContextSetLen, out uint pdwMemoryContext)
 {
     pdwMemoryContext = 0;
     return VSConstants.E_FAIL;
 }
Example #26
0
 public int GetMemoryContext(out IDebugMemoryContext2 ppMemory)
 {
     throw new NotImplementedException();
 }
Example #27
0
        // Compares the memory context to each context in the given array in the manner indicated by compare flags,
        // returning an index of the first context that matches.
        public int Compare(enum_CONTEXT_COMPARE contextCompare, IDebugMemoryContext2[] compareToItems, uint compareToLength, out uint foundIndex)
        {
            foundIndex = uint.MaxValue;

            try
            {
                for (uint c = 0; c < compareToLength; c++)
                {
                    AD7MemoryAddress compareTo = compareToItems[c] as AD7MemoryAddress;
                    if (compareTo == null)
                    {
                        continue;
                    }

                    if (!AD7Engine.ReferenceEquals(_engine, compareTo._engine))
                    {
                        continue;
                    }

                    bool result;

                    switch (contextCompare)
                    {
                        case enum_CONTEXT_COMPARE.CONTEXT_EQUAL:
                            result = (_address == compareTo._address);
                            break;

                        case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN:
                            result = (_address < compareTo._address);
                            break;

                        case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN:
                            result = (_address > compareTo._address);
                            break;

                        case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN_OR_EQUAL:
                            result = (_address <= compareTo._address);
                            break;

                        case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN_OR_EQUAL:
                            result = (_address >= compareTo._address);
                            break;

                        // The debug engine doesn't understand scopes
                        case enum_CONTEXT_COMPARE.CONTEXT_SAME_SCOPE:
                            result = (_address == compareTo._address);
                            break;

                        case enum_CONTEXT_COMPARE.CONTEXT_SAME_FUNCTION:
                            if (_address == compareTo._address)
                            {
                                result = true;
                                break;
                            }
                            string funcThis = Engine.GetAddressDescription(_address);
                            if (string.IsNullOrEmpty(funcThis))
                            {
                                result = false;
                                break;
                            }
                            string funcCompareTo = Engine.GetAddressDescription(compareTo._address);
                            result = (funcThis == funcCompareTo);
                            break;

                        case enum_CONTEXT_COMPARE.CONTEXT_SAME_MODULE:
                            result = (_address == compareTo._address);
                            if (result == false)
                            {
                                DebuggedModule module = _engine.DebuggedProcess.ResolveAddress(_address);

                                if (module != null)
                                {
                                    result = module.AddressInModule(compareTo._address);
                                }
                            }
                            break;

                        case enum_CONTEXT_COMPARE.CONTEXT_SAME_PROCESS:
                            result = true;
                            break;

                        default:
                            // A new comparison was invented that we don't support
                            return Constants.E_NOTIMPL;
                    }

                    if (result)
                    {
                        foundIndex = c;
                        return Constants.S_OK;
                    }
                }

                return Constants.S_FALSE;
            }
            catch (MIException e)
            {
                return e.HResult;
            }
            catch (Exception e)
            {
                return EngineUtils.UnexpectedException(e);
            }
        }
Example #28
0
 int IDebugProperty2.GetMemoryContext(out IDebugMemoryContext2 ppMemory)
 {
     ppMemory = null;
     return(VSConstants.E_NOTIMPL);
 }
Example #29
0
        public int ReadAt(IDebugMemoryContext2 pStartContext, uint dwCount, byte[] rgbMemory, out uint pdwRead, ref uint pdwUnreadable)
        {
            pdwUnreadable = 0;
            AD7MemoryAddress addr = (AD7MemoryAddress)pStartContext;
            uint bytesRead = 0;
            int hr = Constants.S_OK;
            DebuggedProcess.WorkerThread.RunOperation(async () =>
            {
                bytesRead = await DebuggedProcess.ReadProcessMemory(addr.Address, dwCount, rgbMemory);
            });

            if (bytesRead == uint.MaxValue)
            {
                bytesRead = 0;
            }

            if (bytesRead < dwCount) // copied from Concord
            {
                // assume 4096 sized pages: ARM has 4K or 64K pages
                uint pageSize = 4096;
                ulong readEnd = addr.Address + bytesRead;
                ulong nextPageStart = (readEnd + pageSize - 1) / pageSize * pageSize;
                if (nextPageStart == readEnd)
                {
                    nextPageStart = readEnd + pageSize;
                }
                // if we have crossed a page boundry - Unreadable = bytes till end of page
                uint maxUnreadable = dwCount - bytesRead;
                if (addr.Address + dwCount > nextPageStart)
                {
                    pdwUnreadable = (uint)Math.Min(maxUnreadable, nextPageStart - readEnd);
                }
                else
                {
                    pdwUnreadable = (uint)Math.Min(maxUnreadable, pageSize);
                }
            }
            pdwRead = bytesRead;
            return hr;
        }
Example #30
0
 public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     throw new NotImplementedException();
 }
Example #31
0
 int IDebugProperty2.GetMemoryContext(out IDebugMemoryContext2 ppMemory) {
     ppMemory = null;
     return VSConstants.E_NOTIMPL;
 }
 /// <summary>
 ///     Subtracts a specified value from the current context's address to create a new context.
 /// </summary>
 /// <param name="dwCount">The count.</param>
 /// <param name="ppMemCxt">The memory context.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     ppMemCxt = new MonoMemoryAddress(_engine, (uint)dwCount - _address, _documentContext);
     return(S_OK);
 }
 // Subtracts a specified value from the current context's address to create a new context.
 public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     ppMemCxt = new AD7MemoryAddress(_engine, _address - (uint)dwCount, null);
     return(VSConstants.S_OK);
 }
 /// <summary>
 ///     Adds a specified value to the current context's address to create a new context.
 /// </summary>
 /// <param name="dwCount">The count.</param>
 /// <param name="newAddress">The new address.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 public int Add(ulong dwCount, out IDebugMemoryContext2 newAddress)
 {
     newAddress = new MonoMemoryAddress(_engine, (uint)dwCount + _address, _documentContext);
     return(S_OK);
 }
 // Subtracts a specified value from the current context's address to create a new context.
 public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     ppMemCxt = new AD7MemoryAddress(m_engine, (uint)dwCount - m_address);
     return VSConstants.S_OK;
 }
Example #36
0
        /// <summary>
        /// Compares the memory context to each context in the given array in the manner indicated by compare flags, returning an index of the first context that matches.
        /// </summary>
        /// <param name="Compare">[in] A value from the CONTEXT_COMPARE enumeration that determines the type of comparison.</param>
        /// <param name="rgpMemoryContextSet">[in] An array of references to the IDebugMemoryContext2 objects to compare against.</param>
        /// <param name="dwMemoryContextSetLen">[in] The number of contexts in the rgpMemoryContextSet array.</param>
        /// <param name="pdwMemoryContext">[out] Returns the index of the first memory context that satisfies the comparison.</param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code. Returns E_COMPARE_CANNOT_COMPARE if the two contexts cannot be compared.</returns>
        /// <remarks>
        /// A debug engine (DE) does not have to support all types of comparisons, but it must support at least CONTEXT_EQUAL, CONTEXT_LESS_THAN, CONTEXT_GREATER_THAN and CONTEXT_SAME_SCOPE.
        /// </remarks>
        public int Compare(enum_CONTEXT_COMPARE Compare, IDebugMemoryContext2[] rgpMemoryContextSet, uint dwMemoryContextSetLen, out uint pdwMemoryContext)
        {
            if (rgpMemoryContextSet == null)
                throw new ArgumentNullException("rgpMemoryContextSet");
            if (rgpMemoryContextSet.Length < dwMemoryContextSetLen)
                throw new ArgumentException();

            pdwMemoryContext = 0;

            bool relational = false;
            switch (Compare)
            {
            case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN:
            case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN_OR_EQUAL:
            case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN:
            case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN_OR_EQUAL:
                relational = true;
                break;
            }

            JavaDebugCodeContext[] contexts = new JavaDebugCodeContext[dwMemoryContextSetLen];
            for (int i = 0; i < contexts.Length; i++)
            {
                if (rgpMemoryContextSet[i] == null)
                    return VSConstants.E_INVALIDARG;

                contexts[i] = rgpMemoryContextSet[i] as JavaDebugCodeContext;
                if (contexts[i] == null)
                    return AD7Constants.E_COMPARE_CANNOT_COMPARE;

                // relational tests only work if the contexts are in the same scope
                if (relational && !this.Location.GetMethod().Equals(contexts[i].Location.GetMethod()))
                    return AD7Constants.E_COMPARE_CANNOT_COMPARE;
            }

            int index;

            switch (Compare)
            {
            case enum_CONTEXT_COMPARE.CONTEXT_EQUAL:
                index = Array.FindIndex(contexts, i => this.Location.Equals(i.Location));
                break;

            case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN:
                index = Array.FindIndex(contexts, i => i.Location.GetCodeIndex() > this.Location.GetCodeIndex());
                break;

            case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN_OR_EQUAL:
                index = Array.FindIndex(contexts, i => i.Location.GetCodeIndex() >= this.Location.GetCodeIndex());
                break;

            case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN:
                index = Array.FindIndex(contexts, i => i.Location.GetCodeIndex() < this.Location.GetCodeIndex());
                break;

            case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN_OR_EQUAL:
                index = Array.FindIndex(contexts, i => i.Location.GetCodeIndex() <= this.Location.GetCodeIndex());
                break;

            case enum_CONTEXT_COMPARE.CONTEXT_SAME_FUNCTION:
                index = Array.FindIndex(contexts, i => this.Location.GetMethod().Equals(i.Location.GetMethod()));
                break;

            case enum_CONTEXT_COMPARE.CONTEXT_SAME_MODULE:
                throw new NotImplementedException();

            case enum_CONTEXT_COMPARE.CONTEXT_SAME_PROCESS:
                index = Array.FindIndex(contexts, i => this.Program.Process == i.Program.Process);
                break;

            case enum_CONTEXT_COMPARE.CONTEXT_SAME_SCOPE:
                index = Array.FindIndex(contexts, i => this.Location.GetMethod().Equals(i.Location.GetMethod()));
                break;

            default:
                throw new ArgumentException();
            }

            if (index < 0)
            {
                return VSConstants.E_FAIL;
            }

            pdwMemoryContext = (uint)index;
            return VSConstants.S_OK;
        }
Example #37
0
 int IDebugCodeContext2.Add(ulong dwCount, out IDebugMemoryContext2 ppMemCxt) {
     return IDebugMemoryContext2.Add(dwCount, out ppMemCxt);
 }
Example #38
0
 int IDebugMemoryBytesDAP.CreateMemoryContext(ulong address, out IDebugMemoryContext2 ppResult)
 {
     ppResult = new AD7MemoryAddress(this, address, null);
     return(Constants.S_OK);
 }
Example #39
0
 int IDebugCodeContext2.Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt) {
     return IDebugMemoryContext2.Subtract(dwCount, out ppMemCxt);
 }
Example #40
0
 public int GetMemoryContext(out IDebugMemoryContext2 ppMemory)
 {
     ppMemory = null;
     return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
 }
Example #41
0
 public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     ppMemCxt = null;
     return(VSConstants.E_NOTIMPL);
 }
Example #42
0
 // Subtracts a specified value from the current context's address to create a new context.
 public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     ppMemCxt = new AD7MemoryAddress(this._engine, this._frame, this._fileName, this._line - (int)dwCount, this._column);
     return(VSConstants.S_OK);
 }
 /// <summary>
 /// Adds the specified value to the current context and returns a new context.
 /// </summary>
 /// <param name="dwCount">The value to add to the current context.</param>
 /// <param name="ppMemCxt"> Returns a new IDebugMemoryContext2 object.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 /// <remarks>
 /// A memory context is an address, so adding a value to an address produces a new address that requires a new context interface.
 /// 
 /// This method must always produce a new context, even if the resulting address is outside the memory space associated with this context. The only exception to this is if no memory can be allocated for the new context or if ppMemCxt is a null value (which is an error).
 /// </remarks>
 public virtual int Add( ulong dwCount, out IDebugMemoryContext2 ppMemCxt )
 {
     Logger.Debug( string.Empty );
     ppMemCxt = null;
     return VSConstants.E_NOTIMPL;
 }
 int IDebugCodeContext2.Add(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     Debug.WriteLine("AD7DocumentContext: Add");
     throw new NotImplementedException();
 }
 public int GetMemoryContext(out IDebugMemoryContext2 ppMemory)
 {
     throw new NotImplementedException();
 }
 int IDebugMemoryContext2.Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     Debug.WriteLine("AD7DocumentContext: Subtract");
     throw new NotImplementedException();
 }
Example #47
0
 // Returns the memory context for a property value.
 public int GetMemoryContext(out IDebugMemoryContext2 ppMemory)
 {
     ppMemory = null;
     if (_variableInformation.Error)
         return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
     // try to interpret the result as an address
     string v = _variableInformation.Value;
     v = v.Trim();
     if (v.Length == 0)
     {
         return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
     }
     if (v[0] == '{')
     {
         // strip type name and trailing spaces
         v = v.Substring(v.IndexOf('}') + 1);
         v = v.Trim();
     }
     int i = v.IndexOf(' ');
     if (i > 0)
     {
         v = v.Substring(0, i);
     }
     uint addr;
     if (!UInt32.TryParse(v, System.Globalization.NumberStyles.Any, null, out addr))
     {
         if (v.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
         {
             v = v.Substring(2);
             if (!UInt32.TryParse(v, System.Globalization.NumberStyles.AllowHexSpecifier, null, out addr))
             {
                 return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
             }
         }
         else
         {
             return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
         }
     }
     ppMemory = new AD7MemoryAddress(DebuggedProcess.g_Process.Engine, addr, null);
     return Constants.S_OK;
 }
Example #48
0
 public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     Log.Debug("ScriptDocumentContext: IDebugCodeContext2.Subtract");
     ppMemCxt = null;
     return(VSConstants.E_NOTIMPL);
 }
 public int Compare(enum_CONTEXT_COMPARE Compare, IDebugMemoryContext2[] rgpMemoryContextSet,
     uint dwMemoryContextSetLen, out uint pdwMemoryContext)
 {
     throw new NotImplementedException();
 }
Example #50
0
 // Get a memory context for this property within the memory bytes returned by GetMemoryBytes
 public  void GetMemoryContext(out IDebugMemoryContext2 ppMemory) {
   throw new Exception("Not Implemented Yet");
 }
 public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     ppMemCxt = null;
     return VSConstants.E_FAIL;
 }
Example #52
0
 public int GetMemoryContext(out IDebugMemoryContext2 ppMemory)
 {
     ppMemory = null;
     return(Constants.E_NOTIMPL);
 }
Example #53
0
 // Adds a specified value to the current context's address to create a new context.
 public int Add(ulong dwCount, out IDebugMemoryContext2 newAddress)
 {
     newAddress = new AD7MemoryAddress(_engine, (uint)dwCount + _address, null);
     return Constants.S_OK;
 }
Example #54
0
 public int GetMemoryContext(out IDebugMemoryContext2 ppMemory)
 {
     ppMemory = null;
     return(AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT);
 }
Example #55
0
 public int ReadAt(IDebugMemoryContext2 pStartContext, uint dwCount, byte[] rgbMemory, out uint pdwRead, ref uint pdwUnreadable)
 {
     throw new NotImplementedException();
 }
Example #56
0
 // Returns the memory context for a property value.
 public int GetMemoryContext(out IDebugMemoryContext2 ppMemory)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Example #57
0
 // Returns the memory context for a property value.
 public int GetMemoryContext(out IDebugMemoryContext2 ppMemory) {
     ppMemory = null;
     return VSConstants.E_NOTIMPL;
 }
Example #58
0
 public int WriteAt(IDebugMemoryContext2 pStartContext, uint dwCount, byte[] rgbMemory)
 {
     throw new NotImplementedException();
 }
Example #59
0
 public int WriteAt(IDebugMemoryContext2 pStartContext, uint dwCount, byte[] rgbMemory)
 {
     throw new NotImplementedException();
 }
Example #60
0
 public int Subtract(ulong count, out IDebugMemoryContext2 newMemoryContext)
 {
     newMemoryContext = _factory.Create(_address - count, _filename);
     return(VSConstants.S_OK);
 }