Exemplo n.º 1
0
        /// <summary>
        /// Create an instance of the hosting class. Has the lifetime of the target. Depends on the
        /// context service for the current thread and runtime.
        /// </summary>
        /// <param name="services">service provider</param>
        public SOSHost(IServiceProvider services)
        {
            Services      = services;
            Target        = services.GetService <ITarget>() ?? throw new DiagnosticsException("No target");
            TargetWrapper = new TargetWrapper(services);
            Target.DisposeOnDestroy(this);
            ConsoleService = services.GetService <IConsoleService>();
            ModuleService  = services.GetService <IModuleService>();
            ThreadService  = services.GetService <IThreadService>();
            MemoryService  = services.GetService <IMemoryService>();
            TargetWrapper.ServiceWrapper.AddServiceWrapper(SymbolServiceWrapper.IID_ISymbolService, () => new SymbolServiceWrapper(services.GetService <ISymbolService>(), MemoryService));
            _ignoreAddressBitsMask = MemoryService.SignExtensionMask();
            _sosLibrary            = services.GetService <SOSLibrary>();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                var debugClient = new DebugClient(this);
                _interface = debugClient.IDebugClient;
            }
            else
            {
                var lldbServices = new LLDBServices(this);
                _interface = lldbServices.ILLDBServices;
            }
        }
Exemplo n.º 2
0
        public static SOSLibrary Create(IHost host)
        {
            SOSLibrary sosLibrary = null;

            try
            {
                sosLibrary = new SOSLibrary(host);
                sosLibrary.Initialize();
            }
            catch
            {
                sosLibrary.Uninitialize();
                sosLibrary = null;
                throw;
            }
            host.OnShutdownEvent.Register(() => {
                sosLibrary.Uninitialize();
                sosLibrary = null;
            });
            return(sosLibrary);
        }