summaryrefslogtreecommitdiffhomepage
path: root/pkg/bpf/decoder.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-09-16 06:22:25 +0000
committergVisor bot <gvisor-bot@google.com>2020-09-16 06:22:25 +0000
commitcbc7d6a202b7e47457b3aa3daa55ebc5c1fbdb72 (patch)
tree5db961cfe01e42b712f232bd9028df2e33859a31 /pkg/bpf/decoder.go
parentfe3658df8a9fd634c22008533c45e7cb2a5866cc (diff)
parentdcd532e2e416aa81ca9ac42dc153731855f91418 (diff)
Merge release-20200907.0-56-gdcd532e2e (automated)
Diffstat (limited to 'pkg/bpf/decoder.go')
-rw-r--r--pkg/bpf/decoder.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/pkg/bpf/decoder.go b/pkg/bpf/decoder.go
index c8ee0c3b1..069d0395d 100644
--- a/pkg/bpf/decoder.go
+++ b/pkg/bpf/decoder.go
@@ -21,10 +21,15 @@ import (
"gvisor.dev/gvisor/pkg/abi/linux"
)
-// DecodeProgram translates an array of BPF instructions into text format.
-func DecodeProgram(program []linux.BPFInstruction) (string, error) {
+// DecodeProgram translates a compiled BPF program into text format.
+func DecodeProgram(p Program) (string, error) {
+ return DecodeInstructions(p.instructions)
+}
+
+// DecodeInstructions translates an array of BPF instructions into text format.
+func DecodeInstructions(instns []linux.BPFInstruction) (string, error) {
var ret bytes.Buffer
- for line, s := range program {
+ for line, s := range instns {
ret.WriteString(fmt.Sprintf("%v: ", line))
if err := decode(s, line, &ret); err != nil {
return "", err
@@ -34,7 +39,7 @@ func DecodeProgram(program []linux.BPFInstruction) (string, error) {
return ret.String(), nil
}
-// Decode translates BPF instruction into text format.
+// Decode translates a single BPF instruction into text format.
func Decode(inst linux.BPFInstruction) (string, error) {
var ret bytes.Buffer
err := decode(inst, -1, &ret)