traptrace.h revision 843e19887f64dde75055cf8842fc4db2171eff45
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _IA32_SYS_TRAPTRACE_H
#define _IA32_SYS_TRAPTRACE_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/privregs.h>
/*
* Trap tracing. If TRAPTRACE is defined, an entry is recorded every time
* the CPU jumps through the Interrupt Descriptor Table (IDT). One exception
* is the Double Fault handler, which does not record a traptrace entry.
*
* There are facilities to (conditionally) interleave tracing of related
* facilities e.h. x-calls.
*/
/*
* Note: non-assembler files that include this file must include
*/
#define TTR_STACK_DEPTH 10
#ifndef _ASM
#define TTR_PAD1_SIZE (sizeof (long) - 1)
typedef struct {
typedef struct {
union _ttr_info {
struct _idt_entry {
short vector;
} idt_entry;
struct _gate_entry {
int sysnum;
} gate_entry;
struct _xc_entry {
} xc_entry;
} ttr_info;
int ttr_sdepth;
#define TRAPTR_NENT 128
extern size_t trap_trace_bufsize;
extern int trap_trace_freeze;
#define TRAPTRACE_UNFREEZE trap_trace_freeze = 0;
#else /* _ASM */
/*
* ptr -- will be set to a TRAPTRACE entry.
* scr1 -- scratch
* scr1_32 -- 32-bit version of scr1
* scr2 -- scratch
* marker -- register containing byte to store in marker field of entry
*
* Note that this macro defines labels "8" and "9".
*/
#ifdef TRAPTRACE
#if defined(__amd64)
jne 9f; \
jl 8f; \
cmpl $0, trap_trace_freeze; \
jne 9f; \
jl 8f; \
#endif /* __i386 */
/*
* ptr -- pointer to the current TRAPTRACE entry.
* reg -- pointer to the stored registers; must be on the stack
* scr1 -- scratch used as array index
* scr2 -- scratch used as temporary
*
* Note that this macro defines label "9".
* Also captures curthread on exit of loop.
*/
#if defined(__xpv)
#else
#endif
#if defined(__amd64)
/*CSTYLED*/ \
jl 9b; \
/*CSTYLED*/ \
jl 9b; \
#endif /* __i386 */
/*
* The time stamp macro records a high-resolution time stamp for the
* given TRAPTRACE entry. Note that %eax and %edx are plowed by this
* macro; if they are to be preserved, it's up to the caller of the macro.
*/
#if defined(__amd64)
#define TRACE_STAMP(reg) \
rdtsc; \
/*
* %rbp should be set before invoking this macro.
*/
#define TRACE_STACK(tt) \
call getpcstack; \
#define TRACE_STAMP(reg) \
jz 9f; \
rdtsc; \
#define TRACE_STACK(tt) \
pushl $TTR_STACK_DEPTH; \
call getpcstack; \
#endif /* __i386 */
#else
#define TRACE_STAMP(reg)
#define TRACE_STACK(reg)
#endif /* TRAPTRACE */
#endif /* _ASM */
#define TT_INTERRUPT 0xbb
#define TT_TRAP 0xcc
#define TT_INTTRAP 0xdd
/*
* TT_XCALL subcodes:
*/
#define TT_XC_SVC_BEGIN 0 /* xc_serv() entry */
#ifdef __cplusplus
}
#endif
#endif /* _IA32_SYS_TRAPTRACE_H */