public function testGetTitle() { // Create a stack frame with zero fields (special case) $model = new StackFrame(); $title = $model->getTitle(); $this->assertTrue($title == '[WARNING: Stack unwind information not available. Frames below may be wrong.]'); $model->addr_pc = 0x123456; $title = $model->getTitle(); $this->assertTrue($title == '0x123456'); $model->module_id = 1; $model->offs_in_module = 0x43435; $title = $model->getTitle(); $this->assertTrue($title == 'CrashRptd.dll!+0x43435'); // Set some sym info $model->symbol_name = '__test@test@@AAZ'; $model->offs_in_symbol = 0x123; $title = $model->getTitle(); $this->assertTrue($title == 'CrashRptd.dll! __test@test@@AAZ +0x123 '); // Set source file info $model->src_line = 60; $title = $model->getTitle(); $this->assertTrue($title == 'CrashRptd.dll! __test@test@@AAZ +0x123 [line 60]'); $model->src_file_name = 'CrashRpt.cpp'; $title = $model->getTitle(); $this->assertTrue($title == 'CrashRptd.dll! __test@test@@AAZ +0x123 [CrashRpt.cpp: 60]'); // Find a stack frame with symbol info $model = StackFrame::model()->findByPk(1); $title = $model->getTitle(); $this->assertTrue($title == 'CrashRptd.dll! CMainDlg::OnCrash() +0x1 [CrashRptTest.cpp: 1023]'); }
/** * Scans stack trace for this thread and retrieves the uppermost frame * with symbol information. The information is considered as thread entry * point function name. */ public function getThreadFuncName() { // Look for uppermost stack frame. $criteria = new CDbCriteria(); $criteria->compare('thread_id', $this->id); $criteria->addCondition('symbol_name IS NOT NULL'); $criteria->order = 'id DESC'; $stackFrame = StackFrame::model()->find($criteria); if ($stackFrame === null) { return 'n/a'; } else { if (isset($stackFrame->und_symbol_name)) { return $stackFrame->und_symbol_name; } else { return $stackFrame->symbol_name; } } }