xref: /illumos-gate/usr/src/cmd/fm/fmd/common/fmd_trace.h (revision 2a8bcb4e)
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 #include <sys/types.h>
32 #include <stdarg.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 typedef struct fmd_tracerec {
39 	hrtime_t tr_time;	/* high-resolution timestamp */
40 	const char *tr_file;	/* source file name */
41 	uint32_t tr_line;	/* source file line */
42 	uint16_t tr_errno;	/* errno value if error */
43 	uint8_t tr_tag;		/* tag (see <fmd_subr.h>) */
44 	uint8_t tr_depth;	/* depth of tr_stack[] */
45 	char tr_msg[64];	/* formatted message */
46 	uintptr_t tr_stack[1];	/* stack trace (optional) */
47 } fmd_tracerec_t;
48 
49 typedef struct fmd_tracebuf {
50 	fmd_tracerec_t *tb_buf;	/* pointer to first trace record */
51 	fmd_tracerec_t *tb_end;	/* pointer to last trace record */
52 	fmd_tracerec_t *tb_ptr;	/* next trace record to use */
53 	uint_t tb_frames;	/* maximum captured frames */
54 	uint_t tb_recs;		/* number of trace records */
55 	uint_t tb_size;		/* size of each record */
56 	uint_t tb_depth;	/* recursion depth of trace function */
57 } fmd_tracebuf_t;
58 
59 typedef fmd_tracerec_t *fmd_tracebuf_f(fmd_tracebuf_t *,
60     uint_t, const char *, va_list);
61 
62 extern fmd_tracebuf_t *fmd_trace_create(void);
63 extern void fmd_trace_destroy(fmd_tracebuf_t *);
64 
65 extern fmd_tracebuf_f fmd_trace_none;
66 extern fmd_tracebuf_f fmd_trace_lite;
67 extern fmd_tracebuf_f fmd_trace_full;
68 
69 #ifdef	__cplusplus
70 }
71 #endif
72 
73 #endif	/* _FMD_TRACE_H */
74