virtual bool GetToolTipForTableCell(int32 rowIndex, int32 columnIndex, BToolTip** _tip) { Thread* thread = fThreads.ItemAt(rowIndex); if (thread == NULL) return false; BString text; text << "Thread: \"" << thread->Name() << "\" (" << thread->ID() << ")\n"; switch (thread->State()) { case THREAD_STATE_RUNNING: text << "Running"; break; case THREAD_STATE_STOPPED: { switch (thread->StoppedReason()) { case THREAD_STOPPED_DEBUGGER_CALL: text << "Called debugger(): " << thread->StoppedReasonInfo(); break; case THREAD_STOPPED_EXCEPTION: text << "Caused exception: " << thread->StoppedReasonInfo(); break; case THREAD_STOPPED_BREAKPOINT: case THREAD_STOPPED_WATCHPOINT: case THREAD_STOPPED_SINGLE_STEP: case THREAD_STOPPED_DEBUGGED: case THREAD_STOPPED_UNKNOWN: default: text << "Stopped for debugging"; break; } break; } case THREAD_STATE_UNKNOWN: default: text << "Current State Unknown"; break; } BTextToolTip* tip = new(std::nothrow) BTextToolTip(text); if (tip == NULL) return false; *_tip = tip; return true; }
virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, BVariant& value) { Thread* thread = fThreads.ItemAt(rowIndex); if (thread == NULL) return false; switch (columnIndex) { case 0: value.SetTo(thread->ID()); return true; case 1: { switch (thread->State()) { case THREAD_STATE_RUNNING: value.SetTo("Running", B_VARIANT_DONT_COPY_DATA); return true; case THREAD_STATE_STOPPED: break; case THREAD_STATE_UNKNOWN: default: value.SetTo("?", B_VARIANT_DONT_COPY_DATA); return true; } // thread is stopped -- get the reason switch (thread->StoppedReason()) { case THREAD_STOPPED_DEBUGGER_CALL: value.SetTo("Call", B_VARIANT_DONT_COPY_DATA); return true; case THREAD_STOPPED_EXCEPTION: value.SetTo("Exception", B_VARIANT_DONT_COPY_DATA); return true; case THREAD_STOPPED_BREAKPOINT: case THREAD_STOPPED_WATCHPOINT: case THREAD_STOPPED_SINGLE_STEP: case THREAD_STOPPED_DEBUGGED: case THREAD_STOPPED_UNKNOWN: default: value.SetTo("Debugged", B_VARIANT_DONT_COPY_DATA); return true; } } case 2: value.SetTo(thread->Name(), B_VARIANT_DONT_COPY_DATA); return true; default: return false; } }
void CommandLineUserInterface::ThreadStateChanged(const Team::ThreadEvent& event) { if (fSaveReport) { Thread* thread = event.GetThread(); // If we were asked to attach/report on a specific thread // rather than a team, and said thread was still // running, when we attached, we need to wait for its corresponding // stop state before generating a report, else we might not get its // stack trace. if (thread->ID() == fReportTargetThread && thread->State() == THREAD_STATE_STOPPED) { _SubmitSaveReport(); } } }
void CliContext::ProcessPendingEvents() { AutoLocker<Team> teamLocker(fTeam); for (;;) { // get the next event AutoLocker<BLocker> locker(fLock); Event* event = fPendingEvents.RemoveHead(); locker.Unlock(); if (event == NULL) break; ObjectDeleter<Event> eventDeleter(event); // process the event Thread* thread = event->GetThread(); switch (event->Type()) { case EVENT_QUIT: case EVENT_DEBUG_REPORT_CHANGED: case EVENT_USER_INTERRUPT: break; case EVENT_THREAD_ADDED: printf("[new thread: %" B_PRId32 " \"%s\"]\n", thread->ID(), thread->Name()); break; case EVENT_THREAD_REMOVED: printf("[thread terminated: %" B_PRId32 " \"%s\"]\n", thread->ID(), thread->Name()); break; case EVENT_THREAD_STOPPED: printf("[thread stopped: %" B_PRId32 " \"%s\"]\n", thread->ID(), thread->Name()); break; case EVENT_THREAD_STACK_TRACE_CHANGED: if (thread == fCurrentThread) { fCurrentStackTrace = thread->GetStackTrace(); fCurrentStackTrace->AcquireReference(); SetCurrentStackFrameIndex(0); } break; case EVENT_TEAM_MEMORY_BLOCK_RETRIEVED: if (fCurrentBlock != NULL) { fCurrentBlock->ReleaseReference(); fCurrentBlock = NULL; } fCurrentBlock = event->GetMemoryBlock(); break; case EVENT_EXPRESSION_EVALUATED: fExpressionResult = event->GetExpressionResult(); if (fExpressionValue != NULL) { fExpressionValue->ReleaseReference(); fExpressionValue = NULL; } fExpressionValue = event->GetExpressionValue(); if (fExpressionValue != NULL) fExpressionValue->AcquireReference(); break; } } }