Dwarf: Fix DW_AT_use_UTF8 attribute
authorBen Gamari <bgamari.foss@gmail.com>
Sat, 29 Aug 2015 10:24:14 +0000 (12:24 +0200)
committerBen Gamari <ben@smart-cactus.org>
Sat, 29 Aug 2015 11:08:17 +0000 (13:08 +0200)
Previously this was given in the body but not in the abbreviation table.
Who knows what sort of havoc this was wrecking.

Test Plan: Verify against DWARF4 specification

Reviewers: scpmw, austin

Subscribers: Tarrasch, thomie

Differential Revision: https://phabricator.haskell.org/D1172

compiler/nativeGen/Dwarf/Constants.hs
compiler/nativeGen/Dwarf/Types.hs

index 4b334fc..333d670 100644 (file)
@@ -60,13 +60,14 @@ dW_CHILDREN_no  = 0
 dW_CHILDREN_yes = 1
 
 dW_FORM_addr, dW_FORM_data4, dW_FORM_string, dW_FORM_flag,
-  dW_FORM_block1, dW_FORM_ref4 :: Word
+  dW_FORM_block1, dW_FORM_ref4, dW_FORM_flag_present :: Word
 dW_FORM_addr   = 0x01
 dW_FORM_data4  = 0x06
 dW_FORM_string = 0x08
 dW_FORM_flag   = 0x0c
 dW_FORM_block1 = 0x0a
 dW_FORM_ref4   = 0x13
+dW_FORM_flag_present = 0x19
 
 -- | Dwarf native types
 dW_ATE_address, dW_ATE_boolean, dW_ATE_float, dW_ATE_signed,
index 00d0535..f9262b4 100644 (file)
@@ -66,7 +66,8 @@ pprAbbrev :: DwarfAbbrev -> SDoc
 pprAbbrev = pprLEBWord . fromIntegral . fromEnum
 
 -- | Abbreviation declaration. This explains the binary encoding we
--- use for representing @DwarfInfo@.
+-- use for representing 'DwarfInfo'. Be aware that this must be updated
+-- along with 'pprDwarfInfo'.
 pprAbbrevDecls :: Bool -> SDoc
 pprAbbrevDecls haveDebugLine =
   let mkAbbrev abbr tag chld flds =
@@ -76,11 +77,11 @@ pprAbbrevDecls haveDebugLine =
   in dwarfAbbrevSection $$
      ptext dwarfAbbrevLabel <> colon $$
      mkAbbrev DwAbbrCompileUnit dW_TAG_compile_unit dW_CHILDREN_yes
-       ([ (dW_AT_name, dW_FORM_string)
+       ([(dW_AT_name,     dW_FORM_string)
        , (dW_AT_producer, dW_FORM_string)
        , (dW_AT_language, dW_FORM_data4)
        , (dW_AT_comp_dir, dW_FORM_string)
-       , (dW_AT_use_UTF8, dW_FORM_flag)
+       , (dW_AT_use_UTF8, dW_FORM_flag_present)  -- not represented in body
        ] ++
        (if haveDebugLine
         then [ (dW_AT_stmt_list, dW_FORM_data4) ]
@@ -117,7 +118,6 @@ pprDwarfInfoOpen haveSrc (DwarfCompileUnit _ name producer compDir lineLbl) =
   $$ pprString producer
   $$ pprData4 dW_LANG_Haskell
   $$ pprString compDir
-  $$ pprFlag True -- use UTF8
   $$ if haveSrc
      then sectionOffset lineLbl dwarfLineLabel
      else empty