Esempio n. 1
0
        public Analyzer()
        {
            LoggingCommand.Initialize();

            _serviceProvider = new ServiceProvider();
            _consoleProvider = new ConsoleService();
            _commandService  = new CommandService();
            _symbolService   = new SymbolService(this);
            _contextService  = new ContextService(this);

            _serviceProvider.AddService <IHost>(this);
            _serviceProvider.AddService <IConsoleService>(_consoleProvider);
            _serviceProvider.AddService <ICommandService>(_commandService);
            _serviceProvider.AddService <ISymbolService>(_symbolService);
            _serviceProvider.AddService <IContextService>(_contextService);
            _serviceProvider.AddServiceFactory <SOSLibrary>(() => SOSLibrary.Create(this));

            _contextService.ServiceProvider.AddServiceFactory <ClrMDHelper>(() => {
                ClrRuntime clrRuntime = _contextService.Services.GetService <ClrRuntime>();
                return(clrRuntime != null ? new ClrMDHelper(clrRuntime) : null);
            });

            _commandService.AddCommands(new Assembly[] { typeof(Analyzer).Assembly });
            _commandService.AddCommands(new Assembly[] { typeof(ClrMDHelper).Assembly });
            _commandService.AddCommands(new Assembly[] { typeof(SOSHost).Assembly });
            _commandService.AddCommands(typeof(HelpCommand), (services) => new HelpCommand(_commandService, services));
            _commandService.AddCommands(typeof(ExitCommand), (services) => new ExitCommand(_consoleProvider.Stop));
        }
Esempio n. 2
0
        private HostServices()
        {
            _serviceProvider = new ServiceProvider();
            _symbolService   = new SymbolService(this);
            _commandService  = new CommandService(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ">!ext" : null);
            _commandService.AddCommands(new Assembly[] { typeof(HostServices).Assembly });
            _commandService.AddCommands(new Assembly[] { typeof(ClrMDHelper).Assembly });

            _serviceProvider.AddService <IHost>(this);
            _serviceProvider.AddService <ICommandService>(_commandService);
            _serviceProvider.AddService <ISymbolService>(_symbolService);

            _hostWrapper = new HostWrapper(this, () => _targetWrapper);
            _hostWrapper.ServiceWrapper.AddServiceWrapper(IID_IHostServices, this);

            VTableBuilder builder = AddInterface(IID_IHostServices, validate: false);

            builder.AddMethod(new GetHostDelegate(GetHost));
            builder.AddMethod(new RegisterDebuggerServicesDelegate(RegisterDebuggerServices));
            builder.AddMethod(new CreateTargetDelegate(CreateTarget));
            builder.AddMethod(new UpdateTargetDelegate(UpdateTarget));
            builder.AddMethod(new FlushTargetDelegate(FlushTarget));
            builder.AddMethod(new DestroyTargetDelegate(DestroyTarget));
            builder.AddMethod(new DispatchCommandDelegate(DispatchCommand));
            builder.AddMethod(new DispatchCommandDelegate(DisplayHelp));
            builder.AddMethod(new UninitializeDelegate(Uninitialize));
            IHostServices = builder.Complete();

            AddRef();
        }
Esempio n. 3
0
        /// <summary>
        /// Load any extra extensions in the search path
        /// </summary>
        /// <param name="commandService">Used to add the commands</param>
        /// <param name="extensionPath">Extension assembly path</param>
        private void LoadExtension(string extensionPath)
        {
            Assembly assembly = null;

            try
            {
                assembly = Assembly.LoadFrom(extensionPath);
            }
            catch (Exception ex) when(ex is IOException || ex is ArgumentException || ex is BadImageFormatException || ex is System.Security.SecurityException)
            {
                _consoleProvider.WriteLineError($"Extension load {extensionPath} FAILED {ex.Message}");
            }
            if (assembly is not null)
            {
                _commandService.AddCommands(assembly);
                _consoleProvider.WriteLine($"Extension loaded {extensionPath}");
            }
        }