1800b99b8Sopenharmony_ci/* 2800b99b8Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3800b99b8Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4800b99b8Sopenharmony_ci * you may not use this file except in compliance with the License. 5800b99b8Sopenharmony_ci * You may obtain a copy of the License at 6800b99b8Sopenharmony_ci * 7800b99b8Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8800b99b8Sopenharmony_ci * 9800b99b8Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10800b99b8Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11800b99b8Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12800b99b8Sopenharmony_ci * See the License for the specific language governing permissions and 13800b99b8Sopenharmony_ci * limitations under the License. 14800b99b8Sopenharmony_ci */ 15800b99b8Sopenharmony_ci 16800b99b8Sopenharmony_ci#include <gtest/gtest.h> 17800b99b8Sopenharmony_ci#include <memory> 18800b99b8Sopenharmony_ci#include <string> 19800b99b8Sopenharmony_ci 20800b99b8Sopenharmony_ci#include "dfx_regs.h" 21800b99b8Sopenharmony_ci#include "dfx_regs_get.h" 22800b99b8Sopenharmony_ci#include "dfx_ring_buffer_wrapper.h" 23800b99b8Sopenharmony_ci#include "dfx_dump_request.h" 24800b99b8Sopenharmony_ci#include "dfx_thread.h" 25800b99b8Sopenharmony_ci#include "lock_parser.h" 26800b99b8Sopenharmony_ci#include <pthread.h> 27800b99b8Sopenharmony_ci#include "printer.h" 28800b99b8Sopenharmony_ci#include "process_dumper.h" 29800b99b8Sopenharmony_ci#include "dfx_unwind_async_thread.h" 30800b99b8Sopenharmony_ci#include "dfx_unwind_remote.h" 31800b99b8Sopenharmony_ci#include "dfx_util.h" 32800b99b8Sopenharmony_ci#include "dfx_test_util.h" 33800b99b8Sopenharmony_ci 34800b99b8Sopenharmony_ciusing namespace OHOS::HiviewDFX; 35800b99b8Sopenharmony_ciusing namespace testing::ext; 36800b99b8Sopenharmony_ciusing namespace std; 37800b99b8Sopenharmony_ci 38800b99b8Sopenharmony_cinamespace OHOS { 39800b99b8Sopenharmony_cinamespace HiviewDFX { 40800b99b8Sopenharmony_ciclass ProcessDumpTest : public testing::Test { 41800b99b8Sopenharmony_cipublic: 42800b99b8Sopenharmony_ci static void SetUpTestCase(void) {} 43800b99b8Sopenharmony_ci static void TearDownTestCase(void) {} 44800b99b8Sopenharmony_ci void SetUp() {} 45800b99b8Sopenharmony_ci void TearDown() {} 46800b99b8Sopenharmony_ci}; 47800b99b8Sopenharmony_ci} // namespace HiviewDFX 48800b99b8Sopenharmony_ci} // namespace OHOS 49800b99b8Sopenharmony_ci 50800b99b8Sopenharmony_cinamespace { 51800b99b8Sopenharmony_civoid *SleepThread(void *argv) 52800b99b8Sopenharmony_ci{ 53800b99b8Sopenharmony_ci int threadID = *(int*)argv; 54800b99b8Sopenharmony_ci printf("create MultiThread %d", threadID); 55800b99b8Sopenharmony_ci 56800b99b8Sopenharmony_ci const int sleepTime = 10; 57800b99b8Sopenharmony_ci sleep(sleepTime); 58800b99b8Sopenharmony_ci 59800b99b8Sopenharmony_ci return nullptr; 60800b99b8Sopenharmony_ci} 61800b99b8Sopenharmony_ci/** 62800b99b8Sopenharmony_ci * @tc.name: DfxProcessTest001 63800b99b8Sopenharmony_ci * @tc.desc: test DfxProcess Create 64800b99b8Sopenharmony_ci * @tc.type: FUNC 65800b99b8Sopenharmony_ci */ 66800b99b8Sopenharmony_ciHWTEST_F (ProcessDumpTest, DfxProcessTest001, TestSize.Level2) 67800b99b8Sopenharmony_ci{ 68800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxProcessTest001: start."; 69800b99b8Sopenharmony_ci std::shared_ptr<DfxProcess> process = DfxProcess::Create(getpid(), getpid()); 70800b99b8Sopenharmony_ci EXPECT_EQ(false, process == nullptr) << "DfxProcessTest001 Failed"; 71800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxProcessTest001: end."; 72800b99b8Sopenharmony_ci} 73800b99b8Sopenharmony_ci 74800b99b8Sopenharmony_ci/** 75800b99b8Sopenharmony_ci * @tc.name: DfxProcessTest002 76800b99b8Sopenharmony_ci * @tc.desc: test init process threads 77800b99b8Sopenharmony_ci * @tc.type: FUNC 78800b99b8Sopenharmony_ci */ 79800b99b8Sopenharmony_ciHWTEST_F (ProcessDumpTest, DfxProcessTest002, TestSize.Level2) 80800b99b8Sopenharmony_ci{ 81800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxProcessTest002: start."; 82800b99b8Sopenharmony_ci pid_t accountmgrPid = GetProcessPid(ACCOUNTMGR_NAME); 83800b99b8Sopenharmony_ci bool isSuccess = accountmgrPid != 0; 84800b99b8Sopenharmony_ci if (!isSuccess) { 85800b99b8Sopenharmony_ci ASSERT_FALSE(isSuccess); 86800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxProcessTest002: get pid failed."; 87800b99b8Sopenharmony_ci return; 88800b99b8Sopenharmony_ci } 89800b99b8Sopenharmony_ci pid_t pid = accountmgrPid; 90800b99b8Sopenharmony_ci pid_t tid = accountmgrPid; 91800b99b8Sopenharmony_ci auto keyThread = DfxThread::Create(pid, tid, tid); 92800b99b8Sopenharmony_ci auto process = DfxProcess::Create(pid, pid); 93800b99b8Sopenharmony_ci EXPECT_EQ(true, process != nullptr) << "DfxProcessTest002 Failed"; 94800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxProcessTest002: end."; 95800b99b8Sopenharmony_ci} 96800b99b8Sopenharmony_ci 97800b99b8Sopenharmony_ci/** 98800b99b8Sopenharmony_ci * @tc.name: DfxProcessTest003 99800b99b8Sopenharmony_ci * @tc.desc: test init other threads 100800b99b8Sopenharmony_ci * @tc.type: FUNC 101800b99b8Sopenharmony_ci */ 102800b99b8Sopenharmony_ciHWTEST_F (ProcessDumpTest, DfxProcessTest003, TestSize.Level2) 103800b99b8Sopenharmony_ci{ 104800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxProcessTest003: start."; 105800b99b8Sopenharmony_ci std::shared_ptr<DfxProcess> process = DfxProcess::Create(getpid(), getpid()); 106800b99b8Sopenharmony_ci auto ret = process->InitOtherThreads(); 107800b99b8Sopenharmony_ci EXPECT_EQ(true, ret) << "DfxProcessTest003 Failed"; 108800b99b8Sopenharmony_ci auto threads = process->GetOtherThreads(); 109800b99b8Sopenharmony_ci EXPECT_GT(threads.size(), 0) << "DfxProcessTest003 Failed"; 110800b99b8Sopenharmony_ci process->ClearOtherThreads(); 111800b99b8Sopenharmony_ci threads = process->GetOtherThreads(); 112800b99b8Sopenharmony_ci EXPECT_EQ(threads.size(), 0) << "DfxProcessTest003 Failed"; 113800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxProcessTest003: end."; 114800b99b8Sopenharmony_ci} 115800b99b8Sopenharmony_ci 116800b99b8Sopenharmony_ci/** 117800b99b8Sopenharmony_ci * @tc.name: DfxProcessTest004 118800b99b8Sopenharmony_ci * @tc.desc: test Attach Detach 119800b99b8Sopenharmony_ci * @tc.type: FUNC 120800b99b8Sopenharmony_ci */ 121800b99b8Sopenharmony_ciHWTEST_F (ProcessDumpTest, DfxProcessTest004, TestSize.Level2) 122800b99b8Sopenharmony_ci{ 123800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxProcessTest004: start."; 124800b99b8Sopenharmony_ci std::shared_ptr<DfxProcess> process = DfxProcess::Create(getpid(), getpid()); 125800b99b8Sopenharmony_ci auto ret = process->InitOtherThreads(); 126800b99b8Sopenharmony_ci EXPECT_EQ(true, ret) << "DfxProcessTest004 Failed"; 127800b99b8Sopenharmony_ci process->Attach(); 128800b99b8Sopenharmony_ci process->Detach(); 129800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxProcessTest004: end."; 130800b99b8Sopenharmony_ci} 131800b99b8Sopenharmony_ci 132800b99b8Sopenharmony_ci/** 133800b99b8Sopenharmony_ci * @tc.name: DfxProcessTest005 134800b99b8Sopenharmony_ci * @tc.desc: test DfxProcess ChangeTid 135800b99b8Sopenharmony_ci * @tc.type: FUNC 136800b99b8Sopenharmony_ci */ 137800b99b8Sopenharmony_ciHWTEST_F (ProcessDumpTest, DfxProcessTest005, TestSize.Level2) 138800b99b8Sopenharmony_ci{ 139800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxProcessTest005: start."; 140800b99b8Sopenharmony_ci pid_t pid = getpid(); 141800b99b8Sopenharmony_ci std::shared_ptr<DfxProcess> process1 = DfxProcess::Create(pid, pid); 142800b99b8Sopenharmony_ci pid_t ret = process1->ChangeTid(pid, false); 143800b99b8Sopenharmony_ci process1->Attach(); 144800b99b8Sopenharmony_ci process1->Detach(); 145800b99b8Sopenharmony_ci ASSERT_EQ(ret, pid); 146800b99b8Sopenharmony_ci pthread_t tid; 147800b99b8Sopenharmony_ci int threadID[1] = {1}; 148800b99b8Sopenharmony_ci pthread_create(&tid, NULL, SleepThread, &threadID[0]); 149800b99b8Sopenharmony_ci std::shared_ptr<DfxProcess> process2 = DfxProcess::Create(pid, tid); 150800b99b8Sopenharmony_ci ret = process2->ChangeTid(pid, false); 151800b99b8Sopenharmony_ci pthread_join(tid, NULL); 152800b99b8Sopenharmony_ci process2->Attach(); 153800b99b8Sopenharmony_ci process2->Detach(); 154800b99b8Sopenharmony_ci ASSERT_EQ(ret, pid); 155800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxProcessTest005: end."; 156800b99b8Sopenharmony_ci} 157800b99b8Sopenharmony_ci 158800b99b8Sopenharmony_ci/** 159800b99b8Sopenharmony_ci * @tc.name: DfxThreadTest001 160800b99b8Sopenharmony_ci * @tc.desc: test DfxThread Create 161800b99b8Sopenharmony_ci * @tc.type: FUNC 162800b99b8Sopenharmony_ci */ 163800b99b8Sopenharmony_ciHWTEST_F (ProcessDumpTest, DfxThreadTest001, TestSize.Level2) 164800b99b8Sopenharmony_ci{ 165800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxThreadTest001: start."; 166800b99b8Sopenharmony_ci int32_t pid = 1, tid = 1; 167800b99b8Sopenharmony_ci auto thread = DfxThread::Create(pid, tid, tid); 168800b99b8Sopenharmony_ci EXPECT_EQ(true, thread != nullptr) << "DfxThreadTest001 failed"; 169800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxThreadTest001: end."; 170800b99b8Sopenharmony_ci} 171800b99b8Sopenharmony_ci 172800b99b8Sopenharmony_ci/** 173800b99b8Sopenharmony_ci * @tc.name: DfxThreadTest002 174800b99b8Sopenharmony_ci * @tc.desc: test DfxThread GetThreadRegs 175800b99b8Sopenharmony_ci * @tc.type: FUNC 176800b99b8Sopenharmony_ci */ 177800b99b8Sopenharmony_ciHWTEST_F (ProcessDumpTest, DfxThreadTest002, TestSize.Level2) 178800b99b8Sopenharmony_ci{ 179800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxThreadTest002: start."; 180800b99b8Sopenharmony_ci int32_t pid = 243, tid = 243; 181800b99b8Sopenharmony_ci std::shared_ptr<DfxThread> thread = std::make_shared<DfxThread>(pid, tid, tid); 182800b99b8Sopenharmony_ci std::shared_ptr<DfxRegs> inputrefs; 183800b99b8Sopenharmony_ci thread->SetThreadRegs(inputrefs); 184800b99b8Sopenharmony_ci std::shared_ptr<DfxRegs> outputrefs = thread->GetThreadRegs(); 185800b99b8Sopenharmony_ci EXPECT_EQ(true, inputrefs == outputrefs) << "DfxThreadTest002 Failed"; 186800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxThreadTest002: end."; 187800b99b8Sopenharmony_ci} 188800b99b8Sopenharmony_ci 189800b99b8Sopenharmony_ci/** 190800b99b8Sopenharmony_ci * @tc.name: DfxUnwindRemoteTest001 191800b99b8Sopenharmony_ci * @tc.desc: test DfxUnwindRemote UnwindProcess 192800b99b8Sopenharmony_ci * @tc.type: FUNC 193800b99b8Sopenharmony_ci */ 194800b99b8Sopenharmony_ciHWTEST_F (ProcessDumpTest, DfxUnwindRemoteTest001, TestSize.Level2) 195800b99b8Sopenharmony_ci{ 196800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxUnwindRemoteTest001: start."; 197800b99b8Sopenharmony_ci pid_t pid = GetProcessPid(ACCOUNTMGR_NAME); 198800b99b8Sopenharmony_ci pid_t tid = pid; 199800b99b8Sopenharmony_ci std::shared_ptr<DfxThread> thread = DfxThread::Create(pid, tid, tid); 200800b99b8Sopenharmony_ci std::shared_ptr<DfxProcess> process = DfxProcess::Create(pid, pid); 201800b99b8Sopenharmony_ci auto unwinder = std::make_shared<Unwinder>(pid); 202800b99b8Sopenharmony_ci process->keyThread_ = thread; 203800b99b8Sopenharmony_ci thread->Attach(); 204800b99b8Sopenharmony_ci thread->SetThreadRegs(DfxRegs::CreateRemoteRegs(pid)); 205800b99b8Sopenharmony_ci std::shared_ptr<ProcessDumpRequest> request = std::make_shared<ProcessDumpRequest>(); 206800b99b8Sopenharmony_ci bool ret = DfxUnwindRemote::GetInstance().UnwindProcess(request, process, unwinder); 207800b99b8Sopenharmony_ci thread->Detach(); 208800b99b8Sopenharmony_ci EXPECT_EQ(true, ret) << "DfxUnwindRemoteTest001 Failed"; 209800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxUnwindRemoteTest001: end."; 210800b99b8Sopenharmony_ci} 211800b99b8Sopenharmony_ci 212800b99b8Sopenharmony_ci#ifdef UNITTEST 213800b99b8Sopenharmony_ci/** 214800b99b8Sopenharmony_ci * @tc.name: DfxUnwindRemoteTest002 215800b99b8Sopenharmony_ci * @tc.desc: test DfxUnwindRemote UnwindProcess 216800b99b8Sopenharmony_ci * @tc.type: FUNC 217800b99b8Sopenharmony_ci */ 218800b99b8Sopenharmony_ciHWTEST_F (ProcessDumpTest, DfxUnwindRemoteTest002, TestSize.Level2) 219800b99b8Sopenharmony_ci{ 220800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxUnwindRemoteTest002: start."; 221800b99b8Sopenharmony_ci pid_t pid = GetProcessPid(ACCOUNTMGR_NAME); 222800b99b8Sopenharmony_ci pid_t tid = pid; 223800b99b8Sopenharmony_ci std::shared_ptr<DfxProcess> process = DfxProcess::Create(pid, pid); 224800b99b8Sopenharmony_ci auto unwinder = std::make_shared<Unwinder>(pid); 225800b99b8Sopenharmony_ci auto remote = std::make_shared<DfxUnwindRemote>(); 226800b99b8Sopenharmony_ci std::shared_ptr<ProcessDumpRequest> request = std::make_shared<ProcessDumpRequest>(); 227800b99b8Sopenharmony_ci bool ret = remote->UnwindProcess(request, nullptr, unwinder, 0); 228800b99b8Sopenharmony_ci ASSERT_EQ(ret, false); 229800b99b8Sopenharmony_ci ret = remote->UnwindProcess(request, process, unwinder, 0); 230800b99b8Sopenharmony_ci ASSERT_EQ(ret, false); 231800b99b8Sopenharmony_ci std::shared_ptr<DfxThread> thread = DfxThread::Create(pid, tid, tid); 232800b99b8Sopenharmony_ci process->keyThread_ = thread; 233800b99b8Sopenharmony_ci ret = remote->UnwindProcess(request, process, unwinder, 0); 234800b99b8Sopenharmony_ci ASSERT_EQ(ret, false); 235800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxUnwindRemoteTest002: end."; 236800b99b8Sopenharmony_ci} 237800b99b8Sopenharmony_ci 238800b99b8Sopenharmony_ci/** 239800b99b8Sopenharmony_ci * @tc.name: DfxRingBufferWrapperTest001 240800b99b8Sopenharmony_ci * @tc.desc: test DfxRingBufferWrapper SetWriteBufFd 241800b99b8Sopenharmony_ci * @tc.type: FUNC 242800b99b8Sopenharmony_ci */ 243800b99b8Sopenharmony_ciHWTEST_F (ProcessDumpTest, DfxRingBufferWrapperTest001, TestSize.Level2) 244800b99b8Sopenharmony_ci{ 245800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxRingBufferWrapperTest001: start."; 246800b99b8Sopenharmony_ci auto wrapper = std::make_shared<DfxRingBufferWrapper>(); 247800b99b8Sopenharmony_ci wrapper->SetWriteBufFd(-1); 248800b99b8Sopenharmony_ci int ret = wrapper->DefaultWrite(0, nullptr, 0); 249800b99b8Sopenharmony_ci ASSERT_EQ(ret, -1); 250800b99b8Sopenharmony_ci const size_t bufsize = 10; 251800b99b8Sopenharmony_ci char buf[bufsize]; 252800b99b8Sopenharmony_ci ret = wrapper->DefaultWrite(1, buf, bufsize); 253800b99b8Sopenharmony_ci ASSERT_NE(ret, -1); 254800b99b8Sopenharmony_ci ret = wrapper->DefaultWrite(-1, buf, bufsize); 255800b99b8Sopenharmony_ci ASSERT_EQ(ret, 0); 256800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxRingBufferWrapperTest001: end."; 257800b99b8Sopenharmony_ci} 258800b99b8Sopenharmony_ci 259800b99b8Sopenharmony_ci/** 260800b99b8Sopenharmony_ci * @tc.name: DfxRingBufferWrapperTest002 261800b99b8Sopenharmony_ci * @tc.desc: test DfxRingBufferWrapper SetWriteBufFd 262800b99b8Sopenharmony_ci * @tc.type: FUNC 263800b99b8Sopenharmony_ci */ 264800b99b8Sopenharmony_ciHWTEST_F (ProcessDumpTest, DfxRingBufferWrapperTest002, TestSize.Level2) 265800b99b8Sopenharmony_ci{ 266800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxRingBufferWrapperTest002: start."; 267800b99b8Sopenharmony_ci auto wrapper = std::make_shared<DfxRingBufferWrapper>(); 268800b99b8Sopenharmony_ci wrapper->PrintBaseInfo(); 269800b99b8Sopenharmony_ci wrapper->SetWriteBufFd(-1); 270800b99b8Sopenharmony_ci int ret = wrapper->DefaultWrite(0, nullptr, 0); 271800b99b8Sopenharmony_ci ASSERT_EQ(ret, -1); 272800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxRingBufferWrapperTest002: end."; 273800b99b8Sopenharmony_ci} 274800b99b8Sopenharmony_ci 275800b99b8Sopenharmony_ci/** 276800b99b8Sopenharmony_ci * @tc.name: DfxUnwindAsyncThreadTest001 277800b99b8Sopenharmony_ci * @tc.desc: test DfxUnwindAsyncThread GetSubmitterStack 278800b99b8Sopenharmony_ci * @tc.type: FUNC 279800b99b8Sopenharmony_ci */ 280800b99b8Sopenharmony_ciHWTEST_F (ProcessDumpTest, DfxUnwindAsyncThreadTest001, TestSize.Level2) 281800b99b8Sopenharmony_ci{ 282800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxUnwindAsyncThreadTest001: start."; 283800b99b8Sopenharmony_ci Printer printer; 284800b99b8Sopenharmony_ci printer.PrintDumpHeader(nullptr, nullptr, nullptr); 285800b99b8Sopenharmony_ci printer.PrintThreadRegsByConfig(nullptr); 286800b99b8Sopenharmony_ci printer.PrintRegsByConfig(nullptr); 287800b99b8Sopenharmony_ci printer.PrintThreadOpenFiles(nullptr); 288800b99b8Sopenharmony_ci pid_t pid = GetProcessPid(ACCOUNTMGR_NAME); 289800b99b8Sopenharmony_ci pid_t tid = pid; 290800b99b8Sopenharmony_ci std::shared_ptr<DfxThread> thread = DfxThread::Create(pid, tid, tid); 291800b99b8Sopenharmony_ci auto unwinder = std::make_shared<Unwinder>(pid); 292800b99b8Sopenharmony_ci DfxUnwindAsyncThread asyncThread1(thread, unwinder, 0); 293800b99b8Sopenharmony_ci std::vector<DfxFrame> submitterFrames; 294800b99b8Sopenharmony_ci asyncThread1.GetSubmitterStack(submitterFrames); 295800b99b8Sopenharmony_ci ASSERT_EQ(asyncThread1.stackId_, 0); 296800b99b8Sopenharmony_ci DfxUnwindAsyncThread asyncThread2(thread, unwinder, 1); 297800b99b8Sopenharmony_ci asyncThread2.GetSubmitterStack(submitterFrames); 298800b99b8Sopenharmony_ci asyncThread2.UnwindThreadFallback(); 299800b99b8Sopenharmony_ci asyncThread2.UnwindThreadByParseStackIfNeed(); 300800b99b8Sopenharmony_ci ASSERT_EQ(asyncThread2.stackId_, 1); 301800b99b8Sopenharmony_ci DfxUnwindAsyncThread asyncThread3(nullptr, unwinder, 1); 302800b99b8Sopenharmony_ci asyncThread3.UnwindThreadByParseStackIfNeed(); 303800b99b8Sopenharmony_ci ASSERT_EQ(asyncThread3.stackId_, 1); 304800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxUnwindAsyncThreadTest001: end."; 305800b99b8Sopenharmony_ci} 306800b99b8Sopenharmony_ci 307800b99b8Sopenharmony_ci/** 308800b99b8Sopenharmony_ci * @tc.name: DfxUnwindAsyncThreadTest002 309800b99b8Sopenharmony_ci * @tc.desc: test DfxUnwindAsyncThread GetSubmitterStack 310800b99b8Sopenharmony_ci * @tc.type: FUNC 311800b99b8Sopenharmony_ci */ 312800b99b8Sopenharmony_ciHWTEST_F (ProcessDumpTest, DfxUnwindAsyncThreadTest002, TestSize.Level2) 313800b99b8Sopenharmony_ci{ 314800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxUnwindAsyncThreadTest002: start."; 315800b99b8Sopenharmony_ci pid_t pid = GetProcessPid(ACCOUNTMGR_NAME); 316800b99b8Sopenharmony_ci auto unwinder = std::make_shared<Unwinder>(pid); 317800b99b8Sopenharmony_ci DfxUnwindAsyncThread asyncThread1(nullptr, nullptr, 0); 318800b99b8Sopenharmony_ci asyncThread1.UnwindStack(0); 319800b99b8Sopenharmony_ci ASSERT_EQ(asyncThread1.stackId_, 0); 320800b99b8Sopenharmony_ci DfxUnwindAsyncThread asyncThread2(nullptr, unwinder, 0); 321800b99b8Sopenharmony_ci asyncThread2.UnwindStack(0); 322800b99b8Sopenharmony_ci std::vector<DfxFrame> submitterFrames; 323800b99b8Sopenharmony_ci asyncThread2.GetSubmitterStack(submitterFrames); 324800b99b8Sopenharmony_ci ASSERT_EQ(asyncThread2.stackId_, 0); 325800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "DfxUnwindAsyncThreadTest002: end."; 326800b99b8Sopenharmony_ci} 327800b99b8Sopenharmony_ci#endif 328800b99b8Sopenharmony_ci} 329