Lines Matching defs:thread
110 // GC to deadlock if another thread tries to call SuspendAll while the GC is in a runnable state.
150 void MethodEntered(Thread* thread,
165 thread->SetDebugMethodEntry();
172 thread->SetDebugMethodEntry();
174 Dbg::UpdateDebugger(thread, this_object.Get(), method, 0, Dbg::kMethodEntry, nullptr);
178 void MethodExited(Thread* thread,
189 if (thread->IsDebugMethodEntry()) {
193 thread->ClearDebugMethodEntry();
195 Dbg::UpdateDebugger(thread, this_object.Get(), method, dex_pc, events, &return_value);
198 void MethodUnwind(Thread* thread ATTRIBUTE_UNUSED,
208 void DexPcMoved(Thread* thread,
222 if (thread->IsDebugMethodEntry()) {
225 thread->ClearDebugMethodEntry();
227 Dbg::UpdateDebugger(thread, this_object.Get(), method, new_dex_pc, events, nullptr);
231 void FieldRead(Thread* thread ATTRIBUTE_UNUSED,
240 void FieldWritten(Thread* thread ATTRIBUTE_UNUSED,
250 void ExceptionThrown(Thread* thread ATTRIBUTE_UNUSED,
257 void Branch(Thread* /*thread*/, ArtMethod* method, uint32_t dex_pc, int32_t dex_pc_offset)
264 void ExceptionHandled(Thread* thread ATTRIBUTE_UNUSED,
270 void WatchedFramePop(Thread* thread ATTRIBUTE_UNUSED,
343 VLOG(jdwp) << "Debugger thread not active, ignoring DDM send: " << type;
367 ScopedThreadStateChange stsc(art::Thread::Current(), kNative);
398 ReaderMutexLock mu(Thread::Current(), *Locks::breakpoint_lock_);
408 static bool IsSuspendedForDebugger(ScopedObjectAccessUnchecked& soa, Thread* thread)
411 // A thread may be suspended for GC; in this code, we really want to know whether
413 return thread->IsSuspended() && thread->GetDebugSuspendCount() > 0;
446 static Thread* DecodeThread(ScopedObjectAccessUnchecked& soa, JDWP::ObjectId thread_id,
461 // This isn't a thread.
467 Thread* thread = Thread::FromManagedThread(soa, thread_peer);
468 // If thread is null then this a java.lang.Thread without a Thread*. Must be a un-started or a
470 *error = (thread == nullptr) ? JDWP::ERR_THREAD_NOT_ALIVE : JDWP::ERR_NONE;
471 return thread;
563 ScopedObjectAccess soa(Thread::Current());
575 LOG(FATAL) << "Debugger thread failed to initialize";
581 ScopedObjectAccess soa(Thread::Current());
587 // Post VM_DEATH event before the JDWP connection is closed (either by the JDWP thread or the
592 // Prevent the JDWP thread from processing JDWP incoming packets after we close the connection.
602 ScopedObjectAccess soa(Thread::Current());
607 ScopedObjectAccess soa(Thread::Current());
612 ScopedObjectAccess soa(Thread::Current());
627 return Thread::Current()->GetInvokeReq();
630 Thread* Dbg::GetDebugThread() {
654 // Only called from the JDWP handler thread.
659 Thread* const self = Thread::Current();
709 Thread* self = Thread::Current();
851 Thread* self = Thread::Current();
884 OwnedMonitorVisitor(Thread* thread, Context* context,
888 : StackVisitor(thread, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
915 ScopedObjectAccessUnchecked soa(Thread::Current());
917 Thread* thread = DecodeThread(soa, thread_id, &error);
918 if (thread == nullptr) {
921 if (!IsSuspendedForDebugger(soa, thread)) {
925 OwnedMonitorVisitor visitor(thread, context.get(), monitors, stack_depths);
932 ScopedObjectAccessUnchecked soa(Thread::Current());
935 Thread* thread = DecodeThread(soa, thread_id, &error);
936 if (thread == nullptr) {
939 if (!IsSuspendedForDebugger(soa, thread)) {
942 ObjPtr<mirror::Object> contended_monitor_obj = Monitor::GetContendedMonitor(thread);
953 VariableSizedHandleScope hs(Thread::Current());
979 VariableSizedHandleScope hs(Thread::Current());
1001 VariableSizedHandleScope hs(Thread::Current());
1171 StackHandleScope<1> hs(Thread::Current());
1196 ScopedObjectAccessUnchecked soa(Thread::Current());
1282 ScopedObjectAccessUnchecked soa(Thread::Current());
1353 Thread* self = Thread::Current();
1373 Thread* self = Thread::Current();
1404 Thread* self = Thread::Current();
1439 bool Dbg::MatchThread(JDWP::ObjectId expected_thread_id, Thread* event_thread) {
1652 Thread* self = Thread::Current();
1840 Thread* self = Thread::Current();
1949 StackHandleScope<2> hs(Thread::Current());
1974 Thread* self = Thread::Current();
2027 ScopedObjectAccessUnchecked soa(Thread::Current());
2054 ScopedObjectAccessUnchecked soa(Thread::Current());
2062 ScopedObjectAccessUnchecked soa(Thread::Current());
2069 // We still need to report the zombie threads' names, so we can't just call Thread::GetThreadName.
2082 ScopedObjectAccessUnchecked soa(Thread::Current());
2089 // Okay, so it's an object, but is it actually a thread?
2133 ScopedObjectAccessUnchecked soa(Thread::Current());
2150 ScopedObjectAccessUnchecked soa(Thread::Current());
2173 // Get the int "ngroups" count of this thread group...
2181 // Get the ThreadGroup[] "groups" out of this thread group...
2200 ScopedObjectAccessUnchecked soa(Thread::Current());
2217 // Add child thread groups.
2231 ScopedObjectAccessUnchecked soa(Thread::Current());
2274 LOG(FATAL) << "Unknown thread state: " << state;
2280 ScopedObjectAccess soa(Thread::Current());
2285 Thread* thread = DecodeThread(soa, thread_id, &error);
2294 if (IsSuspendedForDebugger(soa, thread)) {
2298 *pThreadStatus = ToJdwpThreadStatus(thread->GetState());
2303 ScopedObjectAccess soa(Thread::Current());
2305 Thread* thread = DecodeThread(soa, thread_id, &error);
2310 expandBufAdd4BE(pReply, thread->GetDebugSuspendCount());
2315 ScopedObjectAccess soa(Thread::Current());
2317 Thread* thread = DecodeThread(soa, thread_id, &error);
2321 thread->Interrupt(soa.Self());
2327 // Do we want threads from all thread groups?
2338 ScopedObjectAccessUnchecked soa(Thread::Current());
2339 std::list<Thread*> all_threads_list;
2341 MutexLock mu(Thread::Current(), *Locks::thread_list_lock_);
2344 for (Thread* t : all_threads_list) {
2346 // Skip the JDWP thread. Some debuggers get bent out of shape when they can't suspend and
2347 // query all threads, so it's easier if we just don't tell them about this thread.
2351 // This thread is being started (and has been registered in the thread list). However, it is
2357 // peer might be null if the thread is still starting up. We can't tell the debugger about
2358 // this thread yet.
2359 // TODO: if we identified threads to the debugger by their Thread*
2370 static int GetStackDepth(Thread* thread) REQUIRES_SHARED(Locks::mutator_lock_) {
2379 thread,
2386 ScopedObjectAccess soa(Thread::Current());
2389 Thread* thread = DecodeThread(soa, thread_id, &error);
2393 if (!IsSuspendedForDebugger(soa, thread)) {
2396 *result = GetStackDepth(thread);
2404 ScopedObjectAccessUnchecked soa(Thread::Current());
2406 Thread* thread = DecodeThread(soa, thread_id, &error);
2410 if (!IsSuspendedForDebugger(soa, thread)) {
2437 thread,
2445 return GetThreadId(Thread::Current());
2448 JDWP::ObjectId Dbg::GetThreadId(Thread* thread) {
2449 ScopedObjectAccessUnchecked soa(Thread::Current());
2450 return gRegistry->Add(thread->GetPeerFromOtherThread());
2455 gc::ScopedGCCriticalSection gcs(Thread::Current(),
2466 Thread* self = Thread::Current();
2476 // Suspend thread to build stack trace.
2479 Thread* thread = thread_list->SuspendThreadByPeer(peer.get(),
2483 if (thread != nullptr) {
2493 ScopedObjectAccessUnchecked soa(Thread::Current());
2497 Thread* thread;
2500 thread = Thread::FromManagedThread(soa, peer);
2502 if (thread == nullptr) {
2503 LOG(WARNING) << "No such thread for resume: " << peer;
2509 needs_resume = thread->GetDebugSuspendCount() > 0;
2512 bool resumed = Runtime::Current()->GetThreadList()->Resume(thread, SuspendReason::kForDebugger);
2523 ScopedObjectAccessUnchecked soa(Thread::Current());
2525 Thread* thread = DecodeThread(soa, thread_id, &error);
2529 if (!IsSuspendedForDebugger(soa, thread)) {
2543 thread,
2551 static JDWP::JdwpError FindAndHandleNonNativeFrame(Thread* thread,
2572 thread,
2582 ScopedObjectAccessUnchecked soa(Thread::Current());
2584 Thread* thread = DecodeThread(soa, thread_id, &error);
2588 if (!IsSuspendedForDebugger(soa, thread)) {
2593 thread,
2751 ScopedObjectAccessUnchecked soa(Thread::Current());
2753 Thread* thread = DecodeThread(soa, thread_id, &error);
2757 if (!IsSuspendedForDebugger(soa, thread)) {
2762 thread,
2774 error = Dbg::SetLocalValue(thread, *stack_visitor, slot, sigByte, value, width);
2793 JDWP::JdwpError Dbg::SetLocalValue(Thread* thread, StackVisitor& visitor, int slot,
2871 // thread's stack. The stub will cause the deoptimization to happen.
2872 if (!visitor.IsShadowFrame() && thread->HasDebuggerShadowFrames()) {
2873 Runtime::Current()->GetInstrumentation()->InstrumentThreadStack(thread);
2902 // we temporarily clear the current thread's exception (if any) and will restore it after
2906 Thread* const self = Thread::Current();
2956 Thread* const self = Thread::Current();
3026 void Dbg::UpdateDebugger(Thread* thread, mirror::Object* this_object,
3038 // see if we're that thread and we've reached a step point.
3039 const SingleStepControl* single_step_control = thread->GetSingleStepControl();
3063 int stack_depth = GetStackDepth(thread);
3088 int stack_depth = GetStackDepth(thread);
3173 MutexLock mu(Thread::Current(), *Locks::deoptimization_lock_);
3248 Thread* const self = Thread::Current();
3288 ReaderMutexLock mu(Thread::Current(), *Locks::breakpoint_lock_);
3321 static DeoptimizationRequest::Kind GetRequiredDeoptimizationKind(Thread* self,
3379 Thread* const self = Thread::Current();
3414 WriterMutexLock mu(Thread::Current(), *Locks::breakpoint_lock_);
3455 bool Dbg::IsForcedInterpreterNeededForCallingImpl(Thread* thread, ArtMethod* m) {
3456 const SingleStepControl* const ssc = thread->GetSingleStepControl();
3475 bool Dbg::IsForcedInterpreterNeededForResolutionImpl(Thread* thread, ArtMethod* m) {
3486 const SingleStepControl* const ssc = thread->GetSingleStepControl();
3498 ssc->GetStackDepth() > GetStackDepth(thread)) {
3509 bool Dbg::IsForcedInstrumentationNeededForResolutionImpl(Thread* thread, ArtMethod* m) {
3524 const SingleStepControl* const ssc = thread->GetSingleStepControl();
3532 ssc->GetStackDepth() > GetStackDepth(thread)) {
3546 bool Dbg::IsForcedInterpreterNeededForUpcallImpl(Thread* thread, ArtMethod* m) {
3561 const SingleStepControl* const ssc = thread->GetSingleStepControl();
3566 if (ssc->GetStackDepth() >= GetStackDepth(thread)) {
3570 if (thread->HasDebuggerShadowFrames()) {
3581 bool Dbg::IsForcedInterpreterNeededForExceptionImpl(Thread* thread) {
3582 const SingleStepControl* const ssc = thread->GetSingleStepControl();
3622 thread,
3630 // Scoped utility class to suspend a thread so that we may do tasks such as walk its stack. Doesn't
3631 // cause suspension if the thread is the current thread.
3634 ScopedDebuggerThreadSuspension(Thread* self, JDWP::ObjectId thread_id)
3647 Thread* suspended_thread;
3659 // Thread terminated from under us while suspending.
3669 Thread* GetThread() const {
3686 Thread* thread_;
3694 Thread* self = Thread::Current();
3703 explicit SingleStepStackVisitor(Thread* thread) REQUIRES_SHARED(Locks::mutator_lock_)
3704 : StackVisitor(thread, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
3731 Thread* const thread = sts.GetThread();
3732 SingleStepStackVisitor visitor(thread);
3746 // Note: if the thread is not running Java code (pure native thread), there is no "current"
3779 // Activate single-step in the thread.
3780 thread->ActivateSingleStepControl(single_step_control);
3783 VLOG(jdwp) << "Single-step thread: " << *thread;
3800 ScopedObjectAccessUnchecked soa(Thread::Current());
3802 Thread* thread = DecodeThread(soa, thread_id, &error);
3804 thread->DeactivateSingleStepControl();
3842 Thread* const self = Thread::Current();
3843 CHECK_EQ(self, GetDebugThread()) << "This must be called by the JDWP thread";
3847 Thread* targetThread = nullptr;
3853 LOG(ERROR) << "InvokeMethod request for invalid thread id " << thread_id;
3857 // Thread is already invoking a method on behalf of the debugger.
3858 LOG(ERROR) << "InvokeMethod request for thread already invoking a method: " << *targetThread;
3862 // Thread is not suspended by an event so it cannot invoke a method.
3863 LOG(ERROR) << "InvokeMethod request for thread not stopped by event: " << *targetThread;
3869 * target thread) once. So if a thread has been suspended more than once (either by
3872 * the threads it has suspended so the target thread can execute the method.
3878 * On the other hand, if we are asked to only resume the target thread, then we follow the
3879 * JDWP specs by resuming that thread only once. This means the thread will remain suspended
3881 * responsibility of the debugger to properly resume that thread before invoking a method).
3889 // The target thread will remain suspended even after we resume it. Let's emit a warning
3890 // to indicate the invoke won't be executed until the thread is resumed.
3892 << suspend_count << "). This thread will invoke the method only once "
3969 // Attaches the DebugInvokeReq to the target thread so it executes the method when
3970 // it is resumed. Once the invocation completes, the target thread will delete it before
3975 // The fact that we've released the thread list lock is a bit risky --- if the thread goes
3982 VLOG(jdwp) << " Resuming event thread only";
3991 Thread* const self = Thread::Current();
3992 CHECK_NE(self, GetDebugThread()) << "This must be called by the event thread";
4145 // Attach the reply to DebugInvokeReq so it can be sent to the debugger when the event thread
4172 CHECK_NE(Thread::Current(), GetDebugThread()) << "This must be called by the event thread";
4177 // We need to prevent other threads (including JDWP thread) from interacting with the debugger
4217 Thread* self = Thread::Current();
4265 Thread* self = Thread::Current();
4288 Thread* self = Thread::Current();
4325 Thread* self = Thread::Current();
4327 LOG(ERROR) << "DDM broadcast in thread state " << self->GetState();
4353 * Send a notification when a thread starts, stops, or changes its name.
4356 * first enabled, it's possible for "thread" to be actively executing.
4358 void Dbg::DdmSendThreadNotification(Thread* t, uint32_t type) {
4370 ScopedObjectAccessUnchecked soa(Thread::Current());
4391 // Enable/disable thread notifications.
4394 // Suspend the VM then post thread start notifications for all threads. Threads attaching will
4398 std::list<Thread*> threads;
4399 Thread* self = Thread::Current();
4406 for (Thread* thread : threads) {
4407 Dbg::DdmSendThreadNotification(thread, CHUNK_TYPE("THCR"));
4414 void Dbg::PostThreadStartOrStop(Thread* t, uint32_t type) {
4421 void Dbg::PostThreadStart(Thread* t) {
4425 void Dbg::PostThreadDeath(Thread* t) {
4786 Thread* self = Thread::Current();
4853 ScopedObjectAccess soa(Thread::Current());
4870 LOG(INFO) << StringPrintf(" Thread %-2d %6zd bytes ", record->GetTid(), record->ByteCount())
5012 * (2b) thread id
5045 Thread* self = Thread::Current();
5145 // (2b) thread id
5205 ReaderMutexLock mu(Thread::Current(), *Locks::breakpoint_lock_);
5212 void Dbg::DbgThreadLifecycleCallback::ThreadStart(Thread* self) {
5216 void Dbg::DbgThreadLifecycleCallback::ThreadDeath(Thread* self) {