MCPcopy Index your code
hub / github.com/cloudflare/ebpf_exporter / Decode

Method Decode

decoder/kstack.go:17–38  ·  view source on GitHub ↗

Decode transforms an array of kernel frame addresses to a newline separated stack of symbols

(in []byte, _ config.Decoder)

Source from the content-addressed store, hash-verified

15
16// Decode transforms an array of kernel frame addresses to a newline separated stack of symbols
17func (k *KStack) Decode(in []byte, _ config.Decoder) ([]byte, error) {
18 addrs := []uintptr{}
19 for off := 0; off < len(in); off += 8 {
20 ptr := util.GetHostByteOrder().Uint64(in[off : off+8])
21 if ptr == 0 {
22 break
23 }
24
25 addrs = append(addrs, uintptr(ptr))
26 }
27
28 stack := make([]string, len(addrs))
29 for i, frame := range k.decoder.Stack(addrs) {
30 if frame.Sym == "" {
31 stack[i] = "??"
32 } else {
33 stack[i] = frame.Sym
34 }
35 }
36
37 return []byte(strings.Join(stack, "\n")), nil
38}

Callers 1

TestKStackDecoderFunction · 0.95

Calls 2

GetHostByteOrderFunction · 0.92
StackMethod · 0.80

Tested by 1

TestKStackDecoderFunction · 0.76