about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-10-26T18·25+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-10-26T18·25+0000
commit0b4ed64d295316146fc4de8a5a2e971b771058b8 (patch)
tree5ab9bfb647145e4200877b86db332288716b91da
parentcd08fb3fdeaeb80f8d980f7ef2ace93cf5194c0e (diff)
* "trace" primop: write the trace to standard error.
-rw-r--r--src/libexpr/primops.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 3d080dec3fc1..b9ba3da64880 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -296,18 +296,19 @@ static Expr prim_getEnv(EvalState & state, const ATermVector & args)
     return makeStr(getEnv(name));
 }
 
-/* for debugging purposes. print the first arg on stdout (perhaps stderr should be used?)
- * and return the second
+
+/* Evaluate the first expression, and print its abstract syntax tree
+   on standard error.  Then return the second expression.  Useful for
+   debugging.
  */
 static Expr prim_trace(EvalState & state, const ATermVector & args)
 {
-    //string str = evalStringNoCtx(state, args[0]);
-
-    Expr a = evalExpr(state, args[0]);
-    printf("traced value: %s\n", atPrint(a).c_str());
+    Expr e = evalExpr(state, args[0]);
+    printMsg(lvlError, format("trace: %1%") % e);
     return evalExpr(state, args[1]);
 }
 
+
 static Expr prim_relativise(EvalState & state, const ATermVector & args)
 {
     PathSet context; /* !!! what to do? */