Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ghc/ghc
  • bgamari/ghc
  • syd/ghc
  • ggreif/ghc
  • watashi/ghc
  • RolandSenn/ghc
  • mpickering/ghc
  • DavidEichmann/ghc
  • carter/ghc
  • harpocrates/ghc
  • ethercrow/ghc
  • mijicd/ghc
  • adamse/ghc
  • alexbiehl/ghc
  • gridaphobe/ghc
  • trofi/ghc
  • supersven/ghc
  • ppk/ghc
  • ulysses4ever/ghc
  • AndreasK/ghc
  • ghuntley/ghc
  • shayne-fletcher-da/ghc
  • fgaz/ghc
  • yav/ghc
  • osa1/ghc
  • mbbx6spp/ghc
  • JulianLeviston/ghc
  • reactormonk/ghc
  • rae/ghc
  • takenobu-hs/ghc
  • michalt/ghc
  • andrewthad/ghc
  • hsyl20/ghc
  • scottgw/ghc
  • sjakobi/ghc
  • angerman/ghc
  • RyanGlScott/ghc
  • hvr/ghc
  • howtonotwin/ghc
  • chessai/ghc
  • m-renaud/ghc
  • brprice/ghc
  • stevehartdata/ghc
  • sighingnow/ghc
  • kgardas/ghc
  • ckoparkar/ghc
  • alp/ghc
  • smaeul/ghc
  • kakkun61/ghc
  • sykloid/ghc
  • newhoggy/ghc
  • toonn/ghc
  • nineonine/ghc
  • Phyx/ghc
  • ezyang/ghc
  • tweag/ghc
  • langston/ghc
  • ndmitchell/ghc
  • rockbmb/ghc
  • artempyanykh/ghc
  • mniip/ghc
  • mynguyenbmc/ghc
  • alexfmpe/ghc
  • crockeea/ghc
  • nh2/ghc
  • vaibhavsagar/ghc
  • phadej/ghc
  • Haskell-mouse/ghc
  • lolotp/ghc
  • spacekitteh/ghc
  • michaelpj/ghc
  • mgsloan/ghc
  • HPCohen/ghc
  • tmobile/ghc
  • radrow/ghc
  • simonmar/ghc
  • _deepfire/ghc
  • Ericson2314/ghc
  • leitao/ghc
  • fumieval/ghc
  • trac-isovector/ghc
  • cblp/ghc
  • xich/ghc
  • ciil/ghc
  • erthalion/ghc
  • xldenis/ghc
  • autotaker/ghc
  • haskell-wasm/ghc
  • kcsongor/ghc
  • agander/ghc
  • Baranowski/ghc
  • trac-dredozubov/ghc
  • 23Skidoo/ghc
  • iustin/ghc
  • ningning/ghc
  • josefs/ghc
  • kabuhr/ghc
  • gallais/ghc
  • dten/ghc
  • expipiplus1/ghc
  • Pluralia/ghc
  • rohanjr/ghc
  • intricate/ghc
  • kirelagin/ghc
  • Javran/ghc
  • DanielG/ghc
  • trac-mizunashi_mana/ghc
  • pparkkin/ghc
  • bollu/ghc
  • ntc2/ghc
  • jaspervdj/ghc
  • JoshMeredith/ghc
  • wz1000/ghc
  • zkourouma/ghc
  • code5hot/ghc
  • jdprice/ghc
  • tdammers/ghc
  • J-mie6/ghc
  • trac-lantti/ghc
  • ch1bo/ghc
  • cgohla/ghc
  • lucamolteni/ghc
  • acairncross/ghc
  • amerocu/ghc
  • chreekat/ghc
  • txsmith/ghc
  • trupill/ghc
  • typetetris/ghc
  • sergv/ghc
  • fryguybob/ghc
  • erikd/ghc
  • trac-roland/ghc
  • setupminimal/ghc
  • Friede80/ghc
  • SkyWriter/ghc
  • xplorld/ghc
  • abrar/ghc
  • obsidiansystems/ghc
  • Icelandjack/ghc
  • adinapoli/ghc
  • trac-matthewbauer/ghc
  • heatsink/ghc
  • dwijnand/ghc
  • Cmdv/ghc
  • alinab/ghc
  • pepeiborra/ghc
  • fommil/ghc
  • luochen1990/ghc
  • rlupton20/ghc
  • applePrincess/ghc
  • lehins/ghc
  • ronmrdechai/ghc
  • leeadam/ghc
  • harendra/ghc
  • mightymosquito1991/ghc
  • trac-gershomb/ghc
  • lucajulian/ghc
  • Rizary/ghc
  • VictorCMiraldo/ghc
  • jamesbrock/ghc
  • andrewdmeier/ghc
  • luke/ghc
  • pranaysashank/ghc
  • cocreature/ghc
  • hithroc/ghc
  • obreitwi/ghc
  • slrtbtfs/ghc
  • kaol/ghc
  • yairchu/ghc
  • Mathemagician98/ghc
  • trac-taylorfausak/ghc
  • leungbk/ghc
  • MichaWiedenmann/ghc
  • chris-martin/ghc
  • TDecki/ghc
  • adithyaov/ghc
  • trac-gelisam/ghc
  • Lysxia/ghc
  • complyue/ghc
  • bwignall/ghc
  • sternmull/ghc
  • sonika/ghc
  • leif/ghc
  • broadwaylamb/ghc
  • myszon/ghc
  • danbroooks/ghc
  • Mechachleopteryx/ghc
  • zardyh/ghc
  • trac-vdukhovni/ghc
  • OmarKhaledAbdo/ghc
  • arrowd/ghc
  • Bodigrim/ghc
  • matheus23/ghc
  • cardenaso11/ghc
  • trac-Athas/ghc
  • mb720/ghc
  • DylanZA/ghc
  • liff/ghc
  • typedrat/ghc
  • trac-claude/ghc
  • jbm/ghc
  • Gertjan423/ghc
  • PHO/ghc
  • JKTKops/ghc
  • kockahonza/ghc
  • msakai/ghc
  • Sir4ur0n/ghc
  • barambani/ghc
  • vishnu.c/ghc
  • dcoutts/ghc
  • trac-runeks/ghc
  • trac-MaxGabriel/ghc
  • lexi.lambda/ghc
  • strake/ghc
  • spavikevik/ghc
  • JakobBruenker/ghc
  • rmanne/ghc
  • gdziadkiewicz/ghc
  • ani/ghc
  • iliastsi/ghc
  • smunix/ghc
  • judah/ghc
  • blackgnezdo/ghc
  • emilypi/ghc
  • trac-bpfoley/ghc
  • muesli4/ghc
  • trac-gkaracha/ghc
  • Kleidukos/ghc
  • nek0/ghc
  • TristanCacqueray/ghc
  • dwulive/ghc
  • mbakke/ghc
  • arybczak/ghc
  • Yang123321/ghc
  • maksbotan/ghc
  • QuietMisdreavus/ghc
  • trac-olshanskydr/ghc
  • emekoi/ghc
  • samuela/ghc
  • josephcsible/ghc
  • dramforever/ghc
  • lpsmith/ghc
  • DenisFrezzato/ghc
  • michivi/ghc
  • jneira/ghc
  • jeffhappily/ghc
  • Ivan-Yudin/ghc
  • nakaji-dayo/ghc
  • gdevanla/ghc
  • galen/ghc
  • fendor/ghc
  • yaitskov/ghc
  • rcythr/ghc
  • awpr/ghc
  • jeremyschlatter/ghc
  • Aver1y/ghc
  • mitchellvitez/ghc
  • merijn/ghc
  • tomjaguarpaw1/ghc
  • trac-NoidedSuper/ghc
  • erewok/ghc
  • trac-junji.hashimoto/ghc
  • adamwespiser/ghc
  • bjaress/ghc
  • jhrcek/ghc
  • leonschoorl/ghc
  • lukasz-golebiewski/ghc
  • sheaf/ghc
  • last-g/ghc
  • carassius1014/ghc
  • eschwartz/ghc
  • dwincort/ghc
  • felixwiemuth/ghc
  • TimWSpence/ghc
  • marcusmonteirodesouza/ghc
  • WJWH/ghc
  • vtols/ghc
  • theobat/ghc
  • BinderDavid/ghc
  • ckoparkar0/ghc
  • alexander-kjeldaas/ghc
  • dme2/ghc
  • philderbeast/ghc
  • aaronallen8455/ghc
  • rayshih/ghc
  • benkard/ghc
  • mpardalos/ghc
  • saidelman/ghc
  • leiftw/ghc
  • ca333/ghc
  • bwroga/ghc
  • nmichael44/ghc
  • trac-crobbins/ghc
  • felixonmars/ghc
  • adityagupta1089/ghc
  • hgsipiere/ghc
  • treeowl/ghc
  • alexpeits/ghc
  • CraigFe/ghc
  • dnlkrgr/ghc
  • kerckhove_ts/ghc
  • cptwunderlich/ghc
  • eiais/ghc
  • hahohihu/ghc
  • sanchayan/ghc
  • lemmih/ghc
  • sehqlr/ghc
  • trac-dbeacham/ghc
  • luite/ghc
  • trac-f-a/ghc
  • vados/ghc
  • luntain/ghc
  • fatho/ghc
  • alexbiehl-gc/ghc
  • dcbdan/ghc
  • tvh/ghc
  • liam-ly/ghc
  • timbobbarnes/ghc
  • GovanifY/ghc
  • shanth2600/ghc
  • gliboc/ghc
  • duog/ghc
  • moxonsghost/ghc
  • zander/ghc
  • masaeedu/ghc
  • georgefst/ghc
  • guibou/ghc
  • nicuveo/ghc
  • mdebruijne/ghc
  • stjordanis/ghc
  • emiflake/ghc
  • wygulmage/ghc
  • frasertweedale/ghc
  • coot/ghc
  • aratamizuki/ghc
  • tsandstr/ghc
  • mrBliss/ghc
  • Anton-Latukha/ghc
  • tadfisher/ghc
  • vapourismo/ghc
  • Sorokin-Anton/ghc
  • basile-henry/ghc
  • trac-mightybyte/ghc
  • AbsoluteNikola/ghc
  • cobrien99/ghc
  • songzh/ghc
  • blamario/ghc
  • aj4ayushjain/ghc
  • trac-utdemir/ghc
  • tangcl/ghc
  • hdgarrood/ghc
  • maerwald/ghc
  • arjun/ghc
  • ratherforky/ghc
  • haskieLambda/ghc
  • EmilGedda/ghc
  • Bogicevic/ghc
  • eddiejessup/ghc
  • kozross/ghc
  • AlistairB/ghc
  • 3Rafal/ghc
  • christiaanb/ghc
  • trac-bit/ghc
  • matsumonkie/ghc
  • trac-parsonsmatt/ghc
  • chisui/ghc
  • jaro/ghc
  • trac-kmiyazato/ghc
  • davidsd/ghc
  • Tritlo/ghc
  • I-B-3/ghc
  • lykahb/ghc
  • AriFordsham/ghc
  • turion1/ghc
  • berberman/ghc
  • christiantakle/ghc
  • zyklotomic/ghc
  • trac-ocramz/ghc
  • CSEdd/ghc
  • doyougnu/ghc
  • mmhat/ghc
  • why-not-try-calmer/ghc
  • plutotulp/ghc
  • kjekac/ghc
  • Manvi07/ghc
  • teo/ghc
  • cactus/ghc
  • CarrieMY/ghc
  • abel/ghc
  • yihming/ghc
  • tsakki/ghc
  • jessicah/ghc
  • oliverbunting/ghc
  • meld/ghc
  • friedbrice/ghc
  • Joald/ghc
  • abarbu/ghc
  • DigitalBrains1/ghc
  • sterni/ghc
  • alexDarcy/ghc
  • hexchain/ghc
  • minimario/ghc
  • zliu41/ghc
  • tommd/ghc
  • jazcarate/ghc
  • peterbecich/ghc
  • alirezaghey/ghc
  • solomon/ghc
  • mikael.urankar/ghc
  • davjam/ghc
  • int-index/ghc
  • MorrowM/ghc
  • nrnrnr/ghc
  • Sonfamm/ghc-test-only
  • afzt1/ghc
  • nguyenhaibinh-tpc/ghc
  • trac-lierdakil/ghc
  • MichaWiedenmann1/ghc
  • jmorag/ghc
  • Ziharrk/ghc
  • trac-MitchellSalad/ghc
  • juampe/ghc
  • jwaldmann/ghc
  • snowleopard/ghc
  • juhp/ghc
  • normalcoder/ghc
  • ksqsf/ghc
  • trac-jberryman/ghc
  • roberth/ghc
  • 1ntEgr8/ghc
  • epworth/ghc
  • MrAdityaAlok/ghc
  • JunmingZhao42/ghc
  • jappeace/ghc
  • trac-Gabriel439/ghc
  • alt-romes/ghc
  • HugoPeters1024/ghc
  • 10ne1/ghc-fork
  • agentultra/ghc
  • Garfield1002/ghc
  • ChickenProp/ghc
  • clyring/ghc
  • MaxHearnden/ghc
  • jumper149/ghc
  • vem/ghc
  • ketzacoatl/ghc
  • Rosuavio/ghc
  • jackohughes/ghc
  • p4l1ly/ghc
  • konsumlamm/ghc
  • shlevy/ghc
  • torsten.schmits/ghc
  • andremarianiello/ghc
  • amesgen/ghc
  • googleson78/ghc
  • InfiniteVerma/ghc
  • uhbif19/ghc
  • yiyunliu/ghc
  • raehik/ghc
  • mrkun/ghc
  • telser/ghc
  • 1Jajen1/ghc
  • slotThe/ghc
  • WinstonHartnett/ghc
  • mpilgrem/ghc
  • dreamsmasher/ghc
  • schuelermine/ghc
  • trac-Viwor/ghc
  • undergroundquizscene/ghc
  • evertedsphere/ghc
  • coltenwebb/ghc
  • oberblastmeister/ghc
  • agrue/ghc
  • lf-/ghc
  • zacwood9/ghc
  • steshaw/ghc
  • high-cloud/ghc
  • SkamDart/ghc
  • PiDelport/ghc
  • maoif/ghc
  • RossPaterson/ghc
  • CharlesTaylor7/ghc
  • ribosomerocker/ghc
  • trac-ramirez7/ghc
  • daig/ghc
  • NicolasT/ghc
  • FinleyMcIlwaine/ghc
  • lawtonnichols/ghc
  • jmtd/ghc
  • ozkutuk/ghc
  • wildsebastian/ghc
  • nikshalark/ghc
  • lrzlin/ghc
  • tobias/ghc
  • fw/ghc
  • hawkinsw/ghc
  • type-dance/ghc
  • rui314/ghc
  • ocharles/ghc
  • wavewave/ghc
  • TheKK/ghc
  • nomeata/ghc
  • trac-csabahruska/ghc
  • jonathanjameswatson/ghc
  • L-as/ghc
  • Axman6/ghc
  • barracuda156/ghc
  • trac-jship/ghc
  • jake-87/ghc
  • meooow/ghc
  • rebeccat/ghc
  • hamana55/ghc
  • Enigmage/ghc
  • kokobd/ghc
  • agevelt/ghc
  • gshen42/ghc
  • chrismwendt/ghc
  • MangoIV/ghc
  • teto/ghc
  • Sookr1/ghc
  • trac-thomasjm/ghc
  • barci2/ghc-dev
  • trac-m4dc4p/ghc
  • dixonary/ghc
  • breakerzirconia/ghc
  • alexsio27444/ghc
  • glocq/ghc
  • sourabhxyz/ghc
  • ryantrinkle/ghc
  • Jade/ghc
  • scedfaliako/ghc
  • martijnbastiaan/ghc
  • trac-george.colpitts/ghc
  • ammarbinfaisal/ghc
  • mimi.vx/ghc
  • lortabac/ghc
  • trac-zyla/ghc
  • benbellick/ghc
  • aadaa-fgtaa/ghc
  • jvanbruegge/ghc
  • archbung/ghc
  • gilmi/ghc
  • mfonism/ghc
  • alex-mckenna/ghc
  • Ei30metry/ghc
  • DiegoDiverio/ghc
  • jorgecunhamendes/ghc
  • liesnikov/ghc
  • akrmn/ghc
  • trac-simplifierticks/ghc
  • jacco/ghc
  • rhendric/ghc
  • damhiya/ghc
  • ryndubei/ghc
  • DaveBarton/ghc
  • trac-Profpatsch/ghc
  • GZGavinZhao/ghc
  • ncfavier/ghc
  • jameshaydon/ghc
  • ajccosta/ghc
  • dschrempf/ghc
  • cydparser/ghc
  • LinuxUserGD/ghc
  • elodielander/ghc
  • facundominguez/ghc
  • psilospore/ghc
  • lachrimae/ghc
  • dylan-thinnes/ghc-type-errors-plugin
  • hamishmack/ghc
  • Leary/ghc
  • lzszt/ghc
  • lyokha/ghc
  • trac-glaubitz/ghc
  • Rewbert/ghc
  • andreabedini/ghc
  • Jasagredo/ghc
  • sol/ghc
  • OlegAlexander/ghc
  • trac-sthibaul/ghc
  • avdv/ghc
  • Wendaolee/ghc
  • ur4t/ghc
  • daylily/ghc
  • boltzmannrain/ghc
  • mmzk1526/ghc
  • trac-fizzixnerd/ghc
  • soulomoon/ghc
  • rwmjones/ghc
  • j14i/ghc
  • tracsis/ghc
  • gesh/ghc
  • flip101/ghc
  • eldritch-cookie/ghc
  • LemonjamesD/ghc
  • pgujjula/ghc
  • skeuchel/ghc
  • noteed/ghc
  • gulin.serge/ghc
  • Torrekie/ghc
  • jlwoodwa/ghc
  • ayanamists/ghc
  • husong998/ghc
  • trac-edmundnoble/ghc
  • josephf/ghc
  • contrun/ghc
  • baulig/ghc
  • edsko/ghc
  • mzschr/ghc-issue-24732
  • ulidtko/ghc
  • Arsen/ghc
  • trac-sjoerd_visscher/ghc
  • crumbtoo/ghc
  • L0neGamer/ghc
  • DrewFenwick/ghc
  • benz0li/ghc
  • MaciejWas/ghc
  • jordanrule/ghc
  • trac-qqwy/ghc
  • LiamGoodacre/ghc
  • isomorpheme/ghc
  • trac-danidiaz/ghc
  • Kariim/ghc
  • MTaimoorZaeem/ghc
  • hololeap/ghc
  • ticat-fp/ghc
  • meritamen/ghc
  • criskell/ghc
  • trac-kraai/ghc
  • aergus/ghc
  • jdral/ghc
  • SamB/ghc
  • Tristian/ghc
  • ywgrit/ghc
  • KatsuPatrick/ghc
  • OsePedro/ghc
  • mpscholten/ghc
  • fp/ghc
  • zaquest/ghc
  • fangyi-zhou/ghc
  • augyg/ghc
640 results
Show changes
Commits on Source (15)
Showing
with 418 additions and 134 deletions
......@@ -299,6 +299,7 @@ data ModuleLabelKind
| MLK_InitializerArray
| MLK_Finalizer String
| MLK_FinalizerArray
| MLK_IPEBuffer
deriving (Eq, Ord)
instance Outputable ModuleLabelKind where
......@@ -306,6 +307,7 @@ instance Outputable ModuleLabelKind where
ppr (MLK_Initializer s) = text ("init__" ++ s)
ppr MLK_FinalizerArray = text "fini_arr"
ppr (MLK_Finalizer s) = text ("fini__" ++ s)
ppr MLK_IPEBuffer = text "ipe_buf"
isIdLabel :: CLabel -> Bool
isIdLabel IdLabel{} = True
......@@ -830,10 +832,10 @@ instance OutputableP Platform InfoProvEnt where
-- Constructing Cost Center Labels
mkCCLabel :: CostCentre -> CLabel
mkCCSLabel :: CostCentreStack -> CLabel
mkIPELabel :: InfoProvEnt -> CLabel
mkIPELabel :: Module -> CLabel
mkCCLabel cc = CC_Label cc
mkCCSLabel ccs = CCS_Label ccs
mkIPELabel ipe = IPE_Label ipe
mkIPELabel mod = ModuleLabel mod MLK_IPEBuffer
mkRtsApFastLabel :: FastString -> CLabel
mkRtsApFastLabel str = RtsLabel (RtsApFast (NonDetFastString str))
......@@ -1011,6 +1013,7 @@ modLabelNeedsCDecl :: ModuleLabelKind -> Bool
-- Code for finalizers and initializers are emitted in stub objects
modLabelNeedsCDecl (MLK_Initializer _) = True
modLabelNeedsCDecl (MLK_Finalizer _) = True
modLabelNeedsCDecl MLK_IPEBuffer = True
-- The finalizer and initializer arrays are emitted in the code of the module
modLabelNeedsCDecl MLK_InitializerArray = False
modLabelNeedsCDecl MLK_FinalizerArray = False
......@@ -1208,6 +1211,7 @@ moduleLabelKindType kind =
MLK_InitializerArray -> DataLabel
MLK_Finalizer _ -> CodeLabel
MLK_FinalizerArray -> DataLabel
MLK_IPEBuffer -> DataLabel
idInfoLabelType :: IdLabelInfo -> CLabelType
idInfoLabelType info =
......
......@@ -224,6 +224,7 @@ import GHC.StgToCmm.Layout hiding (ArgRep(..))
import GHC.StgToCmm.Ticky
import GHC.StgToCmm.Prof
import GHC.StgToCmm.Bind ( emitBlackHoleCode, emitUpdateFrame )
import GHC.StgToCmm.InfoTableProv
import GHC.Cmm.Opt
import GHC.Cmm.Graph
......@@ -1518,9 +1519,8 @@ parseCmmFile cmmpConfig this_mod home_unit filename = do
let fcode = do
((), cmm) <- getCmm $ unEC code "global" (initEnv (pdProfile pdConfig)) [] >> return ()
-- See Note [Mapping Info Tables to Source Positions] (IPE Maps)
let used_info = map (cmmInfoTableToInfoProvEnt this_mod)
(mapMaybe topInfoTable cmm)
((), cmm2) <- getCmm $ mapM_ emitInfoTableProv used_info
let used_info = map (cmmInfoTableToInfoProvEnt this_mod) (mapMaybe topInfoTable cmm)
((), cmm2) <- getCmm $ emitIpeBufferListNode this_mod used_info
return (cmm ++ cmm2, used_info)
(cmm, _) = runC (cmmpStgToCmmConfig cmmpConfig) fstate st fcode
(warnings,errors) = getPsMessages pst
......
......@@ -368,24 +368,17 @@ ipInitCode
:: Bool -- is Opt_InfoTableMap enabled or not
-> Platform
-> Module
-> [InfoProvEnt]
-> CStub
ipInitCode do_info_table platform this_mod ents
ipInitCode do_info_table platform this_mod
| not do_info_table = mempty
| otherwise = initializerCStub platform fn_nm decls body
| otherwise = initializerCStub platform fn_nm ipe_buffer_decl body
where
fn_nm = mkInitializerStubLabel this_mod "ip_init"
decls = vcat
$ map emit_ipe_decl ents
++ [emit_ipe_list ents]
body = text "registerInfoProvList" <> parens local_ipe_list_label <> semi
emit_ipe_decl ipe =
text "extern InfoProvEnt" <+> ipe_lbl <> text "[];"
where ipe_lbl = pprCLabel platform CStyle (mkIPELabel ipe)
local_ipe_list_label = text "local_ipe_" <> ppr this_mod
emit_ipe_list ipes =
text "static InfoProvEnt *" <> local_ipe_list_label <> text "[] ="
<+> braces (vcat $ [ pprCLabel platform CStyle (mkIPELabel ipe) <> comma
| ipe <- ipes
] ++ [text "NULL"])
<> semi
body = text "registerInfoProvList" <> parens (text "&" <> ipe_buffer_label) <> semi
ipe_buffer_label = pprCLabel platform CStyle (mkIPELabel this_mod)
ipe_buffer_decl =
text "extern IpeBufferListNode" <+> ipe_buffer_label <> text ";"
......@@ -1830,7 +1830,7 @@ hscCompileCmmFile hsc_env original_filename filename output_filename = runHsc hs
mod_name = mkModuleName $ "Cmm$" ++ original_filename
cmm_mod = mkHomeModule home_unit mod_name
cmmpConfig = initCmmParserConfig dflags
(cmm, ents) <- ioMsgMaybe
(cmm, _ents) <- ioMsgMaybe
$ do
(warns,errs,cmm) <- withTiming logger (text "ParseCmm"<+>brackets (text filename)) (\_ -> ())
$ parseCmmFile cmmpConfig cmm_mod home_unit filename
......@@ -1857,7 +1857,7 @@ hscCompileCmmFile hsc_env original_filename filename output_filename = runHsc hs
Just h -> h dflags Nothing (Stream.yield cmmgroup)
let foreign_stubs _ =
let ip_init = ipInitCode do_info_table platform cmm_mod ents
let ip_init = ipInitCode do_info_table platform cmm_mod
in NoStubs `appendStubC` ip_init
(_output_filename, (_stub_h_exists, stub_c_exists), _foreign_fps, _caf_infos)
......
module GHC.StgToCmm.InfoTableProv (emitIpeBufferListNode) where
import GHC.Prelude
import GHC.Platform
import GHC.Unit.Module
import GHC.Utils.Outputable
import GHC.Types.SrcLoc (pprUserRealSpan, srcSpanFile)
import GHC.Data.FastString (unpackFS)
import GHC.Cmm.CLabel
import GHC.Cmm.Expr
import GHC.Cmm.Utils
import GHC.StgToCmm.Config
import GHC.StgToCmm.Lit (newByteStringCLit)
import GHC.StgToCmm.Monad
import GHC.StgToCmm.Utils
import GHC.Data.ShortText (ShortText)
import qualified GHC.Data.ShortText as ST
import qualified Data.Map.Strict as M
import Control.Monad.Trans.State.Strict
import qualified Data.ByteString as BS
import qualified Data.ByteString.Builder as BSB
import qualified Data.ByteString.Lazy as BSL
emitIpeBufferListNode :: Module
-> [InfoProvEnt]
-> FCode ()
emitIpeBufferListNode this_mod ents = do
cfg <- getStgToCmmConfig
let ctx = stgToCmmContext cfg
platform = stgToCmmPlatform cfg
let (cg_ipes, strtab) = flip runState emptyStringTable $ do
module_name <- lookupStringTable $ ST.pack $ renderWithContext ctx (ppr this_mod)
mapM (toCgIPE platform ctx module_name) ents
let -- Emit the fields of an IpeBufferEntry struct.
toIpeBufferEntry :: CgInfoProvEnt -> [CmmLit]
toIpeBufferEntry cg_ipe =
[ CmmLabel (ipeInfoTablePtr cg_ipe)
, strtab_offset (ipeTableName cg_ipe)
, strtab_offset (ipeClosureDesc cg_ipe)
, strtab_offset (ipeTypeDesc cg_ipe)
, strtab_offset (ipeLabel cg_ipe)
, strtab_offset (ipeModuleName cg_ipe)
, strtab_offset (ipeSrcFile cg_ipe)
, strtab_offset (ipeSrcSpan cg_ipe)
, int32 0
]
int n = mkIntCLit platform n
int32 n = CmmInt n W32
strtab_offset (StrTabOffset n) = int32 (fromIntegral n)
strings <- newByteStringCLit (getStringTableStrings strtab)
let lits = [ zeroCLit platform -- 'next' field
, strings -- 'strings' field
, int $ length cg_ipes -- 'count' field
] ++ concatMap toIpeBufferEntry cg_ipes
emitDataLits (mkIPELabel this_mod) lits
toCgIPE :: Platform -> SDocContext -> StrTabOffset -> InfoProvEnt -> State StringTable CgInfoProvEnt
toCgIPE platform ctx module_name ipe = do
table_name <- lookupStringTable $ ST.pack $ renderWithContext ctx (pprCLabel platform CStyle (infoTablePtr ipe))
closure_desc <- lookupStringTable $ ST.pack $ show (infoProvEntClosureType ipe)
type_desc <- lookupStringTable $ ST.pack $ infoTableType ipe
let label_str = maybe "" snd (infoTableProv ipe)
let (src_loc_file, src_loc_span) =
case infoTableProv ipe of
Nothing -> ("", "")
Just (span, _) ->
let file = unpackFS $ srcSpanFile span
coords = renderWithContext ctx (pprUserRealSpan False span)
in (file, coords)
label <- lookupStringTable $ ST.pack label_str
src_file <- lookupStringTable $ ST.pack src_loc_file
src_span <- lookupStringTable $ ST.pack src_loc_span
return $ CgInfoProvEnt { ipeInfoTablePtr = infoTablePtr ipe
, ipeTableName = table_name
, ipeClosureDesc = closure_desc
, ipeTypeDesc = type_desc
, ipeLabel = label
, ipeModuleName = module_name
, ipeSrcFile = src_file
, ipeSrcSpan = src_span
}
data CgInfoProvEnt = CgInfoProvEnt
{ ipeInfoTablePtr :: !CLabel
, ipeTableName :: !StrTabOffset
, ipeClosureDesc :: !StrTabOffset
, ipeTypeDesc :: !StrTabOffset
, ipeLabel :: !StrTabOffset
, ipeModuleName :: !StrTabOffset
, ipeSrcFile :: !StrTabOffset
, ipeSrcSpan :: !StrTabOffset
}
data StringTable = StringTable { stStrings :: DList ShortText
, stLength :: !Int
, stLookup :: !(M.Map ShortText StrTabOffset)
}
newtype StrTabOffset = StrTabOffset Int
emptyStringTable :: StringTable
emptyStringTable =
StringTable { stStrings = emptyDList
, stLength = 0
, stLookup = M.empty
}
getStringTableStrings :: StringTable -> BS.ByteString
getStringTableStrings st =
BSL.toStrict $ BSB.toLazyByteString
$ foldMap f $ dlistToList (stStrings st)
where
f x = BSB.shortByteString (ST.contents x) `mappend` BSB.word8 0
lookupStringTable :: ShortText -> State StringTable StrTabOffset
lookupStringTable str = state $ \st ->
case M.lookup str (stLookup st) of
Just off -> (off, st)
Nothing ->
let !st' = st { stStrings = stStrings st `snoc` str
, stLength = stLength st + ST.byteLength str + 1
, stLookup = M.insert str res (stLookup st)
}
res = StrTabOffset (stLength st)
in (res, st')
newtype DList a = DList ([a] -> [a])
emptyDList :: DList a
emptyDList = DList id
snoc :: DList a -> a -> DList a
snoc (DList f) x = DList (f . (x:))
dlistToList :: DList a -> [a]
dlistToList (DList f) = f []
......@@ -11,7 +11,7 @@ module GHC.StgToCmm.Prof (
mkCCostCentre, mkCCostCentreStack,
-- infoTablePRov
initInfoTableProv, emitInfoTableProv,
initInfoTableProv,
-- Cost-centre Profiling
dynProfHdr, profDynAlloc, profAlloc, staticProfHdr, initUpdFrameProf,
......@@ -32,6 +32,7 @@ import GHC.Platform
import GHC.Platform.Profile
import GHC.StgToCmm.Closure
import GHC.StgToCmm.Config
import GHC.StgToCmm.InfoTableProv
import GHC.StgToCmm.Utils
import GHC.StgToCmm.Monad
import GHC.StgToCmm.Lit
......@@ -55,7 +56,6 @@ import GHC.Utils.Encoding
import Control.Monad
import Data.Char (ord)
import Data.Bifunctor (first)
import GHC.Utils.Monad (whenM)
-----------------------------------------------------------------------------
......@@ -274,9 +274,8 @@ sizeof_ccs_words platform
where
(ws,ms) = pc_SIZEOF_CostCentreStack (platformConstants platform) `divMod` platformWordSizeInBytes platform
-- | Emit info-table provenance declarations
initInfoTableProv :: [CmmInfoTable] -> InfoTableProvMap -> FCode CStub
-- Emit the declarations
initInfoTableProv infos itmap
= do
cfg <- getStgToCmmConfig
......@@ -284,42 +283,16 @@ initInfoTableProv infos itmap
info_table = stgToCmmInfoTableMap cfg
platform = stgToCmmPlatform cfg
this_mod = stgToCmmThisModule cfg
-- Output the actual IPE data
mapM_ emitInfoTableProv ents
-- Create the C stub which initialises the IPE map
return (ipInitCode info_table platform this_mod ents)
--- Info Table Prov stuff
emitInfoTableProv :: InfoProvEnt -> FCode ()
emitInfoTableProv ip = do
{ cfg <- getStgToCmmConfig
; let mod = infoProvModule ip
ctx = stgToCmmContext cfg
platform = stgToCmmPlatform cfg
; let (src, label) = maybe ("", "") (first (renderWithContext ctx . ppr)) (infoTableProv ip)
mk_string = newByteStringCLit . utf8EncodeByteString
; label <- mk_string label
; modl <- newByteStringCLit (bytesFS $ moduleNameFS
$ moduleName mod)
; ty_string <- mk_string (infoTableType ip)
; loc <- mk_string src
; table_name <- mk_string (renderWithContext ctx
(pprCLabel platform CStyle (infoTablePtr ip)))
; closure_type <- mk_string (renderWithContext ctx
(text $ show $ infoProvEntClosureType ip))
; let
lits = [ CmmLabel (infoTablePtr ip), -- Info table pointer
table_name, -- char *table_name
closure_type, -- char *closure_desc -- Filled in from the InfoTable
ty_string, -- char *ty_string
label, -- char *label,
modl, -- char *module,
loc, -- char *srcloc,
zero platform -- struct _InfoProvEnt *link
]
; emitDataLits (mkIPELabel ip) lits
}
case ents of
[] -> return mempty
_ -> do
-- Emit IPE buffer
emitIpeBufferListNode this_mod ents
-- Create the C stub which initialises the IPE map
return (ipInitCode info_table platform this_mod)
-- ---------------------------------------------------------------------------
-- Set the current cost centre stack
......
......@@ -615,6 +615,7 @@ Library
GHC.StgToCmm.Foreign
GHC.StgToCmm.Heap
GHC.StgToCmm.Hpc
GHC.StgToCmm.InfoTableProv
GHC.StgToCmm.Layout
GHC.StgToCmm.Lit
GHC.StgToCmm.Monad
......
......@@ -110,20 +110,11 @@ import GHC.Base
import {-# SOURCE #-} GHC.IO.Encoding
import qualified GHC.Foreign as GHC
import GHC.Foreign (CString, CStringLen)
-----------------------------------------------------------------------------
-- Strings
-- representation of strings in C
-- ------------------------------
-- | A C string is a reference to an array of C characters terminated by NUL.
type CString = Ptr CChar
-- | A string with explicit length information in bytes instead of a
-- terminating NUL (allowing NUL characters in the middle of the string).
type CStringLen = (Ptr CChar, Int)
-- exported functions
-- ------------------
--
......
......@@ -121,11 +121,8 @@ import GHC.IORef
import GHC.MVar
import GHC.Real ( fromIntegral )
import GHC.Show ( Show(..), showParen, showString )
import GHC.Stable ( StablePtr(..) )
import GHC.Weak
import Unsafe.Coerce ( unsafeCoerce# )
infixr 0 `par`, `pseq`
-----------------------------------------------------------------------------
......@@ -663,20 +660,6 @@ mkWeakThreadId t@(ThreadId t#) = IO $ \s ->
(# s1, w #) -> (# s1, Weak w #)
data PrimMVar
-- | Make a 'StablePtr' that can be passed to the C function
-- @hs_try_putmvar()@. The RTS wants a 'StablePtr' to the
-- underlying 'MVar#', but a 'StablePtr#' can only refer to
-- lifted types, so we have to cheat by coercing.
newStablePtrPrimMVar :: MVar a -> IO (StablePtr PrimMVar)
newStablePtrPrimMVar (MVar m) = IO $ \s0 ->
case makeStablePtr# (unsafeCoerce# m :: PrimMVar) s0 of
-- Coerce unlifted m :: MVar# RealWorld a
-- to lifted PrimMVar
-- apparently because mkStablePtr is not representation-polymorphic
(# s1, sp #) -> (# s1, StablePtr sp #)
-----------------------------------------------------------------------------
-- Transactional heap operations
-----------------------------------------------------------------------------
......
......@@ -2,10 +2,12 @@
{-# LANGUAGE NoImplicitPrelude
, ExistentialQuantification
, MagicHash
, RecordWildCards
, PatternSynonyms
#-}
{-# LANGUAGE DataKinds, PolyKinds #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# OPTIONS_HADDOCK not-home #-}
-----------------------------------------------------------------------------
......@@ -28,7 +30,8 @@ module GHC.Exception
, ErrorCall(..,ErrorCall)
, errorCallException
, errorCallWithCallStackException
-- re-export CallStack and SrcLoc from GHC.Types
-- * Re-exports from GHC.Types
, CallStack, fromCallSiteList, getCallStack, prettyCallStack
, prettyCallStackLines, showCCSStack
, SrcLoc(..), prettySrcLoc
......@@ -40,6 +43,9 @@ import GHC.Stack.Types
import GHC.OldList
import GHC.IO.Unsafe
import {-# SOURCE #-} GHC.Stack.CCS
import {-# SOURCE #-} GHC.Stack (prettyCallStackLines, prettyCallStack, prettySrcLoc)
import GHC.Exception.Backtrace
import GHC.Exception.Context
import GHC.Exception.Type
-- | Throw an exception. Exceptions may be thrown from purely
......@@ -48,8 +54,10 @@ import GHC.Exception.Type
-- WARNING: You may want to use 'throwIO' instead so that your pure code
-- stays exception-free.
throw :: forall (r :: RuntimeRep). forall (a :: TYPE r). forall e.
Exception e => e -> a
throw e = raise# (toException e)
(?callStack :: CallStack, Exception e) => e -> a
throw e =
let !context = unsafePerformIO collectBacktraces
in raise# (toExceptionWithContext e context)
-- | This is thrown when the user calls 'error'. The first @String@ is the
-- argument given to 'error', second @String@ is the location.
......@@ -89,31 +97,3 @@ showCCSStack :: [String] -> [String]
showCCSStack [] = []
showCCSStack stk = "CallStack (from -prof):" : map (" " ++) (reverse stk)
-- prettySrcLoc and prettyCallStack are defined here to avoid hs-boot
-- files. See Note [Definition of CallStack]
-- | Pretty print a 'SrcLoc'.
--
-- @since 4.9.0.0
prettySrcLoc :: SrcLoc -> String
prettySrcLoc SrcLoc {..}
= foldr (++) ""
[ srcLocFile, ":"
, show srcLocStartLine, ":"
, show srcLocStartCol, " in "
, srcLocPackage, ":", srcLocModule
]
-- | Pretty print a 'CallStack'.
--
-- @since 4.9.0.0
prettyCallStack :: CallStack -> String
prettyCallStack = intercalate "\n" . prettyCallStackLines
prettyCallStackLines :: CallStack -> [String]
prettyCallStackLines cs = case getCallStack cs of
[] -> []
stk -> "CallStack (from HasCallStack):"
: map ((" " ++) . prettyCallSite) stk
where
prettyCallSite (f, loc) = f ++ ", called at " ++ prettySrcLoc loc
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE NamedFieldPuns #-}
module GHC.Exception.Backtrace
( BacktraceMechanism(..)
, collectBacktraces
, collectBacktrace
) where
import GHC.Base
import Data.OldList
import GHC.Show (Show)
import GHC.Exception.Context
import GHC.Stack.Types (HasCallStack, CallStack)
import {-# SOURCE #-} qualified GHC.Stack as CallStack
import {-# SOURCE #-} qualified GHC.ExecutionStack as ExecStack
import {-# SOURCE #-} qualified GHC.Stack.CloneStack as CloneStack
import {-# SOURCE #-} qualified GHC.Stack.CCS as CCS
-- | How to collect a backtrace when an exception is thrown.
data BacktraceMechanism
= -- | collect a cost center stacktrace (only available when built with profiling)
CostCentreBacktraceMech
| -- | use execution stack unwinding with given limit
ExecutionStackBacktraceMech
| -- | collect backtraces from Info Table Provenance Entries
IPEBacktraceMech
| -- | use 'HasCallStack'
HasCallStackBacktraceMech
deriving (Eq, Show)
collectBacktraces :: HasCallStack => IO ExceptionContext
collectBacktraces = do
mconcat `fmap` mapM collect
[ CostCentreBacktraceMech
, ExecutionStackBacktraceMech
, IPEBacktraceMech
, HasCallStackBacktraceMech
]
where
collect mech
| True = collectBacktrace mech -- FIXME
-- | otherwise = return mempty
data CostCentreBacktrace = CostCentreBacktrace [String]
instance ExceptionAnnotation CostCentreBacktrace where
displayExceptionAnnotation (CostCentreBacktrace strs) = CCS.renderStack strs
data ExecutionBacktrace = ExecutionBacktrace String
instance ExceptionAnnotation ExecutionBacktrace where
displayExceptionAnnotation (ExecutionBacktrace str) =
"Native stack backtrace:\n" ++ str
data HasCallStackBacktrace = HasCallStackBacktrace CallStack
instance ExceptionAnnotation HasCallStackBacktrace where
displayExceptionAnnotation (HasCallStackBacktrace cs) =
"HasCallStack backtrace:\n" ++ CallStack.prettyCallStack cs
data InfoProvBacktrace = InfoProvBacktrace [CloneStack.StackEntry]
instance ExceptionAnnotation InfoProvBacktrace where
displayExceptionAnnotation (InfoProvBacktrace stack) =
"Info table provenance backtrace:\n" ++
intercalate "\n" (map (" "++) $ map CloneStack.prettyStackEntry stack)
collectBacktrace :: (?callStack :: CallStack) => BacktraceMechanism -> IO ExceptionContext
collectBacktrace CostCentreBacktraceMech = do
strs <- CCS.currentCallStack
case strs of
[] -> return emptyExceptionContext
_ -> pure $ mkExceptionContext (CostCentreBacktrace strs)
collectBacktrace ExecutionStackBacktraceMech = do
mst <- ExecStack.showStackTrace
case mst of
Nothing -> return emptyExceptionContext
Just st -> return $ mkExceptionContext (ExecutionBacktrace st)
collectBacktrace IPEBacktraceMech = do
stack <- CloneStack.cloneMyStack
stackEntries <- CloneStack.decode stack
return $ mkExceptionContext (InfoProvBacktrace stackEntries)
collectBacktrace HasCallStackBacktraceMech =
return $ mkExceptionContext (HasCallStackBacktrace ?callStack)
{-# LANGUAGE NoImplicitPrelude #-}
module GHC.Exception.Backtrace where
import GHC.Base (IO)
import GHC.Exception.Context (ExceptionContext)
import GHC.Stack.Types (HasCallStack)
data BacktraceMechanism
collectBacktraces :: HasCallStack => IO ExceptionContext
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# OPTIONS_HADDOCK not-home #-}
-----------------------------------------------------------------------------
-- |
-- Module : GHC.Exception.Context
-- Copyright : (c) The University of Glasgow, 1998-2002
-- License : see libraries/base/LICENSE
--
-- Maintainer : cvs-ghc@haskell.org
-- Stability : internal
-- Portability : non-portable (GHC extensions)
--
-- Exception context type.
--
-----------------------------------------------------------------------------
module GHC.Exception.Context
( -- * Exception context
ExceptionContext(..)
, emptyExceptionContext
, mkExceptionContext
, mergeExceptionContexts
-- * Exception annotations
, SomeExceptionAnnotation(..)
, ExceptionAnnotation(..)
) where
import GHC.Base ((++), String, Semigroup(..), Monoid(..))
import GHC.Show (Show(..))
import Data.Typeable.Internal (Typeable)
data ExceptionContext = ExceptionContext [SomeExceptionAnnotation]
instance Semigroup ExceptionContext where
(<>) = mergeExceptionContexts
instance Monoid ExceptionContext where
mempty = emptyExceptionContext
emptyExceptionContext :: ExceptionContext
emptyExceptionContext = ExceptionContext []
mergeExceptionContexts :: ExceptionContext -> ExceptionContext -> ExceptionContext
mergeExceptionContexts (ExceptionContext a) (ExceptionContext b) = ExceptionContext (a ++ b)
mkExceptionContext :: ExceptionAnnotation a => a -> ExceptionContext
mkExceptionContext x = ExceptionContext [SomeExceptionAnnotation x]
data SomeExceptionAnnotation = forall a. ExceptionAnnotation a => SomeExceptionAnnotation a
class Typeable a => ExceptionAnnotation a where
displayExceptionAnnotation :: a -> String
default displayExceptionAnnotation :: Show a => a -> String
displayExceptionAnnotation = show
{-# LANGUAGE NoImplicitPrelude #-}
module GHC.Exception.Context where
data ExceptionContext
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE Trustworthy #-}
{-# OPTIONS_HADDOCK not-home #-}
......@@ -20,7 +21,14 @@
module GHC.Exception.Type
( Exception(..) -- Class
, SomeException(..), ArithException(..)
, SomeException(..)
, exceptionContext
-- * Exception context
, ExceptionContext(..)
, emptyExceptionContext
, mergeExceptionContexts
-- * Arithmetic exceptions
, ArithException(..)
, divZeroException, overflowException, ratioZeroDenomException
, underflowException
) where
......@@ -30,13 +38,17 @@ import Data.Typeable (Typeable, cast)
-- loop: Data.Typeable -> GHC.Err -> GHC.Exception
import GHC.Base
import GHC.Show
import GHC.Exception.Context
{- |
The @SomeException@ type is the root of the exception type hierarchy.
When an exception of type @e@ is thrown, behind the scenes it is
encapsulated in a @SomeException@.
-}
data SomeException = forall e . Exception e => SomeException e
data SomeException = forall e. (Exception e, ?exc_context :: ExceptionContext) => SomeException e
exceptionContext :: SomeException -> ExceptionContext
exceptionContext (SomeException _) = ?exc_context
-- | @since 3.0
instance Show SomeException where
......@@ -129,10 +141,13 @@ Caught MismatchedParentheses
-}
class (Typeable e, Show e) => Exception e where
toException :: e -> SomeException
toException :: e -> SomeException
toExceptionWithContext :: e -> ExceptionContext -> SomeException
fromException :: SomeException -> Maybe e
toException = SomeException
toException e = toExceptionWithContext e emptyExceptionContext
toExceptionWithContext e ctxt = SomeException e
where ?exc_context = ctxt
fromException (SomeException e) = cast e
-- | Render this exception value in a human-friendly manner.
......@@ -146,8 +161,18 @@ class (Typeable e, Show e) => Exception e where
-- | @since 3.0
instance Exception SomeException where
toException se = se
toExceptionWithContext se@(SomeException e) ctxt =
SomeException e
where ?exc_context = ctxt <> exceptionContext se
fromException = Just
displayException (SomeException e) = displayException e
displayException (SomeException e) =
displayException e ++ "\n" ++ displayContext ?exc_context
displayContext :: ExceptionContext -> String
displayContext (ExceptionContext anns0) = go anns0
where
go (SomeExceptionAnnotation ann : anns) = displayExceptionAnnotation ann ++ "\n" ++ go anns
go [] = "\n"
-- |Arithmetic exceptions.
data ArithException
......
{-# LANGUAGE NoImplicitPrelude #-}
-----------------------------------------------------------------------------
-- |
-- Module : GHC.ExecutionStack
......@@ -36,7 +38,7 @@ module GHC.ExecutionStack (
, showStackTrace
) where
import Control.Monad (join)
import GHC.Base
import GHC.ExecutionStack.Internal
-- | Get a trace of the current execution stack state.
......
{-# LANGUAGE NoImplicitPrelude #-}
module GHC.ExecutionStack where
import GHC.Base
showStackTrace :: IO (Maybe String)
......@@ -17,6 +17,7 @@
#include "HsBaseConfig.h"
#include "rts/Libdw.h"
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE MultiWayIf #-}
module GHC.ExecutionStack.Internal (
......@@ -31,7 +32,13 @@ module GHC.ExecutionStack.Internal (
, invalidateDebugCache
) where
import Control.Monad (join)
import GHC.Base
import GHC.Show
import GHC.List (reverse, null)
import GHC.Num ((-))
import GHC.Real (fromIntegral)
import Data.Maybe
import Data.Functor ((<$>))
import Data.Word
import Foreign.C.Types
import Foreign.C.String (peekCString, CString)
......
......@@ -19,6 +19,7 @@
module GHC.Foreign (
-- * C strings with a configurable encoding
CString, CStringLen,
-- conversion of C strings into Haskell strings
--
......@@ -74,8 +75,11 @@ putDebugMsg | c_DEBUG_DUMP = debugLn
| otherwise = const (return ())
-- These definitions are identical to those in Foreign.C.String, but copied in here to avoid a cycle:
-- | A C string is a reference to an array of C characters terminated by NUL.
type CString = Ptr CChar
-- | A string with explicit length information in bytes instead of a
-- terminating NUL (allowing NUL characters in the middle of the string).
type CStringLen = (Ptr CChar, Int)
-- exported functions
......
......@@ -47,6 +47,8 @@ import GHC.ST
import GHC.Exception
import GHC.Show
import GHC.IO.Unsafe
import GHC.Stack.Types ( HasCallStack )
import GHC.Exception.Backtrace ( collectBacktraces )
import Unsafe.Coerce ( unsafeCoerce )
import {-# SOURCE #-} GHC.IO.Exception ( userError, IOError )
......@@ -235,8 +237,10 @@ mplusIO m n = m `catchException` \ (_ :: IOError) -> n
-- for a more technical introduction to how GHC optimises around precise vs.
-- imprecise exceptions.
--
throwIO :: Exception e => e -> IO a
throwIO e = IO (raiseIO# (toException e))
throwIO :: (HasCallStack, Exception e) => e -> IO a
throwIO e = do
ctxt <- collectBacktraces
IO (raiseIO# (toExceptionWithContext e ctxt))
-- -----------------------------------------------------------------------------
-- Controlling asynchronous exception delivery
......