Example #1
0
 internal void Add_DbgThread(DbgAppDomainImpl appDomain)
 {
     Dispatcher.VerifyAccess();
     lock (lockObj)
         appDomains.Add(appDomain);
     AppDomainsChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgAppDomain>(appDomain, added: true));
 }
Example #2
0
        public override DbgEngineAppDomain CreateAppDomain <T>(DbgInternalAppDomain internalAppDomain, string name, int id, DbgEngineMessageFlags messageFlags, T data, Action <DbgEngineAppDomain> onCreated)
        {
            if (disposed)
            {
                throw new ObjectDisposedException(nameof(DbgObjectFactoryImpl));
            }
            var appDomain = new DbgAppDomainImpl(runtime, internalAppDomain, name, id);

            if (data != null)
            {
                appDomain.GetOrCreateData(() => data);
            }
            var engineAppDomain = new DbgEngineAppDomainImpl(appDomain);

            onCreated?.Invoke(engineAppDomain);
            owner.Dispatcher.BeginInvoke(() => owner.AddAppDomain_DbgThread(runtime, appDomain, messageFlags));
            return(engineAppDomain);
        }
Example #3
0
 public DbgModuleImpl(DbgRuntimeImpl runtime, DbgAppDomainImpl appDomain, DbgInternalModule internalModule, bool isExe, ulong address, uint size, DbgImageLayout imageLayout, string name, string filename, bool isDynamic, bool isInMemory, bool?isOptimized, int order, DateTime?timestamp, string version)
 {
     lockObj          = new object();
     this.runtime     = runtime ?? throw new ArgumentNullException(nameof(runtime));
     this.appDomain   = appDomain;
     InternalModule   = internalModule ?? throw new ArgumentNullException(nameof(internalModule));
     this.isExe       = isExe;
     this.address     = address;
     this.size        = size;
     this.imageLayout = imageLayout;
     this.name        = name;
     this.filename    = filename;
     this.isDynamic   = isDynamic;
     this.isInMemory  = isInMemory;
     this.isOptimized = isOptimized;
     this.order       = order;
     this.timestamp   = timestamp?.ToUniversalTime();
     this.version     = version;
 }
Example #4
0
        internal void Remove_DbgThread(DbgAppDomainImpl appDomain, DbgEngineMessageFlags messageFlags)
        {
            Dispatcher.VerifyAccess();
            List <DbgThread>?threadsToRemove = null;
            List <DbgModule>?modulesToRemove = null;

            lock (lockObj) {
                bool b = appDomains.Remove(appDomain);
                if (!b)
                {
                    return;
                }
                for (int i = threads.Count - 1; i >= 0; i--)
                {
                    var thread = threads[i];
                    if (thread.AppDomain == appDomain)
                    {
                        if (threadsToRemove is null)
                        {
                            threadsToRemove = new List <DbgThread>();
                        }
                        threadsToRemove.Add(thread);
                        threads.RemoveAt(i);
                    }
                }
                for (int i = modules.Count - 1; i >= 0; i--)
                {
                    var module = modules[i];
                    if (module.AppDomain == appDomain)
                    {
                        if (modulesToRemove is null)
                        {
                            modulesToRemove = new List <DbgModule>();
                        }
                        modulesToRemove.Add(module);
                        modules.RemoveAt(i);
                    }
                }
            }
            if (threadsToRemove is not null && threadsToRemove.Count != 0)
            {
                ThreadsChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgThread>(threadsToRemove, added: false));
            }
            if (modulesToRemove is not null && modulesToRemove.Count != 0)
            {
                ModulesChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgModule>(modulesToRemove, added: false));
            }
            owner.RemoveAppDomain_DbgThread(this, appDomain, messageFlags);
            AppDomainsChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgAppDomain>(appDomain, added: false));
            if (threadsToRemove is not null)
            {
                foreach (var thread in threadsToRemove)
                {
                    thread.Close(Dispatcher);
                }
            }
            if (modulesToRemove is not null)
            {
                foreach (var module in modulesToRemove)
                {
                    module.Close(Dispatcher);
                }
            }
            appDomain.Close(Dispatcher);
        }
Example #5
0
 public DbgEngineAppDomainImpl(DbgAppDomainImpl appDomain) => this.appDomain = appDomain ?? throw new ArgumentNullException(nameof(appDomain));