diff options
author | Masami Hiramatsu <mhiramat@kernel.org> | 2018-04-25 08:18:32 -0400 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2018-10-10 22:19:08 -0400 |
commit | f451bc89d8357f010304564728ba7c5d38a1d4d5 (patch) | |
tree | 69c3ed88cd496f2d6e125b9278e60f21bb0f04aa | |
parent | 533059281ee594f9fbb9e58042aaec77083ef251 (diff) |
tracing: probeevent: Unify fetch type tables
Unify {k,u}probe_fetch_type_table to probe_fetch_type_table
because the main difference of those type tables (fetcharg
methods) are gone. Now we can consolidate it.
Link: http://lkml.kernel.org/r/152465871274.26224.13999436317830479698.stgit@devbox
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r-- | kernel/trace/trace_kprobe.c | 27 | ||||
-rw-r--r-- | kernel/trace/trace_probe.c | 54 | ||||
-rw-r--r-- | kernel/trace/trace_probe.h | 6 | ||||
-rw-r--r-- | kernel/trace/trace_uprobe.c | 27 |
4 files changed, 39 insertions, 75 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index c024cc40d509..dc1c638daf44 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c | |||
@@ -121,30 +121,6 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs); | |||
121 | static int kretprobe_dispatcher(struct kretprobe_instance *ri, | 121 | static int kretprobe_dispatcher(struct kretprobe_instance *ri, |
122 | struct pt_regs *regs); | 122 | struct pt_regs *regs); |
123 | 123 | ||
124 | /* Fetch type information table */ | ||
125 | static const struct fetch_type kprobes_fetch_type_table[] = { | ||
126 | /* Special types */ | ||
127 | [FETCH_TYPE_STRING] = __ASSIGN_FETCH_TYPE("string", string, string, | ||
128 | sizeof(u32), 1, "__data_loc char[]"), | ||
129 | [FETCH_TYPE_STRSIZE] = __ASSIGN_FETCH_TYPE("string_size", u32, | ||
130 | string_size, sizeof(u32), 0, "u32"), | ||
131 | /* Basic types */ | ||
132 | ASSIGN_FETCH_TYPE(u8, u8, 0), | ||
133 | ASSIGN_FETCH_TYPE(u16, u16, 0), | ||
134 | ASSIGN_FETCH_TYPE(u32, u32, 0), | ||
135 | ASSIGN_FETCH_TYPE(u64, u64, 0), | ||
136 | ASSIGN_FETCH_TYPE(s8, u8, 1), | ||
137 | ASSIGN_FETCH_TYPE(s16, u16, 1), | ||
138 | ASSIGN_FETCH_TYPE(s32, u32, 1), | ||
139 | ASSIGN_FETCH_TYPE(s64, u64, 1), | ||
140 | ASSIGN_FETCH_TYPE_ALIAS(x8, u8, u8, 0), | ||
141 | ASSIGN_FETCH_TYPE_ALIAS(x16, u16, u16, 0), | ||
142 | ASSIGN_FETCH_TYPE_ALIAS(x32, u32, u32, 0), | ||
143 | ASSIGN_FETCH_TYPE_ALIAS(x64, u64, u64, 0), | ||
144 | |||
145 | ASSIGN_FETCH_TYPE_END | ||
146 | }; | ||
147 | |||
148 | /* | 124 | /* |
149 | * Allocate new trace_probe and initialize it (including kprobes). | 125 | * Allocate new trace_probe and initialize it (including kprobes). |
150 | */ | 126 | */ |
@@ -720,8 +696,7 @@ static int create_trace_kprobe(int argc, char **argv) | |||
720 | 696 | ||
721 | /* Parse fetch argument */ | 697 | /* Parse fetch argument */ |
722 | ret = traceprobe_parse_probe_arg(arg, &tk->tp.size, parg, | 698 | ret = traceprobe_parse_probe_arg(arg, &tk->tp.size, parg, |
723 | is_return, true, | 699 | is_return, true); |
724 | kprobes_fetch_type_table); | ||
725 | if (ret) { | 700 | if (ret) { |
726 | pr_info("Parse error at argument[%d]. (%d)\n", i, ret); | 701 | pr_info("Parse error at argument[%d]. (%d)\n", i, ret); |
727 | goto error; | 702 | goto error; |
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index c59c69cb2f2e..d06e67cca3e1 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c | |||
@@ -61,8 +61,29 @@ int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, void *data, void *ent) | |||
61 | 61 | ||
62 | const char PRINT_TYPE_FMT_NAME(string)[] = "\\\"%s\\\""; | 62 | const char PRINT_TYPE_FMT_NAME(string)[] = "\\\"%s\\\""; |
63 | 63 | ||
64 | static const struct fetch_type *find_fetch_type(const char *type, | 64 | /* Fetch type information table */ |
65 | const struct fetch_type *ftbl) | 65 | static const struct fetch_type probe_fetch_types[] = { |
66 | /* Special types */ | ||
67 | __ASSIGN_FETCH_TYPE("string", string, string, sizeof(u32), 1, | ||
68 | "__data_loc char[]"), | ||
69 | /* Basic types */ | ||
70 | ASSIGN_FETCH_TYPE(u8, u8, 0), | ||
71 | ASSIGN_FETCH_TYPE(u16, u16, 0), | ||
72 | ASSIGN_FETCH_TYPE(u32, u32, 0), | ||
73 | ASSIGN_FETCH_TYPE(u64, u64, 0), | ||
74 | ASSIGN_FETCH_TYPE(s8, u8, 1), | ||
75 | ASSIGN_FETCH_TYPE(s16, u16, 1), | ||
76 | ASSIGN_FETCH_TYPE(s32, u32, 1), | ||
77 | ASSIGN_FETCH_TYPE(s64, u64, 1), | ||
78 | ASSIGN_FETCH_TYPE_ALIAS(x8, u8, u8, 0), | ||
79 | ASSIGN_FETCH_TYPE_ALIAS(x16, u16, u16, 0), | ||
80 | ASSIGN_FETCH_TYPE_ALIAS(x32, u32, u32, 0), | ||
81 | ASSIGN_FETCH_TYPE_ALIAS(x64, u64, u64, 0), | ||
82 | |||
83 | ASSIGN_FETCH_TYPE_END | ||
84 | }; | ||
85 | |||
86 | static const struct fetch_type *find_fetch_type(const char *type) | ||
66 | { | 87 | { |
67 | int i; | 88 | int i; |
68 | 89 | ||
@@ -83,21 +104,21 @@ static const struct fetch_type *find_fetch_type(const char *type, | |||
83 | 104 | ||
84 | switch (bs) { | 105 | switch (bs) { |
85 | case 8: | 106 | case 8: |
86 | return find_fetch_type("u8", ftbl); | 107 | return find_fetch_type("u8"); |
87 | case 16: | 108 | case 16: |
88 | return find_fetch_type("u16", ftbl); | 109 | return find_fetch_type("u16"); |
89 | case 32: | 110 | case 32: |
90 | return find_fetch_type("u32", ftbl); | 111 | return find_fetch_type("u32"); |
91 | case 64: | 112 | case 64: |
92 | return find_fetch_type("u64", ftbl); | 113 | return find_fetch_type("u64"); |
93 | default: | 114 | default: |
94 | goto fail; | 115 | goto fail; |
95 | } | 116 | } |
96 | } | 117 | } |
97 | 118 | ||
98 | for (i = 0; ftbl[i].name; i++) { | 119 | for (i = 0; probe_fetch_types[i].name; i++) { |
99 | if (strcmp(type, ftbl[i].name) == 0) | 120 | if (strcmp(type, probe_fetch_types[i].name) == 0) |
100 | return &ftbl[i]; | 121 | return &probe_fetch_types[i]; |
101 | } | 122 | } |
102 | 123 | ||
103 | fail: | 124 | fail: |
@@ -164,8 +185,7 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t, | |||
164 | static int | 185 | static int |
165 | parse_probe_arg(char *arg, const struct fetch_type *type, | 186 | parse_probe_arg(char *arg, const struct fetch_type *type, |
166 | struct fetch_insn **pcode, struct fetch_insn *end, | 187 | struct fetch_insn **pcode, struct fetch_insn *end, |
167 | bool is_return, bool is_kprobe, | 188 | bool is_return, bool is_kprobe) |
168 | const struct fetch_type *ftbl) | ||
169 | { | 189 | { |
170 | struct fetch_insn *code = *pcode; | 190 | struct fetch_insn *code = *pcode; |
171 | unsigned long param; | 191 | unsigned long param; |
@@ -247,12 +267,11 @@ parse_probe_arg(char *arg, const struct fetch_type *type, | |||
247 | tmp = strrchr(arg, ')'); | 267 | tmp = strrchr(arg, ')'); |
248 | 268 | ||
249 | if (tmp) { | 269 | if (tmp) { |
250 | const struct fetch_type *t2; | 270 | const struct fetch_type *t2 = find_fetch_type(NULL); |
251 | 271 | ||
252 | t2 = find_fetch_type(NULL, ftbl); | ||
253 | *tmp = '\0'; | 272 | *tmp = '\0'; |
254 | ret = parse_probe_arg(arg, t2, &code, end, is_return, | 273 | ret = parse_probe_arg(arg, t2, &code, end, is_return, |
255 | is_kprobe, ftbl); | 274 | is_kprobe); |
256 | if (ret) | 275 | if (ret) |
257 | break; | 276 | break; |
258 | if (code->op == FETCH_OP_COMM) | 277 | if (code->op == FETCH_OP_COMM) |
@@ -312,8 +331,7 @@ static int __parse_bitfield_probe_arg(const char *bf, | |||
312 | 331 | ||
313 | /* String length checking wrapper */ | 332 | /* String length checking wrapper */ |
314 | int traceprobe_parse_probe_arg(char *arg, ssize_t *size, | 333 | int traceprobe_parse_probe_arg(char *arg, ssize_t *size, |
315 | struct probe_arg *parg, bool is_return, bool is_kprobe, | 334 | struct probe_arg *parg, bool is_return, bool is_kprobe) |
316 | const struct fetch_type *ftbl) | ||
317 | { | 335 | { |
318 | struct fetch_insn *code, *tmp = NULL; | 336 | struct fetch_insn *code, *tmp = NULL; |
319 | const char *t; | 337 | const char *t; |
@@ -339,7 +357,7 @@ int traceprobe_parse_probe_arg(char *arg, ssize_t *size, | |||
339 | */ | 357 | */ |
340 | if (!t && strcmp(arg, "$comm") == 0) | 358 | if (!t && strcmp(arg, "$comm") == 0) |
341 | t = "string"; | 359 | t = "string"; |
342 | parg->type = find_fetch_type(t, ftbl); | 360 | parg->type = find_fetch_type(t); |
343 | if (!parg->type) { | 361 | if (!parg->type) { |
344 | pr_info("Unsupported type: %s\n", t); | 362 | pr_info("Unsupported type: %s\n", t); |
345 | return -EINVAL; | 363 | return -EINVAL; |
@@ -353,7 +371,7 @@ int traceprobe_parse_probe_arg(char *arg, ssize_t *size, | |||
353 | code[FETCH_INSN_MAX - 1].op = FETCH_OP_END; | 371 | code[FETCH_INSN_MAX - 1].op = FETCH_OP_END; |
354 | 372 | ||
355 | ret = parse_probe_arg(arg, parg->type, &code, &code[FETCH_INSN_MAX - 1], | 373 | ret = parse_probe_arg(arg, parg->type, &code, &code[FETCH_INSN_MAX - 1], |
356 | is_return, is_kprobe, ftbl); | 374 | is_return, is_kprobe); |
357 | if (ret) | 375 | if (ret) |
358 | goto fail; | 376 | goto fail; |
359 | 377 | ||
diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 42c724a7ad11..5c262ed6347c 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h | |||
@@ -184,9 +184,6 @@ DECLARE_BASIC_PRINT_TYPE_FUNC(string); | |||
184 | 184 | ||
185 | #define ASSIGN_FETCH_TYPE_END {} | 185 | #define ASSIGN_FETCH_TYPE_END {} |
186 | 186 | ||
187 | #define FETCH_TYPE_STRING 0 | ||
188 | #define FETCH_TYPE_STRSIZE 1 | ||
189 | |||
190 | #ifdef CONFIG_KPROBE_EVENTS | 187 | #ifdef CONFIG_KPROBE_EVENTS |
191 | bool trace_kprobe_on_func_entry(struct trace_event_call *call); | 188 | bool trace_kprobe_on_func_entry(struct trace_event_call *call); |
192 | bool trace_kprobe_error_injectable(struct trace_event_call *call); | 189 | bool trace_kprobe_error_injectable(struct trace_event_call *call); |
@@ -261,8 +258,7 @@ find_event_file_link(struct trace_probe *tp, struct trace_event_file *file) | |||
261 | } | 258 | } |
262 | 259 | ||
263 | extern int traceprobe_parse_probe_arg(char *arg, ssize_t *size, | 260 | extern int traceprobe_parse_probe_arg(char *arg, ssize_t *size, |
264 | struct probe_arg *parg, bool is_return, bool is_kprobe, | 261 | struct probe_arg *parg, bool is_return, bool is_kprobe); |
265 | const struct fetch_type *ftbl); | ||
266 | 262 | ||
267 | extern int traceprobe_conflict_field_name(const char *name, | 263 | extern int traceprobe_conflict_field_name(const char *name, |
268 | struct probe_arg *args, int narg); | 264 | struct probe_arg *args, int narg); |
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index e076f89ab33a..7772fec84c12 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c | |||
@@ -161,30 +161,6 @@ static unsigned long translate_user_vaddr(unsigned long file_offset) | |||
161 | return base_addr + file_offset; | 161 | return base_addr + file_offset; |
162 | } | 162 | } |
163 | 163 | ||
164 | /* Fetch type information table */ | ||
165 | static const struct fetch_type uprobes_fetch_type_table[] = { | ||
166 | /* Special types */ | ||
167 | [FETCH_TYPE_STRING] = __ASSIGN_FETCH_TYPE("string", string, string, | ||
168 | sizeof(u32), 1, "__data_loc char[]"), | ||
169 | [FETCH_TYPE_STRSIZE] = __ASSIGN_FETCH_TYPE("string_size", u32, | ||
170 | string_size, sizeof(u32), 0, "u32"), | ||
171 | /* Basic types */ | ||
172 | ASSIGN_FETCH_TYPE(u8, u8, 0), | ||
173 | ASSIGN_FETCH_TYPE(u16, u16, 0), | ||
174 | ASSIGN_FETCH_TYPE(u32, u32, 0), | ||
175 | ASSIGN_FETCH_TYPE(u64, u64, 0), | ||
176 | ASSIGN_FETCH_TYPE(s8, u8, 1), | ||
177 | ASSIGN_FETCH_TYPE(s16, u16, 1), | ||
178 | ASSIGN_FETCH_TYPE(s32, u32, 1), | ||
179 | ASSIGN_FETCH_TYPE(s64, u64, 1), | ||
180 | ASSIGN_FETCH_TYPE_ALIAS(x8, u8, u8, 0), | ||
181 | ASSIGN_FETCH_TYPE_ALIAS(x16, u16, u16, 0), | ||
182 | ASSIGN_FETCH_TYPE_ALIAS(x32, u32, u32, 0), | ||
183 | ASSIGN_FETCH_TYPE_ALIAS(x64, u64, u64, 0), | ||
184 | |||
185 | ASSIGN_FETCH_TYPE_END | ||
186 | }; | ||
187 | |||
188 | /* Note that we don't verify it, since the code does not come from user space */ | 164 | /* Note that we don't verify it, since the code does not come from user space */ |
189 | static int | 165 | static int |
190 | process_fetch_insn(struct fetch_insn *code, struct pt_regs *regs, void *dest, | 166 | process_fetch_insn(struct fetch_insn *code, struct pt_regs *regs, void *dest, |
@@ -621,8 +597,7 @@ static int create_trace_uprobe(int argc, char **argv) | |||
621 | 597 | ||
622 | /* Parse fetch argument */ | 598 | /* Parse fetch argument */ |
623 | ret = traceprobe_parse_probe_arg(arg, &tu->tp.size, parg, | 599 | ret = traceprobe_parse_probe_arg(arg, &tu->tp.size, parg, |
624 | is_return, false, | 600 | is_return, false); |
625 | uprobes_fetch_type_table); | ||
626 | if (ret) { | 601 | if (ret) { |
627 | pr_info("Parse error at argument[%d]. (%d)\n", i, ret); | 602 | pr_info("Parse error at argument[%d]. (%d)\n", i, ret); |
628 | goto error; | 603 | goto error; |