diff options
author | Markus Metzger <markus.t.metzger@intel.com> | 2008-01-30 13:31:20 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 13:31:20 +0100 |
commit | a95d67f87e1a5f1b4429be3ba3bf7b4051657908 (patch) | |
tree | 4a67994b901c5dfbf3c2ee752efd53dbce938c36 /include | |
parent | e4811f2568c55e595a7bf15a3b9aba863b31fb94 (diff) |
x86, ptrace: new ptrace BTS API
Here's the new ptrace BTS API that supports two different overflow handling mechanisms (wrap-around and buffer-full-signal) to support two different use cases (debugging and profiling).
It further combines buffer allocation and configuration.
Opens:
- memory rlimit
- overflow signal
What would be the right signal to use?
Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-x86/ds.h | 7 | ||||
-rw-r--r-- | include/asm-x86/ptrace-abi.h | 94 | ||||
-rw-r--r-- | include/asm-x86/ptrace.h | 1 |
3 files changed, 56 insertions, 46 deletions
diff --git a/include/asm-x86/ds.h b/include/asm-x86/ds.h index c9e15381dc7..b84040abee6 100644 --- a/include/asm-x86/ds.h +++ b/include/asm-x86/ds.h @@ -52,11 +52,18 @@ struct bts_struct { } variant; }; +/* Overflow handling mechanisms */ +#define DS_O_SIGNAL 1 /* send overflow signal */ +#define DS_O_WRAP 2 /* wrap around */ extern int ds_allocate(void **, size_t); extern int ds_free(void **); extern int ds_get_bts_size(void *); +extern int ds_get_bts_end(void *); extern int ds_get_bts_index(void *); +extern int ds_set_overflow(void *, int); +extern int ds_get_overflow(void *); +extern int ds_clear(void *); extern int ds_read_bts(void *, size_t, struct bts_struct *); extern int ds_write_bts(void *, const struct bts_struct *); extern unsigned long ds_debugctl_mask(void); diff --git a/include/asm-x86/ptrace-abi.h b/include/asm-x86/ptrace-abi.h index b473ad45e9c..cf2fe4633ee 100644 --- a/include/asm-x86/ptrace-abi.h +++ b/include/asm-x86/ptrace-abi.h @@ -80,51 +80,53 @@ #define PTRACE_SINGLEBLOCK 33 /* resume execution until next branch */ -/* Return maximal BTS buffer size in number of records, - if successuf; -1, otherwise. - EOPNOTSUPP...processor does not support bts tracing */ -#define PTRACE_BTS_MAX_BUFFER_SIZE 40 - -/* Allocate new bts buffer (free old one, if exists) of size DATA bts records; - parameter ADDR is ignored. - Return 0, if successful; -1, otherwise. - EOPNOTSUPP...processor does not support bts tracing - EINVAL.......invalid size in records - ENOMEM.......out of memory */ -#define PTRACE_BTS_ALLOCATE_BUFFER 41 - -/* Return the size of the bts buffer in number of bts records, - if successful; -1, otherwise. - EOPNOTSUPP...processor does not support bts tracing - ENXIO........no buffer allocated */ -#define PTRACE_BTS_GET_BUFFER_SIZE 42 - -/* Read the DATA'th bts record into a ptrace_bts_record buffer - provided in ADDR. - Records are ordered from newest to oldest. - Return 0, if successful; -1, otherwise - EOPNOTSUPP...processor does not support bts tracing - ENXIO........no buffer allocated - EINVAL.......invalid index */ -#define PTRACE_BTS_READ_RECORD 43 - -/* Configure last branch trace; the configuration is given as a bit-mask of - PTRACE_BTS_O_* options in DATA; parameter ADDR is ignored. - Return 0, if successful; -1, otherwise - EOPNOTSUPP...processor does not support bts tracing - ENXIO........no buffer allocated */ -#define PTRACE_BTS_CONFIG 44 - -/* Return the configuration as bit-mask of PTRACE_BTS_O_* options - if successful; -1, otherwise. - EOPNOTSUPP...processor does not support bts tracing - ENXIO........no buffer allocated */ -#define PTRACE_BTS_STATUS 45 - -/* Trace configuration options */ -/* Collect last branch trace */ -#define PTRACE_BTS_O_TRACE_TASK 0x1 -/* Take timestamps when the task arrives and departs */ -#define PTRACE_BTS_O_TIMESTAMPS 0x2 +/* configuration/status structure used in PTRACE_BTS_CONFIG and + PTRACE_BTS_STATUS commands. +*/ +struct ptrace_bts_config { + /* requested or actual size of BTS buffer in bytes */ + unsigned long size; + /* bitmask of below flags */ + unsigned long flags; +}; + +#define PTRACE_BTS_O_TRACE 0x1 /* branch trace */ +#define PTRACE_BTS_O_SCHED 0x2 /* scheduling events w/ jiffies */ +#define PTRACE_BTS_O_SIGNAL 0x4 /* send SIG? on buffer overflow + instead of wrapping around */ +#define PTRACE_BTS_O_CUT_SIZE 0x8 /* cut requested size to max available + instead of failing */ + +#define PTRACE_BTS_CONFIG 40 +/* Configure branch trace recording. + DATA is ignored, ADDR points to a struct ptrace_bts_config. + A new buffer is allocated, iff the size changes. +*/ +#define PTRACE_BTS_STATUS 41 +/* Return the current configuration. + DATA is ignored, ADDR points to a struct ptrace_bts_config + that will contain the result. +*/ +#define PTRACE_BTS_SIZE 42 +/* Return the number of available BTS records. + DATA and ADDR are ignored. +*/ +#define PTRACE_BTS_GET 43 +/* Get a single BTS record. + DATA defines the index into the BTS array, where 0 is the newest + entry, and higher indices refer to older entries. + ADDR is pointing to struct bts_struct (see asm/ds.h). +*/ +#define PTRACE_BTS_CLEAR 44 +/* Clear the BTS buffer. + DATA and ADDR are ignored. +*/ +#define PTRACE_BTS_DRAIN 45 +/* Read all available BTS records and clear the buffer. + DATA is ignored. ADDR points to an array of struct bts_struct of + suitable size. + BTS records are read from oldest to newest. + Returns number of BTS records drained. +*/ #endif diff --git a/include/asm-x86/ptrace.h b/include/asm-x86/ptrace.h index a9a1bab1451..61946fe8c08 100644 --- a/include/asm-x86/ptrace.h +++ b/include/asm-x86/ptrace.h @@ -9,6 +9,7 @@ #ifdef __KERNEL__ +/* the DS BTS struct is used for ptrace as well */ #include <asm/ds.h> struct task_struct; |