From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5366 invoked by alias); 7 Dec 2012 10:37:46 -0000 Received: (qmail 5282 invoked by uid 22791); 7 Dec 2012 10:37:44 -0000 X-SWARE-Spam-Status: No, hits=-7.1 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 07 Dec 2012 10:37:37 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 07 Dec 2012 02:37:36 -0800 X-ExtLoop1: 1 Received: from swsutil001.isw.intel.com ([10.237.237.11]) by fmsmga002.fm.intel.com with ESMTP; 07 Dec 2012 02:37:34 -0800 Received: from ulslx001.iul.intel.com (ulslx001.iul.intel.com [172.28.207.63]) by swsutil001.isw.intel.com (8.13.6/8.13.6/MailSET/Hub) with ESMTP id qB7AbXcS003940; Fri, 7 Dec 2012 10:37:33 GMT Received: from ulslx001.iul.intel.com (localhost [127.0.0.1]) by ulslx001.iul.intel.com with ESMTP id qB7AbWOR025985; Fri, 7 Dec 2012 11:37:32 +0100 Received: (from mmetzger@localhost) by ulslx001.iul.intel.com with id qB7AbWZO025981; Fri, 7 Dec 2012 11:37:32 +0100 From: markus.t.metzger@intel.com To: gdb-patches@sourceware.org Cc: markus.t.metzger@gmail.com, jan.kratochvil@redhat.com, palves@redhat.com, tromey@redhat.com, kettenis@gnu.org, Markus Metzger Subject: [patch v5 00/12] branch tracing support for Atom Date: Fri, 07 Dec 2012 10:37:00 -0000 Message-Id: <1354876644-25749-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-12/txt/msg00146.txt.bz2 From: Markus Metzger I incorporated the feedback from Pedro and Jan on v4. The patch attempting to fix some unprecise disassembly has been dropped. I'll look into changing the behavior of "disas /m" to produce by-address instead of by-source-line disassembly. The ptid argument in the remote serial protocol has been dropped. The general thread is used, instead. There's a new patch documenting the new remote serial protocol packets. The cpuid check has been moved into common/linux-btrace.c. The patch has been changed to align with a corresponding kernel patch to disable BTS support already in the kernel for those processors. Documentation for the command-line interface will be added shortly. Here's an overview of the feature: 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. I do expect some discussion around the commands and their exact spelling and would therefore postpone documentation. - "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 : sub $0x8,%rsp ../../../git/gdb/ui-file.c:176 if (file->magic != &ui_file_magic) 0x0000000000635414 : cmpq $0xb33b94,(%rdi) 0x000000000063541b : jne 0x635426 ../../../git/gdb/ui-file.c:177 internal_error (__FILE__, __LINE__, 0x000000000063541d : 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 : add $0x8,%rsp 0x0000000000635425 : 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 (11): thread, btrace: add generic branch trace support cli, btrace: add btrace cli linux, btrace: perf_event based branch tracing linux, i386, amd64: enable btrace for 32bit and 64bit linux native xml, btrace: define btrace xml document style remote, btrace: add branch trace remote ops btrace, doc: document remote serial protocol gdbserver, btrace: add generic btrace support gdbserver, linux, btrace: add btrace support for linux-low test, btrace: add branch tracing tests btrace, x86: disable on some processors gdb/Makefile.in | 13 +- gdb/amd64-linux-nat.c | 42 + gdb/btrace.c | 863 ++++++++++++++++++++++ gdb/btrace.h | 86 +++ gdb/command.h | 2 +- gdb/common/btrace-common.h | 62 ++ gdb/common/linux-btrace.c | 468 ++++++++++++ gdb/common/linux-btrace.h | 76 ++ gdb/config/i386/linux.mh | 3 +- gdb/config/i386/linux64.mh | 2 +- gdb/doc/gdb.texinfo | 125 ++++ gdb/features/btrace.dtd | 12 + gdb/gdbserver/Makefile.in | 7 +- gdb/gdbserver/config.in | 3 + gdb/gdbserver/configure | 6 + gdb/gdbserver/configure.ac | 5 + gdb/gdbserver/configure.srv | 6 +- gdb/gdbserver/gdbthread.h | 5 + gdb/gdbserver/inferiors.c | 3 + gdb/gdbserver/linux-low.c | 57 ++ gdb/gdbserver/server.c | 175 +++++ gdb/gdbserver/target.h | 33 + gdb/gdbthread.h | 4 + gdb/i386-linux-nat.c | 42 + gdb/infcmd.c | 2 + gdb/remote.c | 171 +++++ gdb/target.c | 69 ++ gdb/target.h | 39 +- gdb/testsuite/Makefile.in | 3 +- gdb/testsuite/configure | 3 +- 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 | 23 + gdb/testsuite/gdb.btrace/allthreads_trace.exp | 345 +++++++++ gdb/testsuite/gdb.btrace/amd64-thr-callback.S | 116 +++ gdb/testsuite/gdb.btrace/b.S | 23 + gdb/testsuite/gdb.btrace/dec.c | 23 + gdb/testsuite/gdb.btrace/decrement.S | 32 + gdb/testsuite/gdb.btrace/decrement.exp | 141 ++++ gdb/testsuite/gdb.btrace/disable_all.exp | 279 +++++++ gdb/testsuite/gdb.btrace/enable.exp | 89 +++ gdb/testsuite/gdb.btrace/enable_all.exp | 282 +++++++ gdb/testsuite/gdb.btrace/enable_range.exp | 281 +++++++ gdb/testsuite/gdb.btrace/i386-thr-callback.S | 116 +++ gdb/testsuite/gdb.btrace/inc.c | 23 + gdb/testsuite/gdb.btrace/list.exp | 175 +++++ gdb/testsuite/gdb.btrace/list_function.c | 31 + gdb/testsuite/gdb.btrace/list_function.exp | 50 ++ gdb/testsuite/gdb.btrace/list_options.exp | 107 +++ gdb/testsuite/gdb.btrace/main.S | 36 + gdb/testsuite/gdb.btrace/main_asm.exp | 109 +++ gdb/testsuite/gdb.btrace/main_segv.S | 32 + gdb/testsuite/gdb.btrace/main_segv.exp | 84 +++ gdb/testsuite/gdb.btrace/threads.c | 96 +++ gdb/testsuite/gdb.btrace/threads_asm.c | 78 ++ gdb/testsuite/gdb.btrace/threads_auto.exp | 123 +++ gdb/testsuite/gdb.btrace/threads_independent.exp | 125 ++++ gdb/testsuite/gdb.btrace/threads_nonstop.exp | 231 ++++++ gdb/testsuite/gdb.btrace/trace_iteration.exp | 265 +++++++ gdb/testsuite/gdb.btrace/x86-list.S | 70 ++ gdb/testsuite/lib/btrace.exp | 78 ++ gdb/thread.c | 4 + 63 files changed, 5857 insertions(+), 15 deletions(-) create mode 100644 gdb/btrace.c create mode 100644 gdb/btrace.h create mode 100644 gdb/common/btrace-common.h create mode 100644 gdb/common/linux-btrace.c create mode 100644 gdb/common/linux-btrace.h create mode 100644 gdb/features/btrace.dtd mode change 100644 => 100755 gdb/remote.c 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/amd64-thr-callback.S 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.S create mode 100755 gdb/testsuite/gdb.btrace/decrement.exp 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 100755 gdb/testsuite/gdb.btrace/i386-thr-callback.S 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_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.S create mode 100755 gdb/testsuite/gdb.btrace/main_segv.exp 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/gdb.btrace/x86-list.S create mode 100644 gdb/testsuite/lib/btrace.exp