MCPcopy Create free account
hub / github.com/imroc/req / stack

Method stack

internal/bisect/bisect.go:441–485  ·  view source on GitHub ↗

stack does the real work for Stack. This lets stack's body handle m == nil and potentially be inlined.

(w Writer)

Source from the content-addressed store, hash-verified

439// stack does the real work for Stack.
440// This lets stack's body handle m == nil and potentially be inlined.
441func (m *Matcher) stack(w Writer) bool {
442 const maxStack = 16
443 var stk [maxStack]uintptr
444 n := runtime.Callers(2, stk[:])
445 // caller #2 is not for printing; need it to normalize PCs if ASLR.
446 if n <= 1 {
447 return false
448 }
449
450 base := stk[0]
451 // normalize PCs
452 for i := range stk[:n] {
453 stk[i] -= base
454 }
455
456 h := Hash(stk[:n])
457 if m.ShouldPrint(h) {
458 var d *dedup
459 for {
460 d = m.dedup.Load()
461 if d != nil {
462 break
463 }
464 d = new(dedup)
465 if m.dedup.CompareAndSwap(nil, d) {
466 break
467 }
468 }
469
470 if m.MarkerOnly() {
471 if !d.seenLossy(h) {
472 PrintMarker(w, h)
473 }
474 } else {
475 if !d.seen(h) {
476 // Restore PCs in stack for printing
477 for i := range stk[:n] {
478 stk[i] += base
479 }
480 printStack(w, h, stk[1:n])
481 }
482 }
483 }
484 return m.ShouldEnable(h)
485}
486
487// Writer is the same interface as io.Writer.
488// It is duplicated here to avoid importing io.

Callers 1

StackMethod · 0.95

Calls 10

ShouldPrintMethod · 0.95
MarkerOnlyMethod · 0.95
seenLossyMethod · 0.95
seenMethod · 0.95
ShouldEnableMethod · 0.95
HashFunction · 0.85
PrintMarkerFunction · 0.85
printStackFunction · 0.85
LoadMethod · 0.80
CompareAndSwapMethod · 0.80

Tested by

no test coverage detected