Lines Matching refs:backtrace
76 Backtrace* backtrace; member
94 std::string DumpFrames(Backtrace* backtrace) { in DumpFrames() argument
95 if (backtrace->NumFrames() == 0) { in DumpFrames()
100 for (size_t i = 0; i < backtrace->NumFrames(); i++) { in DumpFrames()
101 frame += " " + backtrace->FormatFrameData(i) + '\n'; in DumpFrames()
119 bool ReadyLevelBacktrace(Backtrace* backtrace) { in ReadyLevelBacktrace() argument
122 for (Backtrace::const_iterator it = backtrace->begin(); it != backtrace->end(); ++it) { in ReadyLevelBacktrace()
132 void VerifyLevelDump(Backtrace* backtrace) { in VerifyLevelDump() argument
133 ASSERT_GT(backtrace->NumFrames(), static_cast<size_t>(0)) in VerifyLevelDump()
134 << DumpFrames(backtrace); in VerifyLevelDump()
135 ASSERT_LT(backtrace->NumFrames(), static_cast<size_t>(MAX_BACKTRACE_FRAMES)) in VerifyLevelDump()
136 << DumpFrames(backtrace); in VerifyLevelDump()
141 for (size_t i = backtrace->NumFrames()-1; i > 2; i--) { in VerifyLevelDump()
142 if (backtrace->GetFrame(i)->func_name == "test_level_one") { in VerifyLevelDump()
147 ASSERT_LT(static_cast<size_t>(0), frame_num) << DumpFrames(backtrace); in VerifyLevelDump()
148 ASSERT_LE(static_cast<size_t>(3), frame_num) << DumpFrames(backtrace); in VerifyLevelDump()
150 ASSERT_EQ(backtrace->GetFrame(frame_num)->func_name, "test_level_one") in VerifyLevelDump()
151 << DumpFrames(backtrace); in VerifyLevelDump()
152 ASSERT_EQ(backtrace->GetFrame(frame_num-1)->func_name, "test_level_two") in VerifyLevelDump()
153 << DumpFrames(backtrace); in VerifyLevelDump()
154 ASSERT_EQ(backtrace->GetFrame(frame_num-2)->func_name, "test_level_three") in VerifyLevelDump()
155 << DumpFrames(backtrace); in VerifyLevelDump()
156 ASSERT_EQ(backtrace->GetFrame(frame_num-3)->func_name, "test_level_four") in VerifyLevelDump()
157 << DumpFrames(backtrace); in VerifyLevelDump()
161 std::unique_ptr<Backtrace> backtrace( in VerifyLevelBacktrace() local
163 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyLevelBacktrace()
164 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyLevelBacktrace()
165 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in VerifyLevelBacktrace()
167 VerifyLevelDump(backtrace.get()); in VerifyLevelBacktrace()
170 bool ReadyMaxBacktrace(Backtrace* backtrace) { in ReadyMaxBacktrace() argument
171 return (backtrace->NumFrames() == MAX_BACKTRACE_FRAMES); in ReadyMaxBacktrace()
174 void VerifyMaxDump(Backtrace* backtrace) { in VerifyMaxDump() argument
175 ASSERT_EQ(backtrace->NumFrames(), static_cast<size_t>(MAX_BACKTRACE_FRAMES)) in VerifyMaxDump()
176 << DumpFrames(backtrace); in VerifyMaxDump()
178 ASSERT_EQ(backtrace->GetFrame(MAX_BACKTRACE_FRAMES-1)->func_name, "test_recursive_call") in VerifyMaxDump()
179 << DumpFrames(backtrace); in VerifyMaxDump()
183 std::unique_ptr<Backtrace> backtrace( in VerifyMaxBacktrace() local
185 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyMaxBacktrace()
186 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyMaxBacktrace()
187 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in VerifyMaxBacktrace()
189 VerifyMaxDump(backtrace.get()); in VerifyMaxBacktrace()
202 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), tid)); in VerifyThreadTest() local
203 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyThreadTest()
204 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyThreadTest()
205 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in VerifyThreadTest()
207 VerifyFunc(backtrace.get()); in VerifyThreadTest()
223 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), getpid())); in TEST() local
224 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
225 ASSERT_TRUE(backtrace->Unwind(0)); in TEST()
226 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in TEST()
228 ASSERT_TRUE(backtrace->NumFrames() != 0); in TEST()
229 for (const auto& frame : *backtrace ) { in TEST()
233 << DumpFrames(backtrace.get()); in TEST()
321 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, tid, map.get())); in VerifyProcTest() local
322 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyProcTest()
323 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyProcTest()
324 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in VerifyProcTest()
325 if (ReadyFunc(backtrace.get())) { in VerifyProcTest()
326 VerifyFunc(backtrace.get()); in VerifyProcTest()
329 last_dump = DumpFrames(backtrace.get()); in VerifyProcTest()
473 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), gettid())); in VerifyLevelThread() local
474 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyLevelThread()
475 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyLevelThread()
476 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in VerifyLevelThread()
478 VerifyLevelDump(backtrace.get()); in VerifyLevelThread()
486 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), gettid())); in VerifyMaxThread() local
487 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyMaxThread()
488 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyMaxThread()
489 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in VerifyMaxThread()
491 VerifyMaxDump(backtrace.get()); in VerifyMaxThread()
528 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), thread_data.tid)); in TEST() local
529 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
530 ASSERT_TRUE(backtrace->Unwind(0)); in TEST()
531 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in TEST()
533 VerifyLevelDump(backtrace.get()); in TEST()
609 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), thread_data.tid)); in TEST() local
610 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
611 ASSERT_TRUE(backtrace->Unwind(0)); in TEST()
612 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in TEST()
614 VerifyMaxDump(backtrace.get()); in TEST()
629 dump->backtrace = Backtrace::Create(getpid(), dump->thread.tid); in ThreadDump()
630 dump->backtrace->Unwind(0); in ThreadDump()
678 ASSERT_TRUE(dumpers[i].backtrace != nullptr); in TEST()
679 VerifyMaxDump(dumpers[i].backtrace); in TEST()
681 delete dumpers[i].backtrace; in TEST()
682 dumpers[i].backtrace = nullptr; in TEST()
718 ASSERT_TRUE(dumpers[i].backtrace != nullptr); in TEST()
719 VerifyMaxDump(dumpers[i].backtrace); in TEST()
721 delete dumpers[i].backtrace; in TEST()
722 dumpers[i].backtrace = nullptr; in TEST()
778 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), BACKTRACE_CURRENT_THREAD)); in TEST() local
779 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
795 backtrace->FormatFrameData(&frame)); in TEST()
807 backtrace->FormatFrameData(&frame)); in TEST()
820 backtrace->FormatFrameData(&frame)); in TEST()
832 backtrace->FormatFrameData(&frame)); in TEST()
841 backtrace->FormatFrameData(&frame)); in TEST()
850 backtrace->FormatFrameData(&frame)); in TEST()
860 backtrace->FormatFrameData(&frame)); in TEST()
869 backtrace->FormatFrameData(&frame)); in TEST()
985 void RunReadTest(Backtrace* backtrace, uintptr_t read_addr) { in RunReadTest() argument
994 size_t bytes_read = backtrace->Read(read_addr, data, 2 * pagesize); in RunReadTest()
1000 bytes_read = backtrace->Read(read_addr + i, data, 2 * sizeof(word_t)); in RunReadTest()
1011 bytes_read = backtrace->Read(read_addr + i, data, j); in RunReadTest()
1033 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), thread_data.tid)); in TEST() local
1034 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
1036 RunReadTest(backtrace.get(), reinterpret_cast<uintptr_t>(thread_data.data)); in TEST()
1087 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, pid)); in TEST() local
1088 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
1091 size_t bytes_read = backtrace->Read(reinterpret_cast<uintptr_t>(&g_ready), in TEST()
1097 bytes_read = backtrace->Read(reinterpret_cast<uintptr_t>(&g_addr), in TEST()
1102 RunReadTest(backtrace.get(), read_addr); in TEST()
1185 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(BACKTRACE_CURRENT_PROCESS, in TEST() local
1187 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
1190 backtrace->Unwind(0); in TEST()
1198 std::string func_name = backtrace->GetFunctionName(read_addr, &offset); in TEST()
1258 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, BACKTRACE_CURRENT_THREAD)); in TEST() local
1259 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
1262 …ASSERT_EQ(sizeof(uintptr_t), backtrace->Read(reinterpret_cast<uintptr_t>(&g_ready), reinterpret_ca… in TEST()
1264 …ASSERT_EQ(sizeof(uintptr_t), backtrace->Read(reinterpret_cast<uintptr_t>(&g_addr), reinterpret_cas… in TEST()
1267 backtrace->Unwind(0); in TEST()
1274 std::string func_name = backtrace->GetFunctionName(read_addr, &offset); in TEST()
1296 bool FindFuncFrameInBacktrace(Backtrace* backtrace, uintptr_t test_func, size_t* frame_num) { in FindFuncFrameInBacktrace() argument
1298 backtrace->FillInMap(test_func, &map); in FindFuncFrameInBacktrace()
1305 for (Backtrace::const_iterator it = backtrace->begin(); it != backtrace->end(); ++it) { in FindFuncFrameInBacktrace()
1315 void VerifyUnreadableElfFrame(Backtrace* backtrace, uintptr_t test_func, size_t frame_num) { in VerifyUnreadableElfFrame() argument
1316 ASSERT_LT(backtrace->NumFrames(), static_cast<size_t>(MAX_BACKTRACE_FRAMES)) in VerifyUnreadableElfFrame()
1317 << DumpFrames(backtrace); in VerifyUnreadableElfFrame()
1319 ASSERT_TRUE(frame_num != 0) << DumpFrames(backtrace); in VerifyUnreadableElfFrame()
1321 ASSERT_LT(frame_num, backtrace->NumFrames()) << DumpFrames(backtrace); in VerifyUnreadableElfFrame()
1323 uintptr_t diff = backtrace->GetFrame(frame_num)->pc - test_func; in VerifyUnreadableElfFrame()
1324 ASSERT_LT(diff, 200U) << DumpFrames(backtrace); in VerifyUnreadableElfFrame()
1328 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(BACKTRACE_CURRENT_PROCESS, in VerifyUnreadableElfBacktrace() local
1330 ASSERT_TRUE(backtrace.get() != nullptr); in VerifyUnreadableElfBacktrace()
1331 ASSERT_TRUE(backtrace->Unwind(0)); in VerifyUnreadableElfBacktrace()
1332 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in VerifyUnreadableElfBacktrace()
1335 ASSERT_TRUE(FindFuncFrameInBacktrace(backtrace.get(), test_func, &frame_num)); in VerifyUnreadableElfBacktrace()
1337 VerifyUnreadableElfFrame(backtrace.get(), test_func, frame_num); in VerifyUnreadableElfBacktrace()
1386 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, BACKTRACE_CURRENT_THREAD)); in TEST() local
1387 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
1388 ASSERT_TRUE(backtrace->Unwind(0)); in TEST()
1389 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in TEST()
1392 if (FindFuncFrameInBacktrace(backtrace.get(), in TEST()
1395 VerifyUnreadableElfFrame(backtrace.get(), reinterpret_cast<uintptr_t>(test_func), frame_num); in TEST()
1414 std::unique_ptr<Backtrace> backtrace( in TEST() local
1416 ASSERT_TRUE(backtrace.get() != nullptr); in TEST()
1417 ASSERT_FALSE(backtrace->Unwind(0)); in TEST()
1418 ASSERT_EQ(BACKTRACE_UNWIND_ERROR_THREAD_DOESNT_EXIST, backtrace->GetError()); in TEST()
1429 Backtrace* backtrace = Backtrace::Create(pid, tid); in CheckForLeak() local
1430 ASSERT_TRUE(backtrace != nullptr); in CheckForLeak()
1431 ASSERT_TRUE(backtrace->Unwind(0)); in CheckForLeak()
1432 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in CheckForLeak()
1433 delete backtrace; in CheckForLeak()
1440 Backtrace* backtrace = Backtrace::Create(pid, tid); in CheckForLeak() local
1441 ASSERT_TRUE(backtrace != nullptr); in CheckForLeak()
1442 ASSERT_TRUE(backtrace->Unwind(0)); in CheckForLeak()
1443 ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); in CheckForLeak()
1444 delete backtrace; in CheckForLeak()