diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2013-07-03 02:55:36 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2014-01-02 16:17:37 -0500 |
commit | 2dc1018372c3b1db1410c7087de7866d4cad8cc3 (patch) | |
tree | 88e047e0cd2884d7ab639d319478250c31300493 /kernel/trace | |
parent | 14577c39927f86e3dba967f9b511f4a876b7f8bb (diff) |
tracing/kprobes: Move common functions to trace_probe.h
The __get_data_size() and store_trace_args() will be used by uprobes
too. Move them to a common location.
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: zhangwei(Jovi) <jovi.zhangwei@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace_kprobe.c | 48 | ||||
-rw-r--r-- | kernel/trace/trace_probe.h | 48 |
2 files changed, 48 insertions, 48 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 727190698727..fb1a02735d6a 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c | |||
@@ -740,54 +740,6 @@ static const struct file_operations kprobe_profile_ops = { | |||
740 | .release = seq_release, | 740 | .release = seq_release, |
741 | }; | 741 | }; |
742 | 742 | ||
743 | /* Sum up total data length for dynamic arraies (strings) */ | ||
744 | static __kprobes int __get_data_size(struct trace_probe *tp, | ||
745 | struct pt_regs *regs) | ||
746 | { | ||
747 | int i, ret = 0; | ||
748 | u32 len; | ||
749 | |||
750 | for (i = 0; i < tp->nr_args; i++) | ||
751 | if (unlikely(tp->args[i].fetch_size.fn)) { | ||
752 | call_fetch(&tp->args[i].fetch_size, regs, &len); | ||
753 | ret += len; | ||
754 | } | ||
755 | |||
756 | return ret; | ||
757 | } | ||
758 | |||
759 | /* Store the value of each argument */ | ||
760 | static __kprobes void store_trace_args(int ent_size, struct trace_probe *tp, | ||
761 | struct pt_regs *regs, | ||
762 | u8 *data, int maxlen) | ||
763 | { | ||
764 | int i; | ||
765 | u32 end = tp->size; | ||
766 | u32 *dl; /* Data (relative) location */ | ||
767 | |||
768 | for (i = 0; i < tp->nr_args; i++) { | ||
769 | if (unlikely(tp->args[i].fetch_size.fn)) { | ||
770 | /* | ||
771 | * First, we set the relative location and | ||
772 | * maximum data length to *dl | ||
773 | */ | ||
774 | dl = (u32 *)(data + tp->args[i].offset); | ||
775 | *dl = make_data_rloc(maxlen, end - tp->args[i].offset); | ||
776 | /* Then try to fetch string or dynamic array data */ | ||
777 | call_fetch(&tp->args[i].fetch, regs, dl); | ||
778 | /* Reduce maximum length */ | ||
779 | end += get_rloc_len(*dl); | ||
780 | maxlen -= get_rloc_len(*dl); | ||
781 | /* Trick here, convert data_rloc to data_loc */ | ||
782 | *dl = convert_rloc_to_loc(*dl, | ||
783 | ent_size + tp->args[i].offset); | ||
784 | } else | ||
785 | /* Just fetching data normally */ | ||
786 | call_fetch(&tp->args[i].fetch, regs, | ||
787 | data + tp->args[i].offset); | ||
788 | } | ||
789 | } | ||
790 | |||
791 | /* Kprobe handler */ | 743 | /* Kprobe handler */ |
792 | static __kprobes void | 744 | static __kprobes void |
793 | __kprobe_trace_func(struct trace_kprobe *tk, struct pt_regs *regs, | 745 | __kprobe_trace_func(struct trace_kprobe *tk, struct pt_regs *regs, |
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 | } | ||