void VariablesView::VariableTableModel::SetStackFrame(Thread* thread, StackFrame* stackFrame) { if (fContainer != NULL) { AutoLocker<ValueNodeContainer> containerLocker(fContainer); if (fContainerListener != NULL) fContainer->RemoveListener(fContainerListener); fContainer->RemoveAllChildren(); containerLocker.Unlock(); fContainer->ReleaseReference(); fContainer = NULL; } fNodeTable.Clear(true); if (!fNodes.IsEmpty()) { int32 count = fNodes.CountItems(); for (int32 i = 0; i < count; i++) fNodes.ItemAt(i)->ReleaseReference(); fNodes.MakeEmpty(); NotifyNodesRemoved(TreeTablePath(), 0, count); } fStackFrame = stackFrame; fThread = thread; if (fStackFrame != NULL) { fContainer = new(std::nothrow) ValueNodeContainer; if (fContainer == NULL) return; status_t error = fContainer->Init(); if (error != B_OK) { delete fContainer; fContainer = NULL; return; } AutoLocker<ValueNodeContainer> containerLocker(fContainer); if (fContainerListener != NULL) fContainer->AddListener(fContainerListener); for (int32 i = 0; Variable* variable = fStackFrame->ParameterAt(i); i++) { _AddNode(variable); } for (int32 i = 0; Variable* variable = fStackFrame->LocalVariableAt(i); i++) { _AddNode(variable); } // if (!fNodes.IsEmpty()) // NotifyNodesAdded(TreeTablePath(), 0, fNodes.CountItems()); } }
void SetImageDebugInfo(ImageDebugInfo* imageDebugInfo) { // unset old functions if (fSourceFileIndices != NULL) { NotifyNodesRemoved(TreeTablePath(), 0, fSourceFileCount); delete[] fFunctions; fFunctions = NULL; fFunctionCount = 0; delete[] fSourceFileIndices; fSourceFileIndices = NULL; fSourceFileCount = 0; } fImageDebugInfo = imageDebugInfo; // set new functions if (fImageDebugInfo == NULL || fImageDebugInfo->CountFunctions() == 0) return; // create an array with the functions int32 functionCount = fImageDebugInfo->CountFunctions(); FunctionInstance** functions = new(std::nothrow) FunctionInstance*[functionCount]; if (functions == NULL) return; ArrayDeleter<FunctionInstance*> functionsDeleter(functions); for (int32 i = 0; i < functionCount; i++) functions[i] = fImageDebugInfo->FunctionAt(i); // sort them std::sort(functions, functions + functionCount, &_FunctionLess); // eliminate duplicate function instances if (functionCount > 0) { Function* previousFunction = functions[0]->GetFunction(); int32 removed = 0; for (int32 i = 1; i < functionCount; i++) { if (functions[i]->GetFunction() == previousFunction) { removed++; } else { functions[i - removed] = functions[i]; previousFunction = functions[i]->GetFunction(); } } functionCount -= removed; // The array might now be too large, but we can live with that. } // count the different source files int32 sourceFileCount = 1; for (int32 i = 1; i < functionCount; i++) { if (_CompareSourceFileNames(functions[i - 1]->SourceFile(), functions[i]->SourceFile()) != 0) { sourceFileCount++; } } // allocate and init the indices for the source files fSourceFileIndices = new(std::nothrow) int32[sourceFileCount]; if (fSourceFileIndices == NULL) return; fSourceFileCount = sourceFileCount; fSourceFileIndices[0] = 0; int32 sourceFileIndex = 1; for (int32 i = 1; i < functionCount; i++) { if (_CompareSourceFileNames(functions[i - 1]->SourceFile(), functions[i]->SourceFile()) != 0) { fSourceFileIndices[sourceFileIndex++] = i; } } fFunctions = functionsDeleter.Detach(); fFunctionCount = functionCount; NotifyNodesAdded(TreeTablePath(), 0, fSourceFileCount); }