diff options
Diffstat (limited to 'kernel/trace/trace_probe.h')
-rw-r--r-- | kernel/trace/trace_probe.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 984e91ed8a44..d384fbd4025c 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h | |||
@@ -178,3 +178,51 @@ extern ssize_t traceprobe_probes_write(struct file *file, | |||
178 | int (*createfn)(int, char**)); | 178 | int (*createfn)(int, char**)); |
179 | 179 | ||
180 | extern int traceprobe_command(const char *buf, int (*createfn)(int, char**)); | 180 | extern int traceprobe_command(const char *buf, int (*createfn)(int, char**)); |
181 | |||
182 | /* Sum up total data length for dynamic arraies (strings) */ | ||
183 | static inline __kprobes int | ||
184 | __get_data_size(struct trace_probe *tp, struct pt_regs *regs) | ||
185 | { | ||
186 | int i, ret = 0; | ||
187 | u32 len; | ||
188 | |||
189 | for (i = 0; i < tp->nr_args; i++) | ||
190 | if (unlikely(tp->args[i].fetch_size.fn)) { | ||
191 | call_fetch(&tp->args[i].fetch_size, regs, &len); | ||
192 | ret += len; | ||
193 | } | ||
194 | |||
195 | return ret; | ||
196 | } | ||
197 | |||
198 | /* Store the value of each argument */ | ||
199 | static inline __kprobes void | ||
200 | store_trace_args(int ent_size, struct trace_probe *tp, struct pt_regs *regs, | ||
201 | u8 *data, int maxlen) | ||
202 | { | ||
203 | int i; | ||
204 | u32 end = tp->size; | ||
205 | u32 *dl; /* Data (relative) location */ | ||
206 | |||
207 | for (i = 0; i < tp->nr_args; i++) { | ||
208 | if (unlikely(tp->args[i].fetch_size.fn)) { | ||
209 | /* | ||
210 | * First, we set the relative location and | ||
211 | * maximum data length to *dl | ||
212 | */ | ||
213 | dl = (u32 *)(data + tp->args[i].offset); | ||
214 | *dl = make_data_rloc(maxlen, end - tp->args[i].offset); | ||
215 | /* Then try to fetch string or dynamic array data */ | ||
216 | call_fetch(&tp->args[i].fetch, regs, dl); | ||
217 | /* Reduce maximum length */ | ||
218 | end += get_rloc_len(*dl); | ||
219 | maxlen -= get_rloc_len(*dl); | ||
220 | /* Trick here, convert data_rloc to data_loc */ | ||
221 | *dl = convert_rloc_to_loc(*dl, | ||
222 | ent_size + tp->args[i].offset); | ||
223 | } else | ||
224 | /* Just fetching data normally */ | ||
225 | call_fetch(&tp->args[i].fetch, regs, | ||
226 | data + tp->args[i].offset); | ||
227 | } | ||
228 | } | ||