module documentation

Debugging helper functions.

Function ascii_tree Draw a graph, starting at a given position.
Function prettyprint_binding Pretty print a binding with variable id and data.
Function prettyprint_binding_nested Pretty print a binding and its recursive contents.
Function prettyprint_binding_set Pretty print a set of bindings, with optional label.
Function prettyprint_cfg_node A reasonably compact representation of all the bindings at a node.
Function prettyprint_cfg_tree Pretty print a cfg tree with the bindings at each node.
Function program_to_text Generate a text (CFG nodes + assignments) version of a program.
Function root_cause Tries to determine why a binding isn't possible at a node.
Function set_trace_level Undocumented
Function show Pretty print values for debugging.
Function show_ordered_code Print out the block structure of an OrderedCode object as a table.
Function stack_trace Undocumented
Function trace Record args and return value for a function call.
Function tracer Undocumented
Function tracing Undocumented
Function _ascii_tree Draw a graph, starting at a given position.
Function _pretty_variable Return a pretty printed string for a Variable.
Function _setup_tabulate Customise tabulate.
def ascii_tree(node, get_children, get_description=None): (source)

Draw a graph, starting at a given position. Args: node: The node from where to draw. get_children: The function to call to retrieve children. get_description: Optional. A function to call to describe a node. Returns: A string.

def prettyprint_binding(binding, indent_level=0): (source)

Pretty print a binding with variable id and data.

def prettyprint_binding_nested(binding, indent_level=0): (source)

Pretty print a binding and its recursive contents.

def prettyprint_binding_set(binding_set, indent_level=0, label=''): (source)

Pretty print a set of bindings, with optional label.

def prettyprint_cfg_node(node, decorate_after_node=0, full=False): (source)

A reasonably compact representation of all the bindings at a node. Args: node: The node to prettyprint. decorate_after_node: Don't print bindings unless node_id > this. full: Print the full string representation of a binding's data Returns: A prettyprinted node.

def prettyprint_cfg_tree(root, decorate_after_node=0, full=False, forward=False): (source)

Pretty print a cfg tree with the bindings at each node. Args: root: The root node. decorate_after_node: Don't print bindings unless node_id > this. full: Print the full string representation of a binding's data forward: Traverse the tree forwards if true. Returns: A prettyprinted tree.

def program_to_text(program): (source)

Generate a text (CFG nodes + assignments) version of a program. For debugging only. Args: program: An instance of cfg.Program Returns: A string representing all of the data for this program.

def root_cause(binding, node, seen=()): (source)

Tries to determine why a binding isn't possible at a node. This tries to find the innermost source that's still impossible. It only works if the failure isn't due to a combination of bindings. Args: binding: A binding, or a list of bindings. node: The node at which (one of the) binding(s) is impossible. seen: Internal. Bindings already looked at. Returns: A tuple (binding, node), with "binding" the innermost binding that's not possible, and "node" the CFG node at which it isn't.

def set_trace_level(level): (source)

Undocumented

def show(x): (source)

Pretty print values for debugging.

def show_ordered_code(code, extra_col=None): (source)

Print out the block structure of an OrderedCode object as a table. Args: code: A blocks.OrderedCode object extra_col: A map from opcode_index to a single additional cell to display

def stack_trace(indent_level=0, limit=100): (source)

Undocumented

def trace(name, *trace_args): (source)

Record args and return value for a function call. The trace is of the form function name: { function name: arg = value function name: arg = value ... function name: -> return function name: } This will let us write tools to pretty print the traces with indentation etc. Args: name: module name, usually `__name__` *trace_args: function arguments to log Returns: a decorator

def tracer(name=None): (source)

Undocumented

@contextlib.contextmanager
def tracing(level=logging.DEBUG): (source)

Undocumented

def _ascii_tree(out, node, p1, p2, seen, get_children, get_description=None): (source)

Draw a graph, starting at a given position. Args: out: A file-like object to write the ascii tree to. node: The node from where to draw. p1: The current prefix. p2: The upcoming prefix. seen: Nodes we have seen so far (as a set). get_children: The function to call to retrieve children. get_description: Optional. A function to call to describe a node.

def _pretty_variable(var): (source)

Return a pretty printed string for a Variable.

def _setup_tabulate(): (source)

Customise tabulate.