summaryrefslogtreecommitdiff
path: root/internal/generated
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-02-27 20:39:16 +0200
committerPaul Buetow <paul@buetow.org>2024-02-28 00:15:12 +0200
commitd44c509284eaf0db2b1f7d14ede3687ff06c4853 (patch)
treef675f3f1578dbf8a3342fdb67f79ac3b216ed5dd /internal/generated
parent139d2dca45306071a30562a94b69ac20ada515c8 (diff)
introduce event type for better deserializing
Diffstat (limited to 'internal/generated')
-rw-r--r--internal/generated/nqc.raku2
-rw-r--r--internal/generated/types/types.go79
2 files changed, 48 insertions, 33 deletions
diff --git a/internal/generated/nqc.raku b/internal/generated/nqc.raku
index e237b3f..a975df6 100644
--- a/internal/generated/nqc.raku
+++ b/internal/generated/nqc.raku
@@ -53,6 +53,7 @@ class NQCToGoActions {
method !constant-go-string-method returns Str {
qq:to/END/;
+ type EventType uint32
type SyscallId uint32
func (s SyscallId) String() string \{
@@ -121,6 +122,7 @@ class NQCToGoActions {
method member($/) {
my Str $type = $<identifier>.made eq 'SyscallId' ?? 'SyscallId' !! $<type>.made;
+ $type = 'EventType' if $<identifier>.made eq 'EventType';
make $<identifier>.made ~ ' ' ~ ($<arraysize> // '') ~ $type;
}
diff --git a/internal/generated/types/types.go b/internal/generated/types/types.go
index 9483285..e3f89db 100644
--- a/internal/generated/types/types.go
+++ b/internal/generated/types/types.go
@@ -8,6 +8,7 @@ import (
"sync"
)
+type EventType uint32
type SyscallId uint32
func (s SyscallId) String() string {
@@ -131,8 +132,48 @@ func (s SyscallId) String() string {
const MAX_FILENAME_LENGTH = 256
const MAX_PROGNAME_LENGTH = 16
+const ENTER_OPEN_EVENT = 1
+const EXIT_OPEN_EVENT = 2
+const ENTER_NULL_EVENT = 3
+const EXIT_NULL_EVENT = 4
+const ENTER_FD_EVENT = 5
+const EXIT_FD_EVENT = 6
+const ENTER_RET_EVENT = 7
+const EXIT_RET_EVENT = 8
+
+type OpenEnterEvent struct {
+ EventType EventType
+ SyscallId SyscallId
+ Pid uint32
+ Tid uint32
+ Time uint32
+ Filename [MAX_FILENAME_LENGTH]byte
+ Comm [MAX_PROGNAME_LENGTH]byte
+}
+
+func (o OpenEnterEvent) String() string {
+ return fmt.Sprintf("EventType:%v SyscallId:%v Pid:%v Tid:%v Time:%v Filename:%v Comm:%v", o.EventType, o.SyscallId, o.Pid, o.Tid, o.Time, string(o.Filename[:]), string(o.Comm[:]))
+}
+
+var poolOfOpenEnterEvents = sync.Pool{
+ New: func() interface{} { return &OpenEnterEvent{} },
+}
+
+func NewOpenEnterEvent(raw []byte) *OpenEnterEvent {
+ o := poolOfOpenEnterEvents.Get().(*OpenEnterEvent)
+ if err := binary.Read(bytes.NewReader(raw), binary.LittleEndian, o); err != nil {
+ fmt.Println(o, raw, len(raw), err)
+ panic(raw)
+ }
+ return o
+}
+
+func (o *OpenEnterEvent) Recycle() {
+ poolOfOpenEnterEvents.Put(o)
+}
type NullEvent struct {
+ EventType EventType
SyscallId SyscallId
Pid uint32
Tid uint32
@@ -140,7 +181,7 @@ type NullEvent struct {
}
func (n NullEvent) String() string {
- return fmt.Sprintf("SyscallId:%v Pid:%v Tid:%v Time:%v", n.SyscallId, n.Pid, n.Tid, n.Time)
+ return fmt.Sprintf("EventType:%v SyscallId:%v Pid:%v Tid:%v Time:%v", n.EventType, n.SyscallId, n.Pid, n.Tid, n.Time)
}
var poolOfNullEvents = sync.Pool{
@@ -161,6 +202,7 @@ func (n *NullEvent) Recycle() {
}
type FdEvent struct {
+ EventType EventType
SyscallId SyscallId
Pid uint32
Tid uint32
@@ -169,7 +211,7 @@ type FdEvent struct {
}
func (f FdEvent) String() string {
- return fmt.Sprintf("SyscallId:%v Pid:%v Tid:%v Time:%v Fd:%v", f.SyscallId, f.Pid, f.Tid, f.Time, f.Fd)
+ return fmt.Sprintf("EventType:%v SyscallId:%v Pid:%v Tid:%v Time:%v Fd:%v", f.EventType, f.SyscallId, f.Pid, f.Tid, f.Time, f.Fd)
}
var poolOfFdEvents = sync.Pool{
@@ -190,6 +232,7 @@ func (f *FdEvent) Recycle() {
}
type RetEvent struct {
+ EventType EventType
SyscallId SyscallId
Pid uint32
Tid uint32
@@ -198,7 +241,7 @@ type RetEvent struct {
}
func (r RetEvent) String() string {
- return fmt.Sprintf("SyscallId:%v Pid:%v Tid:%v Time:%v Ret:%v", r.SyscallId, r.Pid, r.Tid, r.Time, r.Ret)
+ return fmt.Sprintf("EventType:%v SyscallId:%v Pid:%v Tid:%v Time:%v Ret:%v", r.EventType, r.SyscallId, r.Pid, r.Tid, r.Time, r.Ret)
}
var poolOfRetEvents = sync.Pool{
@@ -218,36 +261,6 @@ func (r *RetEvent) Recycle() {
poolOfRetEvents.Put(r)
}
-type OpenEnterEvent struct {
- SyscallId SyscallId
- Pid uint32
- Tid uint32
- Time uint32
- Filename [MAX_FILENAME_LENGTH]byte
- Comm [MAX_PROGNAME_LENGTH]byte
-}
-
-func (o OpenEnterEvent) String() string {
- return fmt.Sprintf("SyscallId:%v Pid:%v Tid:%v Time:%v Filename:%v Comm:%v", o.SyscallId, o.Pid, o.Tid, o.Time, string(o.Filename[:]), string(o.Comm[:]))
-}
-
-var poolOfOpenEnterEvents = sync.Pool{
- New: func() interface{} { return &OpenEnterEvent{} },
-}
-
-func NewOpenEnterEvent(raw []byte) *OpenEnterEvent {
- o := poolOfOpenEnterEvents.Get().(*OpenEnterEvent)
- if err := binary.Read(bytes.NewReader(raw), binary.LittleEndian, o); err != nil {
- fmt.Println(o, raw, len(raw), err)
- panic(raw)
- }
- return o
-}
-
-func (o *OpenEnterEvent) Recycle() {
- poolOfOpenEnterEvents.Put(o)
-}
-
const SYS_EXIT_CACHESTAT SyscallId = 520
const SYS_ENTER_CACHESTAT SyscallId = 521
const SYS_EXIT_CLOSE_RANGE SyscallId = 692