diff --git a/test/unittest/process_dump/dfx_coredump_test.cpp b/test/unittest/process_dump/dfx_coredump_test.cpp index 3559f79a0174ea118e275535f0683533fdb02a56..a75782009801f6f02e41cb53ffbc1795c7048f5d 100644 --- a/test/unittest/process_dump/dfx_coredump_test.cpp +++ b/test/unittest/process_dump/dfx_coredump_test.cpp @@ -381,10 +381,11 @@ HWTEST_F(DfxCoreDumpTest, DfxCoreDumpTest016, TestSize.Level2) GTEST_LOG_(INFO) << "fork success"; auto pid = getpid(); auto tid = gettid(); - CoreDumpService coreDumpService = CoreDumpService(pid, tid, DfxRegs::Create()); - coreDumpService.StartFirstStageDump(); ProcessDumpRequest request; + CoreDumpService coreDumpService = CoreDumpService(pid, tid, DfxRegs::Create()); + coreDumpService.StartFirstStageDump(request); coreDumpService.StartSecondStageDump(pid, request); + exit(0); } int status; bool isSuccess = waitpid(forkPid, &status, 0) != -1; @@ -441,4 +442,43 @@ HWTEST_F(DfxCoreDumpTest, DfxCoreDumpTest018, TestSize.Level2) ASSERT_TRUE(!ret); GTEST_LOG_(INFO) << "DfxCoreDumpTest018: end."; } + +/** + * @tc.name: DfxCoreDumpTest019 + * @tc.desc: test coredump IsCoredumpAllowed function + * @tc.type: FUNC + */ +HWTEST_F(DfxCoreDumpTest, DfxCoreDumpTest019, TestSize.Level2) +{ + GTEST_LOG_(INFO) << "DfxCoreDumpTest019: start."; + ProcessDumpRequest request; + bool ret = CoreDumpService::IsCoredumpAllowed(request); + ASSERT_TRUE(!ret); + + request.siginfo.si_signo = 42; + request.siginfo.si_code = 3; + ret = CoreDumpService::IsCoredumpAllowed(request); + ASSERT_TRUE(ret); + GTEST_LOG_(INFO) << "DfxCoreDumpTest019: end."; +} + +/** + * @tc.name: DfxCoreDumpTest020 + * @tc.desc: test coredump GetKeyThreadData function + * @tc.type: FUNC + */ +HWTEST_F(DfxCoreDumpTest, DfxCoreDumpTest020, TestSize.Level2) +{ + GTEST_LOG_(INFO) << "DfxCoreDumpTest020: start."; + ProcessDumpRequest request; + auto pid = getpid(); + auto tid = gettid(); + CoreDumpService coreDumpService = CoreDumpService(pid, tid, DfxRegs::Create()); + bool ret = coreDumpService.GetKeyThreadData(request); + ASSERT_TRUE(!ret); + request.tid = tid; + ret = coreDumpService.GetKeyThreadData(request); + ASSERT_TRUE(ret); + GTEST_LOG_(INFO) << "DfxCoreDumpTest020: end."; +} } diff --git a/tools/process_dump/coredump/dfx_coredump_common.h b/tools/process_dump/coredump/dfx_coredump_common.h index 306f2cfb741034ef8ff17629d1a046d1d71b8694..2e45a4b56962e2a2364eb548e939f54171123017 100644 --- a/tools/process_dump/coredump/dfx_coredump_common.h +++ b/tools/process_dump/coredump/dfx_coredump_common.h @@ -16,8 +16,12 @@ #define DFX_COREDUMP_COMMON_H #if defined(__aarch64__) +#include #include #include +#include +#include +#include namespace OHOS { namespace HiviewDFX { @@ -58,6 +62,24 @@ struct CoreDumpThread { pid_t vmPid = 0; }; +struct CoreDumpKeyThreadData { + UserPacMask ntUserPacMask; + struct user_fpsimd_struct ntFpregset; + int fpRegValid; + siginfo_t ntSiginfo; + prstatus_t ntPrstatus; + int prStatusValid; + + CoreDumpKeyThreadData() + : ntUserPacMask {}, + ntFpregset {}, + fpRegValid(0), + ntSiginfo {}, + ntPrstatus {}, + prStatusValid(0) + {} +}; + } // namespace HiviewDFX } // namespace OHOS #endif diff --git a/tools/process_dump/coredump/dfx_coredump_service.cpp b/tools/process_dump/coredump/dfx_coredump_service.cpp index e036410120398de820944e19df72b71f2e2990eb..ac41433cd4f7dd70b5a0194d33f156e9e6693dd3 100644 --- a/tools/process_dump/coredump/dfx_coredump_service.cpp +++ b/tools/process_dump/coredump/dfx_coredump_service.cpp @@ -97,6 +97,11 @@ bool CoreDumpService::IsCoredumpSignal(const ProcessDumpRequest& request) } CoreDumpService::CoreDumpService(int32_t targetPid, int32_t targetTid, std::shared_ptr keyRegs) +{ + SetCoreDumpServiceData(targetPid, targetTid, keyRegs); +} + +void CoreDumpService::SetCoreDumpServiceData(int32_t targetPid, int32_t targetTid, std::shared_ptr keyRegs) { coreDumpThread_.targetPid = targetPid; coreDumpThread_.targetTid = targetTid; @@ -113,8 +118,9 @@ void CoreDumpService::SetVmPid(int32_t vmPid) coreDumpThread_.vmPid = vmPid; } -void CoreDumpService::StartFirstStageDump() +void CoreDumpService::StartFirstStageDump(const ProcessDumpRequest& request) { + SetCoreDumpServiceData(request.pid, request.tid, DfxRegs::CreateFromUcontext(request.context)); StartCoreDump(); WriteSegmentHeader(); WriteNoteSegment(); @@ -122,6 +128,9 @@ void CoreDumpService::StartFirstStageDump() void CoreDumpService::StartSecondStageDump(int32_t vmPid, const ProcessDumpRequest& request) { + if (!IsDoCoredump()) { + return; + } coreDumpThread_.vmPid = vmPid; int pid = coreDumpThread_.targetPid; WriteLoadSegment(); @@ -268,6 +277,7 @@ bool CoreDumpService::WriteNoteSegment() } NoteSegmentWriter note(mappedMemory_, currentPointer_, coreDumpThread_, maps_, keyRegs_); + note.SetKeyThreadData(coreDumpKeyThreadData_); currentPointer_ = note.Write(); status_ = WriteStatus::WRITE_LOAD_SEGMENT_STAGE; return true; @@ -345,6 +355,48 @@ bool CoreDumpService::IsDoCoredump() return false; } +bool CoreDumpService::IsCoredumpAllowed(const ProcessDumpRequest& request) +{ + if (IsCoredumpSignal(request) || (request.siginfo.si_signo == SIGABRT && IsHwasanCoredumpEnabled())) { + return true; + } + return false; +} + +bool CoreDumpService::GetKeyThreadData(const ProcessDumpRequest& request) +{ + pid_t tid = request.tid; + if (tid == 0) { + DFXLOGE("The keythread tid is 0, not to get keythread data"); + return false; + } + + UserPacMask ntUserPacMask; + NoteSegmentWriter::GetRegset(tid, NT_ARM_PAC_MASK, ntUserPacMask); + coreDumpKeyThreadData_.ntUserPacMask = ntUserPacMask; + + struct user_fpsimd_struct ntFpregset; + if (NoteSegmentWriter::GetRegset(tid, NT_FPREGSET, ntFpregset)) { + coreDumpKeyThreadData_.fpRegValid = 1; + } else { + coreDumpKeyThreadData_.fpRegValid = 0; + } + coreDumpKeyThreadData_.ntFpregset = ntFpregset; + + siginfo_t ntSiginfo; + NoteSegmentWriter::GetSiginfoCommon(ntSiginfo, tid); + coreDumpKeyThreadData_.ntSiginfo = ntSiginfo; + + prstatus_t ntPrstatus; + if (NoteSegmentWriter::GetSiginfoCommon(ntPrstatus.pr_info, tid)) { + coreDumpKeyThreadData_.prStatusValid = 1; + } else { + coreDumpKeyThreadData_.prStatusValid = 0; + } + coreDumpKeyThreadData_.ntPrstatus = ntPrstatus; + return true; +} + int CoreDumpService::CreateFileForCoreDump() { bundleName_ = DumpUtils::GetSelfBundleName(); diff --git a/tools/process_dump/coredump/dfx_coredump_service.h b/tools/process_dump/coredump/dfx_coredump_service.h index bd878a59e1e5f1d73c48d719d2edfddad86ea899..53fb79f7fdfb7437252ffbd756500d4206d0e57a 100644 --- a/tools/process_dump/coredump/dfx_coredump_service.h +++ b/tools/process_dump/coredump/dfx_coredump_service.h @@ -38,13 +38,16 @@ public: bool WriteLoadSegment(); bool WriteSectionHeader(); void SetVmPid(int32_t vmPid); - void StartFirstStageDump(); + void StartFirstStageDump(const ProcessDumpRequest& request); void StartSecondStageDump(int32_t vmPid, const ProcessDumpRequest& request); CoreDumpThread GetCoreDumpThread(); std::string GetBundleNameItem(); static bool IsHwasanCoredumpEnabled(); static bool IsCoredumpSignal(const ProcessDumpRequest& request); + static bool IsCoredumpAllowed(const ProcessDumpRequest& request); bool IsDoCoredump(); + bool GetKeyThreadData(const ProcessDumpRequest& request); + void SetCoreDumpServiceData(int32_t targetPid, int32_t targetTid, std::shared_ptr keyRegs); private: void DeInit(); void ObtainDumpRegion(std::string &line, DumpMemoryRegions ®ion); @@ -76,6 +79,7 @@ private: ElapsedTime counter_; std::shared_ptr keyRegs_; bool isHwasanHap_ {false}; + CoreDumpKeyThreadData coreDumpKeyThreadData_; }; } // namespace HiviewDFX } // namespace OHOS diff --git a/tools/process_dump/coredump/dfx_coredump_writer.cpp b/tools/process_dump/coredump/dfx_coredump_writer.cpp index fcb3c54a0bc9badea153de43f7e8739a46073422..700d5f7eb4d4e88d4c6f3812e09aec5efd13aafd 100644 --- a/tools/process_dump/coredump/dfx_coredump_writer.cpp +++ b/tools/process_dump/coredump/dfx_coredump_writer.cpp @@ -33,13 +33,11 @@ #include #include #include -#include #include #include #include #include "dfx_define.h" -#include "dfx_log.h" namespace OHOS { namespace HiviewDFX { @@ -194,6 +192,11 @@ char* NoteSegmentWriter::Write() return currentPointer_; } +void NoteSegmentWriter::SetKeyThreadData(CoreDumpKeyThreadData coreDumpKeyThreadData) +{ + coreDumpKeyThreadData_ = coreDumpKeyThreadData; +} + bool NoteSegmentWriter::PrpsinfoWrite() { NoteWrite(NT_PRPSINFO, sizeof(prpsinfo_t), NOTE_NAME_CORE); @@ -208,18 +211,10 @@ bool NoteSegmentWriter::PrpsinfoWrite() void NoteSegmentWriter::FillPrpsinfo(prpsinfo_t &ntPrpsinfo) { - if (!ReadProcessStat(ntPrpsinfo)) { - DFXLOGE("Read targetPid process stat fail!"); - } - if (!ReadProcessStatus(ntPrpsinfo)) { - DFXLOGE("Read targetPid process status fail!"); - } - if (!ReadProcessComm(ntPrpsinfo)) { - DFXLOGE("Read targetPid process comm fail!"); - } - if (!ReadProcessCmdline(ntPrpsinfo)) { - DFXLOGE("Read targetPid process cmdline fail!"); - } + ReadProcessStat(ntPrpsinfo); + ReadProcessStatus(ntPrpsinfo); + ReadProcessComm(ntPrpsinfo); + ReadProcessCmdline(ntPrpsinfo); } bool NoteSegmentWriter::NoteWrite(uint32_t noteType, size_t descSize, const char* noteName) @@ -385,34 +380,13 @@ bool NoteSegmentWriter::MultiThreadNoteWrite() return true; } -bool NoteSegmentWriter::ThreadNoteWrite(pid_t tid) +void NoteSegmentWriter::ThreadNoteWrite(pid_t tid) { - if (tid == targetTid_) { - ptrace(PTRACE_INTERRUPT, tid, 0, 0); - if (waitpid(tid, nullptr, 0) < 0) { - DFXLOGE("Failed to waitpid tid(%{public}d), errno=%{public}d", tid, errno); - return false; - } - } - if (!PrstatusWrite(tid)) { - DFXLOGE("Failed to write prstatus in (%{public}d)", tid); - } - if (!ArmPacMaskWrite(tid)) { - DFXLOGE("Failed to write arm_pac_mask in (%{public}d)", tid); - } - if (!FpregsetWrite(tid)) { - DFXLOGE("Failed to write fp reg in (%{public}d)", tid); - } - if (!SiginfoWrite(tid)) { - DFXLOGE("Failed to write siginfo in (%{public}d)", tid); - } - if (!ArmTaggedAddrCtrlWrite()) { - DFXLOGE("Failed to write arm tagged"); - } - if (tid == targetTid_) { - ptrace(PTRACE_CONT, tid, 0, 0); - } - return true; + PrstatusWrite(tid); + ArmPacMaskWrite(tid); + FpregsetWrite(tid); + SiginfoWrite(tid); + ArmTaggedAddrCtrlWrite(); } bool NoteSegmentWriter::ArmPacMaskWrite(pid_t tid) @@ -421,13 +395,11 @@ bool NoteSegmentWriter::ArmPacMaskWrite(pid_t tid) return false; } - struct iovec iov; UserPacMask ntUserPacMask; - iov.iov_base = &ntUserPacMask; - iov.iov_len = sizeof(ntUserPacMask); - if (ptrace(PTRACE_GETREGSET, tid, NT_ARM_PAC_MASK, &iov) == -1) { - DFXLOGE("ptrace failed NT_ARM_PAC_MASK, tid:%{public}d,, errno:%{public}d", tid, errno); - return false; + if (tid == targetTid_) { + ntUserPacMask = coreDumpKeyThreadData_.ntUserPacMask; + } else { + GetRegset(tid, NT_ARM_PAC_MASK, ntUserPacMask); } if (!CopyAndAdvance(&ntUserPacMask, sizeof(ntUserPacMask))) { DFXLOGE("Write ntUserPacMask fail, errno:%{public}d", errno); @@ -440,12 +412,8 @@ bool NoteSegmentWriter::PrstatusWrite(pid_t tid) { NoteWrite(NT_PRSTATUS, sizeof(prstatus_t), NOTE_NAME_CORE); prstatus_t ntPrstatus; - if (!GetPrStatus(ntPrstatus, tid)) { - DFXLOGE("Fail to get pr status in (%{public}d)", tid); - } - if (!GetPrReg(ntPrstatus, tid)) { - DFXLOGE("Fail to get pr reg in (%{public}d)", tid); - } + GetPrStatus(ntPrstatus, tid); + GetPrReg(ntPrstatus, tid); if (!CopyAndAdvance(&ntPrstatus, sizeof(ntPrstatus))) { DFXLOGE("Write ntPrstatus fail, errno:%{public}d", errno); return false; @@ -458,15 +426,14 @@ bool NoteSegmentWriter::FpregsetWrite(pid_t tid) if (!NoteWrite(NT_FPREGSET, sizeof(struct user_fpsimd_struct), NOTE_NAME_CORE)) { return false; } - struct iovec iov; - struct user_fpsimd_struct ntFpregset; - iov.iov_base = &ntFpregset; - iov.iov_len = sizeof(ntFpregset); - if (ptrace(PTRACE_GETREGSET, tid, NT_FPREGSET, &iov) == -1) { - DFXLOGE("ptrace failed NT_FPREGSET, tid:%{public}d,, errno:%{public}d", tid, errno); - return false; + struct user_fpsimd_struct ntFpregset; + if (tid == targetTid_) { + ntFpregset = coreDumpKeyThreadData_.ntFpregset; + } else { + GetRegset(tid, NT_FPREGSET, ntFpregset); } + if (!CopyAndAdvance(&ntFpregset, sizeof(ntFpregset))) { DFXLOGE("Write ntFpregset fail, errno:%{public}d", errno); return false; @@ -482,9 +449,12 @@ bool NoteSegmentWriter::SiginfoWrite(pid_t tid) siginfo_t ntSiginfo; - if (ptrace(PTRACE_GETSIGINFO, tid, nullptr, &ntSiginfo) == -1) { - DFXLOGE("ptrace failed PTRACE_GETSIGINFO, tid:%{public}d,, errno:%{public}d", tid, errno); + if (tid == targetTid_) { + ntSiginfo = coreDumpKeyThreadData_.ntSiginfo; + } else { + GetSiginfoCommon(ntSiginfo, tid); } + if (!CopyAndAdvance(&ntSiginfo, sizeof(ntSiginfo))) { DFXLOGE("Write ntSiginfo fail, errno:%{public}d", errno); return false; @@ -505,11 +475,14 @@ bool NoteSegmentWriter::ArmTaggedAddrCtrlWrite() bool NoteSegmentWriter::GetPrStatus(prstatus_t &ntPrstatus, pid_t tid) { - if (ptrace(PTRACE_GETSIGINFO, tid, NULL, &(ntPrstatus.pr_info)) == 0) { - ntPrstatus.pr_cursig = ntPrstatus.pr_info.si_signo; + if (tid == targetTid_ && coreDumpKeyThreadData_.prStatusValid) { + ntPrstatus.pr_cursig = coreDumpKeyThreadData_.ntPrstatus.pr_info.si_signo; } else { - DFXLOGE("ptrace failed PTRACE_GETSIGINFO, tid:%{public}d, errno:%{public}d", tid, errno); + if (GetSiginfoCommon(ntPrstatus.pr_info, tid)) { + ntPrstatus.pr_cursig = ntPrstatus.pr_info.si_signo; + } } + char buffer[1024]; std::string filePath = "/proc/" + std::to_string(tid) + "/status"; FILE *file = fopen(filePath.c_str(), "r"); @@ -537,6 +510,15 @@ bool NoteSegmentWriter::GetPrStatus(prstatus_t &ntPrstatus, pid_t tid) ntPrstatus.pr_pid = tid; ntPrstatus.pr_pgrp = getpgrp(); ntPrstatus.pr_sid = getsid(ntPrstatus.pr_pid); + if (!GetRusage(ntPrstatus)) { + DFXLOGE("failed to get rusage, tid:%{public}d, errno:%{public}d", tid, errno); + return false; + } + return true; +} + +bool NoteSegmentWriter::GetRusage(prstatus_t &ntPrstatus) +{ struct rusage usage; getrusage(RUSAGE_SELF, &usage); if (memcpy_s(&ntPrstatus.pr_utime, sizeof(ntPrstatus.pr_utime), &usage.ru_utime, sizeof(usage.ru_utime)) != 0) { @@ -563,6 +545,7 @@ bool NoteSegmentWriter::GetPrReg(prstatus_t &ntPrstatus, pid_t tid) DFXLOGE("Failed to memcpy regs data, errno = %{public}d", errno); return false; } + ntPrstatus.pr_fpvalid = coreDumpKeyThreadData_.fpRegValid; } else { struct iovec iov; (void)memset_s(&iov, sizeof(iov), 0, sizeof(iov)); @@ -572,17 +555,12 @@ bool NoteSegmentWriter::GetPrReg(prstatus_t &ntPrstatus, pid_t tid) DFXLOGE("ptrace failed NT_PRSTATUS, tid:%{public}d, errno:%{public}d", tid, errno); return false; } - } - struct iovec iovFp; - struct user_fpsimd_struct ntFpregset; - iovFp.iov_base = &ntFpregset; - iovFp.iov_len = sizeof(ntFpregset); - - if (ptrace(PTRACE_GETREGSET, tid, NT_FPREGSET, &iovFp) == -1) { - DFXLOGE("ptrace failed NT_FPREGSET, tid:%{public}d, errno:%{public}d", tid, errno); - ntPrstatus.pr_fpvalid = 0; - } else { - ntPrstatus.pr_fpvalid = 1; + struct user_fpsimd_struct ntFpregset; + if (GetRegset(tid, NT_FPREGSET, ntFpregset)) { + ntPrstatus.pr_fpvalid = 1; + } else { + ntPrstatus.pr_fpvalid = 0; + } } return true; } @@ -758,6 +736,9 @@ char* SectionHeaderTableWriter::Write() void SectionHeaderTableWriter::AdjustOffset(uint8_t remain) { + if (remain > 8) { // 8 + return; + } for (uint8_t i = 0; i < (8 - remain); i++) { // 8 if (remain == 0) { break; diff --git a/tools/process_dump/coredump/dfx_coredump_writer.h b/tools/process_dump/coredump/dfx_coredump_writer.h index 8f071bb5e9e15aae35f490107388c93df229d196..cb7d750f774b46688b59bca133af08389ea3fc9c 100644 --- a/tools/process_dump/coredump/dfx_coredump_writer.h +++ b/tools/process_dump/coredump/dfx_coredump_writer.h @@ -18,9 +18,11 @@ #include #include +#include #include "dfx_coredump_common.h" #include "dfx_regs.h" +#include "dfx_log.h" #include "securec.h" namespace OHOS { @@ -74,6 +76,29 @@ public: std::vector& maps, std::shared_ptr regs) : Writer(mappedMemory, currentPointer), pid_(coreDumpThread.targetPid), targetTid_(coreDumpThread.targetTid), maps_(maps), keyRegs_(regs) {} char* Write() override; + void SetKeyThreadData(CoreDumpKeyThreadData coreDumpKeyThreadData); + template + static bool GetRegset(pid_t tid, int regsetType, T ®set) + { + struct iovec iov; + iov.iov_base = ®set; + iov.iov_len = sizeof(T); + + if (ptrace(PTRACE_GETREGSET, tid, regsetType, &iov) == -1) { + DFXLOGE("ptrace failed regsetType:%{public}d, tid:%{public}d, errno:%{public}d", regsetType, tid, errno); + return false; + } + return true; + } + template + static bool GetSiginfoCommon(T &targetInfo, pid_t tid) + { + if (ptrace(PTRACE_GETSIGINFO, tid, nullptr, &targetInfo) == -1) { + DFXLOGE("ptrace failed PTRACE_GETSIGINFO, tid:%{public}d, errno:%{public}d", tid, errno); + return false; + } + return true; + } private: bool PrpsinfoWrite(); @@ -84,13 +109,14 @@ private: bool ReadProcessComm(prpsinfo_t &ntPrpsinfo); bool ReadProcessCmdline(prpsinfo_t &ntPrpsinfo); bool MultiThreadNoteWrite(); - bool ThreadNoteWrite(pid_t tid); + void ThreadNoteWrite(pid_t tid); bool PrstatusWrite(pid_t tid); bool ArmPacMaskWrite(pid_t tid); bool FpregsetWrite(pid_t tid); bool SiginfoWrite(pid_t tid); bool ArmTaggedAddrCtrlWrite(); bool GetPrStatus(prstatus_t &ntPrstatus, pid_t tid); + bool GetRusage(prstatus_t &ntPrstatus); bool GetPrReg(prstatus_t &ntPrstatus, pid_t tid); bool AuxvWrite(); bool ReadProcessAuxv(Elf64_Nhdr *note); @@ -101,6 +127,7 @@ private: pid_t targetTid_; std::vector maps_; std::shared_ptr keyRegs_; + CoreDumpKeyThreadData coreDumpKeyThreadData_; }; class SectionHeaderTableWriter : public Writer { diff --git a/tools/process_dump/process_dumper.cpp b/tools/process_dump/process_dumper.cpp index ed1f065e9a442338086ec7830f991a8d0be2bbf6..ec4cea33fc493c504afa17a2c60342f5adf393f6 100644 --- a/tools/process_dump/process_dumper.cpp +++ b/tools/process_dump/process_dumper.cpp @@ -485,10 +485,7 @@ bool ProcessDumper::InitUnwinder(const ProcessDumpRequest& request, int &dumpRes } #if defined(__aarch64__) if (coreDumpService_) { - if (CoreDumpService::IsCoredumpSignal(request) || - (request.siginfo.si_signo == SIGABRT && coreDumpService_->IsDoCoredump())) { - coreDumpService_->StartSecondStageDump(vmPid, request); - } + coreDumpService_->StartSecondStageDump(vmPid, request); } #endif process_->SetVmPid(vmPid); @@ -529,6 +526,14 @@ bool ProcessDumper::InitDfxProcess(ProcessDumpRequest& request) NotifyOperateResult(request, OPE_FAIL); return false; } +#if defined(__aarch64__) + if (CoreDumpService::IsCoredumpAllowed(request)) { + coreDumpService_ = std::unique_ptr(new CoreDumpService()); + } + if (coreDumpService_) { + coreDumpService_->GetKeyThreadData(request); + } +#endif DFXLOGI("Init key thread successfully."); NotifyOperateResult(request, OPE_SUCCESS); ptrace(PTRACE_SETOPTIONS, request.tid, NULL, PTRACE_O_TRACEFORK); @@ -540,13 +545,8 @@ bool ProcessDumper::InitDfxProcess(ProcessDumpRequest& request) } DFXLOGI("Finish create all thread."); #if defined(__aarch64__) - if (CoreDumpService::IsCoredumpSignal(request) || - (request.siginfo.si_signo == SIGABRT && CoreDumpService::IsHwasanCoredumpEnabled())) { - coreDumpService_ = std::make_shared(request.pid, request.tid, - DfxRegs::CreateFromUcontext(request.context)); - if (coreDumpService_) { - coreDumpService_->StartFirstStageDump(); - } + if (coreDumpService_) { + coreDumpService_->StartFirstStageDump(request); } #endif return true; diff --git a/tools/process_dump/process_dumper.h b/tools/process_dump/process_dumper.h index 79f397079576d5e850af0e6ef55878121816f344..b98cf030ea11afc401a7ace11ceb0cbe2d8d6282 100644 --- a/tools/process_dump/process_dumper.h +++ b/tools/process_dump/process_dumper.h @@ -72,7 +72,7 @@ private: bool isJsonDump_ = false; uint64_t expectedDumpFinishTime_ = 0; #if defined(__aarch64__) - std::shared_ptr coreDumpService_ = nullptr; + std::unique_ptr coreDumpService_ = nullptr; #endif }; } // namespace HiviewDFX