diff options
| author | Paul Buetow <paul@buetow.org> | 2024-03-06 11:40:52 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-03-06 11:40:52 +0200 |
| commit | b215bafceeecbe97de19fb3111dc080196224ab9 (patch) | |
| tree | 0fb2a826776557e6e2511bb073b06978cbf8997c /internal/c/generated/tracepoints.raku | |
| parent | dbc5a6a2f3554f98579b742fec012dde9a9417e2 (diff) | |
Addresses https://codeberg.org/snonux/ioriotng/issues/23 - fix parameter
positions
Diffstat (limited to 'internal/c/generated/tracepoints.raku')
| -rw-r--r-- | internal/c/generated/tracepoints.raku | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/internal/c/generated/tracepoints.raku b/internal/c/generated/tracepoints.raku index cc78fbb..ad95559 100644 --- a/internal/c/generated/tracepoints.raku +++ b/internal/c/generated/tracepoints.raku @@ -4,8 +4,8 @@ use v6.d; #use Grammar::Debugger; grammar SysTraceFormat { - rule TOP { <wholeformatsection>* } - rule wholeformatsection { <name> <id> <format> <print-fmt> } + rule TOP { <whole-format-section>* } + rule whole-format-section { <name> <id> <format> <print-fmt> } rule name { 'name:' <identifier> } rule id { 'ID:' <number> } rule format { 'format:' <field>* } @@ -33,9 +33,16 @@ class Field { } class Format { + # Fields not accessible from raw tracepoints. + has Field @!internal-fields; + # Fields accessible from raw tracepoints. + has Field @!external-fields; + # Track internal/external field sections. + has Bool $!is-external = False; + has Str $.name is rw; has Int $.id is rw; - has Field @.fields is rw; + # file descriptor passed to syscalls. has Bool $.has-fd is rw = False; # Has tracepoint has got oldname and name @@ -43,19 +50,32 @@ class Format { # Syscall returns with a long value (e.g. bytes read/written) has Bool $.has-long-ret is rw = False; - method push(Field $field) { - push @!fields: $field; - if ($field.name eq 'fd' && $field.type eq 'unsigned int') { + method push(Field \field) { + # External fields start from this field name. + $!is-external = True if field.name eq '__syscall_nr'; + + if $!is-external { + push @!external-fields: field; + } else { + push @!internal-fields: field; + return; + } + + if (field.name eq 'fd' && field.type eq 'unsigned int') { $!has-fd = True; - } elsif ($field.name eq 'newname' && $field.type eq 'const char *') { + } elsif (field.name eq 'newname' && field.type eq 'const char *') { $!has-name = True; - } elsif ($field.name eq 'ret' && $field.type eq 'long') { + } elsif (field.name eq 'ret' && field.type eq 'long') { $.has-long-ret = True; } } + method !field-number(Str \field-name) { + @!external-fields.first(*.name eq field-name, :k) - 1; + } + method generate-constant returns Str { - "#define {$!name.uc} {$!id}" + "#define {$!name.uc} {$!id}"; } method generate-probe returns Str { @@ -69,10 +89,12 @@ class Format { my \extra-data = do if $!has-fd { 'ev->fd = (__s32)ctx->args[0];' } elsif $!has-long-ret { 'ev->ret = ctx->ret;' } elsif $!has-name { - q:to/END/.trim-trailing; - __builtin_memset(&(ev->oldname), 0, sizeof(ev->oldname) + sizeof(ev->newname)); - bpf_probe_read_user_str(ev->oldname, sizeof(ev->oldname), (void*)ctx->args[0]); - bpf_probe_read_user_str(ev->newname, sizeof(ev->newname), (void*)ctx->args[1]); + my Int \oldname-index = self!field-number('oldname'); + my Int \newname-index = self!field-number('newname'); + qq:to/END/.trim-trailing; + __builtin_memset(\&(ev->oldname), 0, sizeof(ev->oldname) + sizeof(ev->newname)); + bpf_probe_read_user_str(ev->oldname, sizeof(ev->oldname), (void*)ctx->args[{oldname-index}]); + bpf_probe_read_user_str(ev->newname, sizeof(ev->newname), (void*)ctx->args[{newname-index}]); END } else { '' }; @@ -108,7 +130,7 @@ class SysTraceFormatActions { method TOP($/) { make @!formats } - method wholeformatsection($/) { + method whole-format-section($/) { push @!formats: $!current-format; $!current-format = Format.new; } |
