code.py

This module defines classes that represent assembly instructions blocks, functions, and calls to external functions. In amoco, such objects are found as node.data in nodes of a cfg.graph. As such,they all provide a common API with:

  • address to identify and locate the object in memory
  • support to get the address range of the object
  • view to display the object
class code.block(instrlist)[source]

A block instance holds a sequence of instructions.

Parameters:instr (list[instruction]) – the sequence of continuous (ordered) instructions
instr

the list of instructions of the block.

Type:list
view

holds the ui.views object used to display the block.

Type:blockView
length

the byte length of the block instructions sequence.

Type:int
support

the memory footprint of the block

Type:tuple
address

the address of the first instruction in the block.

Type:address (cst)
cut(address)[source]

cutting the block at given address will remove instructions after this address, (which needs to be aligned with instructions boundaries.) The effect is thus to reduce the block size.

Parameters:address (cst) – the address where the cut occurs.
Returns:the number of instructions removed from the block.
Return type:int
raw()[source]

returns the raw bytestring of the block instructions.

class code.func(g=None)[source]

A graph of blocks that represents a function’s Control-Flow-Graph (CFG).

Parameters:g (graph_core) – the connected graph component of nodes.
cfg

the graph_core CFG of the function (see cfg.)

Type:graph_core
blocks

the list of blocks in the CFG

Type:list[block]
support

the memory footprint of the function

Type:tuple
blocks

the list of blocks within the function.

Type:blocks (list)
class code.tag[source]

defines keys as class attributes, used in misc attributes to indicate various relevant properties of blocks within functions.

classmethod list()[source]

get the list of all defined keys

classmethod sig(name)[source]

symbols for tag keys used to compute the block’s signature