GDB (API)
/home/stan/gdb/src/gdb/common/linux-btrace.h
Go to the documentation of this file.
00001 /* Linux-dependent part of branch trace support for GDB, and GDBserver.
00002 
00003    Copyright (C) 2013 Free Software Foundation, Inc.
00004 
00005    Contributed by Intel Corp. <markus.t.metzger@intel.com>
00006 
00007    This file is part of GDB.
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; either version 3 of the License, or
00012    (at your option) any later version.
00013 
00014    This program is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017    GNU General Public License for more details.
00018 
00019    You should have received a copy of the GNU General Public License
00020    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00021 
00022 #ifndef LINUX_BTRACE_H
00023 #define LINUX_BTRACE_H
00024 
00025 #include "btrace-common.h"
00026 #include "config.h"
00027 #include "vec.h"
00028 #include "ptid.h"
00029 #include <stddef.h>
00030 #include <stdint.h>
00031 
00032 #if HAVE_LINUX_PERF_EVENT_H
00033 #  include <linux/perf_event.h>
00034 #endif
00035 
00036 /* Branch trace target information per thread.  */
00037 struct btrace_target_info
00038 {
00039 #if HAVE_LINUX_PERF_EVENT_H
00040   /* The Linux perf_event configuration for collecting the branch trace.  */
00041   struct perf_event_attr attr;
00042 
00043   /* The ptid of this thread.  */
00044   ptid_t ptid;
00045 
00046   /* The mmap configuration mapping the branch trace perf_event buffer.
00047 
00048      file      .. the file descriptor
00049      buffer    .. the mmapped memory buffer
00050      size      .. the buffer's size in pages without the configuration page
00051      data_head .. the data head from the last read  */
00052   int file;
00053   void *buffer;
00054   size_t size;
00055   unsigned long data_head;
00056 #endif /* HAVE_LINUX_PERF_EVENT_H */
00057 
00058   /* The size of a pointer in bits for this thread.
00059      The information is used to identify kernel addresses in order to skip
00060      records from/to kernel space.  */
00061   int ptr_bits;
00062 };
00063 
00064 /* Check whether branch tracing is supported.  */
00065 extern int linux_supports_btrace (void);
00066 
00067 /* Enable branch tracing for @ptid.  */
00068 extern struct btrace_target_info *linux_enable_btrace (ptid_t ptid);
00069 
00070 /* Disable branch tracing and deallocate @tinfo.  */
00071 extern int linux_disable_btrace (struct btrace_target_info *tinfo);
00072 
00073 /* Read branch trace data.  */
00074 extern VEC (btrace_block_s) *linux_read_btrace (struct btrace_target_info *,
00075                                                 enum btrace_read_type);
00076 
00077 #endif /* LINUX_BTRACE_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines