diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-10-04 17:53:56 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-10-05 01:10:37 +0200 |
commit | eeac1e70aa880e3aec8742aad1590582d454b8ae (patch) | |
tree | 2ba5ea979010a28fc27fe5ed28ebc1629b07516a /lib/debug.nix | |
parent | 6c2bf141cf87d62cc8e79a155b12d3382dd10558 (diff) |
Remove obsolete checks for missing primops
Diffstat (limited to 'lib/debug.nix')
-rw-r--r-- | lib/debug.nix | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/lib/debug.nix b/lib/debug.nix index d627bc861abb7..8852c22981c5e 100644 --- a/lib/debug.nix +++ b/lib/debug.nix @@ -9,23 +9,15 @@ in rec { + inherit (builtins) addErrorContext; + + addErrorContextToAttrs = lib.mapAttrs (a: v: lib.addErrorContext "while evaluating ${a}" v); + + + traceVal = x: builtins.trace x x; + traceXMLVal = x: builtins.trace (builtins.toXML x) x; + traceXMLValMarked = str: x: builtins.trace (str + builtins.toXML x) x; - # Wrapper aroung the primop `addErrorContext', which shouldn't used - # directly. It evaluates and returns `val', but if an evaluation - # error occurs, the text in `msg' is added to the error context - # (stack trace) printed by Nix. - addErrorContext = - if builtins ? addErrorContext - then builtins.addErrorContext - else msg: val: val; - - addErrorContextToAttrs = lib.mapAttrs (a : v : lib.addErrorContext "while evaluating ${a}" v); - - - traceVal = if builtins ? trace then x: (builtins.trace x x) else x: x; - traceXMLVal = if builtins ? trace then x: (builtins.trace (builtins.toXML x) x) else x: x; - traceXMLValMarked = str: if builtins ? trace then x: (builtins.trace ( str + builtins.toXML x) x) else x: x; - # this can help debug your code as well - designed to not produce thousands of lines traceShowVal = x : trace (showVal x) x; traceShowValMarked = str: x: trace (str + showVal x) x; @@ -44,7 +36,7 @@ rec { else if isString x then "x is a string `${substring 0 50 x}...'" else "x is probably a path `${substring 0 50 (toString x)}...'"; - # trace the arguments passed to function and its result + # trace the arguments passed to function and its result # maybe rewrite these functions in a traceCallXml like style. Then one function is enough traceCall = n : f : a : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a)); traceCall2 = n : f : a : b : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a) (t "arg 2" b)); @@ -70,7 +62,7 @@ rec { then [ { inherit name; expected = test.expected; result = test.expr; } ] else [] ) tests)); - + # create a test assuming that list elements are true # usage: { testX = allTrue [ true ]; } testAllTrue = expr : { inherit expr; expected = map (x: true) expr; }; @@ -109,10 +101,10 @@ rec { let nr = a; in (str: expr: if isFunction expr then - (arg: + (arg: traceCallXml (builtins.add 1 nr) "${str}\n arg ${builtins.toString nr} is \n ${builtins.toXML (strict arg)}" (expr arg) ) - else + else let r = strict expr; in builtins.trace "${str}\n result:\n${builtins.toXML r}" r ); |