llvm-pretty-0.15.0.0: A pretty printing library inspired by the llvm binding.
LicenseBSD3
Maintaineremertens@galois.com
Stabilityprovisional
Safe HaskellNone
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

atFileLines :: AtFileLines a b => b -> a -> FilePath -> Integer -> Module -> a Source #

Given a file and line number and a handler, call the appropriate handler method on every Define, Block, and Stmt that is associated with the line number.

class AtFileLines a b where Source #

The handler passed to atFileLines must be an instance of this class.

Here, b is an object for which the following methods can be called with an accumulator a and the corresponding LLVM AST element that has the lab label type. The method will return an updated accumulator.

Methods

atDefine :: b -> Define -> a -> a Source #

The atDefine method is called (before any enclosed BasicBlock or Stmt elements) if the file and line number are associated with the Define signature line.

atBlockStart :: b -> DefineRel -> BasicBlock -> a -> a Source #

The atBlockStart method is called if the first Stmt in the BasicBlock is associated with the file and line number, and before any Stmts in the block are passed to atStmt. the first block in the Define.

atStmt :: b -> DefineRel -> BlockRel -> Stmt -> a -> a Source #

The atStmt method is called for every Stmt in the basic block that is associated with the file and line number. The boolean value passed is true if the Stmt immediately follows a previous Stmt that was associated with the same line, or if this was the first Stmt in the block.

atGlobal :: b -> Global -> a -> a Source #

The atGlobal method is called for evey Global that is associated with the file and line number.

data DefineRel Source #

Constructors

FirstBlock Bool

first block of a Define, matched file & line?

OtherBlock

other blocks of a Define

Instances

Instances details
Eq DefineRel Source # 
Instance details

Defined in Text.LLVM.DebugUtils

data BlockRel Source #

Constructors

FirstBlockStmt

first statement in a BasicBlock

ContiguousStmt

previous statement also matched the file & line

FirstLineStmt

previous statement did not match the file & line

Instances

Instances details
Eq BlockRel Source # 
Instance details

Defined in Text.LLVM.DebugUtils