Ejemplo n.º 1
0
status_t
DebugReportGenerator::_DumpRunningThreads(BFile& _output)
{
	AutoLocker< ::Team> locker(fTeam);

	BString data("\nActive Threads:\n");
	WRITE_AND_CHECK(_output, data);
	BObjectList< ::Thread> threads;
	::Thread* thread;
	for (ThreadList::ConstIterator it = fTeam->Threads().GetIterator();
		  (thread = it.Next());) {
		 threads.AddItem(thread);
	}

	threads.SortItems(&_CompareThreads);
	for (int32 i = 0; (thread = threads.ItemAt(i)) != NULL; i++) {
		try {
			data.SetToFormat("\tthread %" B_PRId32 ": %s %s\n", thread->ID(),
					thread->Name(), thread->IsMainThread()
						? "(main)" : "");
			WRITE_AND_CHECK(_output, data);

			if (thread->State() == THREAD_STATE_STOPPED) {
				data.SetToFormat("\t\tstate: %s",
					UiUtils::ThreadStateToString(thread->State(),
							thread->StoppedReason()));
				const BString& stoppedInfo = thread->StoppedReasonInfo();
				if (stoppedInfo.Length() != 0)
					data << " (" << stoppedInfo << ")";
				data << "\n\n";
				WRITE_AND_CHECK(_output, data);

				// we need to release our lock on the team here
				// since we might need to block and wait
				// on the stack trace.
				BReference< ::Thread> threadRef(thread);
				locker.Unlock();
				status_t error = _DumpDebuggedThreadInfo(_output, thread);
				if (error != B_OK)
					return error;
				locker.Lock();
			}
		} catch (...) {
			return B_NO_MEMORY;
		}
	}

	return B_OK;
}
Ejemplo n.º 2
0
status_t
DebugReportGenerator::_DumpRunningThreads(BString& _output)
{
	AutoLocker< ::Team> locker(fTeam);

	_output << "\nActive Threads:\n";
	BString data;
	status_t result = B_OK;
	for (ThreadList::ConstIterator it = fTeam->Threads().GetIterator();
		 ::Thread* thread = it.Next();) {
		try {
			data.SetToFormat("\t%s %s, id: %" B_PRId32", state: %s",
					thread->Name(), thread->IsMainThread()
						? "(main)" : "", thread->ID(),
					UiUtils::ThreadStateToString(thread->State(),
							thread->StoppedReason()));

			if (thread->State() == THREAD_STATE_STOPPED) {
				const BString& stoppedInfo = thread->StoppedReasonInfo();
				if (stoppedInfo.Length() != 0)
					data << " (" << stoppedInfo << ")";
			}

			_output << data << "\n";

			if (thread->State() == THREAD_STATE_STOPPED) {
				// we need to release our lock on the team here
				// since we might need to block and wait
				// on the stack trace.
				BReference< ::Thread> threadRef(thread);
				locker.Unlock();
				result = _DumpDebuggedThreadInfo(_output, thread);
				locker.Lock();
			}
			if (result != B_OK)
				return result;
		} catch (...) {
			return B_NO_MEMORY;
		}
	}

	return B_OK;
}