|
|
1.1 root 1: #define _DDI_DKI 1
2: #define _SYSV4 1
3:
4: /*
5: * Simple im-memory traceback buffer for kernel debugging.
6: *
7: * This module exists to service the DDI/DKI cmn_err () function, which takes
8: * care of details like locking. This function is a simple debugging output
9: * which logs characters to a wrap-around memory buffer that might be useful
10: * for post-mortem kernel debugging.
11: */
12:
13: /*
14: *-IMPORTS:
15: * <common/ccompat.h>
16: * __USE_PROTO__
17: * __ARGS ()
18: * <common/xdebug.h>
19: * __LOCAL__
20: */
21:
22: #include <common/ccompat.h>
23: #include <common/xdebug.h>
24:
25:
26: #ifndef DEBUG_BUF_SIZE
27: #define DEBUG_BUF_SIZE 1024
28: #endif
29:
30:
31: #define SIGNATURE "$PUTBUF:"
32:
33:
34: /*
35: * Local state for the simple debug output.
36: */
37:
38: __LOCAL__ struct {
39: unsigned char signature [sizeof (SIGNATURE)];
40: unsigned offset;
41: unsigned char buffer [DEBUG_BUF_SIZE];
42: } _putbuf = {
43: SIGNATURE
44: };
45:
46:
47: /*
48: *-STATUS:
49: * Private to cmn_err ()
50: *
51: *-NAME:
52: * _put_putbuf () simple post-mortem debugging output
53: *
54: *-ARGUMENTS:
55: * outch The character to record in the post-mortem traceback
56: * buffer.
57: *
58: *-DESCRIPTION:
59: * This function provides system-specific debugging output support for
60: * the DDI/DKI cnm_err () function, interfacing to a simple wraparound
61: * traceback buffer.
62: *
63: *-NOTES:
64: * This function does not sleep.
65: *
66: * Driver-defined basic locks, read/write locks and sleep locks may
67: * be held across calls to this function.
68: *
69: * In systems where the contents of main memory are not usually
70: * available after a crash and restart, the traceback memory may be
71: * stored off-line (recorded through a serial port), or checkpointed
72: * into memory not touched by the system boot process (such as network
73: * adapter buffer memory). In such systems, the traceback output may
74: * be "buffered" and only flushed when requested to record a '\n'
75: */
76:
77: #if __USE_PROTO__
78: void (_put_putbuf) (unsigned char outch)
79: #else
80: void
81: _put_putbuf __ARGS ((outch))
82: unsigned char outch;
83: #endif
84: {
85: _putbuf.buffer [_putbuf.offset] = outch;
86: _putbuf.offset = (_putbuf.offset + 1) % sizeof (_putbuf.buffer);
87: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.