/// <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; } }
/// <summary> /// Create an instance of the hosting class /// </summary> /// <param name="target">target instance</param> public SOSHost(ITarget target) { Target = target; ConsoleService = target.Services.GetService <IConsoleService>(); ModuleService = target.Services.GetService <IModuleService>(); ThreadService = target.Services.GetService <IThreadService>(); MemoryService = target.Services.GetService <IMemoryService>(); _ignoreAddressBitsMask = MemoryService.SignExtensionMask(); string rid = InstallHelper.GetRid(); SOSPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), rid); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { var debugClient = new DebugClient(this); _interface = debugClient.IDebugClient; } else { var lldbServices = new LLDBServices(this); _interface = lldbServices.ILLDBServices; } _hostWrapper = new HostWrapper(target.Host); _hostWrapper.AddServiceWrapper(SymbolServiceWrapper.IID_ISymbolService, () => new SymbolServiceWrapper(target.Host)); }