Source file
src/runtime/export_debuglog_test.go
1
2
3
4
5
6
7 package runtime
8
9 const DlogEnabled = dlogEnabled
10
11 const DebugLogBytes = debugLogBytes
12
13 const DebugLogStringLimit = debugLogStringLimit
14
15 type Dlogger = dloggerImpl
16
17 func Dlog() *Dlogger {
18 return dlogImpl()
19 }
20
21 func (l *dloggerImpl) End() { l.end() }
22 func (l *dloggerImpl) B(x bool) *dloggerImpl { return l.b(x) }
23 func (l *dloggerImpl) I(x int) *dloggerImpl { return l.i(x) }
24 func (l *dloggerImpl) I16(x int16) *dloggerImpl { return l.i16(x) }
25 func (l *dloggerImpl) U64(x uint64) *dloggerImpl { return l.u64(x) }
26 func (l *dloggerImpl) Hex(x uint64) *dloggerImpl { return l.hex(x) }
27 func (l *dloggerImpl) P(x any) *dloggerImpl { return l.p(x) }
28 func (l *dloggerImpl) S(x string) *dloggerImpl { return l.s(x) }
29 func (l *dloggerImpl) PC(x uintptr) *dloggerImpl { return l.pc(x) }
30
31 func DumpDebugLog() string {
32 gp := getg()
33 gp.writebuf = make([]byte, 0, 1<<20)
34 printDebugLogImpl()
35 buf := gp.writebuf
36 gp.writebuf = nil
37
38 return string(buf)
39 }
40
41 func ResetDebugLog() {
42 stw := stopTheWorld(stwForTestResetDebugLog)
43 for l := allDloggers; l != nil; l = l.allLink {
44 l.w.write = 0
45 l.w.tick, l.w.nano = 0, 0
46 l.w.r.begin, l.w.r.end = 0, 0
47 l.w.r.tick, l.w.r.nano = 0, 0
48 }
49 startTheWorld(stw)
50 }
51
52 func CountDebugLog() int {
53 stw := stopTheWorld(stwForTestResetDebugLog)
54 i := 0
55 for l := allDloggers; l != nil; l = l.allLink {
56 i++
57 }
58 startTheWorld(stw)
59 return i
60 }
61
View as plain text