Beispiel #1
0
        public ImportedMethod TryImportCurrentMethod()
        {
            if (_currentMethod != null)
            {
                return(_currentMethod);
            }

            IntPtr metadataBlock;
            uint   blockSize;

            try
            {
                metadataBlock = InstructionAddress.ModuleInstance.GetMetaDataBytesPtr(out blockSize);
            }
            catch (DkmException)
            {
                // This can fail when dump debugging if the full heap is not available
                return(null);
            }

            ImportedModule module = Session.Importer.ImportModule(metadataBlock, blockSize);

            _currentMethod = module.GetMethod(InstructionAddress.MethodId.Token);
            return(_currentMethod);
        }
Beispiel #2
0
 private void EnsureMethods()
 {
     if (_methods == null)
     {
         _methods = new List <ImportedMethod>();
         foreach (MethodDefinitionHandle methodHandle in _typeDef.GetMethods())
         {
             ImportedMethod method = Module.ResolveMethod(methodHandle, this);
             _methods.Add(method);
         }
     }
 }
Beispiel #3
0
        public LocalVariable[] GetLocals()
        {
            if (_cachedLocals != null)
            {
                return(_cachedLocals);
            }

            ImportedMethod method = TryImportCurrentMethod();

            _cachedLocals = GetLocalsImpl(method).ToArray();

            return(_cachedLocals);
        }
        internal ImportedMethod ResolveMethod(MethodDefinitionHandle handle, ImportedType declaringType = null)
        {
            ImportedMethod method;

            if (!_resolvedMethods.TryGetValue(handle, out method))
            {
                MethodDefinition methodDef = _reader.GetMethodDefinition(handle);
                if (declaringType == null)
                {
                    declaringType = ResolveType(methodDef.GetDeclaringType());
                }
                var name    = methodDef.Name;
                var strName = this.Reader.GetString(name);
                method = new ImportedMethod(this, methodDef, declaringType);
                _resolvedMethods.Add(handle, method);
            }

            return(method);
        }
Beispiel #5
0
 private IEnumerable <LocalVariable> GetLocalsImpl(ImportedMethod method)
 {
     if (method != null)
     {
         // Get the local symbols from the PDB (symbol file).  If symbols aren't loaded, we
         // can't show any local variables
         DkmClrLocalVariable[] symbols = GetLocalSymbolsFromPdb().ToArray();
         if (symbols.Length != 0)
         {
             // To determine the local types, we need to decode the local variable signature
             // token.  Get the token from the debugger, then use our importer
             // to get the variables types.  We can then construct the correlated list of local
             // types and names.
             int localVarSigToken = InstructionAddress.ModuleInstance.GetLocalSignatureToken(CurrentMethodToken);
             ImmutableArray <XSharpType> localTypes = method.Module.DecodeLocalVariableTypes(localVarSigToken);
             foreach (DkmClrLocalVariable localSymbol in symbols)
             {
                 int slot = localSymbol.Slot;
                 yield return(new LocalVariable(localSymbol.Name, localTypes[slot], slot));
             }
         }
     }
 }