xref: /titanic_52/usr/src/cmd/fm/fmd/common/fmd_trace.h (revision fb3fb4f3d76d55b64440afd0af72775dfad3bd1d)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #ifndef	_FMD_TRACE_H
29 #define	_FMD_TRACE_H
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #include <sys/types.h>
34 #include <stdarg.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 typedef struct fmd_tracerec {
41 	hrtime_t tr_time;	/* high-resolution timestamp */
42 	const char *tr_file;	/* source file name */
43 	uint32_t tr_line;	/* source file line */
44 	uint16_t tr_errno;	/* errno value if error */
45 	uint8_t tr_tag;		/* tag (see <fmd_subr.h>) */
46 	uint8_t tr_depth;	/* depth of tr_stack[] */
47 	char tr_msg[64];	/* formatted message */
48 	uintptr_t tr_stack[1];	/* stack trace (optional) */
49 } fmd_tracerec_t;
50 
51 typedef struct fmd_tracebuf {
52 	fmd_tracerec_t *tb_buf;	/* pointer to first trace record */
53 	fmd_tracerec_t *tb_end;	/* pointer to last trace record */
54 	fmd_tracerec_t *tb_ptr;	/* next trace record to use */
55 	uint_t tb_frames;	/* maximum captured frames */
56 	uint_t tb_recs;		/* number of trace records */
57 	uint_t tb_size;		/* size of each record */
58 	uint_t tb_depth;	/* recursion depth of trace function */
59 } fmd_tracebuf_t;
60 
61 typedef fmd_tracerec_t *fmd_tracebuf_f(fmd_tracebuf_t *,
62     uint_t, const char *, va_list);
63 
64 extern fmd_tracebuf_t *fmd_trace_create(void);
65 extern void fmd_trace_destroy(fmd_tracebuf_t *);
66 
67 extern fmd_tracebuf_f fmd_trace_none;
68 extern fmd_tracebuf_f fmd_trace_lite;
69 extern fmd_tracebuf_f fmd_trace_full;
70 
71 #ifdef	__cplusplus
72 }
73 #endif
74 
75 #endif	/* _FMD_TRACE_H */
76