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

Make function calls show up in stack traces again

Note that adding --show-trace prevents functions calls from being
tail-recursive, so an expression that evaluates without --show-trace
may fail with a stack overflow if --show-trace is given.
This commit is contained in:
Eelco Dolstra 2013-11-12 12:51:59 +01:00
parent 2bcb384e95
commit 89e6781cc5
4 changed files with 34 additions and 25 deletions

View file

@ -89,9 +89,6 @@ static void setLogType(string lt)
}
static bool showTrace = false;
string getArg(const string & opt,
Strings::iterator & i, const Strings::iterator & end)
{
@ -214,7 +211,7 @@ static void initAndRun(int argc, char * * argv)
else if (arg == "--no-build-hook")
settings.useBuildHook = false;
else if (arg == "--show-trace")
showTrace = true;
settings.showTrace = true;
else if (arg == "--option") {
++i; if (i == args.end()) throw UsageError("`--option' requires two arguments");
string name = *i;
@ -299,8 +296,8 @@ int main(int argc, char * * argv)
% e.what() % programId);
return 1;
} catch (BaseError & e) {
printMsg(lvlError, format("error: %1%%2%") % (showTrace ? e.prefix() : "") % e.msg());
if (e.prefix() != "" && !showTrace)
printMsg(lvlError, format("error: %1%%2%") % (settings.showTrace ? e.prefix() : "") % e.msg());
if (e.prefix() != "" && !settings.showTrace)
printMsg(lvlError, "(use `--show-trace' to show detailed location information)");
return e.status;
} catch (std::bad_alloc & e) {