Add --flags=tracing, and document it in README.md

This commit is contained in:
John Wiegley 2018-04-18 16:28:21 -07:00
parent 7188c71d0a
commit 92217059b5
5 changed files with 45 additions and 3 deletions

View File

@ -21,6 +21,21 @@ $ cabal test
$ LANGUAGE_TESTS=yes NIXPKGS_TESTS=yes cabal test
$ ./dist/build/hnix/hnix --help
```
## Building with full debug info
To build `hnix` for debugging, and with full tracing output and stack traces,
use:
```
$ nix-shell --arg doProfiling true
$ cabal configure --enable-tests --enable-profiling --flags=tracing
$ cabal build
$ ./dist/build/hnix/hnix -v5 <args> +RTS -xc
```
Note that this will run quite slowly, but will give the most information as to
what might potentially be going wrong during parsing or evaluation.
## Building with benchmarks enabled
To build `hnix` with benchmarks enabled:
@ -32,7 +47,6 @@ $ cabal build
$ cabal bench
```
## Building with profiling enabled
To build `hnix` with profiling enabled:

View File

@ -2,7 +2,7 @@
--
-- see: https://github.com/sol/hpack
--
-- hash: 7880788afb8b7755b22c9bd91a3c47598fe26b9a643b2bb55816331ae179aa50
-- hash: c030de7d44eabbd21ae044bd9108da5b34d7e3feaf8a8facbc9383c85e382186
name: hnix
version: 0.5.0
@ -25,6 +25,11 @@ source-repository head
type: git
location: https://github.com/jwiegley/hnix
flag tracing
description: Enable full debug tracing
manual: True
default: False
library
exposed-modules:
Nix
@ -103,6 +108,8 @@ library
, unordered-containers >=0.2.9 && <0.3
, vector
, xml
if flag(tracing)
cpp-options: -DENABLE_TRACING=1
default-language: Haskell2010
executable hnix
@ -133,6 +140,8 @@ executable hnix
, text
, transformers
, unordered-containers >=0.2.9 && <0.3
if flag(tracing)
cpp-options: -DENABLE_TRACING=1
default-language: Haskell2010
test-suite hnix-tests
@ -175,6 +184,8 @@ test-suite hnix-tests
, transformers
, unix
, unordered-containers >=0.2.9 && <0.3
if flag(tracing)
cpp-options: -DENABLE_TRACING=1
default-language: Haskell2010
benchmark hnix-benchmarks
@ -205,4 +216,6 @@ benchmark hnix-benchmarks
, text
, transformers
, unordered-containers >=0.2.9 && <0.3
if flag(tracing)
cpp-options: -DENABLE_TRACING=1
default-language: Haskell2010

View File

@ -36,6 +36,16 @@ ghc-options:
# - -fexpose-all-unfoldings
# - -O2
flags:
tracing:
description: Enable full debug tracing
manual: True
default: False
when:
- condition: flag(tracing)
cpp-options: -DENABLE_TRACING=1
library:
source-dirs: src
dependencies:

View File

@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE OverloadedStrings #-}
@ -25,7 +26,11 @@ import Nix.Parser.Library (reservedNames)
import Nix.Parser.Operators
import Nix.StringOperations
import Nix.Thunk
#if ENABLE_TRACING
import Nix.Utils
#else
import Nix.Utils hiding ((<$>))
#endif
import Nix.Value
import Prelude hiding ((<$>))
import Text.PrettyPrint.ANSI.Leijen

View File

@ -55,7 +55,7 @@ valueRef = Value
buildThunk :: MonadVar m => m v -> m (Thunk m v)
buildThunk action =
#if ENABLE_TRACING
let !x = unsafePerformIO (atomicModifyIORef' counter (\x -> (succ x, x))) in
let !x = unsafePerformIO (atomicModifyIORef' counter (\c -> (succ c, c))) in
Thunk x
#else
Thunk