mirror of
https://github.com/NixOS/nix
synced 2025-06-27 04:21:16 +02:00
'debugMode'
This commit is contained in:
parent
7ddef73d02
commit
0600df86b8
7 changed files with 103 additions and 69 deletions
|
@ -25,9 +25,6 @@ enum RepairFlag : bool;
|
|||
|
||||
typedef void (* PrimOpFun) (EvalState & state, const PosIdx pos, Value * * args, Value & v);
|
||||
|
||||
void printEnvBindings(const EvalState &es, const Expr & expr, const Env & env);
|
||||
void printEnvBindings(const SymbolTable & st, const StaticEnv & se, const Env & env, int lvl = 0);
|
||||
|
||||
struct PrimOp
|
||||
{
|
||||
PrimOpFun fun;
|
||||
|
@ -51,6 +48,11 @@ struct Env
|
|||
Value * values[0];
|
||||
};
|
||||
|
||||
extern void runRepl(ref<EvalState> evalState, const ValMap & extraEnv);
|
||||
|
||||
void printEnvBindings(const EvalState &es, const Expr & expr, const Env & env);
|
||||
void printEnvBindings(const SymbolTable & st, const StaticEnv & se, const Env & env, int lvl = 0);
|
||||
|
||||
std::unique_ptr<ValMap> mapStaticEnvBindings(const SymbolTable & st, const StaticEnv & se, const Env & env);
|
||||
|
||||
void copyContext(const Value & v, PathSet & context);
|
||||
|
@ -127,6 +129,7 @@ public:
|
|||
RootValue vImportedDrvToDerivation = nullptr;
|
||||
|
||||
/* Debugger */
|
||||
bool debugMode;
|
||||
bool debugStop;
|
||||
bool debugQuit;
|
||||
std::list<DebugTrace> debugTraces;
|
||||
|
@ -140,13 +143,14 @@ public:
|
|||
return std::shared_ptr<const StaticEnv>();;
|
||||
}
|
||||
|
||||
void debugRepl(const Error * error, const Env & env, const Expr & expr);
|
||||
|
||||
template<class E>
|
||||
[[gnu::noinline, gnu::noreturn]]
|
||||
void debugThrow(const E &error, const Env & env, const Expr & expr)
|
||||
{
|
||||
if (debuggerHook)
|
||||
debuggerHook(*this, &error, env, expr);
|
||||
if (debugMode)
|
||||
debugRepl(&error, env, expr);
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
@ -158,14 +162,15 @@ public:
|
|||
// Call this in the situation where Expr and Env are inaccessible.
|
||||
// The debugger will start in the last context that's in the
|
||||
// DebugTrace stack.
|
||||
if (debuggerHook && !debugTraces.empty()) {
|
||||
if (debugMode && !debugTraces.empty()) {
|
||||
const DebugTrace & last = debugTraces.front();
|
||||
debuggerHook(*this, &e, last.env, last.expr);
|
||||
debugRepl(&e, last.env, last.expr);
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
SrcToStore srcToStore;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue