File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,38 @@ int bpf_usdt_arg_cnt(struct pt_regs *ctx)
108
108
return spec -> arg_cnt ;
109
109
}
110
110
111
+ /* Returns the size in bytes of the #*arg_num* (zero-indexed) USDT argument.
112
+ * Returns negative error if argument is not found or arg_num is invalid.
113
+ */
114
+ static __always_inline
115
+ int bpf_usdt_arg_size (struct pt_regs * ctx , __u64 arg_num )
116
+ {
117
+ struct __bpf_usdt_arg_spec * arg_spec ;
118
+ struct __bpf_usdt_spec * spec ;
119
+ int spec_id ;
120
+
121
+ spec_id = __bpf_usdt_spec_id (ctx );
122
+ if (spec_id < 0 )
123
+ return - ESRCH ;
124
+
125
+ spec = bpf_map_lookup_elem (& __bpf_usdt_specs , & spec_id );
126
+ if (!spec )
127
+ return - ESRCH ;
128
+
129
+ if (arg_num >= BPF_USDT_MAX_ARG_CNT )
130
+ return - ENOENT ;
131
+ barrier_var (arg_num );
132
+ if (arg_num >= spec -> arg_cnt )
133
+ return - ENOENT ;
134
+
135
+ arg_spec = & spec -> args [arg_num ];
136
+
137
+ /* arg_spec->arg_bitshift = 64 - arg_sz * 8
138
+ * so: arg_sz = (64 - arg_spec->arg_bitshift) / 8
139
+ */
140
+ return (unsigned int )(64 - arg_spec -> arg_bitshift ) / 8 ;
141
+ }
142
+
111
143
/* Fetch USDT argument #*arg_num* (zero-indexed) and put its value into *res.
112
144
* Returns 0 on success; negative error, otherwise.
113
145
* On error *res is guaranteed to be set to zero.
You can’t perform that action at this time.
0 commit comments