예제 #1
0
def dump_trace(out_func):
    indents = defaultdict(int)
    bt_formatter = BacktraceFormatter(make_symbolic)

    def lookup_tp(name):
        return gdb.lookup_global_symbol(name).value().dereference()

    tp_fn_entry = lookup_tp('gdb_trace_function_entry')
    tp_fn_exit = lookup_tp('gdb_trace_function_exit')

    for trace in all_traces():
        thread = trace.thread
        time = trace.time
        cpu = trace.cpu
        tp = trace.tp

        def trace_function(indent, annotation, data):
            fn, caller = data
            try:
                block = gdb.block_for_pc(long(fn))
                fn_name = block.function.print_name
            except:
                fn_name = '???'
            out_func('0x%016x %2d %19s %s %s %s\n' % (
                thread,
                cpu,
                format_time(time),
                indent,
                annotation,
                fn_name,
            ))

        if tp.key == tp_fn_entry.address:
            indent = '  ' * indents[thread]
            indents[thread] += 1
            trace_function(indent, '->', trace.data)
        elif tp.key == tp_fn_exit.address:
            indents[thread] -= 1
            if indents[thread] < 0:
                indents[thread] = 0
            indent = '  ' * indents[thread]
            trace_function(indent, '<-', trace.data)
        else:
            out_func('%s\n' % trace.format(bt_formatter))
예제 #2
0
파일: loader.py 프로젝트: avikivity/osv
def dump_trace(out_func):
    indents = defaultdict(int)
    bt_formatter = BacktraceFormatter(make_symbolic)

    def lookup_tp(name):
        return gdb.lookup_global_symbol(name).value().dereference()
    tp_fn_entry = lookup_tp('gdb_trace_function_entry')
    tp_fn_exit = lookup_tp('gdb_trace_function_exit')

    for trace in all_traces():
        thread = trace.thread
        time = trace.time
        cpu = trace.cpu
        tp = trace.tp

        def trace_function(indent, annotation, data):
            fn, caller = data
            try:
                block = gdb.block_for_pc(to_int(fn))
                fn_name = block.function.print_name
            except:
                fn_name = '???'
            out_func('0x%016x %2d %19s %s %s %s\n'
                      % (thread,
                         cpu,
                         format_time(time),
                         indent,
                         annotation,
                         fn_name,
                         ))

        if tp.key == tp_fn_entry.address:
            indent = '  ' * indents[thread]
            indents[thread] += 1
            trace_function(indent, '->', trace.data)
        elif tp.key == tp_fn_exit.address:
            indents[thread] -= 1
            if indents[thread] < 0:
                indents[thread] = 0
            indent = '  ' * indents[thread]
            trace_function(indent, '<-', trace.data)
        else:
            out_func('%s\n' % trace.format(bt_formatter))
예제 #3
0
파일: loader.py 프로젝트: jazeltq/osv
def dump_trace(out_func):
    indents = defaultdict(int)
    bt_formatter = BacktraceFormatter(symbol_resolver, symbol_formatter)

    def lookup_tp(name):
        return gdb.lookup_global_symbol(name).value().dereference()

    tp_fn_entry = lookup_tp("gdb_trace_function_entry")
    tp_fn_exit = lookup_tp("gdb_trace_function_exit")

    for trace in all_traces():
        thread = trace.thread
        time = trace.time
        cpu = trace.cpu
        tp = trace.tp

        def trace_function(indent, annotation, data):
            fn, caller = data
            try:
                block = gdb.block_for_pc(to_int(fn))
                fn_name = block.function.print_name
            except:
                fn_name = "???"
            out_func("0x%016x %2d %19s %s %s %s\n" % (thread, cpu, format_time(time), indent, annotation, fn_name))

        if tp.key == tp_fn_entry.address:
            indent = "  " * indents[thread]
            indents[thread] += 1
            trace_function(indent, "->", trace.data)
        elif tp.key == tp_fn_exit.address:
            indents[thread] -= 1
            if indents[thread] < 0:
                indents[thread] = 0
            indent = "  " * indents[thread]
            trace_function(indent, "<-", trace.data)
        else:
            out_func("%s\n" % trace.format(bt_formatter))