Lines Matching defs:unwinder

31 #include "unwinder.h"
34 #include <unwind.h> // GCC's internal unwinder, part of libgcc
61 * @tc.desc: test unwinder GetStackRange interface in pid == tid
67 auto unwinder = std::make_shared<Unwinder>();
71 ASSERT_TRUE(unwinder->GetStackRange(stackBottom, stackTop));
81 * @tc.desc: test unwinder GetStackRange interface in pid != tid
87 auto unwinder = std::make_shared<Unwinder>();
93 std::thread th([unwinder, &stackBottom, &stackTop, &result] {
94 result = unwinder->GetStackRange(stackBottom, stackTop);
105 * @tc.desc: test unwinder local unwind
111 auto unwinder = std::make_shared<Unwinder>();
113 MAYBE_UNUSED bool unwRet = unwinder->UnwindLocal();
114 unwinder->EnableMethodIdLocal(true);
117 auto frames = unwinder->GetFrames();
122 unwRet = unwinder->UnwindLocal(false, false, DEFAULT_MAX_FRAME_NUM, skipFrameNum);
124 auto frames2 = unwinder->GetFrames();
132 * @tc.desc: test unwinder local unwind n counts
139 std::shared_ptr<Unwinder> unwinder = nullptr;
145 unwinder = it->second;
147 unwinder = std::make_shared<Unwinder>();
150 MAYBE_UNUSED bool unwRet = unwinder->UnwindLocal();
153 auto frames = unwinder->GetFrames();
158 unwinders_[pid] = unwinder;
166 * @tc.desc: test unwinder UnwindLocal interface
177 auto unwinder = std::make_shared<Unwinder>();
180 ASSERT_TRUE(unwinder->UnwindLocal());
186 * @tc.desc: test unwinder remote unwind
199 auto unwinder = std::make_shared<Unwinder>(child);
203 unwRet = unwinder->UnwindRemote(child);
206 auto frames = unwinder->GetFrames();
211 unwRet = unwinder->UnwindRemote(child, false, DEFAULT_MAX_FRAME_NUM, skipFrameNum);
213 auto frames2 = unwinder->GetFrames();
222 * @tc.desc: test unwinder remote unwind n counts
236 std::shared_ptr<Unwinder> unwinder = nullptr;
242 unwinder = it->second;
244 unwinder = std::make_shared<Unwinder>(child);
247 unwRet = unwinder->UnwindRemote(child);
250 auto frames = unwinder->GetFrames();
255 unwinders_[child] = unwinder;
264 * @tc.desc: test unwinder UnwindRemote interface
281 * @tc.desc: test unwinder unwind interface in remote case
294 auto unwinder = std::make_shared<Unwinder>(child);
298 unwinder->SetRegs(regs);
305 unwRet = unwinder->Unwind(&context);
308 auto frames = unwinder->GetFrames();
319 * @tc.desc: test unwinder unwind interface in local case
325 auto unwinder = std::make_shared<Unwinder>();
327 ASSERT_TRUE(unwinder->GetStackRange(stackBottom, stackTop));
337 unwinder->SetRegs(regs);
342 bool unwRet = unwinder->Unwind(&context);
344 auto frames = unwinder->GetFrames();
360 auto unwinder = std::make_shared<Unwinder>();
361 unwinder->IgnoreMixstack(true);
362 MAYBE_UNUSED bool unwRet = unwinder->UnwindLocal();
364 unwinder->EnableFillFrames(false);
365 const auto& frames = unwinder->GetFrames();
368 uint16_t errorCode = unwinder->GetLastErrorCode();
369 uint64_t errorAddr = unwinder->GetLastErrorAddr();
377 * @tc.desc: test unwinder local unwind for
385 auto unwinder = std::make_shared<Unwinder>();
387 MAYBE_UNUSED bool unwRet = unwinder->UnwindLocal();
389 auto frames = unwinder->GetFrames();
405 * @tc.desc: test unwinder Step interface in remote case
418 auto unwinder = std::make_shared<Unwinder>(child);
423 unwinder->SetRegs(regs);
435 unwRet = unwinder->Step(pc, sp, &context);
443 * @tc.desc: test unwinder Step interface in local case
449 auto unwinder = std::make_shared<Unwinder>();
451 ASSERT_TRUE(unwinder->GetStackRange(stackBottom, stackTop));
463 unwinder->SetRegs(regs);
470 bool unwRet = unwinder->Step(pc, sp, &context);
478 * @tc.desc: test unwinder UnwindByFp interface in remote case
491 auto unwinder = std::make_shared<Unwinder>(child);
495 unwinder->SetRegs(regs);
499 unwRet = unwinder->UnwindByFp(&context);
504 auto pcs = unwinder->GetPcs();
506 unwinder->GetFramesByPcs(frames, pcs);
514 * @tc.desc: test unwinder FpStep interface in local case
520 auto unwinder = std::make_shared<Unwinder>();
523 ASSERT_TRUE(unwinder->GetStackRange(stackBottom, stackTop));
534 unwinder->SetRegs(regs);
536 bool unwRet = unwinder->UnwindByFp(&context);
538 auto unwSize = unwinder->GetPcs().size();
544 unwinder->SetRegs(regs);
551 if (!unwinder->FpStep(fp, pc, &context) || (pc == 0)) {
565 * @tc.desc: test unwinder Step interface in lr callback with apply failed case
571 auto unwinder = std::make_shared<Unwinder>();
573 ASSERT_TRUE(unwinder->GetStackRange(stackBottom, stackTop));
585 unwinder->SetRegs(regs);
587 context.maps = unwinder->GetMaps();
595 bool unwRet = unwinder->Step(pc, failSp, &context);
603 * @tc.desc: test unwinder Step interface in lr callback with step failed case
609 auto unwinder = std::make_shared<Unwinder>();
611 ASSERT_TRUE(unwinder->GetStackRange(stackBottom, stackTop));
623 unwinder->SetRegs(regs);
625 context.maps = unwinder->GetMaps();
631 bool unwRet = unwinder->Step(failPc, sp, &context);
660 * @tc.desc: test unwinder FillFrame interface
667 auto unwinder = std::make_shared<Unwinder>();
669 unwinder->FillFrame(frame);
675 unwinder->FillFrame(frame);
685 unwinder->FillFrame(frame);
693 * @tc.desc: test unwinder FillJsFrame interface
700 auto unwinder = std::make_shared<Unwinder>();
702 unwinder->FillJsFrame(frame);
708 unwinder->FillJsFrame(frame);
716 * @tc.desc: test unwinder FillFrames interface
728 auto unwinder = std::make_shared<Unwinder>();
735 unwinder->FillFrames(frames);
743 * @tc.desc: test unwinder UnwindLocalWithContext interface
777 auto unwinder = std::make_shared<Unwinder>();
778 ASSERT_TRUE(unwinder->UnwindLocalWithContext(context));
779 auto frames = unwinder->GetFrames();
804 * @tc.desc: test unwinder UnwindLocalWithTid interface
811 auto unwinder = std::make_shared<Unwinder>();
818 ASSERT_TRUE(unwinder->UnwindLocalWithTid(g_tid));
820 auto pcs = unwinder->GetPcs();
822 unwinder->GetFramesByPcs(frames, pcs);
824 auto frames = unwinder->GetFrames();
853 * @tc.desc: test unwinder UnwindLocal interface
859 auto unwinder = std::make_shared<Unwinder>();
860 if (unwinder->UnwindLocal()) {
861 auto frames = unwinder->GetFrames();
874 * @tc.desc: test unwinder UnwindRemote interface
881 auto unwinder = std::make_shared<Unwinder>(initPid);
883 if (unwinder->UnwindRemote(initPid)) {
884 auto frames = unwinder->GetFrames();
898 * @tc.desc: test unwinder GetSymbolByPc interface
905 auto unwinder = std::make_shared<Unwinder>();
906 unwinder->UnwindLocal();
907 auto frames = unwinder->GetFrames();
912 ASSERT_FALSE(unwinder->GetSymbolByPc(0x00000000, maps, funcName, funcOffset)); // Find map is null
913 ASSERT_FALSE(unwinder->GetSymbolByPc(pc0, maps, funcName, funcOffset)); // Get elf is null
919 * @tc.desc: test unwinder AccessMem interface
925 auto unwinder = std::make_shared<Unwinder>();
938 EXPECT_FALSE(unwinder->AccessMem(&memory, addr, nullptr));
950 auto unwinder = std::make_shared<Unwinder>(getpid());
951 unwinder->EnableUnwindCache(false);
952 unwinder->EnableFpCheckMapExec(false);
953 auto regs = unwinder->GetRegs();
956 unwinder->FillFrame(frame);
957 unwinder->AddFrame(frame);
958 unwinder->ArkWriteJitCodeToFile(1);
959 auto jitCache = unwinder->GetJitCache();