Lines Matching refs:backtrace

80   Backtrace* backtrace;  member
91 static std::string DumpFrames(Backtrace* backtrace) { in DumpFrames() argument
92 if (backtrace->NumFrames() == 0) { in DumpFrames()
97 for (size_t i = 0; i < backtrace->NumFrames(); i++) { in DumpFrames()
98 frame += " " + backtrace->FormatFrameData(i) + '\n'; in DumpFrames()
137 static bool ReadyLevelBacktrace(Backtrace* backtrace) { in ReadyLevelBacktrace() argument
140 for (Backtrace::const_iterator it = backtrace->begin(); it != backtrace->end(); ++it) { in ReadyLevelBacktrace()
150 static void VerifyLevelDump(Backtrace* backtrace) { in VerifyLevelDump() argument
151 ASSERT_GT(backtrace->NumFrames(), static_cast<size_t>(0)) in VerifyLevelDump()
152 << DumpFrames(backtrace); in VerifyLevelDump()
153 ASSERT_LT(backtrace->NumFrames(), static_cast<size_t>(MAX_BACKTRACE_FRAMES)) in VerifyLevelDump()
154 << DumpFrames(backtrace); in VerifyLevelDump()
159 for (size_t i = backtrace->NumFrames()-1; i > 2; i--) { in VerifyLevelDump()
160 if (backtrace->GetFrame(i)->func_name == "test_level_one") { in VerifyLevelDump()
165 ASSERT_LT(static_cast<size_t>(0), frame_num) << DumpFrames(backtrace); in VerifyLevelDump()
166 ASSERT_LE(static_cast<size_t>(3), frame_num) << DumpFrames(backtrace); in VerifyLevelDump()
168 ASSERT_EQ(backtrace->GetFrame(frame_num)->func_name, "test_level_one") in VerifyLevelDump()
169 << DumpFrames(backtrace); in VerifyLevelDump()
170 ASSERT_EQ(backtrace->GetFrame(frame_num-1)->func_name, "test_level_two") in VerifyLevelDump()
171 << DumpFrames(backtrace); in VerifyLevelDump()
172 ASSERT_EQ(backtrace->GetFrame(frame_num-2)->func_name, "test_level_three") in VerifyLevelDump()
173 << DumpFrames(backtrace); in VerifyLevelDump()
174 ASSERT_EQ(backtrace->GetFrame(frame_num-3)->func_name, "test_level_four") in VerifyLevelDump()
175 << DumpFrames(backtrace); in VerifyLevelDump()
179 std::unique_ptr<Backtrace> backtrace( in VerifyLevelBacktrace() local
181 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyLevelBacktrace()
182 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyLevelBacktrace()
183 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in VerifyLevelBacktrace()
185 VerifyLevelDump(backtrace.get()); in VerifyLevelBacktrace()
188 static bool ReadyMaxBacktrace(Backtrace* backtrace) { in ReadyMaxBacktrace() argument
189 return (backtrace->NumFrames() == MAX_BACKTRACE_FRAMES); in ReadyMaxBacktrace()
192 static void VerifyMaxDump(Backtrace* backtrace) { in VerifyMaxDump() argument
193 ASSERT_EQ(backtrace->NumFrames(), static_cast<size_t>(MAX_BACKTRACE_FRAMES)) in VerifyMaxDump()
194 << DumpFrames(backtrace); in VerifyMaxDump()
196 ASSERT_EQ(backtrace->GetFrame(MAX_BACKTRACE_FRAMES-1)->func_name, "test_recursive_call") in VerifyMaxDump()
197 << DumpFrames(backtrace); in VerifyMaxDump()
201 std::unique_ptr<Backtrace> backtrace( in VerifyMaxBacktrace() local
203 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyMaxBacktrace()
204 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyMaxBacktrace()
205 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in VerifyMaxBacktrace()
207 VerifyMaxDump(backtrace.get()); in VerifyMaxBacktrace()
232 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), getpid())); in TEST() local
233 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
234 ASSERT_TRUE(backtrace->Unwind(0)); in TEST()
235 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in TEST()
237 ASSERT_TRUE(backtrace->NumFrames() != 0); in TEST()
238 for (const auto& frame : *backtrace ) { in TEST()
242 << DumpFrames(backtrace.get()); in TEST()
328 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, tid, map.get())); in VerifyProcTest() local
329 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyProcTest()
330 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyProcTest()
331 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in VerifyProcTest()
332 if (ReadyFunc(backtrace.get())) { in VerifyProcTest()
333 VerifyFunc(backtrace.get()); in VerifyProcTest()
336 last_dump = DumpFrames(backtrace.get()); in VerifyProcTest()
476 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), gettid())); in VerifyLevelThread() local
477 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyLevelThread()
478 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyLevelThread()
479 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in VerifyLevelThread()
481 VerifyLevelDump(backtrace.get()); in VerifyLevelThread()
489 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), gettid())); in VerifyMaxThread() local
490 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyMaxThread()
491 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyMaxThread()
492 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in VerifyMaxThread()
494 VerifyMaxDump(backtrace.get()); in VerifyMaxThread()
531 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), thread_data.tid)); in TEST() local
532 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
533 ASSERT_TRUE(backtrace->Unwind(0)); in TEST()
534 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in TEST()
536 VerifyLevelDump(backtrace.get()); in TEST()
612 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), thread_data.tid)); in TEST() local
613 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
614 ASSERT_TRUE(backtrace->Unwind(0)); in TEST()
615 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in TEST()
617 VerifyMaxDump(backtrace.get()); in TEST()
632 dump->backtrace = Backtrace::Create(getpid(), dump->thread.tid); in ThreadDump()
633 dump->backtrace->Unwind(0); in ThreadDump()
681 ASSERT_TRUE(dumpers[i].backtrace != nullptr); in TEST()
682 VerifyMaxDump(dumpers[i].backtrace); in TEST()
684 delete dumpers[i].backtrace; in TEST()
685 dumpers[i].backtrace = nullptr; in TEST()
721 ASSERT_TRUE(dumpers[i].backtrace != nullptr); in TEST()
722 VerifyMaxDump(dumpers[i].backtrace); in TEST()
724 delete dumpers[i].backtrace; in TEST()
725 dumpers[i].backtrace = nullptr; in TEST()
781 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), BACKTRACE_CURRENT_THREAD)); in TEST() local
782 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
798 backtrace->FormatFrameData(&frame)); in TEST()
810 backtrace->FormatFrameData(&frame)); in TEST()
823 backtrace->FormatFrameData(&frame)); in TEST()
835 backtrace->FormatFrameData(&frame)); in TEST()
844 backtrace->FormatFrameData(&frame)); in TEST()
853 backtrace->FormatFrameData(&frame)); in TEST()
863 backtrace->FormatFrameData(&frame)); in TEST()
872 backtrace->FormatFrameData(&frame)); in TEST()
973 static void RunReadTest(Backtrace* backtrace, uintptr_t read_addr) { in RunReadTest() argument
982 size_t bytes_read = backtrace->Read(read_addr, data, 2 * pagesize); in RunReadTest()
988 bytes_read = backtrace->Read(read_addr + i, data, 2 * sizeof(word_t)); in RunReadTest()
999 bytes_read = backtrace->Read(read_addr + i, data, j); in RunReadTest()
1021 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), thread_data.tid)); in TEST() local
1022 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
1024 RunReadTest(backtrace.get(), reinterpret_cast<uintptr_t>(thread_data.data)); in TEST()
1075 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, pid)); in TEST() local
1076 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
1079 size_t bytes_read = backtrace->Read(reinterpret_cast<uintptr_t>(&g_ready), in TEST()
1085 bytes_read = backtrace->Read(reinterpret_cast<uintptr_t>(&g_addr), in TEST()
1090 RunReadTest(backtrace.get(), read_addr); in TEST()
1173 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(BACKTRACE_CURRENT_PROCESS, in TEST() local
1175 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
1178 backtrace->Unwind(0); in TEST()
1186 std::string func_name = backtrace->GetFunctionName(read_addr, &offset); in TEST()
1246 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, BACKTRACE_CURRENT_THREAD)); in TEST() local
1247 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
1250 …ASSERT_EQ(sizeof(uintptr_t), backtrace->Read(reinterpret_cast<uintptr_t>(&g_ready), reinterpret_ca… in TEST()
1252 …ASSERT_EQ(sizeof(uintptr_t), backtrace->Read(reinterpret_cast<uintptr_t>(&g_addr), reinterpret_cas… in TEST()
1255 backtrace->Unwind(0); in TEST()
1262 std::string func_name = backtrace->GetFunctionName(read_addr, &offset); in TEST()
1284 static bool FindFuncFrameInBacktrace(Backtrace* backtrace, uintptr_t test_func, size_t* frame_num) { in FindFuncFrameInBacktrace() argument
1286 backtrace->FillInMap(test_func, &map); in FindFuncFrameInBacktrace()
1293 for (Backtrace::const_iterator it = backtrace->begin(); it != backtrace->end(); ++it) { in FindFuncFrameInBacktrace()
1303 static void VerifyUnreadableElfFrame(Backtrace* backtrace, uintptr_t test_func, size_t frame_num) { in VerifyUnreadableElfFrame() argument
1304 ASSERT_LT(backtrace->NumFrames(), static_cast<size_t>(MAX_BACKTRACE_FRAMES)) in VerifyUnreadableElfFrame()
1305 << DumpFrames(backtrace); in VerifyUnreadableElfFrame()
1307 ASSERT_TRUE(frame_num != 0) << DumpFrames(backtrace); in VerifyUnreadableElfFrame()
1309 ASSERT_LT(frame_num, backtrace->NumFrames()) << DumpFrames(backtrace); in VerifyUnreadableElfFrame()
1311 uintptr_t diff = backtrace->GetFrame(frame_num)->pc - test_func; in VerifyUnreadableElfFrame()
1312 ASSERT_LT(diff, 200U) << DumpFrames(backtrace); in VerifyUnreadableElfFrame()
1316 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(BACKTRACE_CURRENT_PROCESS, in VerifyUnreadableElfBacktrace() local
1318 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyUnreadableElfBacktrace()
1319 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyUnreadableElfBacktrace()
1320 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in VerifyUnreadableElfBacktrace()
1323 ASSERT_TRUE(FindFuncFrameInBacktrace(backtrace.get(), test_func, &frame_num)); in VerifyUnreadableElfBacktrace()
1325 VerifyUnreadableElfFrame(backtrace.get(), test_func, frame_num); in VerifyUnreadableElfBacktrace()
1374 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, BACKTRACE_CURRENT_THREAD)); in TEST() local
1375 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
1376 ASSERT_TRUE(backtrace->Unwind(0)); in TEST()
1377 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in TEST()
1380 if (FindFuncFrameInBacktrace(backtrace.get(), in TEST()
1383 VerifyUnreadableElfFrame(backtrace.get(), reinterpret_cast<uintptr_t>(test_func), frame_num); in TEST()
1402 std::unique_ptr<Backtrace> backtrace( in TEST() local
1404 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
1405 ASSERT_FALSE(backtrace->Unwind(0)); in TEST()
1406 ASSERT_EQ(BACKTRACE_UNWIND_ERROR_THREAD_DOESNT_EXIST, backtrace->GetError()); in TEST()
1410 std::unique_ptr<Backtrace> backtrace( in TEST() local
1412 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
1417 ASSERT_NE(std::string(""), backtrace->GetFunctionName(cur_func_offset, &offset)); in TEST()
1425 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, pid)); in TEST() local
1430 ASSERT_NE(std::string(""), backtrace->GetFunctionName(cur_func_offset, &offset)); in TEST()
1501 static void UnwindFromDevice(Backtrace* backtrace, void* device_map) { in UnwindFromDevice() argument
1505 backtrace->FillInMap(device_map_uint, &map); in UnwindFromDevice()
1511 ASSERT_EQ(std::string(""), backtrace->GetFunctionName(device_map_uint, &offset)); in UnwindFromDevice()
1512 ASSERT_EQ(std::string(""), backtrace->GetFunctionName(device_map_uint, &offset, &map)); in UnwindFromDevice()
1513 ASSERT_EQ(std::string(""), backtrace->GetFunctionName(0, &offset)); in UnwindFromDevice()
1517 backtrace->FillInMap(cur_func_offset, &map); in UnwindFromDevice()
1519 ASSERT_NE(std::string(""), backtrace->GetFunctionName(cur_func_offset, &offset, &map)); in UnwindFromDevice()
1521 ASSERT_EQ(std::string(""), backtrace->GetFunctionName(cur_func_offset, &offset, &map)); in UnwindFromDevice()
1532 ASSERT_TRUE(backtrace->Unwind(0, &ucontext)); in UnwindFromDevice()
1535 ASSERT_EQ(1U, backtrace->NumFrames()); in UnwindFromDevice()
1536 const backtrace_frame_data_t* frame = backtrace->GetFrame(0); in UnwindFromDevice()
1541 ASSERT_TRUE(backtrace->Unwind(1, &ucontext)); in UnwindFromDevice()
1542 ASSERT_EQ(0U, backtrace->NumFrames()); in UnwindFromDevice()
1551 ASSERT_TRUE(backtrace->Unwind(0, &ucontext)); in UnwindFromDevice()
1554 ASSERT_EQ(1U, backtrace->NumFrames()); in UnwindFromDevice()
1555 frame = backtrace->GetFrame(0); in UnwindFromDevice()
1560 ASSERT_TRUE(backtrace->Unwind(1, &ucontext)); in UnwindFromDevice()
1561 ASSERT_EQ(0U, backtrace->NumFrames()); in UnwindFromDevice()
1569 std::unique_ptr<Backtrace> backtrace( in TEST() local
1571 ASSERT_TRUE(backtrace); in TEST()
1573 UnwindFromDevice(backtrace.get(), device_map); in TEST()
1587 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, pid)); in TEST() local
1658 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, pid)); in UnwindThroughSignal() local
1660 size_t bytes_read = backtrace->Read(reinterpret_cast<uintptr_t>(const_cast<int*>(&value)), in UnwindThroughSignal()
1676 std::unique_ptr<Backtrace> backtrace; in UnwindThroughSignal() local
1684 backtrace.reset(Backtrace::Create(pid, pid)); in UnwindThroughSignal()
1685 ASSERT_TRUE(backtrace->Unwind(0)); in UnwindThroughSignal()
1687 for (frame_iter = backtrace->begin(); frame_iter != backtrace->end(); ++frame_iter) { in UnwindThroughSignal()
1702 << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1708 for (; frame_iter != backtrace->end(); ++frame_iter) { in UnwindThroughSignal()
1715 << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1726 ASSERT_LE(frame + 2, names.size()) << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1727 ASSERT_LE(2U, frame) << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1729 ASSERT_EQ("test_signal_action", names[0]) << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1731 ASSERT_EQ("test_signal_handler", names[0]) << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1733 ASSERT_EQ("test_level_three", names[frame]) << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1734 ASSERT_EQ("test_level_two", names[frame + 1]) << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1735 ASSERT_EQ("test_level_one", names[frame + 2]) << DumpFrames(backtrace.get()); in UnwindThroughSignal()
1752 Backtrace* backtrace = Backtrace::Create(pid, tid); in CheckForLeak() local
1753 ASSERT_TRUE(backtrace != nullptr); in CheckForLeak()
1754 ASSERT_TRUE(backtrace->Unwind(0)); in CheckForLeak()
1755 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in CheckForLeak()
1756 delete backtrace; in CheckForLeak()
1763 Backtrace* backtrace = Backtrace::Create(pid, tid); in CheckForLeak() local
1764 ASSERT_TRUE(backtrace != nullptr); in CheckForLeak()
1765 ASSERT_TRUE(backtrace->Unwind(0)); in CheckForLeak()
1766 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in CheckForLeak()
1767 delete backtrace; in CheckForLeak()