Ejemplo n.º 1
0
def test_master_timeout():
    db = pointbreak.create_debugger('python -c "import time; time.sleep(0.5)"', timeout=.25)
    try:
        db.continue_to_last_event()
    except pointbreak.Timeout:
        return
    assert False, "should have raised pointbreak.Timeout"
Ejemplo n.º 2
0
def test_changing_environment():
    env = dict(os.environ)
    env['VVVV'] = '54'
    db = pointbreak.create_debugger(
        'python -c "import os; exit(int(os.environ.get(\'VVVV\', 31)))"',
        environment=env,
        timeout=20)
    e = db.continue_to_last_event()
    assert e.status == 54
Ejemplo n.º 3
0
def test_breakpoint_on_main():
    db = pointbreak.create_debugger('python --version', timeout=20)
    bp = db.add_breakpoint('main')
    event = db.next_event()
    try:
        db.continue_to_last_event()
    except:
        pass
    assert event.name == pointbreak.EVENT_NAME_TRAP
    assert bp in event.triggered, "break point should be triggered"
Ejemplo n.º 4
0
def test_existing_breakpoint_in_program():
    db = pointbreak.create_debugger(
        'python -c "import pointbreak.utils; pointbreak.utils.breakpoint()"',
        timeout=20)
    event = db.next_event()
    assert event.name == pointbreak.EVENT_NAME_TRAP
    try:
        db.continue_to_last_event()
    except:
        pass
Ejemplo n.º 5
0
def test_loading_dynamic_library_and_breaking_on_function():
    db = pointbreak.create_debugger('python  -c "import itertools"', timeout=10)
    # Python 2 and 3 use different conventions for module initialisation
    if sys.version_info < (3,):
        bp = db.add_breakpoint('inititertools')
    else:
        bp = db.add_breakpoint('PyInit_itertools')
    event = db.next_event()
    try:
        db.continue_to_last_event()
    except:
        pass
    assert event.name == pointbreak.EVENT_NAME_TRAP
    assert bp in event.triggered, "break point should be triggered"
Ejemplo n.º 6
0
def test_ptraceunwind_rip():
    db = pointbreak.create_debugger('cat /dev/null')
    assert db.frame.registers.rip, db.registers.rip
Ejemplo n.º 7
0
from __future__ import print_function
import pointbreak


def print_boo(debugger):
    print("Boo!")
    return True


db = pointbreak.create_debugger('ghost')
db.add_breakpoint('there_is_a_ghost', print_boo)
db.continue_to_last_event()
Ejemplo n.º 8
0
from __future__ import print_function
import pointbreak
"""Should print out strings in the python interpreter"""


def print_string_arg1(db):
    print(repr(db.read_string(db.registers.rdi)))
    return True


db = pointbreak.create_debugger('python -c "import itertools"')
db.add_breakpoint('PyString_FromString$', print_string_arg1)
db.add_breakpoint('PyUnicode_FromString$', print_string_arg1)
db.continue_to_last_event()
Ejemplo n.º 9
0
def test_create_debug_no_such_file():
    try:
        pointbreak.create_debugger('zxZUl8a1pp')
    except pointbreak.ExecutableNotFound:
        return
    assert False, "should have raised pointbreak.ExecutableNotFound"
Ejemplo n.º 10
0
def test_create_debug_cat():
    db = pointbreak.create_debugger('cat /dev/null')
    event = db.next_event()
    assert event.name == pointbreak.EVENT_NAME_EXITED