コード例 #1
0
 public MonoDocumentContext(string fileName, TEXT_POSITION start, TEXT_POSITION end, MonoMemoryAddress address)
 {
     this.fileName = fileName;
     this.start    = start;
     this.end      = end;
     this.address  = address;
 }
コード例 #2
0
        public MonoDocumentContext GetDocumentContext(uint address)
        {
            var    docPosition = (IDebugDocumentPosition2)Marshal.GetObjectForIUnknown(requestInfo.bpLocation.unionmember2);
            string documentName;

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

            // Get the location in the document that the breakpoint is in.
            var startPosition = new TEXT_POSITION[1];
            var endPosition   = new TEXT_POSITION[1];

            EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));

            MonoMemoryAddress codeContext = new MonoMemoryAddress(breakpointManager.Engine, address, null);

            return(new MonoDocumentContext(documentName, startPosition[0], endPosition[0], codeContext));
        }
コード例 #3
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 = null;

            try
            {
                memoryAddress = new MonoMemoryAddress(engine, (uint)frame.Address, null);
                return(VSConstants.S_OK);
            }
            catch (ComponentException e)
            {
                return(e.HResult);
            }
            catch (Exception e)
            {
                return(EngineUtils.UnexpectedException(e));
            }
        }
コード例 #4
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));
     }
 }
コード例 #5
0
        public int GetResolutionInfo(enum_BPRESI_FIELDS fields, BP_RESOLUTION_INFO[] resolutionInfo)
        {
            if ((fields & enum_BPRESI_FIELDS.BPRESI_BPRESLOCATION) != 0)
            {
                // The sample engine only supports code breakpoints.
                var location = new BP_RESOLUTION_LOCATION();
                location.bpType = (uint)enum_BP_TYPE.BPT_CODE;

                // The debugger will not QI the IDebugCodeContex2 interface returned here. We must pass the pointer
                // to IDebugCodeContex2 and not IUnknown.
                MonoMemoryAddress codeContext = new MonoMemoryAddress(engine, address, documentContext);
                location.unionmember1           = Marshal.GetComInterfaceForObject(codeContext, typeof(IDebugCodeContext2));
                resolutionInfo[0].bpResLocation = location;
                resolutionInfo[0].dwFields     |= enum_BPRESI_FIELDS.BPRESI_BPRESLOCATION;
            }


            return(VSConstants.S_OK);
        }
コード例 #6
0
        public int Compare(enum_CONTEXT_COMPARE compare, IDebugMemoryContext2[] compareToItems, uint compareToLength, out uint foundIndex)
        {
            foundIndex = uint.MaxValue;

            try
            {
                enum_CONTEXT_COMPARE contextCompare = compare;

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

                    if (!ReferenceEquals(this.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 sample debug engine doesn't understand scopes or functions
                    case enum_CONTEXT_COMPARE.CONTEXT_SAME_SCOPE:
                    case enum_CONTEXT_COMPARE.CONTEXT_SAME_FUNCTION:
                        result = address == compareTo.address;
                        break;

                    case enum_CONTEXT_COMPARE.CONTEXT_SAME_MODULE:
                        result = address == compareTo.address;
                        if (!result)
                        {
/*
 *                              DebuggedModule module = engine.DebuggedProcess.ResolveAddress(address);
 *
 *                              if (module != null)
 *                              {
 *                                  result = (compareTo.address >= module.BaseAddress) &&
 *                                      (compareTo.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));
            }
        }
コード例 #7
0
 public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
 {
     ppMemCxt = new MonoMemoryAddress(engine, (uint)dwCount - address, documentContext);
     return(VSConstants.S_OK);
 }
コード例 #8
0
 public int Add(ulong dwCount, out IDebugMemoryContext2 newAddress)
 {
     newAddress = new MonoMemoryAddress(engine, (uint)dwCount + address, documentContext);
     return(VSConstants.S_OK);
 }