ghc-7.10.3: The GHC API

Safe Haskell | None
Language | Haskell2010

Dwarf.Types

Contents

- Dwarf information
- Dwarf frame
- Utilities

Synopsis

- data DwarfInfo
  - = DwarfCompileUnit {
    - dwChildren :: [DwarfInfo]
    - dwName :: String
    - dwProducer :: String
    - dwCompDir :: String
    - dwLineLabel :: LitString
    }
  - | DwarfSubprogram {
    - dwChildren :: [DwarfInfo]
    - dwName :: String
    - dwLabel :: CLabel
    }
  - | DwarfBlock {
    - dwChildren :: [DwarfInfo]
    - dwLabel :: CLabel
    - dwMarker :: CLabel
    }
- pprDwarfInfo :: Bool -> DwarfInfo -> SDoc
- pprAbbrevDecls :: Bool -> SDoc
- data DwarfFrame = DwarfFrame {
  - dwCieLabel :: CLabel
  - dwCieInit :: UnwindTable
  - dwCieProcs :: [DwarfFrameProc]
  }
- data DwarfFrameProc = DwarfFrameProc {
  - dwFdeProc :: CLabel
  - dwFdeHasInfo :: Bool
  - dwFdeBlocks :: [DwarfFrameBlock]
  }
- data DwarfFrameBlock = DwarfFrameBlock {
  - dwFdeBlock :: CLabel
  - dwFdeBlkHasInfo :: Bool
  - dwFdeUnwind :: UnwindTable
  }
- pprDwarfFrame :: DwarfFrame -> SDoc
- pprByte :: Word8 -> SDoc
- pprData4' :: SDoc -> SDoc
- pprDwWord :: SDoc -> SDoc
- pprWord :: SDoc -> SDoc
- pprLEBWord :: Word -> SDoc
- pprLEBInt :: Int -> SDoc
- wordAlign :: SDoc
- sectionOffset :: LitString -> LitString -> SDoc

# Dwarf information

data DwarfInfo

Individual dwarf records. Each one will be encoded as an entry in the .debug_info section.

Constructors

DwarfCompileUnit |

Fields

dwChildren :: [DwarfInfo]
dwName :: String
dwProducer :: String
dwCompDir :: String
dwLineLabel :: LitString

DwarfSubprogram |

Fields

dwChildren :: [DwarfInfo]
dwName :: String
dwLabel :: CLabel

DwarfBlock |

Fields

dwChildren :: [DwarfInfo]
dwLabel :: CLabel
dwMarker :: CLabel

pprDwarfInfo :: Bool -> DwarfInfo -> SDoc

Generate assembly for DWARF data

pprAbbrevDecls :: Bool -> SDoc

Abbreviation declaration. This explains the binary encoding we use for representing `DwarfInfo`.

# Dwarf frame

data DwarfFrame

Information about unwind instructions for a procedure. This corresponds to a "Common Information Entry" (CIE) in DWARF.

Constructors

DwarfFrame |

Fields

dwCieLabel :: CLabel
dwCieInit :: UnwindTable
dwCieProcs :: [DwarfFrameProc]

data DwarfFrameProc

Unwind instructions for an individual procedure. Corresponds to a "Frame Description Entry" (FDE) in DWARF.

Constructors

DwarfFrameProc |

Fields

dwFdeProc :: CLabel
dwFdeHasInfo :: Bool
dwFdeBlocks :: [DwarfFrameBlock]

  List of blocks. Order must match asm!

data DwarfFrameBlock

Unwind instructions for a block. Will become part of the containing FDE.

Constructors

DwarfFrameBlock |

Fields

dwFdeBlock :: CLabel
dwFdeBlkHasInfo :: Bool
dwFdeUnwind :: UnwindTable

pprDwarfFrame :: DwarfFrame -> SDoc

Header for the .debug_frame section. Here we emit the "Common Information Entry" record that etablishes general call frame parameters and the default stack layout.

# Utilities

pprByte :: Word8 -> SDoc

Assembly for a single byte of constant DWARF data

pprData4' :: SDoc -> SDoc

Assembly for 4 bytes of dynamic DWARF data

pprDwWord :: SDoc -> SDoc

Assembly for a DWARF word of dynamic data. This means 32 bit, as we are generating 32 bit DWARF.

pprWord :: SDoc -> SDoc

Assembly for a machine word of dynamic data. Depends on the architecture we are currently generating code for.

pprLEBWord :: Word -> SDoc

Prints a number in "little endian base 128" format. The idea is to optimize for small numbers by stopping once all further bytes would be 0. The highest bit in every byte signals whether there are further bytes to read.

pprLEBInt :: Int -> SDoc

Same as `pprLEBWord`, but for a signed number

wordAlign :: SDoc

Align assembly at (machine) word boundary

sectionOffset :: LitString -> LitString -> SDoc

Generate an offset into another section. This is tricky because this is handled differently depending on platform: Mac Os expects us to calculate the offset using assembler arithmetic. Linux expects us to just reference the target directly, and will figure out on their own that we actually need an offset. Finally, Windows has a special directive to refer to relative offsets. Fun.