llvm-pretty-0.12.0.0: A pretty printing library inspired by the llvm binding.
LicenseBSD3
Maintaineremertens@galois.com
Stabilityprovisional
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.LLVM.DebugUtils

Description

 
Synopsis

Definition type analyzer

data StructFieldInfo Source #

Record debug information about a field in a struct type.

Constructors

StructFieldInfo 

Fields

Instances

Instances details
Show StructFieldInfo Source # 
Instance details

Defined in Text.LLVM.DebugUtils

data BitfieldInfo Source #

Record debug information about a field within a bitfield. For example, the following C struct:

struct s {
  int32_t w;
  uint8_t x1:1;
  uint8_t x2:2;
  uint8_t y:1;
  int32_t z;
};

Corresponds to the following Info:

Structure
  [ StructFieldInfo { sfiName = "w"
                      , sfiOffset = 0
                      , sfiBitfield = Nothing
                      , sfiInfo = BaseType "int32_t"
                      }
  , StructFieldInfo { sfiName = "x1"
                      , sfiOffset = 32
                      , sfiBitfield = Just (BitfieldInfo { biFieldSize = 1
                                                             , biBitfieldOffset = 32
                                                             })
                      , sfiInfo = BaseType "uint8_t"
                      }
  , StructFieldInfo { sfiName = "x2"
                      , sfiOffset = 33
                      , sfiBitfield = Just (BitfieldInfo { biFieldSize = 2
                                                             , biBitfieldOffset = 32
                                                             })
                      , sfiInfo = BaseType "uint8_t"
                      }
  , StructFieldInfo { sfiName = "y"
                      , sfiOffset = 35
                      , sfiBitfield = Just (BitfieldInfo { biFieldSize = 1
                                                             , biBitfieldOffset = 32
                                                             })
                      , sfiInfo = BaseType "uint8_t"
                      }
  , StructFieldInfo { sfiName = "z"
                      , sfiOffset = 64
                      , sfiBitfield = Nothing
                      , sfiInfo = BaseType "int32_t"
                      }
  ]

Notice that only x1, x2, and y have BitfieldInfos, as they are the only fields that were declared with bitfield syntax.

Constructors

BitfieldInfo 

Fields

  • biFieldSize :: Word64

    The field's size (in bits) within the bitfield. This should not be confused with the size of the field's declared type. For example, the biFieldSize of the x1 field is 1, despite the fact that its declared type, uint8_t, is otherwise 8 bits in size.

  • biBitfieldOffset :: Word64

    The bitfield's offset (in bits) from the start of the struct. Note that for a given field within a bitfield, its sfiOffset is equal to the biBitfieldOffset plus the biFieldSize.

Instances

Instances details
Show BitfieldInfo Source # 
Instance details

Defined in Text.LLVM.DebugUtils

data UnionFieldInfo Source #

Record debug information about a field in a union type.

Constructors

UnionFieldInfo 

Fields

Instances

Instances details
Show UnionFieldInfo Source # 
Instance details

Defined in Text.LLVM.DebugUtils

computeFunctionTypes Source #

Arguments

:: Module

module to search

-> Symbol

function symbol

-> Maybe [Maybe Info]

return and argument type information

Compute the structures of a function's return and argument types using DWARF information metadata of the LLVM module. Different versions of LLVM make this information available via different paths. This function attempts to support the variations.

valMdToInfo :: MdMap -> ValMd -> Info Source #

localVariableNameDeclarations Source #

Arguments

:: IntMap ValMd

unnamed metadata

-> Define

function definition

-> Map Ident Ident

raw name, actual name

Metadata lookup

mkMdMap :: Module -> IntMap ValMd Source #

Compute an IntMap of the unnamed metadata in a module

Type structure dereference

derefInfo Source #

Arguments

:: Info

pointer type information

-> Info

type information of pointer's base type

If the argument describes a pointer, return the information for the type that it points do. If the argument describes an array, return information about the element type.

fieldIndexByPosition Source #

Arguments

:: Int

zero-based field index

-> Info

composite type information

-> Info

type information for specified field

If the argument describes a composite type, returns the type of the field by zero-based index into the list of fields.

fieldIndexByName Source #

Arguments

:: String

field name

-> Info

composite type info

-> Maybe Int

zero-based index of field matching the name

If the argument describes a composite type, return the first, zero-based index of the field in that type that matches the given name.

Info hueristics

guessAliasInfo Source #

Arguments

:: IntMap ValMd

unnamed metadata

-> Ident

alias

-> Info 

Search the metadata for debug info corresponding to a given type alias. This is considered a heuristic because there's no direct mapping between type aliases and debug info. The debug information must be search for a textual match.

Compared to guessTypeInfo, this function first tries to strip the "struct." and "union." prefixes that are commonly added by clang before searching for the type information.

guessTypeInfo Source #

Arguments

:: IntMap ValMd

unnamed metadata

-> String

struct alias

-> Info 

Search the metadata for debug info corresponding to a given type alias. This is considered a heuristic because there's no direct mapping between type aliases and debug info. The debug information must be search for a textual match.

Function arguments

debugInfoArgNames :: Module -> Define -> IntMap String Source #

Find source-level names of function arguments

Line numbers of definitions

debugInfoGlobalLines :: Module -> Map String Int Source #

Map global variable names to the line on which the global is defined

debugInfoDefineLines :: Module -> Map String Int Source #

Map function names to the line on which the function is defined