コード例 #1
0
ファイル: Process.cs プロジェクト: tralivali1234/debugger
        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);
        }
コード例 #2
0
ファイル: Thread.cs プロジェクト: tralivali1234/debugger
 public CommandResult Step(ThreadingModel model, StepMode mode, StepFrame frame)
 {
     lock (this) {
         check_alive();
         return(servant.Step(model, mode, frame));
     }
 }
コード例 #3
0
ファイル: CarRace.cs プロジェクト: stauent/MultiThreading
        /// <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;
            }
        }
コード例 #4
0
ファイル: GUIManager.cs プロジェクト: tralivali1234/debugger
        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);
                }
            };
        }
コード例 #5
0
ファイル: Process.cs プロジェクト: tralivali1234/debugger
        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);
        }
コード例 #6
0
        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();
            }
        }
コード例 #7
0
ファイル: Process.cs プロジェクト: tralivali1234/debugger
        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);
        }
コード例 #8
0
ファイル: Process.cs プロジェクト: tralivali1234/debugger
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
ファイル: Thread.cs プロジェクト: tralivali1234/debugger
 void IOperationHost.OperationCompleted(SingleSteppingEngine sse, TargetEventArgs args, ThreadingModel model)
 {
 }
コード例 #11
0
 public override int GetHashCode()
 {
     return(Server.GetHashCode() ^ CommandLine.GetHashCode()
            ^ ServerType.GetHashCode() ^ ThreadingModel.GetHashCode()
            ^ RawServer.GetSafeHashCode());
 }
コード例 #12
0
ファイル: ThreadServant.cs プロジェクト: baulig/debugger
 public abstract CommandResult Step(ThreadingModel model, StepMode mode, StepFrame frame);
コード例 #13
0
ファイル: Process.cs プロジェクト: baulig/debugger
        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);
        }
コード例 #14
0
        // 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);
            }
        }
コード例 #15
0
		public extern ThreadingAttribute(ThreadingModel model);
コード例 #16
0
		/// <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;
		}
コード例 #17
0
ファイル: Command.cs プロジェクト: baulig/debugger
 protected override CommandResult DoStep(Thread thread, ThreadingModel model, ScriptingContext context)
 {
     return thread.Finish (Native);
 }
コード例 #18
0
ファイル: ThreadingAttribute.cs プロジェクト: Openwinrt/owr
 public ThreadingAttribute(ThreadingModel model);
コード例 #19
0
ファイル: CoreFile.cs プロジェクト: baulig/debugger
 public override CommandResult Step(ThreadingModel model, StepMode mode, StepFrame frame)
 {
     throw new InvalidOperationException ();
 }
コード例 #20
0
 protected override ThreadingModel GetThreadingModelCore()
 {
     return(ThreadingModel.CreateDedicatedThreadingModel(Environment.ProcessorCount));
 }
コード例 #21
0
        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);
            }
        }
コード例 #22
0
 internal GlobalCommandResult(Debugger debugger, ThreadingModel model)
     : base(model)
 {
     this.Debugger = debugger;
 }
コード例 #23
0
ファイル: Debugger.cs プロジェクト: baulig/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 ();
            }
        }
コード例 #24
0
ファイル: Operation.cs プロジェクト: baulig/debugger
 internal OperationCommandResult(ThreadingModel model)
 {
     this.ThreadingModel = model;
 }
コード例 #25
0
ファイル: Command.cs プロジェクト: baulig/debugger
 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);
 }
コード例 #26
0
 public abstract CommandResult Step(ThreadingModel model, StepMode mode, StepFrame frame);
コード例 #27
0
ファイル: Command.cs プロジェクト: baulig/debugger
 protected abstract CommandResult DoStep(Thread thread, ThreadingModel model, ScriptingContext context);
コード例 #28
0
ファイル: Command.cs プロジェクト: baulig/debugger
 protected override CommandResult DoStep(Thread thread, ThreadingModel model, ScriptingContext context)
 {
     return thread.Step (model, StepMode.Run, null);
 }
コード例 #29
0
ファイル: Process.cs プロジェクト: tralivali1234/debugger
 void IOperationHost.OperationCompleted(SingleSteppingEngine caller, TargetEventArgs result, ThreadingModel model)
 {
     Process.OperationCompleted(caller, result, model);
 }
コード例 #30
0
ファイル: Command.cs プロジェクト: baulig/debugger
 protected override CommandResult DoStep(Thread thread, ThreadingModel model, ScriptingContext context)
 {
     context.Interpreter.Style.IsNative = false;
     return thread.Step (model, StepMode.SourceLine, null);
 }
コード例 #31
0
ファイル: Process.cs プロジェクト: tralivali1234/debugger
 internal ProcessCommandResult(Process process, ThreadingModel model)
     : base(model)
 {
     this.Process = process;
 }
コード例 #32
0
ファイル: Command.cs プロジェクト: baulig/debugger
 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);
 }
コード例 #33
0
ファイル: Process.cs プロジェクト: tralivali1234/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();
            }
        }
コード例 #34
0
 public override CommandResult Step(ThreadingModel model, StepMode mode, StepFrame frame)
 {
     throw new InvalidOperationException();
 }
コード例 #35
0
ファイル: Process.cs プロジェクト: baulig/debugger
 internal ProcessCommandResult(Process process, ThreadingModel model)
     : base(model)
 {
     this.Process = process;
 }
コード例 #36
0
ファイル: Process.cs プロジェクト: baulig/debugger
        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);
        }
コード例 #37
0
ファイル: Process.cs プロジェクト: baulig/debugger
        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);
        }
コード例 #38
0
ファイル: Process.cs プロジェクト: baulig/debugger
 void IOperationHost.OperationCompleted(SingleSteppingEngine caller, TargetEventArgs result, ThreadingModel model)
 {
     Process.OperationCompleted (caller, result, model);
 }
コード例 #39
0
ファイル: Debugger.cs プロジェクト: baulig/debugger
 internal GlobalCommandResult(Debugger debugger, ThreadingModel model)
     : base(model)
 {
     this.Debugger = debugger;
 }
コード例 #40
0
ファイル: Process.cs プロジェクト: baulig/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 ();
            }
        }
コード例 #41
0
        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));
            });
        }
コード例 #42
0
ファイル: Process.cs プロジェクト: baulig/debugger
        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;
        }
コード例 #43
0
ファイル: Thread.cs プロジェクト: baulig/debugger
 void IOperationHost.OperationCompleted(SingleSteppingEngine sse, TargetEventArgs args, ThreadingModel model)
 {
 }
コード例 #44
0
ファイル: Thread.cs プロジェクト: baulig/debugger
 public CommandResult Step(ThreadingModel model, StepMode mode, StepFrame frame)
 {
     lock (this) {
         check_alive ();
         return servant.Step (model, mode, frame);
     }
 }
コード例 #45
0
ファイル: Operation.cs プロジェクト: tralivali1234/debugger
 internal OperationCommandResult(ThreadingModel model)
 {
     this.ThreadingModel = model;
 }
コード例 #46
0
ファイル: ServiceInfo.cs プロジェクト: dox0/DotNet471RS3
        // 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);
            }
        }
コード例 #47
0
ファイル: Debugger.cs プロジェクト: baulig/debugger
        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;
        }