-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
erpc.go
55 lines (47 loc) · 1.3 KB
/
erpc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
//go:build linux
// Package ptracer holds ptracer related files
package ptracer
import (
"syscall"
)
const (
// RPCCmd defines the ioctl CMD magic used by APM to register span TLS
RPCCmd uint64 = 0xdeadc001
// RegisterSpanTLSOp defines the span TLS register op code
RegisterSpanTLSOp uint8 = 6
)
func registerERPCHandlers(handlers map[int]syscallHandler) []string {
fimHandlers := []syscallHandler{
{
IDs: []syscallID{{ID: IoctlNr, Name: "ioctl"}},
Func: nil,
ShouldSend: nil,
RetFunc: nil,
},
}
syscallList := []string{}
for _, h := range fimHandlers {
for _, id := range h.IDs {
if id.ID >= 0 { // insert only available syscalls
handlers[id.ID] = h
syscallList = append(syscallList, id.Name)
}
}
}
return syscallList
}
func handleERPC(tracer *Tracer, process *Process, regs syscall.PtraceRegs) []byte {
fd := tracer.ReadArgUint64(regs, 1)
if fd != RPCCmd {
return nil
}
pRequests, err := tracer.ReadArgData(process.Pid, regs, 2, 257)
if err != nil || len(pRequests) == 0 {
return nil
}
return pRequests
}