Lines Matching defs:request

224 void InfoRemoteProcessResult(std::shared_ptr<ProcessDumpRequest> request, int result, int type)
226 if (request == nullptr) {
229 if (request->pmPipeFd[0] != -1) {
230 close(request->pmPipeFd[0]);
231 request->pmPipeFd[0] = -1;
235 OHOS_TEMP_FAILURE_RETRY(write(request->pmPipeFd[1], &result, sizeof(result)));
238 OHOS_TEMP_FAILURE_RETRY(write(request->vmPipeFd[1], &result, sizeof(result)));
301 std::shared_ptr<ProcessDumpRequest> request = std::make_shared<ProcessDumpRequest>();
302 resDump_ = DumpProcess(request);
312 if (isCrash_ && (request->dumpMode == FUSION_MODE) && IsBlockCrashProcess()) {
313 DFXLOGI("start block crash process pid %{public}d nspid %{public}d", request->pid, request->nsPid);
314 if (syscall(SYS_tgkill, request->nsPid, request->tid, SIGSTOP) != 0) {
315 DFXLOGE("send signal stop to nsPid %{public}d fail %{public}s", request->nsPid, strerror(errno));
322 DfxStackInfoFormatter formatter(process_, request);
331 ReportSigDumpStats(request);
333 // request resFd_ to write back the result to dumpcatch
334 if (request->siginfo.si_signo == SIGDUMP && resFd_ == -1) {
335 resFd_ = RequestPipeFd(request->pid, FaultLoggerPipeType::PIPE_FD_JSON_WRITE_RES);
337 resFd_ = RequestPipeFd(request->pid, FaultLoggerPipeType::PIPE_FD_WRITE_RES);
345 request->processName, request->pid, request->tid);
346 Report(request, jsonInfo);
349 void ProcessDumper::Report(std::shared_ptr<ProcessDumpRequest> request, std::string &jsonInfo)
351 if (request == nullptr) {
352 DFXLOGE("request is nullptr.");
355 if (request->msg.type == MESSAGE_FDSAN_DEBUG ||
356 request->msg.type == MESSAGE_JEMALLOC ||
357 request->msg.type == MESSAGE_BADFD) {
358 ReportAddrSanitizer(*request, jsonInfo);
364 if ((request->dumpMode == FUSION_MODE) && isCrash_) {
365 InfoRemoteProcessResult(request, OPE_CONTINUE, MAIN_PROCESS);
369 static int32_t ReadRequestAndCheck(std::shared_ptr<ProcessDumpRequest> request)
373 ssize_t readCount = OHOS_TEMP_FAILURE_RETRY(read(STDIN_FILENO, request.get(), sizeof(ProcessDumpRequest)));
374 request->threadName[NAME_BUF_LEN - 1] = '\0';
375 request->processName[NAME_BUF_LEN - 1] = '\0';
376 request->msg.body[MAX_FATAL_MSG_SIZE - 1] = '\0';
377 request->appRunningId[MAX_APP_RUNNING_UNIQUE_ID_LEN - 1] = '\0';
380 ReportCrashException(request->processName, request->pid, request->uid,
401 void ProcessDumper::InitRegs(std::shared_ptr<ProcessDumpRequest> request, int &dumpRes)
405 if (request->dumpMode == FUSION_MODE) {
406 if (!DfxUnwindRemote::GetInstance().InitProcessAllThreadRegs(request, process_)) {
412 InfoRemoteProcessResult(request, opeResult, MAIN_PROCESS);
417 bool ProcessDumper::IsTargetProcessAlive(std::shared_ptr<ProcessDumpRequest> request)
419 if ((request->dumpMode == SPLIT_MODE) && ((!isCrash_ && (syscall(SYS_getppid) != request->nsPid)) ||
420 (isCrash_ && (syscall(SYS_getppid) != request->vmNsPid)))) {
423 ReportCrashException(request->processName, request->pid, request->uid,
430 void ProcessDumper::UnwindWriteJit(const ProcessDumpRequest &request)
443 jitRequest.pid = request.pid;
444 jitRequest.tid = request.tid;
445 jitRequest.uid = request.uid;
449 DFXLOGE("request jitlog fd failed.");
477 void ProcessDumper::GetCrashObj(std::shared_ptr<ProcessDumpRequest> request)
480 if (!isCrash_ || request->crashObj == 0) {
483 uintptr_t type = request->crashObj >> 56; // 56 :: Move 56 bit to the right
484 uintptr_t addr = request->crashObj & 0xffffffffffffff;
488 process_->SetFatalMessage(process_->GetFatalMessage() + ReadStringByPtrace(request->nsPid, addr));
498 bool ProcessDumper::Unwind(std::shared_ptr<ProcessDumpRequest> request, int &dumpRes, pid_t vmPid)
502 int tid = request->siginfo.si_value.sival_int;
503 tid = tid != 0 ? tid : request->nsPid;
511 GetCrashObj(request);
512 if (!DfxUnwindRemote::GetInstance().UnwindProcess(request, process_, unwinder_, vmPid)) {
518 UnwindWriteJit(*request);
522 int ProcessDumper::DumpProcess(std::shared_ptr<ProcessDumpRequest> request)
528 if ((dumpRes = ReadRequestAndCheck(request)) != DumpErrorCode::DUMP_ESUCCESS) {
531 SetProcessdumpTimeout(request->siginfo);
532 isCrash_ = request->siginfo.si_signo != SIGDUMP;
533 bool isLeakDump = request->siginfo.si_signo == SIGLEAK_STACK;
538 if ((request->dumpMode == SPLIT_MODE) && (((!isCrash_) && (syscall(SYS_getppid) != request->nsPid)) ||
539 ((isCrash_ || isLeakDump) && (syscall(SYS_getppid) != request->vmNsPid)))) {
542 request->processName, request->nsPid, syscall(SYS_getppid), request->siginfo.si_signo);
548 request->siginfo.si_value.sival_int, request->pid, request->nsPid, request->tid, request->threadName);
550 if (InitProcessInfo(request) < 0) {
555 InitRegs(request, dumpRes);
557 if (!InitUnwinder(request, vmPid, dumpRes) && (isCrash_ && !isLeakDump)) {
561 if (InitPrintThread(request) < 0) {
565 ReadFdTable(*request);
566 if (!Unwind(request, dumpRes, vmPid)) {
570 if (request->dumpMode == FUSION_MODE) {
571 InfoRemoteProcessResult(request, opeResult, VIRTUAL_PROCESS);
573 if (dumpRes == DumpErrorCode::DUMP_ESUCCESS && !IsTargetProcessAlive(request)) {
579 bool ProcessDumper::InitVmThread(std::shared_ptr<ProcessDumpRequest> request)
581 if (request == nullptr || process_ == nullptr) {
584 if (isCrash_ && request->vmPid != 0) {
585 if (getppid() != request->vmNsPid) {
586 DFXLOGE("VM process(%{public}d) should be parent pid.", request->vmNsPid);
587 ReportCrashException(request->processName, request->pid, request->uid,
591 process_->vmThread_ = DfxThread::Create(request->vmPid, request->vmPid, request->vmNsPid);
593 DFXLOGE("Failed to attach vm thread(%{public}d).", request->vmNsPid);
597 process_->vmThread_->SetThreadRegs(DfxRegs::CreateFromUcontext(request->context));
598 process_->vmThread_->threadInfo_.threadName = std::string(request->threadName);
603 bool ProcessDumper::InitKeyThread(std::shared_ptr<ProcessDumpRequest> request)
605 if (request == nullptr || process_ == nullptr) {
608 pid_t nsTid = request->tid;
613 ReportCrashException(request->processName, request->pid, request->uid,
619 if ((process_->keyThread_ != nullptr) && request->dumpMode == FUSION_MODE) {
623 if ((process_->keyThread_ != nullptr) && (request->dumpMode == SPLIT_MODE) && !isCrash_) {
624 process_->keyThread_->SetThreadRegs(DfxRegs::CreateFromUcontext(request->context));
628 process_->keyThread_->threadInfo_.threadName = std::string(request->threadName);
633 bool ProcessDumper::InitUnwinder(std::shared_ptr<ProcessDumpRequest> request, pid_t &vmPid, int &dumpRes)
637 if (request->dumpMode == FUSION_MODE) {
640 ReportCrashException(request->processName, request->pid, request->uid,
657 if (request->dumpMode == FUSION_MODE) {
671 ReportCrashException(request->processName, request->pid, request->uid,
680 int ProcessDumper::InitProcessInfo(std::shared_ptr<ProcessDumpRequest> request)
683 if (request->pid <= 0) {
686 process_ = DfxProcess::Create(request->pid, request->nsPid);
691 process_->processInfo_.processName = std::string(request->processName);
693 process_->processInfo_.uid = request->uid;
694 process_->recycleTid_ = request->recycleTid;
695 process_->SetFatalMessage(request->msg.body);
697 if (!InitVmThread(request)) {
701 if (!InitKeyThread(request)) {
706 bool isLeakDump = request->siginfo.si_signo == SIGLEAK_STACK;
713 if (request->dumpMode == FUSION_MODE) {
725 int ProcessDumper::GetLogTypeByRequest(const ProcessDumpRequest &request)
727 switch (request.siginfo.si_signo) {
729 switch (request.msg.type) {
765 int ProcessDumper::InitPrintThread(std::shared_ptr<ProcessDumpRequest> request)
771 faultloggerdRequest.type = ProcessDumper::GetLogTypeByRequest(*request);
772 faultloggerdRequest.pid = request->pid;
773 faultloggerdRequest.tid = request->tid;
774 faultloggerdRequest.uid = request->uid;
775 faultloggerdRequest.time = request->timeStamp;
781 fd = CreateFileForCrash(request->pid, request->timeStamp);
785 jsonFd_ = RequestPipeFd(request->pid, FaultLoggerPipeType::PIPE_FD_JSON_WRITE_BUF);
788 fd = RequestPipeFd(request->pid, FaultLoggerPipeType::PIPE_FD_WRITE_BUF);
789 resFd_ = RequestPipeFd(request->pid, FaultLoggerPipeType::PIPE_FD_WRITE_RES);
792 resFd_ = RequestPipeFd(request->pid, FaultLoggerPipeType::PIPE_FD_JSON_WRITE_RES);
800 DFXLOGW("Failed to request fd from faultloggerd.");
801 ReportCrashException(request->processName, request->pid, request->uid,
842 void ProcessDumper::ReportSigDumpStats(const std::shared_ptr<ProcessDumpRequest> &request) const
851 stat->pid = request->pid;
852 stat->signalTime = request->timeStamp;
856 request->processName, sizeof(request->processName)) != 0) {
873 void ProcessDumper::ReportAddrSanitizer(ProcessDumpRequest &request, std::string &jsonInfo)
876 std::string fingerPrint = request.processName;
893 "MODULE", request.processName,
894 "PID", request.pid,
895 "HAPPEN_TIME", request.timeStamp,
904 void ProcessDumper::ReadFdTable(const ProcessDumpRequest &request)
908 (request.siginfo.si_signo == SIGLEAK_STACK &&
909 (request.msg.type == NONE ||
910 request.msg.type == MESSAGE_FATAL ||
911 request.msg.type == MESSAGE_JEMALLOC))) {
914 process_->openFiles = GetOpenFiles(request.pid, request.nsPid, request.fdTableAddr);
915 reporter_ = std::make_shared<CppCrashReporter>(request.timeStamp, process_, request.dumpMode);