Python gdb.Breakpoint() Examples

The following are 8 code examples of gdb.Breakpoint(). 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 gdb , or try the search function .
Example #1
Source File: gdb_utils.py    From debugger-utils with MIT License 6 votes vote down vote up
def info(entry, *args):
    """In most cases, simply execute given arguments
    and return results as string.
    When `entry` is:
    * locals/args: Return dict{variable=value}
    * breakpoints: Return a list of gdb.Breakpoint
    * threads: Return a list of (is_current_thread, num, ptid, name, frame)
    """
    if entry.startswith(('ar', 'lo')):
        info = gdb.execute('info ' + entry, to_string=True).splitlines()
        # No arguments or No locals
        if len(info) == 1 and info[0].startswith('No '):
            return {}
        group = {}
        for line in info:
            variable, _, value = line.partition('=')
            group[variable.rstrip()] = value.lstrip()
        return group
    elif entry.startswith('b'):
        return gdb.breakpoints()
    elif entry.startswith('th'):
        return info_threads(*args)
    return gdb.execute(
        'info %s %s' % (entry, args_to_string(*args)), to_string=True) 
Example #2
Source File: gdb.py    From 7billionhumans with MIT License 5 votes vote down vote up
def __init__(self):
        gdb.Breakpoint.__init__(self, "ResetLevel")
        self.cnt = 24 
Example #3
Source File: gdb.py    From 7billionhumans with MIT License 5 votes vote down vote up
def __init__(self):
        gdb.Breakpoint.__init__(self, "TestTick") 
Example #4
Source File: gdb.py    From 7billionhumans with MIT License 5 votes vote down vote up
def __init__(self):
        gdb.Breakpoint.__init__(self, "ElevatorTick") 
Example #5
Source File: gdb_tools.py    From bootloader_instrumentation_suite with MIT License 5 votes vote down vote up
def __init__(self, spec, twin, typ=None):
        self._stop = twin.stop
        self.companion = twin
        gdb.Breakpoint.__init__(self, spec, internal=True) 
Example #6
Source File: gdb_utils.py    From debugger-utils with MIT License 5 votes vote down vote up
def br(location, threadnum='', condition='', commands=None,
        temporary=False, probe_modifier=''):
    """Return a gdb.Breakpoint object
    br('main.cpp:2') # break main.cpp:2
    # break 2 thread 2 if result != NULL
    br('2', threadnum=2, condition='result != NULL')
    # threadnum can be the name of specific thread.
    # We only set breakpoint on single thread, so make sure this name is unique.
    br('2', threadnum='foo')

    # break 2 and run the given function `callback`
    br('2', commands=callback)

    # temporary break
    br('2', temporary=True)
    """
    if commands is not None:
        if not hasattr(commands, '__call__'):
            raise TypeError('commands argument should be a function')
    if threadnum != '':
        if isinstance(threadnum, str):
            thread_name = find_first_threadnum_with_name(threadnum)
            if thread_name is None:
                raise gdb.GdbError('Given thread name is not found')
        threadnum = 'thread %d' % threadnum
    if condition != '':
        condition = 'if ' + condition
    if temporary:
        gdb.execute('tbreak ' + args_to_string(
            probe_modifier, location, threadnum, condition))
    else:
        gdb.execute('break ' + args_to_string(
            probe_modifier, location, threadnum, condition))
    if commands is not None:
        bp = get_last_breakpoint()
        register_callback_to_breakpoint_num(bp.number, commands)
        return bp
    return get_last_breakpoint() 
Example #7
Source File: gdb_utils.py    From debugger-utils with MIT License 5 votes vote down vote up
def delete(*args):
    """
    delete()              # delete all breakpoints
    delete('1')           # delete breakpoint 1
    delete('bookmark', 1) # delete bookmark 1
    delete(gdb.Breakpoint) # delete given Breakpoint object
    """
    if len(args) == 0:
        gdb.execute('delete')
    elif isinstance(args[0], gdb.Breakpoint):
        args[0].delete()
    else:
        gdb.execute('delete ' + args_to_string(*filter(None, args))) 
Example #8
Source File: gdb_utils.py    From debugger-utils with MIT License 5 votes vote down vote up
def stop(callback, breakpoint=None, remove=False):
    """Run callback while gdb stops on breakpoints.
    If `breakpoint` is given, run it while specific breakpoint is hit.
    If `remove` is True, remove callback instead of adding it.
    """
    if not remove:
        if isinstance(breakpoint, gdb.Breakpoint):
            register_callback_to_breakpoint_num(breakpoint.number, callback)
        else:
            gdb.events.stop.connect(callback)
    else:
        if isinstance(breakpoint, gdb.Breakpoint):
            remove_callback_to_breakpoint_num(breakpoint.number, callback)
        else:
            gdb.events.stop.disconnect(callback)