void SuspendUserThreads(ThreadingModel model, SingleSteppingEngine caller) { Report.Debug(DebugFlags.Threads, "Suspending user threads: {0} {1}", model, caller); foreach (SingleSteppingEngine engine in thread_hash.Values) { Report.Debug(DebugFlags.Threads, " check user thread: {0} {1}", engine, engine.Thread.ThreadFlags); if (engine == caller) { continue; } if (((engine.Thread.ThreadFlags & Thread.Flags.Immutable) != 0) && ((model & ThreadingModel.StopImmutableThreads) == 0)) { continue; } if (((engine.Thread.ThreadFlags & Thread.Flags.Daemon) != 0) && ((model & ThreadingModel.StopDaemonThreads) == 0)) { continue; } engine.SuspendUserThread(); } Report.Debug(DebugFlags.Threads, "Done suspending user threads: {0} {1}", model, caller); }
public CommandResult Step(ThreadingModel model, StepMode mode, StepFrame frame) { lock (this) { check_alive(); return(servant.Step(model, mode, frame)); } }
/// <summary> /// This method creates a new thread and starts it in the background, OR /// it uses an existing ThreadPool thread based on the input parameter. /// </summary> /// <param name="ThreadingModel">Specifies the threading model to use when executing the code</param> public void Drive(ThreadingModel Model = ThreadingModel.ManualThreads) { // Create a dummy object just to show how to pass a parameter into a thread Wind windy = new Wind(Model); switch (windy.Model) { case ThreadingModel.ManualThreads: { Thread backgroundThread = new Thread(new ParameterizedThreadStart(Go)); backgroundThread.Name = $"car {CarId}"; backgroundThread.IsBackground = true; backgroundThread.Start(windy); } break; case ThreadingModel.ThreadPoolThreads: { // There is a cost with starting a new thread, so for purposes of efficiency, the thread pool holds onto created // (but inactive) threads until needed. A ThreadPool thread is ALWAAYS a background thread. WaitCallback workItem = new WaitCallback(Go); ThreadPool.QueueUserWorkItem(workItem, windy); } break; case ThreadingModel.TaskThreads: { Task task = new Task(() => Go(windy)); task.Start(); } break; } }
internal GUIManager(Debugger debugger) { this.Debugger = debugger; this.ThreadingModel = ThreadingModel.Global; debugger.ProcessExitedEvent += delegate(Debugger dummy, Process process) { try { if (ProcessExitedEvent == null) { return; } ST.ThreadPool.QueueUserWorkItem(delegate { ProcessExitedEvent(debugger, process); }); } catch (Exception ex) { Report.Error("Caught exception while sending process {0} exit:\n{1}", process, ex); } }; debugger.TargetEvent += delegate(Thread thread, TargetEventArgs args) { try { if (TargetEvent == null) { return; } ST.ThreadPool.QueueUserWorkItem(delegate { TargetEvent(thread, args); }); } catch (Exception ex) { Report.Error("{0} caught exception while sending {1}:\n{2}", thread, args, ex); } }; }
internal CommandResult StartOperation(ThreadingModel model, SingleSteppingEngine caller) { if (!ThreadManager.InBackgroundThread) { throw new InternalError(); } if ((current_state != ProcessState.Stopped) && (current_state != ProcessState.SingleThreaded)) { throw new TargetException(TargetError.NotStopped); } if ((model & ThreadingModel.ThreadingMode) == ThreadingModel.Single) { current_state = ProcessState.SingleThreaded; if ((model & ThreadingModel.ResumeThreads) != 0) { ResumeUserThreads(model, caller); } return(new ThreadCommandResult(caller.Thread)); } else if ((model & ThreadingModel.ThreadingMode) != ThreadingModel.Process) { throw new ArgumentException(); } lock (this) { current_state = ProcessState.Running; stopped_event.Reset(); current_operation = new ProcessCommandResult(this, model); } ResumeUserThreads(model, caller); return(current_operation); }
void OperationCompleted(SingleSteppingEngine caller, TargetEventArgs result, ThreadingModel model) { if (!ThreadManager.InBackgroundThread) { throw new InternalError(); } foreach (Process process in process_hash.Values) { process.OperationCompleted(caller, result, model); } lock (this) { current_operation = null; stopped_event.Set(); } }
void ResumeUserThreads(ThreadingModel model, SingleSteppingEngine caller) { Report.Debug(DebugFlags.Threads, "Resuming user threads: {0}", caller); foreach (SingleSteppingEngine engine in thread_hash.Values) { if (engine == caller) { continue; } if ((engine.Thread.ThreadFlags & Thread.Flags.AutoRun) == 0) { continue; } if (((engine.Thread.ThreadFlags & Thread.Flags.Immutable) != 0) && ((model & ThreadingModel.StopImmutableThreads) == 0)) { continue; } if (((engine.Thread.ThreadFlags & Thread.Flags.Daemon) != 0) && ((model & ThreadingModel.StopDaemonThreads) == 0)) { continue; } CommandResult result; if (current_operation != null) { result = current_operation; } else { result = new ThreadCommandResult(engine.Thread); } engine.ResumeUserThread(result); } Report.Debug(DebugFlags.Threads, "Resumed user threads: {0}", caller); }
internal void StartGlobalOperation(ThreadingModel model, SingleSteppingEngine caller, OperationCommandResult operation) { if (!ThreadManager.InBackgroundThread) { throw new InternalError(); } if ((current_state != ProcessState.Stopped) && (current_state != ProcessState.SingleThreaded)) { throw new TargetException(TargetError.NotStopped); } lock (this) { current_state = ProcessState.Running; stopped_event.Reset(); current_operation = operation; } ResumeUserThreads(model, caller); }
internal CommandResult StartOperation(ThreadingModel model, SingleSteppingEngine caller) { if (!ThreadManager.InBackgroundThread) { throw new InternalError(); } if ((model & ThreadingModel.ThreadingMode) == ThreadingModel.Default) { if (Inferior.HasThreadEvents) { model |= ThreadingModel.Single; } else { model |= ThreadingModel.Process; } } if ((model & ThreadingModel.ThreadingMode) != ThreadingModel.Global) { return(caller.Process.StartOperation(model, caller)); } if (current_operation != null) { throw new TargetException(TargetError.NotStopped); } lock (this) { stopped_event.Reset(); current_operation = new GlobalCommandResult(this, model); } foreach (Process process in process_hash.Values) { process.StartGlobalOperation(model, caller, current_operation); } return(current_operation); }
void IOperationHost.OperationCompleted(SingleSteppingEngine sse, TargetEventArgs args, ThreadingModel model) { }
public override int GetHashCode() { return(Server.GetHashCode() ^ CommandLine.GetHashCode() ^ ServerType.GetHashCode() ^ ThreadingModel.GetHashCode() ^ RawServer.GetSafeHashCode()); }
public abstract CommandResult Step(ThreadingModel model, StepMode mode, StepFrame frame);
void SuspendUserThreads(ThreadingModel model, SingleSteppingEngine caller) { Report.Debug (DebugFlags.Threads, "Suspending user threads: {0} {1}", model, caller); foreach (SingleSteppingEngine engine in thread_hash.Values) { Report.Debug (DebugFlags.Threads, " check user thread: {0} {1}", engine, engine.Thread.ThreadFlags); if (engine == caller) continue; if (((engine.Thread.ThreadFlags & Thread.Flags.Immutable) != 0) && ((model & ThreadingModel.StopImmutableThreads) == 0)) continue; if (((engine.Thread.ThreadFlags & Thread.Flags.Daemon) != 0) && ((model & ThreadingModel.StopDaemonThreads) == 0)) continue; engine.SuspendUserThread (); } Report.Debug (DebugFlags.Threads, "Done suspending user threads: {0} {1}", model, caller); }
// NOTE: Construction of this thing is quite inefficient-- it // has several nested loops that could probably be // improved. Such optimizations have been left for when // it turns out to be a performance problem, for the // sake of simplicity. // public ServiceInfo(Guid clsid, ServiceElement service, ComCatalogObject application, ComCatalogObject classObject, HostingMode hostingMode) { // Simple things... // this.service = service; this.clsid = clsid; this.appid = Fx.CreateGuid((string)application.GetValue("ID")); this.partitionId = Fx.CreateGuid((string)application.GetValue("AppPartitionID")); this.bitness = (Bitness)classObject.GetValue("Bitness"); this.transactionOption = (TransactionOption)classObject.GetValue("Transaction"); this.hostingMode = hostingMode; this.managedType = TypeCacheManager.ResolveClsidToType(clsid); this.serviceName = application.Name + "." + classObject.Name; this.udts = new Dictionary<Guid, List<Type>>(); // Isolation Level COMAdminIsolationLevel adminIsolationLevel; adminIsolationLevel = (COMAdminIsolationLevel)classObject.GetValue("TxIsolationLevel"); switch (adminIsolationLevel) { case COMAdminIsolationLevel.Any: this.isolationLevel = IsolationLevel.Unspecified; break; case COMAdminIsolationLevel.ReadUncommitted: this.isolationLevel = IsolationLevel.ReadUncommitted; break; case COMAdminIsolationLevel.ReadCommitted: this.isolationLevel = IsolationLevel.ReadCommitted; break; case COMAdminIsolationLevel.RepeatableRead: this.isolationLevel = IsolationLevel.RepeatableRead; break; case COMAdminIsolationLevel.Serializable: this.isolationLevel = IsolationLevel.Serializable; break; default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed( SR.GetString(SR.InvalidIsolationLevelValue, this.clsid, adminIsolationLevel))); } // Threading Model // COMAdminThreadingModel adminThreadingModel; adminThreadingModel = (COMAdminThreadingModel)classObject.GetValue("ThreadingModel"); switch (adminThreadingModel) { case COMAdminThreadingModel.Apartment: case COMAdminThreadingModel.Main: this.threadingModel = ThreadingModel.STA; objectPoolingEnabled = false; break; default: this.threadingModel = ThreadingModel.MTA; objectPoolingEnabled = (bool)classObject.GetValue("ObjectPoolingEnabled"); break; } // Object Pool settings // if (objectPoolingEnabled) { maxPoolSize = (int)classObject.GetValue("MaxPoolSize"); } else maxPoolSize = 0; // Security Settings // bool appSecurityEnabled; appSecurityEnabled = (bool)application.GetValue( "ApplicationAccessChecksEnabled"); if (appSecurityEnabled) { bool classSecurityEnabled; classSecurityEnabled = (bool)classObject.GetValue( "ComponentAccessChecksEnabled"); if (classSecurityEnabled) { this.checkRoles = true; } } // Component Roles // ComCatalogCollection roles; roles = classObject.GetCollection("RolesForComponent"); this.componentRoleMembers = CatalogUtil.GetRoleMembers(application, roles); // Contracts // One ContractInfo per unique IID exposed, so we need to // filter duplicates. // this.contracts = new List<ContractInfo>(); ComCatalogCollection interfaces; interfaces = classObject.GetCollection("InterfacesForComponent"); foreach (ServiceEndpointElement endpoint in service.Endpoints) { ContractInfo contract = null; if (endpoint.Contract == ServiceMetadataBehavior.MexContractName) continue; Guid iid; if (DiagnosticUtility.Utility.TryCreateGuid(endpoint.Contract, out iid)) { // (Filter duplicates.) bool duplicate = false; foreach (ContractInfo otherContract in this.contracts) { if (iid == otherContract.IID) { duplicate = true; break; } } if (duplicate) continue; foreach (ComCatalogObject interfaceObject in interfaces) { Guid otherInterfaceID; if (DiagnosticUtility.Utility.TryCreateGuid((string)interfaceObject.GetValue("IID"), out otherInterfaceID)) { if (otherInterfaceID == iid) { contract = new ContractInfo(iid, endpoint, interfaceObject, application); break; } } } } if (contract == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed( SR.GetString(SR.EndpointNotAnIID, clsid.ToString("B").ToUpperInvariant(), endpoint.Contract))); } this.contracts.Add(contract); } }
public extern ThreadingAttribute(ThreadingModel model);
/// <summary> /// Creates and initializes a new instance of the attribute. /// </summary> /// <param name="model">One of the enumeration values.</param> public ThreadingAttribute( ThreadingModel model ) { Model = model; }
protected override CommandResult DoStep(Thread thread, ThreadingModel model, ScriptingContext context) { return thread.Finish (Native); }
public ThreadingAttribute(ThreadingModel model);
public override CommandResult Step(ThreadingModel model, StepMode mode, StepFrame frame) { throw new InvalidOperationException (); }
protected override ThreadingModel GetThreadingModelCore() { return(ThreadingModel.CreateDedicatedThreadingModel(Environment.ProcessorCount)); }
void LoadConfigurationFromStream(Stream stream) { XmlReaderSettings settings = new XmlReaderSettings (); Assembly ass = Assembly.GetExecutingAssembly (); using (Stream schema = ass.GetManifestResourceStream ("DebuggerConfiguration")) settings.Schemas.Add (null, new XmlTextReader (schema)); XmlReader reader = XmlReader.Create (stream, settings); XPathDocument doc = new XPathDocument (reader); XPathNavigator nav = doc.CreateNavigator (); XPathNodeIterator iter = nav.Select ("/DebuggerConfiguration/Configuration/*"); while (iter.MoveNext ()) { if (iter.Current.Name == "LoadNativeSymtabs") LoadNativeSymtabs = Boolean.Parse (iter.Current.Value); else if (iter.Current.Name == "StayInThread") { ; // ignore, this is no longer in use. } else if (iter.Current.Name == "FollowFork") FollowFork = Boolean.Parse (iter.Current.Value); else if (iter.Current.Name == "OpaqueFileNames") OpaqueFileNames = Boolean.Parse (iter.Current.Value); else if (iter.Current.Name == "StopOnManagedSignals") StopOnManagedSignals = Boolean.Parse (iter.Current.Value); else if (iter.Current.Name == "NestedBreakStates") NestedBreakStates = Boolean.Parse (iter.Current.Value); else if (iter.Current.Name == "RedirectOutput") RedirectOutput = Boolean.Parse (iter.Current.Value); else if (iter.Current.Name == "Martin_Boston_07102008") { ; // ignore, this is no longer in use. } else if (iter.Current.Name == "BrokenThreading") { ; // ignore, this is no longer in use. } else if (iter.Current.Name == "StopDaemonThreads") { if (Boolean.Parse (iter.Current.Value)) threading_model |= ThreadingModel.StopDaemonThreads; else threading_model &= ~ThreadingModel.StopDaemonThreads; } else if (iter.Current.Name == "StopImmutableThreads") { if (Boolean.Parse (iter.Current.Value)) threading_model |= ThreadingModel.StopImmutableThreads; else threading_model &= ~ThreadingModel.StopImmutableThreads; } else if (iter.Current.Name == "ThreadingModel") { switch (iter.Current.Value.ToLower ()) { case "single": threading_model |= ThreadingModel.Single; break; case "process": threading_model |= ThreadingModel.Process; break; case "global": threading_model |= ThreadingModel.Global; break; case "default": break; default: Report.Error ("Invalid value `{0}' in 'ThreadingModel'", iter.Current.Value); break; } } else if (iter.Current.Name == "UserNotifications") { switch (iter.Current.Value.ToLower ()) { case "+threads": case "threads": user_notifications |= UserNotificationType.Threads; break; case "-threads": user_notifications &= ~UserNotificationType.Threads; break; default: Report.Error ("Invalid value `{0}' in 'UserNotifications'", iter.Current.Value); break; } } else { Report.Error ("Invalid configuration item `{0}'", iter.Current.Name); } } iter = nav.Select ("/DebuggerConfiguration/ModuleGroups/ModuleGroup"); while (iter.MoveNext ()) { string name = iter.Current.GetAttribute ("name", ""); ModuleGroup group = CreateModuleGroup (name); group.SetSessionData (iter); } iter = nav.Select ("/DebuggerConfiguration/DirectoryMap/Map"); while (iter.MoveNext ()) { string from = iter.Current.GetAttribute ("from", ""); string to = iter.Current.GetAttribute ("to", ""); directory_maps.Add (from, to); } }
internal GlobalCommandResult(Debugger debugger, ThreadingModel model) : base(model) { this.Debugger = debugger; }
void OperationCompleted(SingleSteppingEngine caller, TargetEventArgs result, ThreadingModel model) { if (!ThreadManager.InBackgroundThread) throw new InternalError (); foreach (Process process in process_hash.Values) { process.OperationCompleted (caller, result, model); } lock (this) { current_operation = null; stopped_event.Set (); } }
internal OperationCommandResult(ThreadingModel model) { this.ThreadingModel = model; }
protected override CommandResult DoStep(Thread thread, ThreadingModel model, ScriptingContext context) { context.Interpreter.Style.IsNative = true; return thread.Step (model, Native ? StepMode.NativeInstruction : StepMode.SingleInstruction, null); }
public abstract CommandResult Step(ThreadingModel model, StepMode mode, StepFrame frame);
protected abstract CommandResult DoStep(Thread thread, ThreadingModel model, ScriptingContext context);
protected override CommandResult DoStep(Thread thread, ThreadingModel model, ScriptingContext context) { return thread.Step (model, StepMode.Run, null); }
void IOperationHost.OperationCompleted(SingleSteppingEngine caller, TargetEventArgs result, ThreadingModel model) { Process.OperationCompleted(caller, result, model); }
protected override CommandResult DoStep(Thread thread, ThreadingModel model, ScriptingContext context) { context.Interpreter.Style.IsNative = false; return thread.Step (model, StepMode.SourceLine, null); }
internal ProcessCommandResult(Process process, ThreadingModel model) : base(model) { this.Process = process; }
protected override bool DoResolveBase(ScriptingContext context) { threading_model = context.Interpreter.DebuggerConfiguration.ThreadingModel; if (SingleThread && EntireProcess) throw new ScriptingException ("Cannot use both `-single-thread' and `-entire-process'."); if (wait) { if (SingleThread || EntireProcess) throw new ScriptingException ("Cannot use `-single-thread' or `-entire-process' together with `-wait'."); threading_model &= ~ThreadingModel.ThreadingMode; threading_model |= ThreadingModel.Single | ThreadingModel.ResumeThreads; } else if (SingleThread) { threading_model &= ~ThreadingModel.ThreadingMode; threading_model |= ThreadingModel.Single; } else if (EntireProcess) { threading_model &= ~ThreadingModel.ThreadingMode; threading_model |= ThreadingModel.Process; } return base.DoResolveBase (context); }
internal void OperationCompleted(SingleSteppingEngine caller, TargetEventArgs result, ThreadingModel model) { if (!ThreadManager.InBackgroundThread && Inferior.HasThreadEvents) { throw new InternalError(); } if (current_state == ProcessState.Stopping) { return; } else if (current_state != ProcessState.Running) { throw new InternalError(); } if ((result != null) && (caller != main_thread) && ((result.Type == TargetEventType.TargetExited) || (result.Type == TargetEventType.TargetSignaled))) { return; } current_state = ProcessState.Stopping; SuspendUserThreads(model, caller); lock (this) { current_state = ProcessState.Stopped; current_operation.Completed(); current_operation = null; stopped_event.Set(); } }
public override CommandResult Step(ThreadingModel model, StepMode mode, StepFrame frame) { throw new InvalidOperationException(); }
internal ProcessCommandResult(Process process, ThreadingModel model) : base(model) { this.Process = process; }
void ResumeUserThreads(ThreadingModel model, SingleSteppingEngine caller) { Report.Debug (DebugFlags.Threads, "Resuming user threads: {0}", caller); foreach (SingleSteppingEngine engine in thread_hash.Values) { if (engine == caller) continue; if ((engine.Thread.ThreadFlags & Thread.Flags.AutoRun) == 0) continue; if (((engine.Thread.ThreadFlags & Thread.Flags.Immutable) != 0) && ((model & ThreadingModel.StopImmutableThreads) == 0)) continue; if (((engine.Thread.ThreadFlags & Thread.Flags.Daemon) != 0) && ((model & ThreadingModel.StopDaemonThreads) == 0)) continue; CommandResult result; if (current_operation != null) result = current_operation; else result = new ThreadCommandResult (engine.Thread); engine.ResumeUserThread (result); } Report.Debug (DebugFlags.Threads, "Resumed user threads: {0}", caller); }
internal void StartGlobalOperation(ThreadingModel model, SingleSteppingEngine caller, OperationCommandResult operation) { if (!ThreadManager.InBackgroundThread) throw new InternalError (); if ((current_state != ProcessState.Stopped) && (current_state != ProcessState.SingleThreaded)) throw new TargetException (TargetError.NotStopped); lock (this) { current_state = ProcessState.Running; stopped_event.Reset (); current_operation = operation; } ResumeUserThreads (model, caller); }
void IOperationHost.OperationCompleted(SingleSteppingEngine caller, TargetEventArgs result, ThreadingModel model) { Process.OperationCompleted (caller, result, model); }
internal GlobalCommandResult(Debugger debugger, ThreadingModel model) : base(model) { this.Debugger = debugger; }
internal void OperationCompleted(SingleSteppingEngine caller, TargetEventArgs result, ThreadingModel model) { if (!ThreadManager.InBackgroundThread && Inferior.HasThreadEvents) throw new InternalError (); if (current_state == ProcessState.Stopping) return; else if (current_state != ProcessState.Running) throw new InternalError (); if ((result != null) && (caller != main_thread) && ((result.Type == TargetEventType.TargetExited) || (result.Type == TargetEventType.TargetSignaled))) return; current_state = ProcessState.Stopping; SuspendUserThreads (model, caller); lock (this) { current_state = ProcessState.Stopped; current_operation.Completed (); current_operation = null; stopped_event.Set (); } }
public override CommandResult Step(ThreadingModel model, StepMode mode, StepFrame frame) { StartOperation (); return (CommandResult) SendCommand (delegate { Report.Debug (DebugFlags.SSE, "{0} step: {1} {2} {3}", this, model, mode, frame); CommandResult result = process.Debugger.StartOperation (model, this); return ProcessOperation (new OperationStep (this, mode, frame, result)); }); }
internal CommandResult StartOperation(ThreadingModel model, SingleSteppingEngine caller) { if (!ThreadManager.InBackgroundThread) throw new InternalError (); if ((current_state != ProcessState.Stopped) && (current_state != ProcessState.SingleThreaded)) throw new TargetException (TargetError.NotStopped); if ((model & ThreadingModel.ThreadingMode) == ThreadingModel.Single) { current_state = ProcessState.SingleThreaded; if ((model & ThreadingModel.ResumeThreads) != 0) ResumeUserThreads (model, caller); return new ThreadCommandResult (caller.Thread); } else if ((model & ThreadingModel.ThreadingMode) != ThreadingModel.Process) { throw new ArgumentException (); } lock (this) { current_state = ProcessState.Running; stopped_event.Reset (); current_operation = new ProcessCommandResult (this, model); } ResumeUserThreads (model, caller); return current_operation; }
void IOperationHost.OperationCompleted(SingleSteppingEngine sse, TargetEventArgs args, ThreadingModel model) { }
public CommandResult Step(ThreadingModel model, StepMode mode, StepFrame frame) { lock (this) { check_alive (); return servant.Step (model, mode, frame); } }
internal OperationCommandResult(ThreadingModel model) { this.ThreadingModel = model; }
// NOTE: Construction of this thing is quite inefficient-- it // has several nested loops that could probably be // improved. Such optimizations have been left for when // it turns out to be a performance problem, for the // sake of simplicity. // public ServiceInfo(Guid clsid, ServiceElement service, ComCatalogObject application, ComCatalogObject classObject, HostingMode hostingMode) { // Simple things... // this.service = service; this.clsid = clsid; this.appid = Fx.CreateGuid((string)application.GetValue("ID")); this.partitionId = Fx.CreateGuid((string)application.GetValue("AppPartitionID")); this.bitness = (Bitness)classObject.GetValue("Bitness"); this.transactionOption = (TransactionOption)classObject.GetValue("Transaction"); this.hostingMode = hostingMode; this.managedType = TypeCacheManager.ResolveClsidToType(clsid); this.serviceName = application.Name + "." + classObject.Name; this.udts = new Dictionary <Guid, List <Type> >(); // Isolation Level COMAdminIsolationLevel adminIsolationLevel; adminIsolationLevel = (COMAdminIsolationLevel)classObject.GetValue("TxIsolationLevel"); switch (adminIsolationLevel) { case COMAdminIsolationLevel.Any: this.isolationLevel = IsolationLevel.Unspecified; break; case COMAdminIsolationLevel.ReadUncommitted: this.isolationLevel = IsolationLevel.ReadUncommitted; break; case COMAdminIsolationLevel.ReadCommitted: this.isolationLevel = IsolationLevel.ReadCommitted; break; case COMAdminIsolationLevel.RepeatableRead: this.isolationLevel = IsolationLevel.RepeatableRead; break; case COMAdminIsolationLevel.Serializable: this.isolationLevel = IsolationLevel.Serializable; break; default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed( SR.GetString(SR.InvalidIsolationLevelValue, this.clsid, adminIsolationLevel))); } // Threading Model // COMAdminThreadingModel adminThreadingModel; adminThreadingModel = (COMAdminThreadingModel)classObject.GetValue("ThreadingModel"); switch (adminThreadingModel) { case COMAdminThreadingModel.Apartment: case COMAdminThreadingModel.Main: this.threadingModel = ThreadingModel.STA; objectPoolingEnabled = false; break; default: this.threadingModel = ThreadingModel.MTA; objectPoolingEnabled = (bool)classObject.GetValue("ObjectPoolingEnabled"); break; } // Object Pool settings // if (objectPoolingEnabled) { maxPoolSize = (int)classObject.GetValue("MaxPoolSize"); } else { maxPoolSize = 0; } // Security Settings // bool appSecurityEnabled; appSecurityEnabled = (bool)application.GetValue( "ApplicationAccessChecksEnabled"); if (appSecurityEnabled) { bool classSecurityEnabled; classSecurityEnabled = (bool)classObject.GetValue( "ComponentAccessChecksEnabled"); if (classSecurityEnabled) { this.checkRoles = true; } } // Component Roles // ComCatalogCollection roles; roles = classObject.GetCollection("RolesForComponent"); this.componentRoleMembers = CatalogUtil.GetRoleMembers(application, roles); // Contracts // One ContractInfo per unique IID exposed, so we need to // filter duplicates. // this.contracts = new List <ContractInfo>(); ComCatalogCollection interfaces; interfaces = classObject.GetCollection("InterfacesForComponent"); foreach (ServiceEndpointElement endpoint in service.Endpoints) { ContractInfo contract = null; if (endpoint.Contract == ServiceMetadataBehavior.MexContractName) { continue; } Guid iid; if (DiagnosticUtility.Utility.TryCreateGuid(endpoint.Contract, out iid)) { // (Filter duplicates.) bool duplicate = false; foreach (ContractInfo otherContract in this.contracts) { if (iid == otherContract.IID) { duplicate = true; break; } } if (duplicate) { continue; } foreach (ComCatalogObject interfaceObject in interfaces) { Guid otherInterfaceID; if (DiagnosticUtility.Utility.TryCreateGuid((string)interfaceObject.GetValue("IID"), out otherInterfaceID)) { if (otherInterfaceID == iid) { contract = new ContractInfo(iid, endpoint, interfaceObject, application); break; } } } } if (contract == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed( SR.GetString(SR.EndpointNotAnIID, clsid.ToString("B").ToUpperInvariant(), endpoint.Contract))); } this.contracts.Add(contract); } }
internal CommandResult StartOperation(ThreadingModel model, SingleSteppingEngine caller) { if (!ThreadManager.InBackgroundThread) throw new InternalError (); if ((model & ThreadingModel.ThreadingMode) == ThreadingModel.Default) { if (Inferior.HasThreadEvents) model |= ThreadingModel.Single; else model |= ThreadingModel.Process; } if ((model & ThreadingModel.ThreadingMode) != ThreadingModel.Global) return caller.Process.StartOperation (model, caller); if (current_operation != null) throw new TargetException (TargetError.NotStopped); lock (this) { stopped_event.Reset (); current_operation = new GlobalCommandResult (this, model); } foreach (Process process in process_hash.Values) { process.StartGlobalOperation (model, caller, current_operation); } return current_operation; }