1*ef5ccd6cSJohn Marino /* Linux-dependent part of branch trace support for GDB, and GDBserver. 2*ef5ccd6cSJohn Marino 3*ef5ccd6cSJohn Marino Copyright (C) 2013 Free Software Foundation, Inc. 4*ef5ccd6cSJohn Marino 5*ef5ccd6cSJohn Marino Contributed by Intel Corp. <markus.t.metzger@intel.com> 6*ef5ccd6cSJohn Marino 7*ef5ccd6cSJohn Marino This file is part of GDB. 8*ef5ccd6cSJohn Marino 9*ef5ccd6cSJohn Marino This program is free software; you can redistribute it and/or modify 10*ef5ccd6cSJohn Marino it under the terms of the GNU General Public License as published by 11*ef5ccd6cSJohn Marino the Free Software Foundation; either version 3 of the License, or 12*ef5ccd6cSJohn Marino (at your option) any later version. 13*ef5ccd6cSJohn Marino 14*ef5ccd6cSJohn Marino This program is distributed in the hope that it will be useful, 15*ef5ccd6cSJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of 16*ef5ccd6cSJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17*ef5ccd6cSJohn Marino GNU General Public License for more details. 18*ef5ccd6cSJohn Marino 19*ef5ccd6cSJohn Marino You should have received a copy of the GNU General Public License 20*ef5ccd6cSJohn Marino along with this program. If not, see <http://www.gnu.org/licenses/>. */ 21*ef5ccd6cSJohn Marino 22*ef5ccd6cSJohn Marino #ifndef LINUX_BTRACE_H 23*ef5ccd6cSJohn Marino #define LINUX_BTRACE_H 24*ef5ccd6cSJohn Marino 25*ef5ccd6cSJohn Marino #include "btrace-common.h" 26*ef5ccd6cSJohn Marino #include "config.h" 27*ef5ccd6cSJohn Marino #include "vec.h" 28*ef5ccd6cSJohn Marino #include "ptid.h" 29*ef5ccd6cSJohn Marino #include <stddef.h> 30*ef5ccd6cSJohn Marino #include <stdint.h> 31*ef5ccd6cSJohn Marino 32*ef5ccd6cSJohn Marino #if HAVE_LINUX_PERF_EVENT_H 33*ef5ccd6cSJohn Marino # include <linux/perf_event.h> 34*ef5ccd6cSJohn Marino #endif 35*ef5ccd6cSJohn Marino 36*ef5ccd6cSJohn Marino /* Branch trace target information per thread. */ 37*ef5ccd6cSJohn Marino struct btrace_target_info 38*ef5ccd6cSJohn Marino { 39*ef5ccd6cSJohn Marino #if HAVE_LINUX_PERF_EVENT_H 40*ef5ccd6cSJohn Marino /* The Linux perf_event configuration for collecting the branch trace. */ 41*ef5ccd6cSJohn Marino struct perf_event_attr attr; 42*ef5ccd6cSJohn Marino 43*ef5ccd6cSJohn Marino /* The ptid of this thread. */ 44*ef5ccd6cSJohn Marino ptid_t ptid; 45*ef5ccd6cSJohn Marino 46*ef5ccd6cSJohn Marino /* The mmap configuration mapping the branch trace perf_event buffer. 47*ef5ccd6cSJohn Marino 48*ef5ccd6cSJohn Marino file .. the file descriptor 49*ef5ccd6cSJohn Marino buffer .. the mmapped memory buffer 50*ef5ccd6cSJohn Marino size .. the buffer's size in pages without the configuration page 51*ef5ccd6cSJohn Marino data_head .. the data head from the last read */ 52*ef5ccd6cSJohn Marino int file; 53*ef5ccd6cSJohn Marino void *buffer; 54*ef5ccd6cSJohn Marino size_t size; 55*ef5ccd6cSJohn Marino unsigned long data_head; 56*ef5ccd6cSJohn Marino #endif /* HAVE_LINUX_PERF_EVENT_H */ 57*ef5ccd6cSJohn Marino 58*ef5ccd6cSJohn Marino /* The size of a pointer in bits for this thread. 59*ef5ccd6cSJohn Marino The information is used to identify kernel addresses in order to skip 60*ef5ccd6cSJohn Marino records from/to kernel space. */ 61*ef5ccd6cSJohn Marino int ptr_bits; 62*ef5ccd6cSJohn Marino }; 63*ef5ccd6cSJohn Marino 64*ef5ccd6cSJohn Marino /* Check whether branch tracing is supported. */ 65*ef5ccd6cSJohn Marino extern int linux_supports_btrace (void); 66*ef5ccd6cSJohn Marino 67*ef5ccd6cSJohn Marino /* Enable branch tracing for @ptid. */ 68*ef5ccd6cSJohn Marino extern struct btrace_target_info *linux_enable_btrace (ptid_t ptid); 69*ef5ccd6cSJohn Marino 70*ef5ccd6cSJohn Marino /* Disable branch tracing and deallocate @tinfo. */ 71*ef5ccd6cSJohn Marino extern int linux_disable_btrace (struct btrace_target_info *tinfo); 72*ef5ccd6cSJohn Marino 73*ef5ccd6cSJohn Marino /* Read branch trace data. */ 74*ef5ccd6cSJohn Marino extern VEC (btrace_block_s) *linux_read_btrace (struct btrace_target_info *, 75*ef5ccd6cSJohn Marino enum btrace_read_type); 76*ef5ccd6cSJohn Marino 77*ef5ccd6cSJohn Marino #endif /* LINUX_BTRACE_H */ 78