Ejemplo n.º 1
0
        //TODO: If decompiler settings change, we need to invalidate the cached data in DbgEvaluationContext, see decompiler.Settings.VersionChanged
        DbgLanguageDebugInfo GetOrCreateDebugInfo(DbgEvaluationContext context, RuntimeState state, IDbgDotNetCodeLocation location, CancellationToken cancellationToken)
        {
            DbgLanguageDebugInfoKey key;

            if (location.DbgModule is DbgModule dbgModule)
            {
                key = new DbgLanguageDebugInfoKey(dbgModule, location.Token);
            }
            else
            {
                key = new DbgLanguageDebugInfoKey(location.Module, location.Token);
            }

            var debugInfos = state.DebugInfos;

            lock (state.LockObj) {
                if (debugInfos.Count > 0 && debugInfos[0].debugInfo.MethodDebugInfo.DebugInfoVersion != decompiler.Settings.Version)
                {
                    debugInfos.Clear();
                }
                for (int i = debugInfos.Count - 1; i >= 0; i--)
                {
                    var info = debugInfos[i];
                    if (info.key.Equals(key))
                    {
                        if (i != debugInfos.Count - 1)
                        {
                            debugInfos.RemoveAt(i);
                            debugInfos.Add(info);
                        }
                        return(info.debugInfo);
                    }
                }
            }

            var debugInfo = CreateDebugInfo(context, location, cancellationToken);

            if (debugInfo == null)
            {
                return(null);
            }
            lock (state.LockObj) {
                if (debugInfos.Count == RuntimeState.MAX_CACHED_DEBUG_INFOS)
                {
                    debugInfos.RemoveAt(0);
                }
                debugInfos.Add((key, debugInfo));
            }
            return(debugInfo);
        }
Ejemplo n.º 2
0
        DbgLanguageDebugInfo GetOrCreateDebugInfo(RuntimeState state, IDbgDotNetCodeLocation location, CancellationToken cancellationToken)
        {
            DbgLanguageDebugInfoKey key;

            if (location.DbgModule is DbgModule dbgModule)
            {
                key = new DbgLanguageDebugInfoKey(dbgModule, location.Token);
            }
            else
            {
                key = new DbgLanguageDebugInfoKey(location.Module, location.Token);
            }

            var debugInfos = state.DebugInfos;

            lock (state.LockObj) {
                for (int i = debugInfos.Count - 1; i >= 0; i--)
                {
                    var info = debugInfos[i];
                    if (info.key.Equals(key))
                    {
                        if (i != debugInfos.Count - 1)
                        {
                            debugInfos.RemoveAt(i);
                            debugInfos.Add(info);
                        }
                        return(info.debugInfo);
                    }
                }
            }

            var debugInfo = CreateDebugInfo(location, cancellationToken);

            if (debugInfo == null)
            {
                return(null);
            }
            lock (state.LockObj) {
                if (debugInfos.Count == RuntimeState.MAX_CACHED_DEBUG_INFOS)
                {
                    debugInfos.RemoveAt(0);
                }
                debugInfos.Add((key, debugInfo));
            }
            return(debugInfo);
        }
Ejemplo n.º 3
0
 public bool Equals(DbgLanguageDebugInfoKey other) =>
 token == other.token &&
 module == other.module &&
 refreshedVersion == other.refreshedVersion &&
 moduleId == other.moduleId;
Ejemplo n.º 4
0
 public bool Equals(DbgLanguageDebugInfoKey other) =>
 token == other.token &&
 module == other.module &&
 moduleId == other.moduleId;