Lines Matching refs:backtrace
87 Backtrace* backtrace; member
95 static void VerifyLevelDump(Backtrace* backtrace, create_func_t create_func = nullptr,
97 static void VerifyMaxDump(Backtrace* backtrace, create_func_t create_func = nullptr,
123 static std::string DumpFrames(Backtrace* backtrace) { in DumpFrames() argument
124 if (backtrace->NumFrames() == 0) { in DumpFrames()
129 for (size_t i = 0; i < backtrace->NumFrames(); i++) { in DumpFrames()
130 frame += " " + backtrace->FormatFrameData(i) + '\n'; in DumpFrames()
180 static bool ReadyLevelBacktrace(Backtrace* backtrace) { in ReadyLevelBacktrace() argument
183 for (Backtrace::const_iterator it = backtrace->begin(); it != backtrace->end(); ++it) { in ReadyLevelBacktrace()
193 static void VerifyLevelDump(Backtrace* backtrace, create_func_t, map_create_func_t) { in VerifyLevelDump() argument
194 ASSERT_GT(backtrace->NumFrames(), static_cast<size_t>(0)) in VerifyLevelDump()
195 << DumpFrames(backtrace); in VerifyLevelDump()
196 ASSERT_LT(backtrace->NumFrames(), static_cast<size_t>(MAX_BACKTRACE_FRAMES)) in VerifyLevelDump()
197 << DumpFrames(backtrace); in VerifyLevelDump()
202 for (size_t i = backtrace->NumFrames()-1; i > 2; i--) { in VerifyLevelDump()
203 if (backtrace->GetFrame(i)->func_name == "test_level_one") { in VerifyLevelDump()
208 ASSERT_LT(static_cast<size_t>(0), frame_num) << DumpFrames(backtrace); in VerifyLevelDump()
209 ASSERT_LE(static_cast<size_t>(3), frame_num) << DumpFrames(backtrace); in VerifyLevelDump()
211 ASSERT_EQ(backtrace->GetFrame(frame_num)->func_name, "test_level_one") in VerifyLevelDump()
212 << DumpFrames(backtrace); in VerifyLevelDump()
213 ASSERT_EQ(backtrace->GetFrame(frame_num-1)->func_name, "test_level_two") in VerifyLevelDump()
214 << DumpFrames(backtrace); in VerifyLevelDump()
215 ASSERT_EQ(backtrace->GetFrame(frame_num-2)->func_name, "test_level_three") in VerifyLevelDump()
216 << DumpFrames(backtrace); in VerifyLevelDump()
217 ASSERT_EQ(backtrace->GetFrame(frame_num-3)->func_name, "test_level_four") in VerifyLevelDump()
218 << DumpFrames(backtrace); in VerifyLevelDump()
222 std::unique_ptr<Backtrace> backtrace( in VerifyLevelBacktrace() local
224 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyLevelBacktrace()
225 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyLevelBacktrace()
226 VERIFY_NO_ERROR(backtrace->GetError().error_code); in VerifyLevelBacktrace()
228 VerifyLevelDump(backtrace.get()); in VerifyLevelBacktrace()
231 static bool ReadyMaxBacktrace(Backtrace* backtrace) { in ReadyMaxBacktrace() argument
232 return (backtrace->NumFrames() == MAX_BACKTRACE_FRAMES); in ReadyMaxBacktrace()
235 static void VerifyMaxDump(Backtrace* backtrace, create_func_t, map_create_func_t) { in VerifyMaxDump() argument
236 ASSERT_EQ(backtrace->NumFrames(), static_cast<size_t>(MAX_BACKTRACE_FRAMES)) in VerifyMaxDump()
237 << DumpFrames(backtrace); in VerifyMaxDump()
239 ASSERT_EQ(backtrace->GetFrame(MAX_BACKTRACE_FRAMES-1)->func_name, "test_recursive_call") in VerifyMaxDump()
240 << DumpFrames(backtrace); in VerifyMaxDump()
244 std::unique_ptr<Backtrace> backtrace( in VerifyMaxBacktrace() local
246 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyMaxBacktrace()
247 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyMaxBacktrace()
248 ASSERT_EQ(BACKTRACE_UNWIND_ERROR_EXCEED_MAX_FRAMES_LIMIT, backtrace->GetError().error_code); in VerifyMaxBacktrace()
250 VerifyMaxDump(backtrace.get()); in VerifyMaxBacktrace()
275 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), getpid())); in TEST_F() local
276 ASSERT_TRUE(backtrace.get() != nullptr); in TEST_F()
277 ASSERT_TRUE(backtrace->Unwind(0)); in TEST_F()
278 VERIFY_NO_ERROR(backtrace->GetError().error_code); in TEST_F()
280 ASSERT_TRUE(backtrace->NumFrames() != 0); in TEST_F()
282 for (const auto& frame : *backtrace ) { in TEST_F()
286 ASSERT_TRUE(name != lib) << DumpFrames(backtrace.get()); in TEST_F()
295 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), getpid())); in TEST_F() local
296 ASSERT_TRUE(backtrace.get() != nullptr); in TEST_F()
297 backtrace->SetSkipFrames(false); in TEST_F()
298 ASSERT_TRUE(backtrace->Unwind(0)); in TEST_F()
299 VERIFY_NO_ERROR(backtrace->GetError().error_code); in TEST_F()
301 ASSERT_TRUE(backtrace->NumFrames() != 0); in TEST_F()
303 for (const auto& frame : *backtrace) { in TEST_F()
321 << DumpFrames(backtrace.get()); in TEST_F()
407 std::unique_ptr<Backtrace> backtrace(create_func(pid, tid, map.get())); in VerifyProcTest() local
408 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyProcTest()
409 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyProcTest()
410 if (ReadyFunc(backtrace.get())) { in VerifyProcTest()
411 VerifyFunc(backtrace.get(), create_func, map_create_func); in VerifyProcTest()
414 last_dump = DumpFrames(backtrace.get()); in VerifyProcTest()
546 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), android::base::GetThreadId())); in VerifyLevelThread() local
547 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyLevelThread()
548 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyLevelThread()
549 VERIFY_NO_ERROR(backtrace->GetError().error_code); in VerifyLevelThread()
551 VerifyLevelDump(backtrace.get()); in VerifyLevelThread()
559 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), android::base::GetThreadId())); in VerifyMaxThread() local
560 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyMaxThread()
561 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyMaxThread()
562 ASSERT_EQ(BACKTRACE_UNWIND_ERROR_EXCEED_MAX_FRAMES_LIMIT, backtrace->GetError().error_code); in VerifyMaxThread()
564 VerifyMaxDump(backtrace.get()); in VerifyMaxThread()
601 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), thread_data.tid)); in TEST_F() local
602 ASSERT_TRUE(backtrace.get() != nullptr); in TEST_F()
603 ASSERT_TRUE(backtrace->Unwind(0)); in TEST_F()
604 VERIFY_NO_ERROR(backtrace->GetError().error_code); in TEST_F()
606 VerifyLevelDump(backtrace.get()); in TEST_F()
683 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), thread_data.tid)); in TEST_F() local
684 ASSERT_TRUE(backtrace.get() != nullptr); in TEST_F()
685 ASSERT_TRUE(backtrace->Unwind(0)); in TEST_F()
686 ASSERT_EQ(BACKTRACE_UNWIND_ERROR_EXCEED_MAX_FRAMES_LIMIT, backtrace->GetError().error_code); in TEST_F()
688 VerifyMaxDump(backtrace.get()); in TEST_F()
703 dump->backtrace = Backtrace::Create(getpid(), dump->thread.tid, dump->map); in ThreadDump()
704 dump->backtrace->Unwind(0); in ThreadDump()
757 ASSERT_TRUE(dumpers[i].backtrace != nullptr); in MultipleThreadDumpTest()
758 VerifyMaxDump(dumpers[i].backtrace); in MultipleThreadDumpTest()
760 delete dumpers[i].backtrace; in MultipleThreadDumpTest()
761 dumpers[i].backtrace = nullptr; in MultipleThreadDumpTest()
822 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), BACKTRACE_CURRENT_THREAD)); in TEST_F() local
823 ASSERT_TRUE(backtrace.get() != nullptr); in TEST_F()
840 backtrace->FormatFrameData(&frame)); in TEST_F()
853 backtrace->FormatFrameData(&frame)); in TEST_F()
866 backtrace->FormatFrameData(&frame)); in TEST_F()
879 backtrace->FormatFrameData(&frame)); in TEST_F()
888 backtrace->FormatFrameData(&frame)); in TEST_F()
897 backtrace->FormatFrameData(&frame)); in TEST_F()
908 backtrace->FormatFrameData(&frame)); in TEST_F()
917 backtrace->FormatFrameData(&frame)); in TEST_F()
1054 static void RunReadTest(Backtrace* backtrace, uint64_t read_addr) { in RunReadTest() argument
1063 size_t bytes_read = backtrace->Read(read_addr, data, 2 * pagesize); in RunReadTest()
1069 bytes_read = backtrace->Read(read_addr + i, data, 2 * sizeof(word_t)); in RunReadTest()
1080 bytes_read = backtrace->Read(read_addr + i, data, j); in RunReadTest()
1102 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), thread_data.tid)); in TEST_F() local
1103 ASSERT_TRUE(backtrace.get() != nullptr); in TEST_F()
1105 RunReadTest(backtrace.get(), reinterpret_cast<uint64_t>(thread_data.data)); in TEST_F()
1158 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, pid)); in TEST_F() local
1159 ASSERT_TRUE(backtrace.get() != nullptr); in TEST_F()
1162 size_t bytes_read = backtrace->Read(reinterpret_cast<uint64_t>(&g_ready), in TEST_F()
1167 bytes_read = backtrace->Read(reinterpret_cast<uint64_t>(&g_addr), in TEST_F()
1171 RunReadTest(backtrace.get(), read_addr); in TEST_F()
1244 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(BACKTRACE_CURRENT_PROCESS, in TEST_F() local
1246 ASSERT_TRUE(backtrace.get() != nullptr); in TEST_F()
1249 backtrace->Unwind(0); in TEST_F()
1256 std::string func_name = backtrace->GetFunctionName(read_addr, &offset); in TEST_F()
1317 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, BACKTRACE_CURRENT_THREAD)); in TEST_F() local
1318 ASSERT_TRUE(backtrace.get() != nullptr); in TEST_F()
1322 backtrace->Read(reinterpret_cast<uint64_t>(&g_ready), in TEST_F()
1326 backtrace->Read(reinterpret_cast<uint64_t>(&g_addr), in TEST_F()
1330 backtrace->Unwind(0); in TEST_F()
1337 std::string func_name = backtrace->GetFunctionName(read_addr, &offset); in TEST_F()
1359 static bool FindFuncFrameInBacktrace(Backtrace* backtrace, uint64_t test_func, size_t* frame_num) { in FindFuncFrameInBacktrace() argument
1361 backtrace->FillInMap(test_func, &map); in FindFuncFrameInBacktrace()
1368 for (Backtrace::const_iterator it = backtrace->begin(); it != backtrace->end(); ++it) { in FindFuncFrameInBacktrace()
1378 static void VerifyUnreadableElfFrame(Backtrace* backtrace, uint64_t test_func, size_t frame_num) { in VerifyUnreadableElfFrame() argument
1379 ASSERT_LT(backtrace->NumFrames(), static_cast<size_t>(MAX_BACKTRACE_FRAMES)) in VerifyUnreadableElfFrame()
1380 << DumpFrames(backtrace); in VerifyUnreadableElfFrame()
1382 ASSERT_TRUE(frame_num != 0) << DumpFrames(backtrace); in VerifyUnreadableElfFrame()
1384 ASSERT_LT(frame_num, backtrace->NumFrames()) << DumpFrames(backtrace); in VerifyUnreadableElfFrame()
1386 uint64_t diff = backtrace->GetFrame(frame_num)->pc - test_func; in VerifyUnreadableElfFrame()
1387 ASSERT_LT(diff, 200U) << DumpFrames(backtrace); in VerifyUnreadableElfFrame()
1391 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(BACKTRACE_CURRENT_PROCESS, in VerifyUnreadableElfBacktrace() local
1393 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyUnreadableElfBacktrace()
1394 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyUnreadableElfBacktrace()
1395 VERIFY_NO_ERROR(backtrace->GetError().error_code); in VerifyUnreadableElfBacktrace()
1399 ASSERT_TRUE(FindFuncFrameInBacktrace(backtrace.get(), test_func, &frame_num)) in VerifyUnreadableElfBacktrace()
1400 << DumpFrames(backtrace.get()); in VerifyUnreadableElfBacktrace()
1402 VerifyUnreadableElfFrame(backtrace.get(), test_func, frame_num); in VerifyUnreadableElfBacktrace()
1452 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, BACKTRACE_CURRENT_THREAD)); in TEST_F() local
1453 ASSERT_TRUE(backtrace.get() != nullptr); in TEST_F()
1454 ASSERT_TRUE(backtrace->Unwind(0)); in TEST_F()
1455 VERIFY_NO_ERROR(backtrace->GetError().error_code); in TEST_F()
1458 if (FindFuncFrameInBacktrace(backtrace.get(), reinterpret_cast<uint64_t>(test_func), in TEST_F()
1461 VerifyUnreadableElfFrame(backtrace.get(), reinterpret_cast<uint64_t>(test_func), frame_num); in TEST_F()
1480 std::unique_ptr<Backtrace> backtrace( in TEST_F() local
1482 ASSERT_TRUE(backtrace.get() != nullptr); in TEST_F()
1483 ASSERT_FALSE(backtrace->Unwind(0)); in TEST_F()
1484 ASSERT_EQ(BACKTRACE_UNWIND_ERROR_THREAD_DOESNT_EXIST, backtrace->GetError().error_code); in TEST_F()
1488 std::unique_ptr<Backtrace> backtrace( in TEST_F() local
1490 ASSERT_TRUE(backtrace.get() != nullptr); in TEST_F()
1495 ASSERT_NE(std::string(""), backtrace->GetFunctionName(cur_func_offset, &offset)); in TEST_F()
1503 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, pid)); in TEST_F() local
1508 ASSERT_NE(std::string(""), backtrace->GetFunctionName(cur_func_offset, &offset)); in TEST_F()
1579 static void UnwindFromDevice(Backtrace* backtrace, void* device_map) { in UnwindFromDevice() argument
1583 backtrace->FillInMap(device_map_uint, &map); in UnwindFromDevice()
1589 ASSERT_EQ(std::string(""), backtrace->GetFunctionName(device_map_uint, &offset)); in UnwindFromDevice()
1590 ASSERT_EQ(std::string(""), backtrace->GetFunctionName(device_map_uint, &offset, &map)); in UnwindFromDevice()
1591 ASSERT_EQ(std::string(""), backtrace->GetFunctionName(0, &offset)); in UnwindFromDevice()
1595 backtrace->FillInMap(cur_func_offset, &map); in UnwindFromDevice()
1597 ASSERT_NE(std::string(""), backtrace->GetFunctionName(cur_func_offset, &offset, &map)); in UnwindFromDevice()
1599 ASSERT_EQ(std::string(""), backtrace->GetFunctionName(cur_func_offset, &offset, &map)); in UnwindFromDevice()
1610 ASSERT_TRUE(backtrace->Unwind(0, &ucontext)); in UnwindFromDevice()
1613 ASSERT_EQ(1U, backtrace->NumFrames()); in UnwindFromDevice()
1614 const backtrace_frame_data_t* frame = backtrace->GetFrame(0); in UnwindFromDevice()
1619 ASSERT_TRUE(backtrace->Unwind(1, &ucontext)); in UnwindFromDevice()
1620 ASSERT_EQ(0U, backtrace->NumFrames()); in UnwindFromDevice()
1629 ASSERT_TRUE(backtrace->Unwind(0, &ucontext)); in UnwindFromDevice()
1632 ASSERT_EQ(1U, backtrace->NumFrames()); in UnwindFromDevice()
1633 frame = backtrace->GetFrame(0); in UnwindFromDevice()
1638 ASSERT_TRUE(backtrace->Unwind(1, &ucontext)); in UnwindFromDevice()
1639 ASSERT_EQ(0U, backtrace->NumFrames()); in UnwindFromDevice()
1647 std::unique_ptr<Backtrace> backtrace( in TEST_F() local
1649 ASSERT_TRUE(backtrace); in TEST_F()
1651 UnwindFromDevice(backtrace.get(), device_map); in TEST_F()
1665 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, pid)); in TEST_F() local
1667 UnwindFromDevice(backtrace.get(), device_map); in TEST_F()
1734 std::unique_ptr<Backtrace> backtrace(create_func(pid, pid, map.get())); in UnwindThroughSignal() local
1736 size_t bytes_read = backtrace->Read(reinterpret_cast<uint64_t>(const_cast<int*>(&value)), in UnwindThroughSignal()
1753 std::unique_ptr<Backtrace> backtrace; in UnwindThroughSignal() local
1763 backtrace.reset(create_func(pid, pid, map.get())); in UnwindThroughSignal()
1764 ASSERT_TRUE(backtrace->Unwind(0)); in UnwindThroughSignal()
1766 for (frame_iter = backtrace->begin(); frame_iter != backtrace->end(); ++frame_iter) { in UnwindThroughSignal()
1781 << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1787 for (; frame_iter != backtrace->end(); ++frame_iter) { in UnwindThroughSignal()
1794 << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1805 ASSERT_LE(frame + 2, names.size()) << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1806 ASSERT_LE(2U, frame) << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1808 ASSERT_EQ("test_signal_action", names[0]) << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1810 ASSERT_EQ("test_signal_handler", names[0]) << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1812 ASSERT_EQ("test_level_three", names[frame]) << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1813 ASSERT_EQ("test_level_two", names[frame + 1]) << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1814 ASSERT_EQ("test_level_one", names[frame + 2]) << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1829 std::unique_ptr<Backtrace> backtrace( in TestFrameSkipNumbering() local
1831 backtrace->Unwind(1); in TestFrameSkipNumbering()
1832 ASSERT_NE(0U, backtrace->NumFrames()); in TestFrameSkipNumbering()
1833 ASSERT_EQ(0U, backtrace->GetFrame(0)->num); in TestFrameSkipNumbering()
1849 Backtrace* backtrace = Backtrace::Create(pid, tid, map.get()); in CheckForLeak() local
1850 ASSERT_TRUE(backtrace != nullptr); in CheckForLeak()
1851 ASSERT_TRUE(backtrace->Unwind(0)); in CheckForLeak()
1852 VERIFY_NO_ERROR(backtrace->GetError().error_code); in CheckForLeak()
1853 delete backtrace; in CheckForLeak()