Python源码示例:gdb.Breakpoint()

示例1
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) 
示例2
def __init__(self):
        gdb.Breakpoint.__init__(self, "ResetLevel")
        self.cnt = 24 
示例3
def __init__(self):
        gdb.Breakpoint.__init__(self, "TestTick") 
示例4
def __init__(self):
        gdb.Breakpoint.__init__(self, "ElevatorTick") 
示例5
def __init__(self, spec, twin, typ=None):
        self._stop = twin.stop
        self.companion = twin
        gdb.Breakpoint.__init__(self, spec, internal=True) 
示例6
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() 
示例7
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))) 
示例8
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)