Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475-- | DWARF encoding parameters: endianness, format (32/64-bit), and-- the combined 'Encoding' record used throughout parsing.module Data.Dwarf.Encoding ( -- * Endianness Endianness(..)
-- * DWARF format , Format(..) , formatWordSize , formatInitialLengthSize
-- * Combined encoding parameters , Encoding(..) ) where
import Data.Word (Word8)
-------------------------------------------------------------------------- Endianness------------------------------------------------------------------------
-- | Byte order for multi-byte values.data Endianness = LittleEndian | BigEndian deriving stock (Eq, Ord, Show)
-------------------------------------------------------------------------- DWARF format (32-bit vs 64-bit)------------------------------------------------------------------------
-- | DWARF uses two formats which affect the size of section offsets-- and the initial length field. The vast majority of DWARF data uses-- 'Dwarf32'; 'Dwarf64' exists for debug information exceeding 4 GiB.data Format = Dwarf32 -- ^ 4-byte section offsets | Dwarf64 -- ^ 8-byte section offsets deriving stock (Eq, Ord, Show)
-- | Size in bytes of a section offset in this format.---- >>> formatWordSize Dwarf32-- 4-- >>> formatWordSize Dwarf64-- 8formatWordSize :: Format -> Word8formatWordSize Dwarf32 = 4formatWordSize Dwarf64 = 8
-- | Size in bytes of the initial length field (including the 64-bit sentinel).---- >>> formatInitialLengthSize Dwarf32-- 4-- >>> formatInitialLengthSize Dwarf64-- 12formatInitialLengthSize :: Format -> Word8formatInitialLengthSize Dwarf32 = 4formatInitialLengthSize Dwarf64 = 12
-------------------------------------------------------------------------- Combined encoding parameters------------------------------------------------------------------------
-- | The three parameters that together determine how to decode most-- DWARF structures: the DWARF version, the target address size, and-- the 32/64-bit format.data Encoding = Encoding { encodingVersion :: {-# UNPACK #-} !Int -- ^ DWARF version (2, 3, 4, or 5). , encodingAddressSize :: {-# UNPACK #-} !Word8 -- ^ Size of a target address in bytes (typically 4 or 8). , encodingFormat :: !Format -- ^ 32-bit or 64-bit DWARF format. } deriving stock (Eq, Show)