1. 13 Jan, 2016 1 commit
    • Simon Marlow's avatar
      Add -prof stack trace to assert · 6cb860a9
      Simon Marlow authored
      Summary:
      So that assertion failures have full call stack information attached
      when using `ghc -fexternal-interpreter -prof`.  Here's one I just
      collected by inserting a dummy assert in Happy:
      
      ```
      *** Exception: Assertion failed
      CallStack (from ImplicitParams):
        assert, called at ./First.lhs:37:11 in main:First
      CallStack (from -prof):
        First.mkFirst (First.lhs:37:11-27)
        First.mkFirst (First.lhs:37:11-93)
        Main.main2.runParserGen.first (Main.lhs:107:48-56)
        Main.main2.runParserGen.first (Main.lhs:107:27-57)
        Main.main2.runParserGen (Main.lhs:(96,9)-(276,9))
        Main.main2.runParserGen (Main.lhs:(90,9)-(276,10))
        Main.main2.runParserGen (Main.lhs:(86,9)-(276,10))
        Main.main2.runParserGen (Main.lhs:(85,9)-(276,10))
        Main.main2 (Main.lhs:74:20-43)
        Main.main2 (Main.lhs:(64,9)-(78,61))
        Main.main (Main.lhs:57:9-18)
      ```
      
      Test Plan: validate
      
      Reviewers: erikd, hvr, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1765
      
      GHC Trac Issues: #11047
      6cb860a9
  2. 21 Dec, 2015 1 commit
    • Simon Marlow's avatar
      Maintain cost-centre stacks in the interpreter · c8c44fd9
      Simon Marlow authored
      Summary:
      Breakpoints become SCCs, so we have detailed call-stack info for
      interpreted code.  Currently this only works when GHC is compiled with
      -prof, but D1562 (Remote GHCi) removes this constraint so that in the
      future call stacks will be available without building your own GHCi.
      
      How can you get a stack trace?
      
      * programmatically: GHC.Stack.currentCallStack
      * I've added an experimental :where command that shows the stack when
        stopped at a breakpoint
      * `error` attaches a call stack automatically, although since calls to
        `error` are often lifted out to the top level, this is less useful
        than it might be (ImplicitParams still works though).
      * Later we might attach call stacks to all exceptions
      
      Other related changes in this diff:
      
      * I reduced the number of places that get ticks attached for
        breakpoints.  In particular there was a breakpoint around the whole
        declaration, which was often redundant because it bound no variables.
        This reduces clutter in the stack traces and speeds up compilation.
      
      * I tidied up some RealSrcSpan stuff in InteractiveUI, and made a few
        other small cleanups
      
      Test Plan: validate
      
      Reviewers: ezyang, bgamari, austin, hvr
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1595
      
      GHC Trac Issues: #11047
      c8c44fd9
  3. 16 Dec, 2015 1 commit
  4. 13 Nov, 2015 1 commit
    • Simon Marlow's avatar
      Make 'error' include the CCS call stack when profiled · 8988be85
      Simon Marlow authored
      Summary:
      The idea here is that this gives a more detailed stack trace in two
      cases:
      
      1. With `-prof` and `-fprof-auto`
      2. In GHCi (see #11047)
      
      Example, with an error inserted in nofib/shootout/binary-trees:
      
      ```
      $ ./Main 3
      Main: z
      CallStack (from ImplicitParams):
        error, called at Main.hs:67:29 in main:Main
      CallStack (from -prof):
        Main.check' (Main.hs:(67,1)-(68,82))
        Main.check (Main.hs:63:1-21)
        Main.stretch (Main.hs:32:35-57)
        Main.main.c (Main.hs:32:9-57)
        Main.main (Main.hs:(27,1)-(43,42))
        Main.CAF (<entire-module>)
      ```
      
      This doesn't quite obsolete +RTS -xc, which also attempts to display
      more information in the case when the error is in a CAF, but I'm
      exploring other solutions to that.
      
      Includes submodule updates.
      
      Test Plan: validate
      
      Reviewers: simonpj, ezyang, gridaphobe, bgamari, hvr, austin
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1426
      8988be85
  5. 02 Oct, 2015 1 commit
    • Ben Gamari's avatar
      Move CallStack back to base · 74424346
      Ben Gamari authored
      CallStack requires tuples, instances of which are defined in GHC.Tuple.
      Unfortunately the change made in D757 to the `Typeable` deriving
      mechanism means that `GHC.Tuple` must import `GHC.Types` for types
      necessary to generate type representations.  This results in a cycle.
      
      Test Plan: Validate
      
      Reviewers: gridaphobe, austin, hvr
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1298
      74424346
  6. 02 Sep, 2015 1 commit
    • Eric Seidel's avatar
      Use IP based CallStack in error and undefined · 6740d70d
      Eric Seidel authored
      This patch modifies `error`, `undefined`, and `assertError` to use
      implicit call-stacks to provide better error messages to users.
      
      There are a few knock-on effects:
      
      - `GHC.Classes.IP` is now wired-in so it can be used in the wired-in
        types for `error` and `undefined`.
      
      - `TysPrim.tyVarList` has been replaced with a new function
        `TysPrim.mkTemplateTyVars`. `tyVarList` made it easy to introduce
        subtle bugs when you need tyvars of different kinds. The naive
      
        ```
        tv1 = head $ tyVarList kind1
        tv2 = head $ tyVarList kind2
        ```
      
        would result in `tv1` and `tv2` sharing a `Unique`, thus substitutions
        would be applied incorrectly, treating `tv1` and `tv2` as the same
        tyvar. `mkTemplateTyVars` avoids this pitfall by taking a list of kinds
        and producing a single tyvar of each kind.
      
      - The types `GHC.SrcLoc.SrcLoc` and `GHC.Stack.CallStack` now live in
        ghc-prim.
      
      - The type `GHC.Exception.ErrorCall` has a new constructor
        `ErrorCallWithLocation` that takes two `String`s instead of one, the
        2nd one being arbitrary metadata about the error (but usually the
        call-stack). A bi-directional pattern synonym `ErrorCall` continues to
        provide the old API.
      
      Updates Cabal, array, and haddock submodules.
      
      Reviewers: nh2, goldfire, simonpj, hvr, rwbarton, austin, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, rodlogic, goldfire, maoe, simonmar, carter,
      liyang, bgamari, thomie
      
      Differential Revision: https://phabricator.haskell.org/D861
      
      GHC Trac Issues: #5273
      6740d70d
  7. 25 Apr, 2015 1 commit
  8. 19 Jan, 2015 1 commit
    • Eric Seidel's avatar
      Expose source locations via Implicit Parameters of type GHC.Location.Location · c024af13
      Eric Seidel authored
      Summary:
      IPs with this type will always be solved for the current source
      location. If another IP of the same type is in scope, the two locations will be
      appended, creating a call-stack. The Location type is kept abstract so users
      cannot create them, but a Location can be turned into a list of SrcLocs, which
      correspond to individual locations in a program. Each SrcLoc contains a
      package/module/file name and start/end lines and columns.
      
      The only thing missing from the SrcLoc in my opinion is the name of the
      top-level definition it inhabits. I suspect that would also be useful, but it's
      not clear to me how to extract the current top-level binder from within the
      constraint solver. (Surely I'm just missing something here?)
      
      I made the (perhaps controversial) decision to have GHC completely ignore
      the names of Location IPs, meaning that in the following code:
      
          bar :: (?myloc :: Location) => String
          bar = foo
      
          foo :: (?loc :: Location) => String
          foo = show ?loc
      
      if I call `bar`, the resulting call-stack will include locations for
      
      1. the use of `?loc` inside `foo`,
      2. `foo`s call-site inside `bar`, and
      3. `bar`s call-site, wherever that may be.
      
      This makes Location IPs very special indeed, and I'm happy to change it if the
      dissonance is too great.
      
      I've also left out any changes to base to make use of Location IPs, since there
      were some concerns about a snowball effect. I think it would be reasonable to
      mark this as an experimental feature for now (it is!), and defer using it in
      base until we have more experience with it. It is, after all, quite easy to
      define your own version of `error`, `undefined`, etc. that use Location IPs.
      
      Test Plan: validate, new test-case is testsuite/tests/typecheck/should_run/IPLocation.hs
      
      Reviewers: austin, hvr, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonmar, rodlogic, carter, thomie
      
      Differential Revision: https://phabricator.haskell.org/D578
      
      GHC Trac Issues: #9049
      c024af13
  9. 16 Dec, 2014 1 commit
  10. 21 Nov, 2014 1 commit
  11. 24 Sep, 2014 1 commit
  12. 18 Sep, 2014 1 commit
  13. 15 Sep, 2014 1 commit
    • Herbert Valerio Riedel's avatar
      Export `Traversable()` and `Foldable()` from Prelude · c0fa383d
      Herbert Valerio Riedel authored
      This exposes *only* the type-classes w/o any of their methods.
      This is the very first step for implementing BPP (see #9586), which
      already requires breaking up several import-cycles leading back to `Prelude`.
      
      Ideally, importing `Prelude` should be avoided in most `base` modules,
      as `Prelude` does not define any entities, but rather re-exports
      existing ones.
      
      Test Plan: validate passes
      
      Reviewers: ekmett, austin
      
      Reviewed By: ekmett, austin
      
      Subscribers: simonmar, ezyang, carter
      
      Differential Revision: https://phabricator.haskell.org/D209
      
      GHC Trac Issues: #9586
      c0fa383d
  14. 28 Sep, 2013 1 commit
  15. 22 Sep, 2013 1 commit
  16. 21 Sep, 2013 1 commit
    • Herbert Valerio Riedel's avatar
      Add Haddock `/Since: 4.7.0.0/` comments to new symbols · 77f32dad
      Herbert Valerio Riedel authored
      
      
      These annotations were added in such a way, that the line
      
      {{{
      /Since: 4.7.0.0/
      }}}
      
      represents the last paragraph of the Haddock comment.
      
      Maybe Haddock will have support for this meta-syntax at some point, and
      be able to inherited the since-version property to the children of an
      annotated symbol and display the since-version property in the rendered
      documentation only in cases when it's not visually obvious (for
      instance, when re-exporting documentation strings).
      Signed-off-by: Herbert Valerio Riedel's avatarHerbert Valerio Riedel <hvr@gnu.org>
      77f32dad
  17. 21 Aug, 2012 1 commit
    • Simon Marlow's avatar
      add errorWithStackTrace · 889ff4aa
      Simon Marlow authored
      -- | Like the function 'error', but appends a stack trace to the error
      -- message if one is available.
      errorWithStackTrace :: String -> a
      889ff4aa
  18. 06 Dec, 2011 1 commit
  19. 02 Dec, 2011 1 commit
  20. 01 Dec, 2011 1 commit
  21. 30 Nov, 2011 2 commits
  22. 29 Nov, 2011 1 commit
    • Simon Marlow's avatar
      Add a way to get hold of the current call stack · 135680b7
      Simon Marlow authored
        GHC.Stack.currentCallStack :: IO [String]
      
      At the moment this uses the profiler's cost-centre stack; maybe in the
      future it might use some other mechanism.  Right now it only gives
      useful results when profiling and using -fprof-auto or similar, but it
      could be quite handy. e.g.
      
      f :: Int -> IO Int
      f x = do currentCallStack >>= print; return (x+1)
      
      mapM :: Monad m => (a -> m b) -> [a] -> m [b]
      mapM f xs = go xs
        where go []     = return []
              go (x:xs) = do
                x' <- f x
                xs' <- mapM f xs
                return (x':xs')
      
      main = mapM f [42,42]
      
      $ ./stack
      ["MAIN.MAIN","Main.main","Main.mapM","Main.mapM.go","Main.f"]
      ["MAIN.MAIN","Main.main","Main.mapM","Main.mapM.go","Main.f"]
      135680b7