ghc-9.6.3: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.CmmToAsm.Dwarf.Types

Contents

- Dwarf information
- Dwarf address range table
- Dwarf frame
- Utilities

Synopsis

- data DwarfInfo
  - = DwarfCompileUnit {
    - dwChildren :: [DwarfInfo]
    - dwName :: String
    - dwProducer :: String
    - dwCompDir :: String
    - dwLowLabel :: CLabel
    - dwHighLabel :: CLabel
    }
  - | DwarfSubprogram {
    - dwChildren :: [DwarfInfo]
    - dwName :: String
    - dwLabel :: CLabel
    - dwParent :: Maybe CLabel
    }
  - | DwarfBlock {
    - dwChildren :: [DwarfInfo]
    - dwLabel :: CLabel
    - dwMarker :: Maybe CLabel
    }
  - | DwarfSrcNote {
    - dwSrcSpan :: RealSrcSpan
    }
- pprDwarfInfo :: IsDoc doc => Platform -> Bool -> DwarfInfo -> doc
- pprAbbrevDecls :: IsDoc doc => Platform -> Bool -> doc
- data DwarfARange = DwarfARange {
  - dwArngStartLabel :: CLabel
  - dwArngEndLabel :: CLabel
  }
- pprDwarfARanges :: IsDoc doc => Platform -> [DwarfARange] -> Unique -> doc
- data DwarfFrame = DwarfFrame {
  - dwCieLabel :: CLabel
  - dwCieInit :: UnwindTable
  - dwCieProcs :: [DwarfFrameProc]
  }
- data DwarfFrameProc = DwarfFrameProc {
  - dwFdeProc :: CLabel
  - dwFdeHasInfo :: Bool
  - dwFdeBlocks :: [DwarfFrameBlock]
  }
- data DwarfFrameBlock = DwarfFrameBlock {
  - dwFdeBlkHasInfo :: Bool
  - dwFdeUnwind :: [UnwindPoint]
  }
- pprDwarfFrame :: forall doc. IsDoc doc => Platform -> DwarfFrame -> doc
- pprByte :: IsDoc doc => Word8 -> doc
- pprHalf :: IsDoc doc => Word16 -> doc
- pprData4' :: IsDoc doc => Line doc -> doc
- pprDwWord :: IsDoc doc => Line doc -> doc
- pprWord :: IsDoc doc => Platform -> Line doc -> doc
- pprLEBWord :: IsDoc doc => Word -> doc
- pprLEBInt :: IsDoc doc => Int -> doc
- wordAlign :: IsDoc doc => Platform -> doc
- sectionOffset :: IsDoc doc => Platform -> Line doc -> Line doc -> doc

# Dwarf information

data DwarfInfo Source #

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
- dwLowLabel :: CLabel
- dwHighLabel :: CLabel

DwarfSubprogram |

Fields

- dwChildren :: [DwarfInfo]
- dwName :: String
- dwLabel :: CLabel
- dwParent :: Maybe CLabel

  label of DIE belonging to the parent tick

DwarfBlock |

Fields

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

DwarfSrcNote |

Fields

- dwSrcSpan :: RealSrcSpan

pprDwarfInfo :: IsDoc doc => Platform -> Bool -> DwarfInfo -> doc Source #

Generate assembly for DWARF data

pprAbbrevDecls :: IsDoc doc => Platform -> Bool -> doc Source #

Abbreviation declaration. This explains the binary encoding we use for representing `DwarfInfo`. Be aware that this must be updated along with `pprDwarfInfo`.

# Dwarf address range table

data DwarfARange Source #

A DWARF address range. This is used by the debugger to quickly locate which compilation unit a given address belongs to. This type assumes a non-segmented address-space.

Constructors

DwarfARange |

Fields

- dwArngStartLabel :: CLabel
- dwArngEndLabel :: CLabel

pprDwarfARanges :: IsDoc doc => Platform -> [DwarfARange] -> Unique -> doc Source #

Print assembler directives corresponding to a DWARF `.debug_aranges` address table entry.

# Dwarf frame

data DwarfFrame Source #

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 Source #

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 Source #

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

Constructors

DwarfFrameBlock |

Fields

- dwFdeBlkHasInfo :: Bool
- dwFdeUnwind :: [UnwindPoint]

  these unwind points must occur in the same order as they occur in the block

#### Instances

Instances details

OutputableP Platform DwarfFrameBlock Source # |
Instance details Defined in GHC.CmmToAsm.Dwarf.Types Methods pdoc :: Platform -> DwarfFrameBlock -> SDoc Source #

pprDwarfFrame :: forall doc. IsDoc doc => Platform -> DwarfFrame -> doc Source #

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

# Utilities

pprByte :: IsDoc doc => Word8 -> doc Source #

Assembly for a single byte of constant DWARF data

pprHalf :: IsDoc doc => Word16 -> doc Source #

Assembly for a two-byte constant integer

pprData4' :: IsDoc doc => Line doc -> doc Source #

Assembly for 4 bytes of dynamic DWARF data

pprDwWord :: IsDoc doc => Line doc -> doc Source #

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

pprWord :: IsDoc doc => Platform -> Line doc -> doc Source #

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

pprLEBWord :: IsDoc doc => Word -> doc Source #

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 :: IsDoc doc => Int -> doc Source #

Same as `pprLEBWord`, but for a signed number

wordAlign :: IsDoc doc => Platform -> doc Source #

Align assembly at (machine) word boundary

sectionOffset :: IsDoc doc => Platform -> Line doc -> Line doc -> doc Source #

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.