From 595971e195e2147205b0b6fda019b112c795315d Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Wed, 4 Mar 2020 22:22:20 -0400 Subject: [PATCH] log all ifd --- src/libexpr/eval.hh | 5 ++++- src/libexpr/primops.cc | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 1485dc7fe299..169d9bb93bce 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -286,7 +286,7 @@ public: /* Print statistics. */ void printStats(); - void realiseContext(const PathSet & context); + void realiseContext(const PathSet & context, const Pos &pos, const string reason); private: @@ -369,6 +369,9 @@ struct EvalSettings : Config Setting traceFunctionCalls{this, false, "trace-function-calls", "Emit log messages for each function entry and exit at the 'vomit' log level (-vvvv)."}; + + Setting logAllIFD{this, false, "log-all-ifd", + "Emit log messages for all IFD at 'info' log level"}; }; extern EvalSettings evalSettings; diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index fc6c8296b4a9..1740e4430633 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -45,7 +45,7 @@ std::pair decodeContext(const string & s) InvalidPathError::InvalidPathError(const Path & path) : EvalError("path '%s' is not valid", path), path(path) {} -void EvalState::realiseContext(const PathSet & context) +void EvalState::realiseContext(const PathSet & context, const Pos &pos, const string reason) { std::vector drvs; @@ -56,6 +56,9 @@ void EvalState::realiseContext(const PathSet & context) throw InvalidPathError(store->printStorePath(ctx)); if (!decoded.second.empty() && ctx.isDerivation()) { drvs.push_back(StorePathWithOutputs{ctx.clone(), {decoded.second}}); + if (evalSettings.logAllIFD) { + printInfo(format("%1% importing from derivation %2% via %3%") % pos % decoded.first % reason); + } /* Add the output of this derivation to the allowed paths. */ @@ -91,7 +94,7 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args Path path = state.coerceToPath(pos, *args[1], context); try { - state.realiseContext(context); + state.realiseContext(context, pos, "scopedImport"); } catch (InvalidPathError & e) { throw EvalError(format("cannot import '%1%', since path '%2%' is not valid, at %3%") % path % e.path % pos); @@ -168,7 +171,7 @@ void prim_importNative(EvalState & state, const Pos & pos, Value * * args, Value Path path = state.coerceToPath(pos, *args[0], context); try { - state.realiseContext(context); + state.realiseContext(context, pos, "importNative"); } catch (InvalidPathError & e) { throw EvalError(format("cannot import '%1%', since path '%2%' is not valid, at %3%") % path % e.path % pos); @@ -215,7 +218,7 @@ void prim_exec(EvalState & state, const Pos & pos, Value * * args, Value & v) commandArgs.emplace_back(state.coerceToString(pos, *elems[i], context, false, false)); } try { - state.realiseContext(context); + state.realiseContext(context, pos, "exec"); } catch (InvalidPathError & e) { throw EvalError(format("cannot execute '%1%', since path '%2%' is not valid, at %3%") % program % e.path % pos); @@ -831,7 +834,7 @@ static void prim_pathExists(EvalState & state, const Pos & pos, Value * * args, PathSet context; Path path = state.coerceToPath(pos, *args[0], context); try { - state.realiseContext(context); + state.realiseContext(context, pos, "pathExists"); } catch (InvalidPathError & e) { throw EvalError(format( "cannot check the existence of '%1%', since path '%2%' is not valid, at %3%") @@ -876,7 +879,7 @@ static void prim_readFile(EvalState & state, const Pos & pos, Value * * args, Va PathSet context; Path path = state.coerceToPath(pos, *args[0], context); try { - state.realiseContext(context); + state.realiseContext(context, pos, "readFile"); } catch (InvalidPathError & e) { throw EvalError(format("cannot read '%1%', since path '%2%' is not valid, at %3%") % path % e.path % pos); @@ -913,7 +916,7 @@ static void prim_findFile(EvalState & state, const Pos & pos, Value * * args, Va string path = state.coerceToString(pos, *i->value, context, false, false); try { - state.realiseContext(context); + state.realiseContext(context, pos, "findFile"); } catch (InvalidPathError & e) { throw EvalError(format("cannot find '%1%', since path '%2%' is not valid, at %3%") % path % e.path % pos); @@ -947,7 +950,7 @@ static void prim_readDir(EvalState & state, const Pos & pos, Value * * args, Val PathSet ctx; Path path = state.coerceToPath(pos, *args[0], ctx); try { - state.realiseContext(ctx); + state.realiseContext(ctx, pos, "readDir"); } catch (InvalidPathError & e) { throw EvalError(format("cannot read '%1%', since path '%2%' is not valid, at %3%") % path % e.path % pos);