Python ipdb.launch_ipdb_on_exception() Examples

The following are 3 code examples of ipdb.launch_ipdb_on_exception(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module ipdb , or try the search function .
Example #1
Source File: __main__.py    From knmt with GNU General Public License v3.0 5 votes vote down vote up
def run_in_ipdb(func, args):
    import ipdb
    with ipdb.launch_ipdb_on_exception():
        func(args) 
Example #2
Source File: __init__.py    From hase with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def main(argv: List[str] = sys.argv) -> Any:
    args = parse_arguments(argv)
    if args.debug:
        from ipdb import launch_ipdb_on_exception

        with launch_ipdb_on_exception():
            return args.func(args)
    return args.func(args) 
Example #3
Source File: pt.py    From hase with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def build_cfg(instructions: List[Instruction], loader: Loader) -> CFG:
    """
    Check that calls matches returns and that syscalls and non-jumps do not change the control flow.
    """
    stack = []  # type: List[int]
    builder = CfgBuilder(instructions)
    for (i, instruction) in enumerate(instructions):
        if i > 0:
            previous = instructions[i - 1]
            if (
                previous.iclass in BLOCK_TERMINATORS
                or previous.ip + previous.size != instruction.ip
            ):
                builder.add_edge(previous, instruction)

            if previous.iclass == InstructionClass.ptic_return:
                if len(stack) != 0:
                    return_ip = stack.pop()
                    if return_ip != instruction.ip:
                        previous_loc = loader.find_location(instructions[i - 1].ip)
                        instruction_loc = loader.find_location(instruction.ip)
                        return_loc = loader.find_location(return_ip)
                        l.warning(
                            "unexpected call return {} from {} found: expected {}".format(
                                instruction_loc, previous_loc, return_loc
                            )
                        )
                        stack = []

        if instruction.iclass == InstructionClass.ptic_call:
            return_ip = instruction.ip + instruction.size
            stack.append(return_ip)
    from ipdb import launch_ipdb_on_exception

    with launch_ipdb_on_exception():
        return builder.cfg()