summaryrefslogtreecommitdiff
path: root/compiler/codeGen/CgProf.hs
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2011-12-02 13:09:14 +0000
committerSimon Marlow <marlowsd@gmail.com>2011-12-02 15:11:33 +0000
commit1469f1eb7817fbc46b17e994498450a9a6b12ea7 (patch)
tree698f0eadb98ed4276f2faf183492e9bfc2276b6b /compiler/codeGen/CgProf.hs
parent6f4bde149e46146125d688d9ff719c2e5e0800c2 (diff)
downloadhaskell-1469f1eb7817fbc46b17e994498450a9a6b12ea7.tar.gz
More changes aimed at improving call stacks.
- Attach a SrcSpan to every CostCentre. This had the side effect that CostCentres that used to be merged because they had the same name are now considered distinct; so I had to add a Unique to CostCentre to give them distinct object-code symbols. - New flag: -fprof-auto-calls. This flag adds an automatic SCC to every call site (application, to be precise). This is typically more useful for call stacks than annotating whole functions. Various tidy-ups at the same time: removed unused NoCostCentre constructor, and refactored a bit in Coverage.lhs. The call stack we get from traceStack now looks like this: Stack trace: Main.CAF (<entire-module>) Main.main.xs (callstack002.hs:18:12-24) Main.map (callstack002.hs:13:12-16) Main.map.go (callstack002.hs:15:21-34) Main.map.go (callstack002.hs:15:21-23) Main.f (callstack002.hs:10:7-43)
Diffstat (limited to 'compiler/codeGen/CgProf.hs')
-rw-r--r--compiler/codeGen/CgProf.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/codeGen/CgProf.hs b/compiler/codeGen/CgProf.hs
index 3e247ff4d6..92adf1afa7 100644
--- a/compiler/codeGen/CgProf.hs
+++ b/compiler/codeGen/CgProf.hs
@@ -170,11 +170,15 @@ emitCostCentreDecl cc = do
-- All cost centres will be in the main package, since we
-- don't normally use -auto-all or add SCCs to other packages.
-- Hence don't emit the package name in the module here.
+ ; loc <- newByteStringCLit $ bytesFS $ mkFastString $
+ showSDoc (ppr (costCentreSrcSpan cc))
+ -- XXX going via FastString to get UTF-8 encoding is silly
; let
lits = [ zero, -- StgInt ccID,
label, -- char *label,
modl, -- char *module,
- zero, -- StgWord time_ticks
+ loc, -- char *srcloc,
+ zero, -- StgWord time_ticks
zero64, -- StgWord64 mem_alloc
is_caf, -- StgInt is_caf
zero -- struct _CostCentre *link