예제 #1
0
        ThreadProperties GetThreadProperties_MonoDebug(ThreadMirror thread, DbgThreadData threadData, bool isCreateThread, bool forceReadName, bool isMainThread, bool isFinalizerThread, bool canFuncEval)
        {
            debuggerThread.VerifyAccess();
            var appDomain = TryGetEngineAppDomain(thread.Domain)?.AppDomain;

            ulong id;

            if (thread.VirtualMachine.Version.AtLeast(2, 3))
            {
                id = (uint)thread.TID;
            }
            else if (thread.VirtualMachine.Version.AtLeast(2, 1))
            {
                id = (ulong)thread.ThreadId;
            }
            else
            {
                id = 0;
            }

            if (isCreateThread)
            {
                forceReadName = true;
            }

            var time = DateTime.UtcNow;

            var managedId = threadData.Last?.ManagedId;

            if (managedId is null && canFuncEval)
            {
                bool getManagedId = forceReadName;
                if (!getManagedId && threadData.GetManagedIdCounter < MaxCheckNewManagedId)
                {
                    getManagedId = time - threadData.LastManagedIdUpdateTime >= TimeSpan.FromMilliseconds(CheckNewManagedIdDelayMilliseconds);
                }
                if (getManagedId)
                {
                    threadData.GetManagedIdCounter++;
                    managedId = GetManagedId(thread);
                    threadData.LastManagedIdUpdateTime = time;
                }
            }

            if (threadData.Last?.Name is null && time - threadData.LastNameUpdateTime >= TimeSpan.FromMilliseconds(CheckNewThreadNameDelayMilliseconds))
            {
                forceReadName = true;
            }

            string?name;

            if (forceReadName)
            {
                name = GetThreadName(thread);
                threadData.LastNameUpdateTime = time;
            }
            else
            {
                name = threadData.Last?.Name;
            }

            int suspendedCount = (thread.ThreadState & ST.ThreadState.Suspended) != 0 ? 1 : 0;
            var threadState    = thread.ThreadState;
            var kind           = GetThreadKind(thread, isMainThread, isFinalizerThread);

            return(new ThreadProperties(appDomain, kind, id, managedId, name, suspendedCount, threadState));
        }
예제 #2
0
 public ObjectConstantsFactory(DbgProcess process, ThreadMirror thread)
 {
     this.process = process;
     this.thread  = thread;
 }
예제 #3
0
 FuncEval CreateFuncEval(DbgEvaluationContext context, ThreadMirror monoThread, CancellationToken cancellationToken) =>
 funcEvalFactory.CreateFuncEval(a => OnFuncEvalComplete(a, context), monoThread, context.FuncEvalTimeout, suspendOtherThreads: (context.Options & DbgEvaluationContextOptions.RunAllThreads) == 0, cancellationToken: cancellationToken);
예제 #4
0
 public DbgThreadData(ThreadMirror monoThread, bool isMainThread, bool isFinalizerThread)
 {
     MonoThread        = monoThread ?? throw new ArgumentNullException(nameof(monoThread));
     IsMainThread      = isMainThread;
     IsFinalizerThread = isFinalizerThread;
 }
예제 #5
0
 public FuncEvalImpl(IDebugMessageDispatcher debugMessageDispatcher, FuncEvalFactory.FuncEvalState funcEvalState, Action <FuncEval> onEvalComplete, ThreadMirror thread, TimeSpan funcEvalTimeout, bool suspendOtherThreads, CancellationToken cancellationToken)
 {
     this.debugMessageDispatcher = debugMessageDispatcher ?? throw new ArgumentNullException(nameof(debugMessageDispatcher));
     this.funcEvalState          = funcEvalState ?? throw new ArgumentNullException(nameof(funcEvalState));
     this.onEvalComplete         = onEvalComplete ?? throw new ArgumentNullException(nameof(onEvalComplete));
     this.thread = thread ?? throw new ArgumentNullException(nameof(thread));
     endTime     = DateTime.UtcNow + funcEvalTimeout;
     this.suspendOtherThreads = suspendOtherThreads;
     this.cancellationToken   = cancellationToken;
 }
예제 #6
0
 public FuncEval CreateFuncEval(Action <FuncEval> onEvalComplete, ThreadMirror thread, TimeSpan funcEvalTimeout, bool suspendOtherThreads, CancellationToken cancellationToken) =>
 new FuncEvalImpl(debugMessageDispatcher, funcEvalState, onEvalComplete, thread, funcEvalTimeout, suspendOtherThreads, cancellationToken);
예제 #7
0
 public DbgEngineStepperImpl(DbgDotNetCodeRangeService dbgDotNetCodeRangeService, DbgEngineImpl engine, DbgThread thread, ThreadMirror monoThread)
 {
     this.dbgDotNetCodeRangeService = dbgDotNetCodeRangeService ?? throw new ArgumentNullException(nameof(dbgDotNetCodeRangeService));
     this.engine     = engine ?? throw new ArgumentNullException(nameof(engine));
     this.thread     = thread ?? throw new ArgumentNullException(nameof(thread));
     this.monoThread = monoThread ?? throw new ArgumentNullException(nameof(monoThread));
 }
예제 #8
0
 public MonoThread(DebuggedMonoProcess debuggedMonoProcess, MonoEngine engine, ThreadMirror threadMirror)
 {
     this.debuggedMonoProcess = debuggedMonoProcess;
     _engine      = engine;
     ThreadMirror = threadMirror;
 }
예제 #9
0
 public DbgEngineStackWalkerImpl(Lazy <DbgDotNetCodeLocationFactory> dbgDotNetCodeLocationFactory, DbgEngineImpl engine, ThreadMirror monoThread, DbgThread thread)
 {
     this.dbgDotNetCodeLocationFactory = dbgDotNetCodeLocationFactory ?? throw new ArgumentNullException(nameof(dbgDotNetCodeLocationFactory));
     this.engine     = engine ?? throw new ArgumentNullException(nameof(engine));
     this.monoThread = monoThread ?? throw new ArgumentNullException(nameof(monoThread));
     this.thread     = thread ?? throw new ArgumentNullException(nameof(thread));
     continueCounter = engine.ContinueCounter;
 }