xref: /titanic_41/usr/src/cmd/fm/fmd/common/fmd_trace.h (revision 70025d765b044c6d8594bb965a2247a61e991a99)
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  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_FMD_TRACE_H
28 #define	_FMD_TRACE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <stdarg.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 typedef struct fmd_tracerec {
40 	hrtime_t tr_time;	/* high-resolution timestamp */
41 	const char *tr_file;	/* source file name */
42 	uint32_t tr_line;	/* source file line */
43 	uint16_t tr_errno;	/* errno value if error */
44 	uint8_t tr_tag;		/* tag (see <fmd_subr.h>) */
45 	uint8_t tr_depth;	/* depth of tr_stack[] */
46 	char tr_msg[64];	/* formatted message */
47 	uintptr_t tr_stack[1];	/* stack trace (optional) */
48 } fmd_tracerec_t;
49 
50 typedef struct fmd_tracebuf {
51 	fmd_tracerec_t *tb_buf;	/* pointer to first trace record */
52 	fmd_tracerec_t *tb_end;	/* pointer to last trace record */
53 	fmd_tracerec_t *tb_ptr;	/* next trace record to use */
54 	uint_t tb_frames;	/* maximum captured frames */
55 	uint_t tb_recs;		/* number of trace records */
56 	uint_t tb_size;		/* size of each record */
57 } fmd_tracebuf_t;
58 
59 typedef fmd_tracerec_t *fmd_tracebuf_f(fmd_tracebuf_t *,
60     uint8_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