1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 08:31:16 +02:00

Merge branch 'debugThrow' into debug-exploratory-PR

This commit is contained in:
Ben Burdette 2022-05-12 14:11:35 -06:00
commit 4f48095c66
7 changed files with 121 additions and 212 deletions

View file

@ -130,7 +130,31 @@ public:
bool debugStop;
bool debugQuit;
std::list<DebugTrace> debugTraces;
void debugLastTrace(Error & e) const;
template<class E>
[[gnu::noinline, gnu::noreturn]]
void debugThrow(const E &error, const Env & env, const Expr & expr) const
{
if (debuggerHook)
debuggerHook(&error, env, expr);
throw error;
}
template<class E>
[[gnu::noinline, gnu::noreturn]]
void debugThrowLastTrace(E & e) const
{
// 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()) {
const DebugTrace & last = debugTraces.front();
debuggerHook(&e, last.env, last.expr);
}
throw e;
}
private:
SrcToStore srcToStore;