1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-10 12:36:01 +01:00

Merge pull request #13219 from xokdvium/eval-profiler

libexpr: Add `EvalProfiler` and use it for `FunctionCallTrace`
This commit is contained in:
Jörg Thalheim 2025-05-18 21:35:43 +02:00 committed by GitHub
commit 638b7ec6c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 202 additions and 13 deletions

View file

@ -372,6 +372,10 @@ EvalState::EvalState(
);
createBaseEnv(settings);
/* Register function call tracer. */
if (settings.traceFunctionCalls)
profiler.addProfiler(make_ref<FunctionCallTrace>());
}
@ -1526,9 +1530,14 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
{
auto _level = addCallDepth(pos);
auto trace = settings.traceFunctionCalls
? std::make_unique<FunctionCallTrace>(positions[pos])
: nullptr;
auto neededHooks = profiler.getNeededHooks();
if (neededHooks.test(EvalProfiler::preFunctionCall)) [[unlikely]]
profiler.preFunctionCallHook(*this, fun, args, pos);
Finally traceExit_{[&](){
if (profiler.getNeededHooks().test(EvalProfiler::postFunctionCall)) [[unlikely]]
profiler.postFunctionCallHook(*this, fun, args, pos);
}};
forceValue(fun, pos);