Lines Matching refs:ctx
245 bool HookManager::HandleHookContext(const std::shared_ptr<HookManagerCtx>& ctx)
247 if (ctx == nullptr) {
250 if (ctx->pid > 0) {
251 ctx->smbName = "hooknativesmb_" + std::to_string(ctx->pid);
252 } else if (!ctx->processName.empty()) {
253 ctx->smbName = "hooknativesmb_" + ctx->processName;
256 ctx->pid, ctx->processName.c_str());
261 ctx->shareMemoryBlock = ShareMemoryAllocator::GetInstance().CreateMemoryBlockLocal(ctx->smbName, bufferSize);
262 CHECK_TRUE(ctx->shareMemoryBlock != nullptr, false, "CreateMemoryBlockLocal FAIL %s", ctx->smbName.c_str());
264 ctx->eventNotifier = EventNotifier::Create(0, EventNotifier::NONBLOCK);
265 CHECK_NOTNULL(ctx->eventNotifier, false, "create EventNotifier for %s failed!", ctx->smbName.c_str());
268 ctx->eventPoller = std::make_unique<EpollEventPoller>(DEFAULT_EVENT_POLLING_INTERVAL);
269 CHECK_NOTNULL(ctx->eventPoller, false, "create event poller FAILED!");
271 ctx->eventPoller->Init();
272 ctx->eventPoller->Start();
274 PROFILER_LOG_INFO(LOG_CORE, "hookservice smbFd = %d, eventFd = %d\n", ctx->shareMemoryBlock->GetfileDescriptor(),
275 ctx->eventNotifier->GetFd());
277 ctx->isRecordAccurately = hookConfig_.record_accurately();
281 hookConfig_.fp_unwind(), hookConfig_.max_stack_depth(), ctx->isRecordAccurately);
288 ctx->stackPreprocess = std::make_shared<StackPreprocess>(nullptr, hookConfig_, pluginDataClockId,
290 ctx->stackPreprocess->SetFlushSize(shareMemorySize_);
291 ctx->stackPreprocess->SetNmdFd(nmdParamInfo_.fd);
292 ctx->eventPoller->AddFileDescriptor(
293 ctx->eventNotifier->GetFd(),
294 std::bind(&StackPreprocess::TakeResultsFromShmem, ctx->stackPreprocess,
295 ctx->eventNotifier, ctx->shareMemoryBlock));
297 ctx->stackData = std::make_shared<StackDataRepeater>(STACK_DATA_SIZE);
298 CHECK_TRUE(ctx->stackData != nullptr, false, "Create StackDataRepeater FAIL");
299 ctx->stackPreprocess = std::make_shared<StackPreprocess>(ctx->stackData, hookConfig_, pluginDataClockId,
301 ctx->stackPreprocess->SetFlushSize(shareMemorySize_);
302 ctx->eventPoller->AddFileDescriptor(
303 ctx->eventNotifier->GetFd(),
304 [this, &ctx] { this->ReadShareMemory(ctx); });
307 ctx->stackPreprocess->SetWriter(g_buffWriter);
309 ctx->stackPreprocess->SetWriter(const_cast<WriterStructPtr>(writerAdapter_->GetStruct()));