Пример #1
0
TeamWindow::~TeamWindow()
{
	if (fThreadListView != NULL)
		fThreadListView->UnsetListener();
	if (fStackTraceView != NULL)
		fStackTraceView->UnsetListener();
	if (fSourceView != NULL)
		fSourceView->UnsetListener();
	if (fInspectorWindow != NULL) {
		BMessenger messenger(fInspectorWindow);
		if (messenger.LockTarget())
			fInspectorWindow->Quit();
	}

	fTeam->RemoveListener(this);

	_SetActiveSourceCode(NULL);
	_SetActiveFunction(NULL);
	_SetActiveBreakpoint(NULL);
	_SetActiveStackFrame(NULL);
	_SetActiveStackTrace(NULL);
	_SetActiveImage(NULL);
	_SetActiveThread(NULL);

	delete fFilePanel;

	if (fActiveSourceWorker > 0)
		wait_for_thread(fActiveSourceWorker, NULL);
}
Пример #2
0
void
TeamWindow::_HandleSourceCodeChanged()
{
	// If we don't have an active function anymore, the message is obsolete.
	if (fActiveFunction == NULL)
		return;

	// get a reference to the source code
	AutoLocker< ::Team> locker(fTeam);

	SourceCode* sourceCode = fActiveFunction->GetFunction()->GetSourceCode();
	LocatableFile* sourceFile = NULL;
	BString sourceText;
	BString truncatedText;
	if (sourceCode == NULL)
		sourceCode = fActiveFunction->GetSourceCode();

	if (sourceCode != NULL)
		sourceFile = fActiveFunction->GetFunctionDebugInfo()->SourceFile();

	if (sourceFile != NULL && !sourceFile->GetLocatedPath(sourceText))
		sourceFile->GetPath(sourceText);

	if (sourceCode != NULL && sourceCode->GetSourceFile() == NULL
		&& sourceFile != NULL) {
		sourceText.Prepend("Click to locate source file '");
		sourceText += "'";
		truncatedText = sourceText;
		fSourcePathView->TruncateString(&truncatedText, B_TRUNCATE_MIDDLE,
			fSourcePathView->Bounds().Width());
		if (sourceText != truncatedText)
			fSourcePathView->SetToolTip(sourceText.String());
		fSourcePathView->SetText(truncatedText.String());
	} else if (sourceFile != NULL) {
		sourceText.Prepend("File: ");
		fSourcePathView->SetText(sourceText.String());
	} else
		fSourcePathView->SetText("Source file unavailable.");

	BReference<SourceCode> sourceCodeReference(sourceCode);

	locker.Unlock();

	_SetActiveSourceCode(sourceCode);
}
Пример #3
0
void
TeamWindow::_HandleSourceCodeChanged()
{
	// If we don't have an active function anymore, the message is obsolete.
	if (fActiveFunction == NULL)
		return;

	// get a reference to the source code
	AutoLocker< ::Team> locker(fTeam);

	SourceCode* sourceCode = fActiveFunction->GetFunction()->GetSourceCode();
	if (sourceCode == NULL)
		sourceCode = fActiveFunction->GetSourceCode();

	BReference<SourceCode> sourceCodeReference(sourceCode);

	locker.Unlock();

	_SetActiveSourceCode(sourceCode);
}
Пример #4
0
TeamWindow::~TeamWindow()
{
	if (fThreadListView != NULL)
		fThreadListView->UnsetListener();
	if (fStackTraceView != NULL)
		fStackTraceView->UnsetListener();
	if (fSourceView != NULL)
		fSourceView->UnsetListener();

	fTeam->RemoveListener(this);

	_SetActiveSourceCode(NULL);
	_SetActiveFunction(NULL);
	_SetActiveBreakpoint(NULL);
	_SetActiveStackFrame(NULL);
	_SetActiveStackTrace(NULL);
	_SetActiveImage(NULL);
	_SetActiveThread(NULL);

	delete fFilePanel;
}
Пример #5
0
void
TeamWindow::_SetActiveFunction(FunctionInstance* functionInstance)
{
	if (functionInstance == fActiveFunction)
		return;

	AutoLocker< ::Team> locker(fTeam);

	if (fActiveFunction != NULL) {
		fActiveFunction->GetFunction()->RemoveListener(this);
		fActiveFunction->ReleaseReference();
	}

	// to avoid listener feedback problems, first unset the active function and
	// set the new image, if any
	locker.Unlock();

	fActiveFunction = NULL;

	if (functionInstance != NULL)
		_SetActiveImage(fTeam->ImageByAddress(functionInstance->Address()));

	fActiveFunction = functionInstance;

	locker.Lock();

	SourceCode* sourceCode = NULL;
	BReference<SourceCode> sourceCodeReference;

	if (fActiveFunction != NULL) {
		fActiveFunction->AcquireReference();
		fActiveFunction->GetFunction()->AddListener(this);

		Function* function = fActiveFunction->GetFunction();
		sourceCode = function->GetSourceCode();
		if (sourceCode == NULL)
			sourceCode = fActiveFunction->GetSourceCode();
		sourceCodeReference.SetTo(sourceCode);

		// If the source code is not loaded yet, request it.
		if (function->SourceCodeState() == FUNCTION_SOURCE_NOT_LOADED)
			fListener->FunctionSourceCodeRequested(fActiveFunction);
	}

	locker.Unlock();

	_SetActiveSourceCode(sourceCode);

	fImageFunctionsView->SetFunction(fActiveFunction);

	locker.Lock();

	// look if our current stack trace has a frame matching the selected
	// function. If so, set it to match.
	StackFrame* matchingFrame = NULL;
	BReference<StackFrame> frameRef;

	if (fActiveStackTrace != NULL) {
		for (int32 i = 0; i < fActiveStackTrace->CountFrames(); i++) {
			StackFrame* frame = fActiveStackTrace->FrameAt(i);
			if (frame->Function() == fActiveFunction) {
				matchingFrame = frame;
				frameRef.SetTo(frame);
				break;
			}
		}
	}

	locker.Unlock();

	if (matchingFrame != NULL)
		_SetActiveStackFrame(matchingFrame);
}