Commit 80d7ce80 authored by Bartosz Nitka's avatar Bartosz Nitka Committed by Ben Gamari

Add pprSTrace for debugging with call stacks

I've spent quite a bit of time giving unique labels to my `pprTrace`
calls and then trying to intuit where the function is called from.
Thanks to the new implicit parameter CallStack functionality I don't
have to do that anymore.

Test Plan: harbormaster

Reviewers: austin, simonmar, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie

Differential Revision:
parent 932d5036
{-# LANGUAGE CPP, ImplicitParams #-}
(c) The University of Glasgow 2006-2012
(c) The GRASP Project, Glasgow University, 1992-1998
......@@ -73,7 +74,7 @@ module Outputable (
-- * Error handling and debugging utilities
pprPanic, pprSorry, assertPprPanic, pprPgmError,
pprTrace, warnPprTrace,
pprTrace, warnPprTrace, pprSTrace,
trace, pgmError, panic, sorry, assertPanic,
) where
......@@ -109,6 +110,8 @@ import Data.Graph (SCC(..))
import GHC.Fingerprint
import GHC.Show ( showMultiLineString )
import GHC.Stack
import GHC.Exception
......@@ -1030,6 +1033,17 @@ pprTrace str doc x
| opt_NoDebugOutput = x
| otherwise = pprDebugAndThen unsafeGlobalDynFlags trace (text str) doc x
-- | If debug output is on, show some 'SDoc' on the screen along
-- with a call stack when available.
#if __GLASGOW_HASKELL__ >= 710
pprSTrace :: (?location :: CallStack) => SDoc -> a -> a
pprSTrace = pprTrace (showCallStack ?location)
pprSTrace :: SDoc -> a -> a
pprSTrace = pprTrace "no callstack info"
warnPprTrace :: Bool -> String -> Int -> SDoc -> a -> a
-- ^ Just warn about an assertion failure, recording the given file and line number.
-- Should typically be accessed with the WARN macros
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment