[PATCH 00/16] branch tracing support
Hui Zhu
teawater@gmail.com
Fri May 11 00:25:00 GMT 2012
Hi Markus,
Thanks for your work. I think this function is very interesting.
But I didn't find the patch for the doc in your patches list. I
suggest you add it.
PS, do you have any data about how much speed decrease when btrace enable.
Thanks,
Hui
On Thu, May 10, 2012 at 11:13 PM, <markus.t.metzger@intel.com> wrote:
> From: Markus Metzger <markus.t.metzger@intel.com>
>
> IA hardware offers a feature called Branch Trace Store (BTS) that stores a log
> of branches into an OS provided ring buffer.
>
> Linux supports this feature since 2.6.32 as part of the perf_event interface.
>
> Branch tracing is very useful to debug problems that do not immediatly result in
> a crash. It is particularly useful for bugs that make other debugger features
> fail, e.g. a corrupted stack that breaks unwinding.
>
> In comparison with reverse debugging, branch tracing is less powerful but
> faster. In addition, the list view (see below) provides a quick overview of
> where you are, comparable with the backtrace command.
>
> This series adds commands to enable/disable branch tracing as well as to display
> the recorded trace:
>
> - "btrace enable/disable" perform the obvious operation
>
> They accept an optional range argument specifying the range of threads to
> enable/disable branch tracing for. If no argument is given, they target the
> current thread.
>
> They further accept the following arguments:
>
> all targets all threads
> auto turns automatic enabling for new threads on/off
>
> - "btrace list" prints the blocks that have been traced; one line per block.
>
> The output may be configured using modifiers (default: /fl). It prints:
> the block number
> /a the begin and end code address of that block
> /f the function containing the block
> /l the source lines contained in the block
>
> It accepts an optional range argument specifying the range of blocks to be
> listed. If no argument is given, all blocks are listed.
>
> Blocks are ordered from newest to oldest; block 1 always contains the
> current location.
>
> (gdb) btrace list 24-34
> 24 in stdio_file_flush () at ../../../git/gdb/ui-file.c:525-529
> 25 in ui_file_data () at ../../../git/gdb/ui-file.c:175-180
> 26 in stdio_file_flush () at ../../../git/gdb/ui-file.c:522-523
> 27 in gdb_flush () at ../../../git/gdb/ui-file.c:185
> 28 in gdb_wait_for_event () at ../../../git/gdb/event-loop.c:840-847
> 29 in gdb_do_one_event () at ../../../git/gdb/event-loop.c:461
> 30 in gdb_do_one_event () at ../../../git/gdb/event-loop.c:453
> 31 in process_event () at ../../../git/gdb/event-loop.c:407
> 32 in process_event () at ../../../git/gdb/event-loop.c:361-367
> 33 in process_event () at ../../../git/gdb/event-loop.c:1041-1043
> 34 in process_event () at ../../../git/gdb/event-loop.c:1041-1045
>
> - "btrace" prints the branch trace disassembly
>
> Branch trace is printed block-by-block. Typically, one block at a time is
> printed. Repeated commands will iterate over all blocks similar to the list
> command.
>
> It supports the /m and /r modifiers accepted by the disassemble command.
>
> It accepts an optional range argument specifying the range of blocks to be
> printed. If more than one block is given, blocks are printed in reverse
> order to preserve the original control flow.
>
> (gdb) btrace /m 25
> ../../../git/gdb/ui-file.c:175 {
> 0x0000000000635410 <ui_file_data+0>: sub $0x8,%rsp
>
> ../../../git/gdb/ui-file.c:176 if (file->magic != &ui_file_magic)
> 0x0000000000635414 <ui_file_data+4>: cmpq $0xb33b94,(%rdi)
> 0x000000000063541b <ui_file_data+11>: jne 0x635426 <ui_file_data+22>
>
> ../../../git/gdb/ui-file.c:177 internal_error (__FILE__, __LINE__,
> 0x000000000063541d <ui_file_data+13>: mov 0x50(%rdi),%rax
>
> ../../../git/gdb/ui-file.c:178 _("ui_file_data: bad magic number"));
> ../../../git/gdb/ui-file.c:179 return file->to_data;
> ../../../git/gdb/ui-file.c:180 }
> 0x0000000000635421 <ui_file_data+17>: add $0x8,%rsp
> 0x0000000000635425 <ui_file_data+21>: retq
>
> Mixed source and disassembly does not work very well for inlined functions,
> a problem that it shares with the disassemble command.
>
> Barkha Ahuja (1):
> test, btrace: more branch tracing tests
>
> Markus Metzger (15):
> disas: add precise instructions flag
> source: add flags to print_source_lines ()
> source, disasm: optionally prefix source lines with filename
> thread, btrace: add generic branch trace support
> cli, btrace: add btrace cli
> configure: add check for perf_event header
> configure: autoreconf
> linux, btrace: perf_event based branch tracing
> btrace, linux: add linux native btrace target ops
> btrace, config: enable btrace for 32bit and 64bit linux native
> test, btrace: add branch trace tests
> xml, btrace: define btrace xml document style
> remote, btrace: add branch trace remote ops
> gdbserver, btrace: add generic btrace support
> gdbserver, linux, btrace: add btrace support for linux-low
>
> .gitignore | 2 +
> gdb/Makefile.in | 14 +-
> gdb/amd64-linux-nat.c | 2 +
> gdb/btrace.c | 939 ++++++++++++++++++++++
> gdb/btrace.h | 92 +++
> gdb/command.h | 2 +-
> gdb/common/linux-btrace.c | 368 +++++++++
> gdb/common/linux-btrace.h | 76 ++
> gdb/config.in | 3 +
> gdb/config/i386/linux.mh | 3 +-
> gdb/config/i386/linux64.mh | 2 +-
> gdb/configure | 13 +
> gdb/configure.ac | 2 +
> gdb/disasm.c | 40 +-
> gdb/disasm.h | 8 +-
> gdb/features/btrace.dtd | 12 +
> gdb/gdbserver/Makefile.in | 6 +-
> gdb/gdbserver/config.in | 3 +
> gdb/gdbserver/configure | 2 +-
> gdb/gdbserver/configure.ac | 2 +-
> gdb/gdbserver/configure.srv | 34 +-
> gdb/gdbserver/gdbthread.h | 5 +
> gdb/gdbserver/inferiors.c | 3 +
> gdb/gdbserver/linux-low.c | 42 +
> gdb/gdbserver/server.c | 171 ++++
> gdb/gdbserver/target.h | 38 +
> gdb/gdbthread.h | 4 +
> gdb/i386-linux-nat.c | 2 +
> gdb/infcmd.c | 2 +
> gdb/linux-nat-btrace.c | 86 ++
> gdb/linux-nat-btrace.h | 28 +
> gdb/remote.c | 208 +++++
> gdb/source.c | 19 +-
> gdb/symtab.h | 6 +
> gdb/target.c | 20 +
> gdb/target.h | 36 +-
> gdb/testsuite/configure.ac | 2 +-
> gdb/testsuite/gdb.base/page.exp | 3 +-
> gdb/testsuite/gdb.btrace/Makefile.in | 13 +
> gdb/testsuite/gdb.btrace/a.s | 24 +
> gdb/testsuite/gdb.btrace/allthreads_trace.exp | 270 +++++++
> gdb/testsuite/gdb.btrace/b.s | 23 +
> gdb/testsuite/gdb.btrace/dec.c | 4 +
> gdb/testsuite/gdb.btrace/decrement.exp | 140 ++++
> gdb/testsuite/gdb.btrace/decrement.s | 32 +
> gdb/testsuite/gdb.btrace/disable_all.exp | 198 +++++
> gdb/testsuite/gdb.btrace/enable.exp | 83 ++
> gdb/testsuite/gdb.btrace/enable_all.exp | 201 +++++
> gdb/testsuite/gdb.btrace/enable_range.exp | 198 +++++
> gdb/testsuite/gdb.btrace/inc.c | 4 +
> gdb/testsuite/gdb.btrace/list.exp | 169 ++++
> gdb/testsuite/gdb.btrace/list.s | 68 ++
> gdb/testsuite/gdb.btrace/list_function.c | 12 +
> gdb/testsuite/gdb.btrace/list_function.exp | 59 ++
> gdb/testsuite/gdb.btrace/list_options.exp | 107 +++
> gdb/testsuite/gdb.btrace/main.s | 32 +
> gdb/testsuite/gdb.btrace/main_asm.exp | 113 +++
> gdb/testsuite/gdb.btrace/main_segv.exp | 84 ++
> gdb/testsuite/gdb.btrace/main_segv.s | 28 +
> gdb/testsuite/gdb.btrace/sanity_crash.exp | 69 ++
> gdb/testsuite/gdb.btrace/sanity_crash.s | 52 ++
> gdb/testsuite/gdb.btrace/thr_callback_32.s | 116 +++
> gdb/testsuite/gdb.btrace/thr_callback_64.s | 116 +++
> gdb/testsuite/gdb.btrace/threads.c | 96 +++
> gdb/testsuite/gdb.btrace/threads_asm.c | 78 ++
> gdb/testsuite/gdb.btrace/threads_auto.exp | 113 +++
> gdb/testsuite/gdb.btrace/threads_independent.exp | 119 +++
> gdb/testsuite/gdb.btrace/threads_nonstop.exp | 182 +++++
> gdb/testsuite/gdb.btrace/trace_iteration.exp | 264 ++++++
> gdb/testsuite/lib/btrace.exp | 72 ++
> gdb/thread.c | 3 +
> 71 files changed, 5393 insertions(+), 49 deletions(-)
> create mode 100644 gdb/btrace.c
> create mode 100644 gdb/btrace.h
> create mode 100644 gdb/common/linux-btrace.c
> create mode 100644 gdb/common/linux-btrace.h
> create mode 100644 gdb/features/btrace.dtd
> create mode 100644 gdb/linux-nat-btrace.c
> create mode 100644 gdb/linux-nat-btrace.h
> create mode 100755 gdb/testsuite/gdb.btrace/Makefile.in
> create mode 100755 gdb/testsuite/gdb.btrace/a.s
> create mode 100755 gdb/testsuite/gdb.btrace/allthreads_trace.exp
> create mode 100755 gdb/testsuite/gdb.btrace/b.s
> create mode 100644 gdb/testsuite/gdb.btrace/dec.c
> create mode 100755 gdb/testsuite/gdb.btrace/decrement.exp
> create mode 100755 gdb/testsuite/gdb.btrace/decrement.s
> create mode 100755 gdb/testsuite/gdb.btrace/disable_all.exp
> create mode 100644 gdb/testsuite/gdb.btrace/enable.exp
> create mode 100755 gdb/testsuite/gdb.btrace/enable_all.exp
> create mode 100755 gdb/testsuite/gdb.btrace/enable_range.exp
> create mode 100644 gdb/testsuite/gdb.btrace/inc.c
> create mode 100644 gdb/testsuite/gdb.btrace/list.exp
> create mode 100644 gdb/testsuite/gdb.btrace/list.s
> create mode 100644 gdb/testsuite/gdb.btrace/list_function.c
> create mode 100644 gdb/testsuite/gdb.btrace/list_function.exp
> create mode 100755 gdb/testsuite/gdb.btrace/list_options.exp
> create mode 100755 gdb/testsuite/gdb.btrace/main.s
> create mode 100755 gdb/testsuite/gdb.btrace/main_asm.exp
> create mode 100755 gdb/testsuite/gdb.btrace/main_segv.exp
> create mode 100755 gdb/testsuite/gdb.btrace/main_segv.s
> create mode 100755 gdb/testsuite/gdb.btrace/sanity_crash.exp
> create mode 100755 gdb/testsuite/gdb.btrace/sanity_crash.s
> create mode 100755 gdb/testsuite/gdb.btrace/thr_callback_32.s
> create mode 100755 gdb/testsuite/gdb.btrace/thr_callback_64.s
> create mode 100755 gdb/testsuite/gdb.btrace/threads.c
> create mode 100755 gdb/testsuite/gdb.btrace/threads_asm.c
> create mode 100755 gdb/testsuite/gdb.btrace/threads_auto.exp
> create mode 100755 gdb/testsuite/gdb.btrace/threads_independent.exp
> create mode 100755 gdb/testsuite/gdb.btrace/threads_nonstop.exp
> create mode 100755 gdb/testsuite/gdb.btrace/trace_iteration.exp
> create mode 100644 gdb/testsuite/lib/btrace.exp
>
More information about the Gdb-patches
mailing list