From 448f40be71dffa86a6581c3696627ccc1bdf74f2 Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Mon, 19 Feb 2024 15:04:00 -0500 Subject: 4.0 documentation - Refactored Type Documentation - Added Projects - Added Type Archives - Added New Sidebar Documentation - Added String Concepts - Added Light/Dark Mode - Added New Tab Documentation - Added BNIL Guide: HLIL docs - Added new cookbook examples - Added migration guide - Added script for building docsets - Added documentation for themes - Updated all images to Ninja Edit - API Docs : Documents BasicBlockEdge and BasicBlock - API Docs : Documents CoreVariable, Variable, and VariableNameAndType - API Docs : Corrects note on `BinaryView.update_analysis` and `BinaryView.update_analysis_and_wait` to represent that analysis is run by default for you now. - Many, many other changes --- python/basicblock.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'python/basicblock.py') diff --git a/python/basicblock.py b/python/basicblock.py index a22b540f..6c03fe32 100644 --- a/python/basicblock.py +++ b/python/basicblock.py @@ -33,6 +33,18 @@ from . import function as _function @dataclass(frozen=True) class BasicBlockEdge: + """ + ``class BasicBlockEdge`` represents the edges that connect basic blocks in graph view. + + :cvar type: The :py:meth:`enums.BranchType` of the edge; Whether the edge is a true branch, false branch, unconditional, etc. + :cvar source: The basic block that the edge originates from. + :cvar target: The basic block that the edge is going to. + :cvar backedge: Whether this edge targets to a node whose control flow can eventually flow back through the source node of this edge. + :Example: + + >>> current_basic_block.outgoing_edges + [, ] + """ type: BranchType source: 'BasicBlock' target: 'BasicBlock' @@ -50,7 +62,18 @@ class BasicBlockEdge: class BasicBlock: """ - The ``BasicBlock`` object is returned during analysis and should not be directly instantiated. + The ``class BasicBlock`` object is returned during analysis and should not be directly instantiated. + + Basic blocks contain a sequence of instructions that must execute in-order with no branches. + We include calls in basic blocks, which technically violates that assumption, but you can mark + functions as `func.can_return = False` if a given function should terminate basic blocks. + :Example: + + >>> for func in bv.functions: + >>> for bb in func: + >>> # Any block-based analysis could start here + >>> for inst in bb: + >>> pass # Optionally do something here with instructions """ def __init__(self, handle: core.BNBasicBlockHandle, view: Optional['binaryview.BinaryView'] = None): self._view = view -- cgit v1.3.1