macaw-base
Safe HaskellNone
LanguageHaskell2010

Data.Macaw.CFG.Core

Description

Defines data types needed to represent values, assignments, and statements from Machine code.

This is a low-level CFG representation where the entire program is a single CFG.

Synopsis

Stmt level declarations

data Stmt arch ids Source #

A statement in our control flow graph language.

Constructors

AssignStmt !(Assignment arch ids tp) 
WriteMem !(ArchAddrValue arch ids) !(MemRepr tp) !(Value arch ids tp)

This denotes a write to memory, and consists of an address to write to, a MemRepr defining how the value should be stored in memory, and the value to be written.

CondWriteMem !(Value arch ids BoolType) !(ArchAddrValue arch ids) !(MemRepr tp) !(Value arch ids tp)

This denotes a write to memory that only executes if the condition is true.

InstructionStart !(ArchAddrWord arch) !Text

The start of an instruction

The information includes the offset relative to the start of the block and the disassembler output if available (or empty string if unavailable)

Comment !Text

A user-level comment

ExecArchStmt !(ArchStmt arch (Value arch ids))

Execute an architecture specific statement

ArchState !(ArchMemAddr arch) !(MapF (ArchReg arch) (Value arch ids))

Address of an instruction and the *machine* registers that it updates (with their associated macaw values after the execution of the instruction).

Instances

Instances details
ArchConstraints arch => Show (Stmt arch ids) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

showsPrec :: Int -> Stmt arch ids -> ShowS #

show :: Stmt arch ids -> String #

showList :: [Stmt arch ids] -> ShowS #

data Assignment arch ids (tp :: Type) Source #

An assignment consists of a unique location identifier and a right- hand side that returns a value.

Constructors

Assignment 

Fields

Instances

Instances details
ArchConstraints arch => Pretty (Assignment arch ids tp) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

pretty :: Assignment arch ids tp -> Doc ann

prettyList :: [Assignment arch ids tp] -> Doc ann

newtype AssignId ids (tp :: Type) Source #

An AssignId is a unique identifier used to identify assignment statements, in a manner similar to SSA (single static assignment) form. AssignIds are typed, and also include a type variable ids that intuitively denotes the set of identifiers from which they are drawn.

Constructors

AssignId (Nonce ids tp) 

Instances

Instances details
TestEquality (AssignId ids :: Type -> Type) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

testEquality :: forall (a :: Type) (b :: Type). AssignId ids a -> AssignId ids b -> Maybe (a :~: b) #

OrdF (AssignId ids :: Type -> Type) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

compareF :: forall (x :: Type) (y :: Type). AssignId ids x -> AssignId ids y -> OrderingF x y

leqF :: forall (x :: Type) (y :: Type). AssignId ids x -> AssignId ids y -> Bool

ltF :: forall (x :: Type) (y :: Type). AssignId ids x -> AssignId ids y -> Bool

geqF :: forall (x :: Type) (y :: Type). AssignId ids x -> AssignId ids y -> Bool

gtF :: forall (x :: Type) (y :: Type). AssignId ids x -> AssignId ids y -> Bool

ShowF (AssignId ids :: Type -> Type) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

withShow :: forall p q (tp :: Type) a. p (AssignId ids) -> q tp -> (Show (AssignId ids tp) => a) -> a

showF :: forall (tp :: Type). AssignId ids tp -> String

showsPrecF :: forall (tp :: Type). Int -> AssignId ids tp -> String -> String

Show (AssignId ids tp) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

showsPrec :: Int -> AssignId ids tp -> ShowS #

show :: AssignId ids tp -> String #

showList :: [AssignId ids tp] -> ShowS #

Eq (AssignId ids tp) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

(==) :: AssignId ids tp -> AssignId ids tp -> Bool #

(/=) :: AssignId ids tp -> AssignId ids tp -> Bool #

Ord (AssignId ids tp) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

compare :: AssignId ids tp -> AssignId ids tp -> Ordering #

(<) :: AssignId ids tp -> AssignId ids tp -> Bool #

(<=) :: AssignId ids tp -> AssignId ids tp -> Bool #

(>) :: AssignId ids tp -> AssignId ids tp -> Bool #

(>=) :: AssignId ids tp -> AssignId ids tp -> Bool #

max :: AssignId ids tp -> AssignId ids tp -> AssignId ids tp #

min :: AssignId ids tp -> AssignId ids tp -> AssignId ids tp #

Value

data Value arch ids (tp :: Type) where Source #

A value at runtime

Values are only well-defined in the context of a particular block, and are immutable within that context (i.e. their value would not change from a memory write).

Constructors

CValue :: forall arch (tp :: Type) ids. !(CValue arch tp) -> Value arch ids tp

A constant value

AssignedValue :: forall arch ids (tp :: Type). !(Assignment arch ids tp) -> Value arch ids tp

Value from an assignment statement.

Initial :: forall arch (tp :: Type) ids. !(ArchReg arch tp) -> Value arch ids tp

Represents the value assigned to the register when the block started.

Instances

Instances details
OrdF (ArchReg arch) => TestEquality (Value arch ids :: Type -> Type) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

testEquality :: forall (a :: Type) (b :: Type). Value arch ids a -> Value arch ids b -> Maybe (a :~: b) #

(RegisterInfo r, r ~ ArchReg arch) => PrettyRegValue r (Value arch ids) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

ppValueEq :: forall (tp :: Type) ann. r tp -> Value arch ids tp -> Maybe (Doc ann) Source #

OrdF (ArchReg arch) => EqF (Value arch ids :: Type -> Type) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

eqF :: forall (a :: Type). Value arch ids a -> Value arch ids a -> Bool

OrdF (ArchReg arch) => OrdF (Value arch ids :: Type -> Type) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

compareF :: forall (x :: Type) (y :: Type). Value arch ids x -> Value arch ids y -> OrderingF x y

leqF :: forall (x :: Type) (y :: Type). Value arch ids x -> Value arch ids y -> Bool

ltF :: forall (x :: Type) (y :: Type). Value arch ids x -> Value arch ids y -> Bool

geqF :: forall (x :: Type) (y :: Type). Value arch ids x -> Value arch ids y -> Bool

gtF :: forall (x :: Type) (y :: Type). Value arch ids x -> Value arch ids y -> Bool

HasRepr (ArchReg arch) TypeRepr => HasRepr (Value arch ids :: Type -> Type) TypeRepr Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

typeRepr :: forall (tp :: Type). Value arch ids tp -> TypeRepr tp Source #

ShowF (ArchReg arch) => Show (Value arch ids tp) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

showsPrec :: Int -> Value arch ids tp -> ShowS #

show :: Value arch ids tp -> String #

showList :: [Value arch ids tp] -> ShowS #

OrdF (ArchReg arch) => Eq (Value arch ids tp) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

(==) :: Value arch ids tp -> Value arch ids tp -> Bool #

(/=) :: Value arch ids tp -> Value arch ids tp -> Bool #

OrdF (ArchReg arch) => Ord (Value arch ids tp) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

compare :: Value arch ids tp -> Value arch ids tp -> Ordering #

(<) :: Value arch ids tp -> Value arch ids tp -> Bool #

(<=) :: Value arch ids tp -> Value arch ids tp -> Bool #

(>) :: Value arch ids tp -> Value arch ids tp -> Bool #

(>=) :: Value arch ids tp -> Value arch ids tp -> Bool #

max :: Value arch ids tp -> Value arch ids tp -> Value arch ids tp #

min :: Value arch ids tp -> Value arch ids tp -> Value arch ids tp #

ArchConstraints arch => Pretty (AssignRhs arch (Value arch ids) tp) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

pretty :: AssignRhs arch (Value arch ids) tp -> Doc ann

prettyList :: [AssignRhs arch (Value arch ids) tp] -> Doc ann

ShowF (ArchReg arch) => Pretty (Value arch ids tp) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

pretty :: Value arch ids tp -> Doc ann

prettyList :: [Value arch ids tp] -> Doc ann

data CValue arch (tp :: Type) where Source #

A constant whose value does not change during execution.

Constructors

BVCValue :: forall (n :: Natural) arch. 1 <= n => !(NatRepr n) -> !Integer -> CValue arch ('BVType n)

A constant bitvector

The integer should be between 0 and 2^n-1.

BoolCValue :: forall arch. !Bool -> CValue arch 'BoolType

A constant Boolean

RelocatableCValue :: forall arch. !(AddrWidthRepr (ArchAddrWidth arch)) -> !(MemAddr (ArchAddrWidth arch)) -> CValue arch ('BVType (ArchAddrWidth arch))

A memory address

SymbolCValue :: forall arch. !(AddrWidthRepr (ArchAddrWidth arch)) -> !SymbolIdentifier -> CValue arch ('BVType (ArchAddrWidth arch))

This denotes the address of a symbol identifier in the binary.

This appears when dealing with relocations.

Instances

Instances details
TestEquality (CValue arch :: Type -> Type) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

testEquality :: forall (a :: Type) (b :: Type). CValue arch a -> CValue arch b -> Maybe (a :~: b) #

HashableF (CValue arch :: Type -> Type) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

hashWithSaltF :: forall (tp :: Type). Int -> CValue arch tp -> Int

hashF :: forall (tp :: Type). CValue arch tp -> Int

OrdF (CValue arch :: Type -> Type) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

compareF :: forall (x :: Type) (y :: Type). CValue arch x -> CValue arch y -> OrderingF x y

leqF :: forall (x :: Type) (y :: Type). CValue arch x -> CValue arch y -> Bool

ltF :: forall (x :: Type) (y :: Type). CValue arch x -> CValue arch y -> Bool

geqF :: forall (x :: Type) (y :: Type). CValue arch x -> CValue arch y -> Bool

gtF :: forall (x :: Type) (y :: Type). CValue arch x -> CValue arch y -> Bool

HasRepr (CValue arch :: Type -> Type) TypeRepr Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

typeRepr :: forall (tp :: Type). CValue arch tp -> TypeRepr tp Source #

Show (CValue arch tp) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

showsPrec :: Int -> CValue arch tp -> ShowS #

show :: CValue arch tp -> String #

showList :: [CValue arch tp] -> ShowS #

Eq (CValue arch tp) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

(==) :: CValue arch tp -> CValue arch tp -> Bool #

(/=) :: CValue arch tp -> CValue arch tp -> Bool #

Hashable (CValue arch tp) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

hashWithSalt :: Int -> CValue arch tp -> Int

hash :: CValue arch tp -> Int

Pretty (CValue arch tp) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

pretty :: CValue arch tp -> Doc ann

prettyList :: [CValue arch tp] -> Doc ann

pattern BoolValue :: forall tp arch ids. () => tp ~ BoolType => Bool -> Value arch ids tp Source #

A constant Boolean

pattern BVValue :: forall tp arch ids (n :: Nat). () => (tp ~ BVType n, 1 <= n) => NatRepr n -> Integer -> Value arch ids tp Source #

A constant bitvector

The integer should be between 0 and 2^n-1.

pattern RelocatableValue :: forall tp arch ids. () => tp ~ BVType (ArchAddrWidth arch) => AddrWidthRepr (ArchAddrWidth arch) -> MemAddr (ArchAddrWidth arch) -> Value arch ids tp Source #

A memory address

pattern SymbolValue :: forall tp arch ids. () => tp ~ BVType (ArchAddrWidth arch) => AddrWidthRepr (ArchAddrWidth arch) -> SymbolIdentifier -> Value arch ids tp Source #

This denotes the address of a symbol identifier in the binary.

This appears when dealing with relocations.

type BVValue arch ids (w :: Nat) = Value arch ids (BVType w) Source #

A value with a bitvector type.

valueAsApp :: forall arch ids (tp :: Type). Value arch ids tp -> Maybe (App (Value arch ids) tp) Source #

Return the value evaluated if this is from an App.

valueAsArchFn :: forall arch ids (tp :: Type). Value arch ids tp -> Maybe (ArchFn arch (Value arch ids) tp) Source #

Return the architecture-specific function associated with a value.

valueAsRhs :: forall arch ids (tp :: Type). Value arch ids tp -> Maybe (AssignRhs arch (Value arch ids) tp) Source #

Return the right-hand side if this is an assignment.

valueAsMemAddr :: MemWidth (ArchAddrWidth arch) => BVValue arch ids (ArchAddrWidth arch) -> Maybe (ArchMemAddr arch) Source #

This returns a segmented address if the value can be interpreted as a literal memory address, and returns nothing otherwise.

valueAsSegmentOff :: Memory (ArchAddrWidth arch) -> BVValue arch ids (ArchAddrWidth arch) -> Maybe (ArchSegmentOff arch) Source #

Returns a segment offset associated with the value if one can be defined.

valueAsStaticMultiplication :: forall arch ids (w :: Nat). BVValue arch ids w -> Maybe (Natural, BVValue arch ids w) Source #

data StackOffsetView arch (tp :: Type) where Source #

A stack offset that can also capture the width must match the pointer width.

Constructors

StackOffsetView :: forall arch. !Integer -> StackOffsetView arch ('BVType (ArchAddrWidth arch)) 

appAsStackOffset Source #

Arguments

:: forall arch ids (tp :: Type). MemWidth (ArchAddrWidth arch) 
=> (Value arch ids (BVType (ArchAddrWidth arch)) -> Maybe Integer)

Function for inferring if argument is a stack offset.

-> App (Value arch ids) tp 
-> Maybe (StackOffsetView arch tp) 

This pattern matches on an app to see if it can be used to adjust a stack offset.

asBaseOffset :: forall arch ids (w :: Nat). Value arch ids (BVType w) -> (Value arch ids (BVType w), Integer) Source #

class IPAlignment arch where Source #

During the jump-table detection phase of code discovery, we have the following problem: we are given a value which represents the computation done to create an address to jump to. We'd like to look at the shape of that computation and check whether it "looks like a jump table" -- say, whether it is the computation array_base + pointer_size * i for some unknown index i.

However, some architectures have special rules about what addresses are valid jump targets, and so there is frequently a sort of "standard prelude" which converts an arbitrary address into a valid jump target. For example, on PowerPC, the instruction pointer is always a multiple of four, so any computed jump strips off the bottom two bits. We'd like the jump-table detection code to be able to ignore that standard prelude when looking for jump-table-like computations (without having to know that the right thing to look for is "ignore the bottom two bits").

The fromIPAligned method below gives specific architectures a hook for stripping away the prelude and leaving the underlying computed value (which is potentially an invalid jump target!).

Of course, after stripping away the cleanup parts of the computation, checking the unclean computation for specific patterns, and finding particular concrete values that the unclean computation could evaluate to, the discovery code then needs to be able to re-clean the concrete values. The toIPAligned method gives architectures a hook to do that direction of translation.

Methods

fromIPAligned :: ArchAddrValue arch ids -> Maybe (ArchAddrValue arch ids) Source #

Take an aligned value and strip away the bits of the semantics that align it, leaving behind a (potentially unaligned) value. Return Nothing if the input value does not appear to be a valid value for the instruction pointer.

toIPAligned :: MemAddr (ArchAddrWidth arch) -> MemAddr (ArchAddrWidth arch) Source #

Take an unaligned memory address and clean it up so that it is a valid value for the instruction pointer.

mkLit :: forall (n :: Natural) arch ids. 1 <= n => NatRepr n -> Integer -> Value arch ids (BVType n) Source #

bvValue :: forall (n :: Nat) arch ids. (KnownNat n, 1 <= n) => Integer -> Value arch ids (BVType n) Source #

ppValueAssignments :: forall arch ids (tp :: Type) ann. ArchConstraints arch => Value arch ids tp -> Doc ann Source #

This pretty prints all the history used to create a value.

ppValueAssignmentList :: forall arch ids (tp :: Type) ann. ArchConstraints arch => [Value arch ids tp] -> Doc ann Source #

RegState

data RegState (r :: k -> Type) (f :: k -> Type) Source #

This represents the state of the processor registers.

Instances

Instances details
FoldableF (RegState r :: (k -> Type) -> Type) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

foldMapF :: Monoid m => (forall (s :: k). e s -> m) -> RegState r e -> m

foldrF :: (forall (s :: k). e s -> b -> b) -> b -> RegState r e -> b

foldlF :: (forall (s :: k). b -> e s -> b) -> b -> RegState r e -> b

foldrF' :: (forall (s :: k). e s -> b -> b) -> b -> RegState r e -> b

foldlF' :: (forall (s :: k). b -> e s -> b) -> b -> RegState r e -> b

toListF :: (forall (tp :: k). f tp -> a) -> RegState r f -> [a]

FunctorF (RegState r :: (k -> Type) -> Type) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

fmapF :: (forall (x :: k). f x -> g x) -> RegState r f -> RegState r g

TraversableF (RegState r :: (k -> Type) -> Type) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

traverseF :: Applicative m => (forall (s :: k). e s -> m (f s)) -> RegState r e -> m (RegState r f)

PrettyRegValue r f => Show (RegState r f) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

showsPrec :: Int -> RegState r f -> ShowS #

show :: RegState r f -> String #

showList :: [RegState r f] -> ShowS #

(OrdF r, EqF f) => Eq (RegState r f) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

(==) :: RegState r f -> RegState r f -> Bool #

(/=) :: RegState r f -> RegState r f -> Bool #

PrettyRegValue r f => Pretty (RegState r f) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

pretty :: RegState r f -> Doc ann

prettyList :: [RegState r f] -> Doc ann

regStateMap :: forall {v} (r :: v -> Type) (f :: v -> Type). RegState r f -> MapF r f Source #

Return underlying map of register state.

getBoundValue :: forall {k} r (tp :: k) f. OrdF r => r tp -> RegState r f -> f tp Source #

boundValue :: forall {k} r (f :: k -> Type) (tp :: k). OrdF r => r tp -> Lens' (RegState r f) (f tp) Source #

Get a register out of the state.

cmpRegState Source #

Arguments

:: forall {k} (r :: k -> Type) f g. OrdF r 
=> (forall (u :: k). f u -> g u -> Bool)

Function for checking if two values are equal.

-> RegState r f 
-> RegState r g 
-> Bool 

Compares if two register states are equal.

curIP :: forall (r :: Type -> Type) (f :: Type -> Type). RegisterInfo r => Lens' (RegState r f) (f (BVType (RegAddrWidth r))) Source #

mkRegState :: RegisterInfo r => (forall (tp :: Type). r tp -> f tp) -> RegState r f Source #

mkRegStateM :: (RegisterInfo r, Applicative m) => (forall (tp :: Type). r tp -> m (f tp)) -> m (RegState r f) Source #

mapRegsWith :: (forall (tp :: k). r tp -> f tp -> g tp) -> RegState r f -> RegState r g Source #

Traverse the register state with the name of each register and value.

traverseRegsWith :: forall {k} m r f g. Applicative m => (forall (tp :: k). r tp -> f tp -> m (g tp)) -> RegState r f -> m (RegState r g) Source #

Traverse the register state with the name of each register and value.

traverseRegsWith_ :: forall {k} m r f. Applicative m => (forall (tp :: k). r tp -> f tp -> m ()) -> RegState r f -> m () Source #

Traverse the register state with the name of each register and value.

zipWithRegState :: forall (r :: Type -> Type) f g h. RegisterInfo r => (forall (u :: Type). f u -> g u -> h u) -> RegState r f -> RegState r g -> RegState r h Source #

ppRegMap :: forall (r :: Type -> Type) (v :: Type -> Type) ann. PrettyRegValue r v => MapF r v -> Doc ann Source #

Pretty printing

ppAssignId :: forall ids (tp :: Type) ann. AssignId ids tp -> Doc ann Source #

ppValue :: forall arch ids (tp :: Type) ann. ShowF (ArchReg arch) => Prec -> Value arch ids tp -> Doc ann Source #

Pretty print a value.

ppStmt Source #

Arguments

:: ArchConstraints arch 
=> (ArchAddrWord arch -> Doc ann)

Function for pretty printing an instruction address offset

-> Stmt arch ids 
-> Doc ann 

class PrettyF (f :: k -> Type) where Source #

Pretty print over all instances of a type.

Methods

prettyF :: forall (tp :: k) ann. f tp -> Doc ann Source #

Instances

Instances details
ShowF r => PrettyF (BoundLoc r :: Type -> Type) Source # 
Instance details

Defined in Data.Macaw.AbsDomain.StackAnalysis

Methods

prettyF :: forall (tp :: Type) ann. BoundLoc r tp -> Doc ann Source #

type ArchConstraints arch = (RegisterInfo (ArchReg arch), FoldableFC (ArchFn arch), IsArchFn (ArchFn arch), IsArchStmt (ArchStmt arch), FoldableF (ArchStmt arch), IsArchTermStmt (ArchTermStmt arch), IPAlignment arch) Source #

Constructs expected by architectures type classes.

class PrettyRegValue (r :: Type -> Type) (f :: Type -> Type) where Source #

This class provides a way of optionally pretty printing the contents of a register or omitting them.

Methods

ppValueEq :: forall (tp :: Type) ann. r tp -> f tp -> Maybe (Doc ann) Source #

ppValueEq should return a doc if the contents of the given register should be printed, and Nothing if the contents should be ignored.

Instances

Instances details
(MemWidth w, ShowF r) => PrettyRegValue r (AbsValue w) Source #

Print a list of Docs vertically separated.

Instance details

Defined in Data.Macaw.AbsDomain.AbsState

Methods

ppValueEq :: forall (tp :: Type) ann. r tp -> AbsValue w tp -> Maybe (Doc ann) Source #

(RegisterInfo r, r ~ ArchReg arch) => PrettyRegValue r (Value arch ids) Source # 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

ppValueEq :: forall (tp :: Type) ann. r tp -> Value arch ids tp -> Maybe (Doc ann) Source #

class IsArchFn (f :: (Type -> Type) -> Type -> Type) where Source #

Typeclass for architecture-specific functions

Methods

ppArchFn Source #

Arguments

:: forall m v ann (tp :: Type). Applicative m 
=> (forall (u :: Type). v u -> m (Doc ann))

Function for pretty printing vlaue.

-> f v tp 
-> m (Doc ann) 

A function for pretty printing an archFn of a given type.

class IsArchStmt (f :: (Type -> Type) -> Type) where Source #

Typeclass for architecture-specific statements

Methods

ppArchStmt Source #

Arguments

:: (forall (u :: Type). v u -> Doc ann)

Function for pretty printing value.

-> f v 
-> Doc ann 

A function for pretty printing an architecture statement of a given type.

class IsArchTermStmt (f :: (Type -> Type) -> Type) where Source #

Methods

ppArchTermStmt Source #

Arguments

:: (forall (u :: Type). v u -> Doc ann)

Function to pretty print contained values

-> f v 
-> Doc ann 

collectValueRep Source #

Arguments

:: forall arch ids (tp :: Type) ann. ArchConstraints arch 
=> Prec

Outer precedence

-> Value arch ids tp 
-> State (MapF (AssignId ids) (DocF ann)) (Doc ann) 

This pretty prints a value's representation while saving the pretty printed repreentation of subvalues in a map.

ppValueAssignments' :: State (MapF (AssignId ids) (DocF ann)) (Doc ann) -> Doc ann Source #

This pretty prints all the history used to create a value.

data DocF ann (a :: Type) Source #

Helper type to wrap up a Doc with a dummy type argument; used to put Docs into heterogenous maps in the below

Utilities

addrWidthTypeRepr :: forall (w :: Natural). AddrWidthRepr w -> TypeRepr (BVType w) Source #

A type repr for the address width

RegisterInfo

class (OrdF r, ShowF r, MemWidth (RegAddrWidth r), HasRepr r TypeRepr) => RegisterInfo (r :: Type -> Type) where Source #

This class provides access to information about registers.

Methods

archRegs :: [Some r] Source #

List of all arch registers.

archRegSet :: MapF r (Const () :: Type -> Type) Source #

Set of all arch registers (expressed as a Map of units). Preferable to archRegs when building a map.

sp_reg :: r (BVType (RegAddrWidth r)) Source #

The stack pointer register

ip_reg :: r (BVType (RegAddrWidth r)) Source #

The instruction pointer register

syscall_num_reg :: r (BVType (RegAddrWidth r)) Source #

The register used to store system call numbers.

syscallArgumentRegs :: [r (BVType (RegAddrWidth r))] Source #

Registers used for passing system call arguments

asStackAddrOffset :: forall arch ids (tp :: Type). RegisterInfo (ArchReg arch) => Value arch ids tp -> Maybe (BVValue arch ids (ArchAddrWidth arch)) Source #

Returns a offset if the value is an offset of the stack.

References

refsInValue :: forall arch ids (tp :: Type). Value arch ids tp -> Set (Some (AssignId ids)) Source #

Synonyms

type ArchAddrValue arch ids = BVValue arch ids (ArchAddrWidth arch) Source #

A address value for a specific architecture

type ArchSegmentOff arch = MemSegmentOff (ArchAddrWidth arch) Source #

A pair containing a segment and valid offset within the segment.

type family ArchBlockPrecond arch Source #

This family maps architecture parameters to information needed to successfully translate machine code into Macaw CFGs.

This is currently used for registers values that are required to be known constants at translation time. For example, on X86_64, due to aliasing between the FPU and MMX registers, we require that the floating point stack value is known at translation time so that we do not need to check which register is modified when pushing or poping from the x86 stack.

If no preconditions are needed, this can just be set to the unit type.

class FoldableFC (t :: (k -> Type) -> l -> Type) where #

Minimal complete definition

foldMapFC | foldrFC

Methods

foldMapFC :: forall f m. Monoid m => (forall (x :: k). f x -> m) -> forall (x :: l). t f x -> m #

foldrFC :: (forall (x :: k). f x -> b -> b) -> forall (x :: l). b -> t f x -> b #

foldlFC :: forall f b. (forall (x :: k). b -> f x -> b) -> forall (x :: l). b -> t f x -> b #

foldrFC' :: (forall (x :: k). f x -> b -> b) -> forall (x :: l). b -> t f x -> b #

foldlFC' :: forall f b. (forall (x :: k). b -> f x -> b) -> forall (x :: l). b -> t f x -> b #

toListFC :: (forall (x :: k). f x -> a) -> forall (x :: l). t f x -> [a] #

Instances

Instances details
FoldableFC App Source # 
Instance details

Defined in Data.Macaw.CFG.App

Methods

foldMapFC :: forall f m. Monoid m => (forall (x :: Type). f x -> m) -> forall (x :: Type). App f x -> m #

foldrFC :: (forall (x :: Type). f x -> b -> b) -> forall (x :: Type). b -> App f x -> b #

foldlFC :: forall f b. (forall (x :: Type). b -> f x -> b) -> forall (x :: Type). b -> App f x -> b #

foldrFC' :: (forall (x :: Type). f x -> b -> b) -> forall (x :: Type). b -> App f x -> b #

foldlFC' :: forall f b. (forall (x :: Type). b -> f x -> b) -> forall (x :: Type). b -> App f x -> b #

toListFC :: (forall (x :: Type). f x -> a) -> forall (x :: Type). App f x -> [a] #

FoldableFC (ArchFn arch) => FoldableFC (AssignRhs arch :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.Macaw.CFG.AssignRhs

Methods

foldMapFC :: forall f m. Monoid m => (forall (x :: Type). f x -> m) -> forall (x :: Type). AssignRhs arch f x -> m #

foldrFC :: (forall (x :: Type). f x -> b -> b) -> forall (x :: Type). b -> AssignRhs arch f x -> b #

foldlFC :: forall f b. (forall (x :: Type). b -> f x -> b) -> forall (x :: Type). b -> AssignRhs arch f x -> b #

foldrFC' :: (forall (x :: Type). f x -> b -> b) -> forall (x :: Type). b -> AssignRhs arch f x -> b #

foldlFC' :: forall f b. (forall (x :: Type). b -> f x -> b) -> forall (x :: Type). b -> AssignRhs arch f x -> b #

toListFC :: (forall (x :: Type). f x -> a) -> forall (x :: Type). AssignRhs arch f x -> [a] #

FoldableFC (Assignment :: (k -> Type) -> Ctx k -> Type) 
Instance details

Defined in Data.Parameterized.Context.Safe

Methods

foldMapFC :: forall f m. Monoid m => (forall (x :: k). f x -> m) -> forall (x :: Ctx k). Assignment f x -> m #

foldrFC :: (forall (x :: k). f x -> b -> b) -> forall (x :: Ctx k). b -> Assignment f x -> b #

foldlFC :: forall f b. (forall (x :: k). b -> f x -> b) -> forall (x :: Ctx k). b -> Assignment f x -> b #

foldrFC' :: (forall (x :: k). f x -> b -> b) -> forall (x :: Ctx k). b -> Assignment f x -> b #

foldlFC' :: forall f b. (forall (x :: k). b -> f x -> b) -> forall (x :: Ctx k). b -> Assignment f x -> b #

toListFC :: (forall (x :: k). f x -> a) -> forall (x :: Ctx k). Assignment f x -> [a] #

FoldableFC (Assignment :: (k -> Type) -> Ctx k -> Type) 
Instance details

Defined in Data.Parameterized.Context.Unsafe

Methods

foldMapFC :: forall f m. Monoid m => (forall (x :: k). f x -> m) -> forall (x :: Ctx k). Assignment f x -> m #

foldrFC :: (forall (x :: k). f x -> b -> b) -> forall (x :: Ctx k). b -> Assignment f x -> b #

foldlFC :: forall f b. (forall (x :: k). b -> f x -> b) -> forall (x :: Ctx k). b -> Assignment f x -> b #

foldrFC' :: (forall (x :: k). f x -> b -> b) -> forall (x :: Ctx k). b -> Assignment f x -> b #

foldlFC' :: forall f b. (forall (x :: k). b -> f x -> b) -> forall (x :: Ctx k). b -> Assignment f x -> b #

toListFC :: (forall (x :: k). f x -> a) -> forall (x :: Ctx k). Assignment f x -> [a] #

FoldableFC (List :: (k -> Type) -> [k] -> Type) 
Instance details

Defined in Data.Parameterized.List

Methods

foldMapFC :: forall f m. Monoid m => (forall (x :: k). f x -> m) -> forall (x :: [k]). List f x -> m #

foldrFC :: (forall (x :: k). f x -> b -> b) -> forall (x :: [k]). b -> List f x -> b #

foldlFC :: forall f b. (forall (x :: k). b -> f x -> b) -> forall (x :: [k]). b -> List f x -> b #

foldrFC' :: (forall (x :: k). f x -> b -> b) -> forall (x :: [k]). b -> List f x -> b #

foldlFC' :: forall f b. (forall (x :: k). b -> f x -> b) -> forall (x :: [k]). b -> List f x -> b #

toListFC :: (forall (x :: k). f x -> a) -> forall (x :: [k]). List f x -> [a] #