Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132-- | String lookup from @.debug_str@ and @.debug_line_str@ sections.---- Both sections are flat concatenations of null-terminated UTF-8 strings.-- Lookup skips to the given byte offset and reads until the first @\\0@.module Data.Dwarf.Read.Str ( lookupStr , lookupDebugStr , lookupDebugLineStr ) where
import Data.ByteString (ByteString)import Data.Word (Word64)
import Data.Dwarf.Reader (Reader(..), runParse, getNullTerminated)import Data.Dwarf.Section (DebugStr(..), DebugLineStr(..))import Data.Dwarf.Types (DwarfError(..))
-- | Skip to @offset@ bytes in a reader and read a null-terminated string.lookupStr :: Reader r => r -> Word64 -> Either DwarfError ByteStringlookupStr r off = do r' <- skip (fromIntegral off) r (s, _) <- runParse getNullTerminated r' Right s
-- | Look up a string in @.debug_str@ by byte offset (resolves 'ValStrOffset').lookupDebugStr :: Reader r => DebugStr r -> Word64 -> Either DwarfError ByteStringlookupDebugStr (DebugStr r) = lookupStr r
-- | Look up a string in @.debug_line_str@ by byte offset (resolves 'ValLineStrOffset').lookupDebugLineStr :: Reader r => DebugLineStr r -> Word64 -> Either DwarfError ByteStringlookupDebugLineStr (DebugLineStr r) = lookupStr r