mate.build.tob_chess_utils.tools.margin module

exception mate.build.tob_chess_utils.tools.margin.MarginError

Bases: mate_common.error.MateError

A generic error, internal to margin-walker.

class mate.build.tob_chess_utils.tools.margin.MarginWalkerContext(options: mate.build.tob_chess_utils.tools.margin.MarginWalkerOptions)

Bases: object

Parameters

options (mate.build.tob_chess_utils.tools.margin.MarginWalkerOptions) –

emit_edge(source: str, dest: str, edge_kind: mate_common.models.cpg_types.mate.EdgeKind) Iterator[Dict[str, Any]]
Parameters
Return type

Iterator[Dict[str, Any]]

emit_node(uuid: str, attrs: Dict[str, Any]) Dict[str, Any]
Parameters
  • uuid (str) –

  • attrs (Dict[str, Any]) –

Return type

Dict[str, Any]

next_id() str
Return type

str

property options: mate.build.tob_chess_utils.tools.margin.MarginWalkerOptions
class mate.build.tob_chess_utils.tools.margin.MarginWalkerOptions(sanity_checks: bool = False, omit_plt_stub_nodes: bool = False, omit_translation_unit_nodes: bool = False, omit_type_nodes: bool = False, omit_global_nodes: bool = False, omit_wedlock_function_nodes: bool = False, omit_param_nodes: bool = False, omit_var_nodes: bool = False, omit_asm_inst_nodes: bool = False, omit_arg_edges: bool = True)

Bases: object

Parameters
  • sanity_checks (bool) –

  • omit_plt_stub_nodes (bool) –

  • omit_translation_unit_nodes (bool) –

  • omit_type_nodes (bool) –

  • omit_global_nodes (bool) –

  • omit_wedlock_function_nodes (bool) –

  • omit_param_nodes (bool) –

  • omit_var_nodes (bool) –

  • omit_asm_inst_nodes (bool) –

  • omit_arg_edges (bool) –

Return type

None

omit_arg_edges: bool = True
omit_asm_inst_nodes: bool = False
omit_global_nodes: bool = False
omit_param_nodes: bool = False
omit_plt_stub_nodes: bool = False
omit_translation_unit_nodes: bool = False
omit_type_nodes: bool = False
omit_var_nodes: bool = False
omit_wedlock_function_nodes: bool = False
sanity_checks: bool = False
mate.build.tob_chess_utils.tools.margin.emit_asm_inst_nodes_and_edges(ctx: mate.build.tob_chess_utils.tools.margin.MarginWalkerContext, abb_uuid: str, instr_dicts: List[Dict[str, Any]]) Iterator[Dict[str, Any]]
Parameters
Return type

Iterator[Dict[str, Any]]

mate.build.tob_chess_utils.tools.margin.emit_aspirin_param_nodes_and_edges(ctx: mate.build.tob_chess_utils.tools.margin.MarginWalkerContext, asp_params: List[Dict[str, Any]], wed: Dict[str, Any], type_node_map: Dict[str, str], wed_func_uuid: str) Iterator[Dict[str, Any]]

Yields nodes and edges related to DWARF parameters, as related by aspirin.

The following nodes are emitted::
  • DWARFArgument (one per DWARF parameter)

The following edges are emitted::
  • HasDWARFType (one per DWARFArgument, relating to DWARFType)

  • ArgumentToDWARFArgument (one per DWARFArgument, relating to Argument)

  • MIFunctionToDWARFArgument (one per DWARFArgument, relating to MachineFunction)

Parameters
Return type

Iterator[Dict[str, Any]]

mate.build.tob_chess_utils.tools.margin.emit_aspirin_var_nodes_and_edges(ctx: mate.build.tob_chess_utils.tools.margin.MarginWalkerContext, asp_vars: List[Dict[str, Any]], wed: Dict[str, Any], type_node_map: Dict[str, str], wed_func_uuid: str) Iterator[Dict[str, Any]]

Yields a DWARFLocalVariable node (and corresponding HasDWARFType edge) for every parameter in asp_params, using context in wed to produce the appropriate ID format for pairing with MATE’s LocalVariable nodes.

Parameters
Return type

Iterator[Dict[str, Any]]

mate.build.tob_chess_utils.tools.margin.emit_global_variable_nodes_and_edges(ctx: mate.build.tob_chess_utils.tools.margin.MarginWalkerContext, asp_global_dicts: List[Dict[str, Any]], type_node_map: Dict[str, str]) Iterator[Dict[str, Any]]

Yields a ASMGlobalVariable node (and corresponding HasDWARFType edge) for every global variable record in asp_global_dicts, using the already constructed type_node_map for type edge drawing.

Parameters
Return type

Iterator[Dict[str, Any]]

mate.build.tob_chess_utils.tools.margin.emit_plt_stub_nodes(ctx: mate.build.tob_chess_utils.tools.margin.MarginWalkerContext, asp_plt_dicts: List[Dict[str, Any]]) Iterator[Dict[str, Any]]
Parameters
Return type

Iterator[Dict[str, Any]]

mate.build.tob_chess_utils.tools.margin.emit_translation_unit_nodes_and_edges(ctx: mate.build.tob_chess_utils.tools.margin.MarginWalkerContext, cu_dict: Dict[str, Any], asp_module_dict: Dict[str, Any]) Iterator[Dict[str, Any]]

Yields a TranslationUnit node for every compilation unit in cu_dict, as well as edges to the containing LLVM module.

Parameters
Return type

Iterator[Dict[str, Any]]

mate.build.tob_chess_utils.tools.margin.emit_type_nodes_and_edges(ctx: mate.build.tob_chess_utils.tools.margin.MarginWalkerContext, ti_map: Dict[str, Any], type_node_map: Dict[str, str]) Iterator[Dict[str, Any]]

Yields a DWARFType node for every type in ti_map, building up a map of type IDs to DWARFType node UUIDs along the way.

Parameters
Return type

Iterator[Dict[str, Any]]

mate.build.tob_chess_utils.tools.margin.emit_wedlock_function_nodes(ctx: mate.build.tob_chess_utils.tools.margin.MarginWalkerContext, wed_dicts: List[Dict[str, Any]], asp_func_dicts: List[Dict[str, Any]]) Iterator[Tuple[Dict[str, Any], Dict[str, Any], Dict[str, Any]]]

Yields a MachineFunction node (and associated Wedlock + Aspirin function records) for every record in wed_dicts.

Parameters
Return type

Iterator[Tuple[Dict[str, Any], Dict[str, Any], Dict[str, Any]]]

mate.build.tob_chess_utils.tools.margin.main() None
Return type

None

mate.build.tob_chess_utils.tools.margin.margin(wed_dicts: List[Dict[str, Any]], asp_dicts: List[Dict[str, Any]], ti_map: Dict[str, Any], cu_dict: Dict[str, Any], options: mate.build.tob_chess_utils.tools.margin.MarginWalkerOptions = MarginWalkerOptions(sanity_checks=False, omit_plt_stub_nodes=False, omit_translation_unit_nodes=False, omit_type_nodes=False, omit_global_nodes=False, omit_wedlock_function_nodes=False, omit_param_nodes=False, omit_var_nodes=False, omit_asm_inst_nodes=False, omit_arg_edges=True)) Iterator[Dict[str, Any]]
Parameters
Return type

Iterator[Dict[str, Any]]

mate.build.tob_chess_utils.tools.margin.sanity_checks(asp_bb_dicts: List[Dict[str, Any]]) None
Parameters

asp_bb_dicts (List[Dict[str, Any]]) –

Return type

None