Ticket #2052 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

hpc ignores files containing LINES pragmas that refer to .hsc files

Reported by: dons Owned by: AndyGill
Priority: normal Milestone: 6.10.1
Component: Code Coverage Version: 6.8.2
Keywords: hpc, hsc2hs Cc: dons@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

ghc -hpc generates no ticks for files containing LINE pragmas that point back to .hsc files. Removing the LINE pragmas, and ticks are generated.

An example. This simple .hsc file:

main = print "hello, world"

Generates this A.hs file:

{-# LINE 1 "A.hsc" #-}
main = print "hello, world"
{-# LINE 2 "A.hsc" #-}

Compiling this with -fhpc, we see no ticks produced:

{ AbsBinds [] [] [Main.main <= [] main_aif]

    Main.main :: GHC.IOBase.IO ()
    []
    { print_aie = System.IO.print @ [GHC.Base.Char] $dShow_ail
      main_aif = print_aie "hello, world" }
  :Main.main = GHC.TopHandler.runMainIO @ () Main.main
  $dShow_ail = GHC.Show.$f21 @ GHC.Base.Char $dShow_aiW
  $dShow_aiW = GHC.Show.$f18 }

Run this, and get the hpc report:

$ ./a.out 
"hello, world"

$ hpc report a.out.tix 
100% expressions used (0/0)
100% boolean coverage (0/0)

0/0 declarations.

However, an identical file, without LINE pragmas, goes through just fine:

$ ghc -fhpc B.hs -ddump-hpc 
{ AbsBinds [] [] [Main.main <= [] main_aif]
    Main.main :: GHC.IOBase.IO ()
    []
    { print_aie = System.IO.print @ [GHC.Base.Char] $dShow_ail
      -- tick id = (2, [])
      main_aif = tick<1>(print_aie (tick<0>("got you"))) }
  :Main.main = GHC.TopHandler.runMainIO @ () Main.main
  $dShow_ail = GHC.Show.$f21 @ GHC.Base.Char $dShow_aiW
  $dShow_aiW = GHC.Show.$f18 }

And the result has valid hpc .tix

$ hpc report a.out.tix 
100% expressions used (2/2)
100% boolean coverage (0/0)

Change History

Changed 5 years ago by igloo

  • difficulty set to Unknown
  • milestone set to 6.8.3

This sounds like it should be trivial to fix, so let's aim to do so for 6.8.3.

Changed 5 years ago by AndyGill

  • owner changed from andy@… to AndyGill
  • status changed from new to assigned

It is not quite that easy, because the Span info has been messed up. Typically this just effects the error messages, but here the info *has* to be correct for hpc to work.

Changed 5 years ago by igloo

Hmm; you can generate the ticks and report percentages at least, I'd have thought? While this isn't ideal, it's better than nothing.

Changed 5 years ago by igloo

  • milestone changed from 6.8.3 to 6.10.1

Changed 5 years ago by AndyGill

  • status changed from assigned to closed
  • resolution set to fixed

Changed 5 years ago by simonmar

  • architecture changed from Multiple to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Multiple to Unknown/Multiple
Note: See TracTickets for help on using tickets.