...

Source file src/runtime/export_debuglog_test.go

Documentation: runtime

     1  // Copyright 2019 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Export debuglog guts for testing.
     6  
     7  package runtime
     8  
     9  const DlogEnabled = dlogEnabled
    10  
    11  const DebugLogBytes = debugLogBytes
    12  
    13  const DebugLogStringLimit = debugLogStringLimit
    14  
    15  var Dlog = dlog
    16  
    17  func (l *dlogger) End()                  { l.end() }
    18  func (l *dlogger) B(x bool) *dlogger     { return l.b(x) }
    19  func (l *dlogger) I(x int) *dlogger      { return l.i(x) }
    20  func (l *dlogger) I16(x int16) *dlogger  { return l.i16(x) }
    21  func (l *dlogger) U64(x uint64) *dlogger { return l.u64(x) }
    22  func (l *dlogger) Hex(x uint64) *dlogger { return l.hex(x) }
    23  func (l *dlogger) P(x any) *dlogger      { return l.p(x) }
    24  func (l *dlogger) S(x string) *dlogger   { return l.s(x) }
    25  func (l *dlogger) PC(x uintptr) *dlogger { return l.pc(x) }
    26  
    27  func DumpDebugLog() string {
    28  	gp := getg()
    29  	gp.writebuf = make([]byte, 0, 1<<20)
    30  	printDebugLog()
    31  	buf := gp.writebuf
    32  	gp.writebuf = nil
    33  
    34  	return string(buf)
    35  }
    36  
    37  func ResetDebugLog() {
    38  	stw := stopTheWorld(stwForTestResetDebugLog)
    39  	for l := allDloggers; l != nil; l = l.allLink {
    40  		l.w.write = 0
    41  		l.w.tick, l.w.nano = 0, 0
    42  		l.w.r.begin, l.w.r.end = 0, 0
    43  		l.w.r.tick, l.w.r.nano = 0, 0
    44  	}
    45  	startTheWorld(stw)
    46  }
    47  

View as plain text