Maintain cost-centre stacks in the interpreter
authorSimon Marlow <marlowsd@gmail.com>
Sat, 31 Oct 2015 17:38:34 +0000 (17:38 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Mon, 21 Dec 2015 18:51:26 +0000 (18:51 +0000)
commitc8c44fd91b509b9eb644c826497ed5268e89363a
tree90bc2f24a7886afb8f0036b322f839168c880057
parentee6fba89b066fdf8408e6a18db343a4177e613f6
Maintain cost-centre stacks in the interpreter

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
92 files changed:
compiler/codeGen/StgCmmProf.hs
compiler/deSugar/Coverage.hs
compiler/deSugar/Desugar.hs
compiler/ghci/ByteCodeAsm.hs
compiler/ghci/ByteCodeGen.hs
compiler/ghci/ByteCodeInstr.hs
compiler/ghci/ByteCodeTypes.hs
compiler/ghci/GHCi.hs
compiler/ghci/Linker.hs
compiler/main/BreakArray.hs
compiler/main/DynFlags.hs
compiler/main/GHC.hs
compiler/main/HscTypes.hs
compiler/main/InteractiveEval.hs
compiler/main/InteractiveEvalTypes.hs
compiler/prelude/primops.txt.pp
ghc/GhciMonad.hs
ghc/InteractiveUI.hs
includes/rts/prof/CCS.h
includes/stg/MiscClosures.h
libraries/base/GHC/Stack.hs
libraries/base/GHC/Stack/CCS.hsc
libraries/ghci/GHCi/Message.hs
libraries/ghci/GHCi/Run.hs
rts/Disassembler.c
rts/Interpreter.c
rts/PrimOps.cmm
rts/Printer.c
rts/Printer.h
rts/Profiling.c
rts/RtsSymbols.c
testsuite/tests/ghci.debugger/scripts/T2740.script
testsuite/tests/ghci.debugger/scripts/T2740.stdout
testsuite/tests/ghci.debugger/scripts/break001.script
testsuite/tests/ghci.debugger/scripts/break001.stdout
testsuite/tests/ghci.debugger/scripts/break003.stdout
testsuite/tests/ghci.debugger/scripts/break005.stdout
testsuite/tests/ghci.debugger/scripts/break006.script
testsuite/tests/ghci.debugger/scripts/break006.stderr
testsuite/tests/ghci.debugger/scripts/break006.stdout
testsuite/tests/ghci.debugger/scripts/break008.stdout
testsuite/tests/ghci.debugger/scripts/break009.stdout
testsuite/tests/ghci.debugger/scripts/break010.stdout
testsuite/tests/ghci.debugger/scripts/break011.stdout
testsuite/tests/ghci.debugger/scripts/break012.script
testsuite/tests/ghci.debugger/scripts/break012.stdout
testsuite/tests/ghci.debugger/scripts/break013.script
testsuite/tests/ghci.debugger/scripts/break013.stdout
testsuite/tests/ghci.debugger/scripts/break014.stdout
testsuite/tests/ghci.debugger/scripts/break017.stdout
testsuite/tests/ghci.debugger/scripts/break018.script
testsuite/tests/ghci.debugger/scripts/break018.stdout
testsuite/tests/ghci.debugger/scripts/break020.stdout
testsuite/tests/ghci.debugger/scripts/break021.script
testsuite/tests/ghci.debugger/scripts/break021.stdout
testsuite/tests/ghci.debugger/scripts/break022/break022.script
testsuite/tests/ghci.debugger/scripts/break022/break022.stdout
testsuite/tests/ghci.debugger/scripts/break023/break023.stdout
testsuite/tests/ghci.debugger/scripts/break024.stdout
testsuite/tests/ghci.debugger/scripts/break025.stdout
testsuite/tests/ghci.debugger/scripts/break026.script
testsuite/tests/ghci.debugger/scripts/break026.stdout
testsuite/tests/ghci.debugger/scripts/break027.script
testsuite/tests/ghci.debugger/scripts/break027.stdout
testsuite/tests/ghci.debugger/scripts/break028.stdout
testsuite/tests/ghci.debugger/scripts/dynbrk002.stdout
testsuite/tests/ghci.debugger/scripts/dynbrk007.stdout
testsuite/tests/ghci.debugger/scripts/dynbrk008.script
testsuite/tests/ghci.debugger/scripts/dynbrk008.stdout
testsuite/tests/ghci.debugger/scripts/dynbrk009.script
testsuite/tests/ghci.debugger/scripts/dynbrk009.stdout
testsuite/tests/ghci.debugger/scripts/getargs.stdout
testsuite/tests/ghci.debugger/scripts/hist001.stdout
testsuite/tests/ghci.debugger/scripts/listCommand001.stdout
testsuite/tests/ghci.debugger/scripts/listCommand002.stdout
testsuite/tests/ghci.debugger/scripts/print005.stdout
testsuite/tests/ghci.debugger/scripts/print018.script
testsuite/tests/ghci.debugger/scripts/print018.stdout
testsuite/tests/ghci.debugger/scripts/print020.stdout
testsuite/tests/ghci.debugger/scripts/print022.script
testsuite/tests/ghci.debugger/scripts/print022.stdout
testsuite/tests/ghci.debugger/scripts/print025.script
testsuite/tests/ghci.debugger/scripts/print025.stdout
testsuite/tests/ghci.debugger/scripts/print029.script
testsuite/tests/ghci.debugger/scripts/print029.stdout
testsuite/tests/ghci.debugger/scripts/print030.script
testsuite/tests/ghci.debugger/scripts/print030.stdout
testsuite/tests/ghci.debugger/scripts/print031.script
testsuite/tests/ghci.debugger/scripts/print031.stdout
testsuite/tests/ghci.debugger/scripts/print032.script
testsuite/tests/ghci.debugger/scripts/print032.stdout
testsuite/tests/ghci.debugger/scripts/result001.stdout