diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-06 12:30:52 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-06 12:30:52 -0400 |
commit | 4aed2fd8e3181fea7c09ba79cf64e7e3f4413bf9 (patch) | |
tree | 1f69733e5daab4915a76a41de0e4d1dc61e12cfb /tools/perf/util/probe-event.c | |
parent | 3a3527b6461b1298cc53ce72f336346739297ac8 (diff) | |
parent | fc9ea5a1e53ee54f681e226d735008e2a6f8f470 (diff) |
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (162 commits)
tracing/kprobes: unregister_trace_probe needs to be called under mutex
perf: expose event__process function
perf events: Fix mmap offset determination
perf, powerpc: fsl_emb: Restore setting perf_sample_data.period
perf, powerpc: Convert the FSL driver to use local64_t
perf tools: Don't keep unreferenced maps when unmaps are detected
perf session: Invalidate last_match when removing threads from rb_tree
perf session: Free the ref_reloc_sym memory at the right place
x86,mmiotrace: Add support for tracing STOS instruction
perf, sched migration: Librarize task states and event headers helpers
perf, sched migration: Librarize the GUI class
perf, sched migration: Make the GUI class client agnostic
perf, sched migration: Make it vertically scrollable
perf, sched migration: Parameterize cpu height and spacing
perf, sched migration: Fix key bindings
perf, sched migration: Ignore unhandled task states
perf, sched migration: Handle ignored migrate out events
perf: New migration tool overview
tracing: Drop cpparg() macro
perf: Use tracepoint_synchronize_unregister() to flush any pending tracepoint call
...
Fix up trivial conflicts in Makefile and drivers/cpufreq/cpufreq.c
Diffstat (limited to 'tools/perf/util/probe-event.c')
-rw-r--r-- | tools/perf/util/probe-event.c | 271 |
1 files changed, 187 insertions, 84 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 914c67095d96..2e665cb84055 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * probe-event.c : perf-probe definition to kprobe_events format converter | 2 | * probe-event.c : perf-probe definition to probe_events format converter |
3 | * | 3 | * |
4 | * Written by Masami Hiramatsu <mhiramat@redhat.com> | 4 | * Written by Masami Hiramatsu <mhiramat@redhat.com> |
5 | * | 5 | * |
@@ -120,8 +120,11 @@ static int open_vmlinux(void) | |||
120 | return open(machine.vmlinux_maps[MAP__FUNCTION]->dso->long_name, O_RDONLY); | 120 | return open(machine.vmlinux_maps[MAP__FUNCTION]->dso->long_name, O_RDONLY); |
121 | } | 121 | } |
122 | 122 | ||
123 | /* Convert trace point to probe point with debuginfo */ | 123 | /* |
124 | static int convert_to_perf_probe_point(struct kprobe_trace_point *tp, | 124 | * Convert trace point to probe point with debuginfo |
125 | * Currently only handles kprobes. | ||
126 | */ | ||
127 | static int kprobe_convert_to_perf_probe(struct probe_trace_point *tp, | ||
125 | struct perf_probe_point *pp) | 128 | struct perf_probe_point *pp) |
126 | { | 129 | { |
127 | struct symbol *sym; | 130 | struct symbol *sym; |
@@ -151,8 +154,8 @@ static int convert_to_perf_probe_point(struct kprobe_trace_point *tp, | |||
151 | } | 154 | } |
152 | 155 | ||
153 | /* Try to find perf_probe_event with debuginfo */ | 156 | /* Try to find perf_probe_event with debuginfo */ |
154 | static int try_to_find_kprobe_trace_events(struct perf_probe_event *pev, | 157 | static int try_to_find_probe_trace_events(struct perf_probe_event *pev, |
155 | struct kprobe_trace_event **tevs, | 158 | struct probe_trace_event **tevs, |
156 | int max_tevs) | 159 | int max_tevs) |
157 | { | 160 | { |
158 | bool need_dwarf = perf_probe_event_need_dwarf(pev); | 161 | bool need_dwarf = perf_probe_event_need_dwarf(pev); |
@@ -169,11 +172,11 @@ static int try_to_find_kprobe_trace_events(struct perf_probe_event *pev, | |||
169 | } | 172 | } |
170 | 173 | ||
171 | /* Searching trace events corresponding to probe event */ | 174 | /* Searching trace events corresponding to probe event */ |
172 | ntevs = find_kprobe_trace_events(fd, pev, tevs, max_tevs); | 175 | ntevs = find_probe_trace_events(fd, pev, tevs, max_tevs); |
173 | close(fd); | 176 | close(fd); |
174 | 177 | ||
175 | if (ntevs > 0) { /* Succeeded to find trace events */ | 178 | if (ntevs > 0) { /* Succeeded to find trace events */ |
176 | pr_debug("find %d kprobe_trace_events.\n", ntevs); | 179 | pr_debug("find %d probe_trace_events.\n", ntevs); |
177 | return ntevs; | 180 | return ntevs; |
178 | } | 181 | } |
179 | 182 | ||
@@ -195,6 +198,65 @@ static int try_to_find_kprobe_trace_events(struct perf_probe_event *pev, | |||
195 | return ntevs; | 198 | return ntevs; |
196 | } | 199 | } |
197 | 200 | ||
201 | /* | ||
202 | * Find a src file from a DWARF tag path. Prepend optional source path prefix | ||
203 | * and chop off leading directories that do not exist. Result is passed back as | ||
204 | * a newly allocated path on success. | ||
205 | * Return 0 if file was found and readable, -errno otherwise. | ||
206 | */ | ||
207 | static int get_real_path(const char *raw_path, const char *comp_dir, | ||
208 | char **new_path) | ||
209 | { | ||
210 | const char *prefix = symbol_conf.source_prefix; | ||
211 | |||
212 | if (!prefix) { | ||
213 | if (raw_path[0] != '/' && comp_dir) | ||
214 | /* If not an absolute path, try to use comp_dir */ | ||
215 | prefix = comp_dir; | ||
216 | else { | ||
217 | if (access(raw_path, R_OK) == 0) { | ||
218 | *new_path = strdup(raw_path); | ||
219 | return 0; | ||
220 | } else | ||
221 | return -errno; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | *new_path = malloc((strlen(prefix) + strlen(raw_path) + 2)); | ||
226 | if (!*new_path) | ||
227 | return -ENOMEM; | ||
228 | |||
229 | for (;;) { | ||
230 | sprintf(*new_path, "%s/%s", prefix, raw_path); | ||
231 | |||
232 | if (access(*new_path, R_OK) == 0) | ||
233 | return 0; | ||
234 | |||
235 | if (!symbol_conf.source_prefix) | ||
236 | /* In case of searching comp_dir, don't retry */ | ||
237 | return -errno; | ||
238 | |||
239 | switch (errno) { | ||
240 | case ENAMETOOLONG: | ||
241 | case ENOENT: | ||
242 | case EROFS: | ||
243 | case EFAULT: | ||
244 | raw_path = strchr(++raw_path, '/'); | ||
245 | if (!raw_path) { | ||
246 | free(*new_path); | ||
247 | *new_path = NULL; | ||
248 | return -ENOENT; | ||
249 | } | ||
250 | continue; | ||
251 | |||
252 | default: | ||
253 | free(*new_path); | ||
254 | *new_path = NULL; | ||
255 | return -errno; | ||
256 | } | ||
257 | } | ||
258 | } | ||
259 | |||
198 | #define LINEBUF_SIZE 256 | 260 | #define LINEBUF_SIZE 256 |
199 | #define NR_ADDITIONAL_LINES 2 | 261 | #define NR_ADDITIONAL_LINES 2 |
200 | 262 | ||
@@ -244,6 +306,7 @@ int show_line_range(struct line_range *lr) | |||
244 | struct line_node *ln; | 306 | struct line_node *ln; |
245 | FILE *fp; | 307 | FILE *fp; |
246 | int fd, ret; | 308 | int fd, ret; |
309 | char *tmp; | ||
247 | 310 | ||
248 | /* Search a line range */ | 311 | /* Search a line range */ |
249 | ret = init_vmlinux(); | 312 | ret = init_vmlinux(); |
@@ -266,6 +329,15 @@ int show_line_range(struct line_range *lr) | |||
266 | return ret; | 329 | return ret; |
267 | } | 330 | } |
268 | 331 | ||
332 | /* Convert source file path */ | ||
333 | tmp = lr->path; | ||
334 | ret = get_real_path(tmp, lr->comp_dir, &lr->path); | ||
335 | free(tmp); /* Free old path */ | ||
336 | if (ret < 0) { | ||
337 | pr_warning("Failed to find source file. (%d)\n", ret); | ||
338 | return ret; | ||
339 | } | ||
340 | |||
269 | setup_pager(); | 341 | setup_pager(); |
270 | 342 | ||
271 | if (lr->function) | 343 | if (lr->function) |
@@ -308,8 +380,8 @@ end: | |||
308 | 380 | ||
309 | #else /* !DWARF_SUPPORT */ | 381 | #else /* !DWARF_SUPPORT */ |
310 | 382 | ||
311 | static int convert_to_perf_probe_point(struct kprobe_trace_point *tp, | 383 | static int kprobe_convert_to_perf_probe(struct probe_trace_point *tp, |
312 | struct perf_probe_point *pp) | 384 | struct perf_probe_point *pp) |
313 | { | 385 | { |
314 | pp->function = strdup(tp->symbol); | 386 | pp->function = strdup(tp->symbol); |
315 | if (pp->function == NULL) | 387 | if (pp->function == NULL) |
@@ -320,8 +392,8 @@ static int convert_to_perf_probe_point(struct kprobe_trace_point *tp, | |||
320 | return 0; | 392 | return 0; |
321 | } | 393 | } |
322 | 394 | ||
323 | static int try_to_find_kprobe_trace_events(struct perf_probe_event *pev, | 395 | static int try_to_find_probe_trace_events(struct perf_probe_event *pev, |
324 | struct kprobe_trace_event **tevs __unused, | 396 | struct probe_trace_event **tevs __unused, |
325 | int max_tevs __unused) | 397 | int max_tevs __unused) |
326 | { | 398 | { |
327 | if (perf_probe_event_need_dwarf(pev)) { | 399 | if (perf_probe_event_need_dwarf(pev)) { |
@@ -557,7 +629,7 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev) | |||
557 | /* Parse perf-probe event argument */ | 629 | /* Parse perf-probe event argument */ |
558 | static int parse_perf_probe_arg(char *str, struct perf_probe_arg *arg) | 630 | static int parse_perf_probe_arg(char *str, struct perf_probe_arg *arg) |
559 | { | 631 | { |
560 | char *tmp; | 632 | char *tmp, *goodname; |
561 | struct perf_probe_arg_field **fieldp; | 633 | struct perf_probe_arg_field **fieldp; |
562 | 634 | ||
563 | pr_debug("parsing arg: %s into ", str); | 635 | pr_debug("parsing arg: %s into ", str); |
@@ -580,7 +652,7 @@ static int parse_perf_probe_arg(char *str, struct perf_probe_arg *arg) | |||
580 | pr_debug("type:%s ", arg->type); | 652 | pr_debug("type:%s ", arg->type); |
581 | } | 653 | } |
582 | 654 | ||
583 | tmp = strpbrk(str, "-."); | 655 | tmp = strpbrk(str, "-.["); |
584 | if (!is_c_varname(str) || !tmp) { | 656 | if (!is_c_varname(str) || !tmp) { |
585 | /* A variable, register, symbol or special value */ | 657 | /* A variable, register, symbol or special value */ |
586 | arg->var = strdup(str); | 658 | arg->var = strdup(str); |
@@ -590,10 +662,11 @@ static int parse_perf_probe_arg(char *str, struct perf_probe_arg *arg) | |||
590 | return 0; | 662 | return 0; |
591 | } | 663 | } |
592 | 664 | ||
593 | /* Structure fields */ | 665 | /* Structure fields or array element */ |
594 | arg->var = strndup(str, tmp - str); | 666 | arg->var = strndup(str, tmp - str); |
595 | if (arg->var == NULL) | 667 | if (arg->var == NULL) |
596 | return -ENOMEM; | 668 | return -ENOMEM; |
669 | goodname = arg->var; | ||
597 | pr_debug("%s, ", arg->var); | 670 | pr_debug("%s, ", arg->var); |
598 | fieldp = &arg->field; | 671 | fieldp = &arg->field; |
599 | 672 | ||
@@ -601,22 +674,38 @@ static int parse_perf_probe_arg(char *str, struct perf_probe_arg *arg) | |||
601 | *fieldp = zalloc(sizeof(struct perf_probe_arg_field)); | 674 | *fieldp = zalloc(sizeof(struct perf_probe_arg_field)); |
602 | if (*fieldp == NULL) | 675 | if (*fieldp == NULL) |
603 | return -ENOMEM; | 676 | return -ENOMEM; |
604 | if (*tmp == '.') { | 677 | if (*tmp == '[') { /* Array */ |
605 | str = tmp + 1; | 678 | str = tmp; |
606 | (*fieldp)->ref = false; | 679 | (*fieldp)->index = strtol(str + 1, &tmp, 0); |
607 | } else if (tmp[1] == '>') { | ||
608 | str = tmp + 2; | ||
609 | (*fieldp)->ref = true; | 680 | (*fieldp)->ref = true; |
610 | } else { | 681 | if (*tmp != ']' || tmp == str + 1) { |
611 | semantic_error("Argument parse error: %s\n", str); | 682 | semantic_error("Array index must be a" |
612 | return -EINVAL; | 683 | " number.\n"); |
684 | return -EINVAL; | ||
685 | } | ||
686 | tmp++; | ||
687 | if (*tmp == '\0') | ||
688 | tmp = NULL; | ||
689 | } else { /* Structure */ | ||
690 | if (*tmp == '.') { | ||
691 | str = tmp + 1; | ||
692 | (*fieldp)->ref = false; | ||
693 | } else if (tmp[1] == '>') { | ||
694 | str = tmp + 2; | ||
695 | (*fieldp)->ref = true; | ||
696 | } else { | ||
697 | semantic_error("Argument parse error: %s\n", | ||
698 | str); | ||
699 | return -EINVAL; | ||
700 | } | ||
701 | tmp = strpbrk(str, "-.["); | ||
613 | } | 702 | } |
614 | |||
615 | tmp = strpbrk(str, "-."); | ||
616 | if (tmp) { | 703 | if (tmp) { |
617 | (*fieldp)->name = strndup(str, tmp - str); | 704 | (*fieldp)->name = strndup(str, tmp - str); |
618 | if ((*fieldp)->name == NULL) | 705 | if ((*fieldp)->name == NULL) |
619 | return -ENOMEM; | 706 | return -ENOMEM; |
707 | if (*str != '[') | ||
708 | goodname = (*fieldp)->name; | ||
620 | pr_debug("%s(%d), ", (*fieldp)->name, (*fieldp)->ref); | 709 | pr_debug("%s(%d), ", (*fieldp)->name, (*fieldp)->ref); |
621 | fieldp = &(*fieldp)->next; | 710 | fieldp = &(*fieldp)->next; |
622 | } | 711 | } |
@@ -624,11 +713,13 @@ static int parse_perf_probe_arg(char *str, struct perf_probe_arg *arg) | |||
624 | (*fieldp)->name = strdup(str); | 713 | (*fieldp)->name = strdup(str); |
625 | if ((*fieldp)->name == NULL) | 714 | if ((*fieldp)->name == NULL) |
626 | return -ENOMEM; | 715 | return -ENOMEM; |
716 | if (*str != '[') | ||
717 | goodname = (*fieldp)->name; | ||
627 | pr_debug("%s(%d)\n", (*fieldp)->name, (*fieldp)->ref); | 718 | pr_debug("%s(%d)\n", (*fieldp)->name, (*fieldp)->ref); |
628 | 719 | ||
629 | /* If no name is specified, set the last field name */ | 720 | /* If no name is specified, set the last field name (not array index)*/ |
630 | if (!arg->name) { | 721 | if (!arg->name) { |
631 | arg->name = strdup((*fieldp)->name); | 722 | arg->name = strdup(goodname); |
632 | if (arg->name == NULL) | 723 | if (arg->name == NULL) |
633 | return -ENOMEM; | 724 | return -ENOMEM; |
634 | } | 725 | } |
@@ -693,16 +784,17 @@ bool perf_probe_event_need_dwarf(struct perf_probe_event *pev) | |||
693 | return false; | 784 | return false; |
694 | } | 785 | } |
695 | 786 | ||
696 | /* Parse kprobe_events event into struct probe_point */ | 787 | /* Parse probe_events event into struct probe_point */ |
697 | int parse_kprobe_trace_command(const char *cmd, struct kprobe_trace_event *tev) | 788 | static int parse_probe_trace_command(const char *cmd, |
789 | struct probe_trace_event *tev) | ||
698 | { | 790 | { |
699 | struct kprobe_trace_point *tp = &tev->point; | 791 | struct probe_trace_point *tp = &tev->point; |
700 | char pr; | 792 | char pr; |
701 | char *p; | 793 | char *p; |
702 | int ret, i, argc; | 794 | int ret, i, argc; |
703 | char **argv; | 795 | char **argv; |
704 | 796 | ||
705 | pr_debug("Parsing kprobe_events: %s\n", cmd); | 797 | pr_debug("Parsing probe_events: %s\n", cmd); |
706 | argv = argv_split(cmd, &argc); | 798 | argv = argv_split(cmd, &argc); |
707 | if (!argv) { | 799 | if (!argv) { |
708 | pr_debug("Failed to split arguments.\n"); | 800 | pr_debug("Failed to split arguments.\n"); |
@@ -734,7 +826,7 @@ int parse_kprobe_trace_command(const char *cmd, struct kprobe_trace_event *tev) | |||
734 | tp->offset = 0; | 826 | tp->offset = 0; |
735 | 827 | ||
736 | tev->nargs = argc - 2; | 828 | tev->nargs = argc - 2; |
737 | tev->args = zalloc(sizeof(struct kprobe_trace_arg) * tev->nargs); | 829 | tev->args = zalloc(sizeof(struct probe_trace_arg) * tev->nargs); |
738 | if (tev->args == NULL) { | 830 | if (tev->args == NULL) { |
739 | ret = -ENOMEM; | 831 | ret = -ENOMEM; |
740 | goto out; | 832 | goto out; |
@@ -776,8 +868,11 @@ int synthesize_perf_probe_arg(struct perf_probe_arg *pa, char *buf, size_t len) | |||
776 | len -= ret; | 868 | len -= ret; |
777 | 869 | ||
778 | while (field) { | 870 | while (field) { |
779 | ret = e_snprintf(tmp, len, "%s%s", field->ref ? "->" : ".", | 871 | if (field->name[0] == '[') |
780 | field->name); | 872 | ret = e_snprintf(tmp, len, "%s", field->name); |
873 | else | ||
874 | ret = e_snprintf(tmp, len, "%s%s", | ||
875 | field->ref ? "->" : ".", field->name); | ||
781 | if (ret <= 0) | 876 | if (ret <= 0) |
782 | goto error; | 877 | goto error; |
783 | tmp += ret; | 878 | tmp += ret; |
@@ -877,13 +972,13 @@ char *synthesize_perf_probe_command(struct perf_probe_event *pev) | |||
877 | } | 972 | } |
878 | #endif | 973 | #endif |
879 | 974 | ||
880 | static int __synthesize_kprobe_trace_arg_ref(struct kprobe_trace_arg_ref *ref, | 975 | static int __synthesize_probe_trace_arg_ref(struct probe_trace_arg_ref *ref, |
881 | char **buf, size_t *buflen, | 976 | char **buf, size_t *buflen, |
882 | int depth) | 977 | int depth) |
883 | { | 978 | { |
884 | int ret; | 979 | int ret; |
885 | if (ref->next) { | 980 | if (ref->next) { |
886 | depth = __synthesize_kprobe_trace_arg_ref(ref->next, buf, | 981 | depth = __synthesize_probe_trace_arg_ref(ref->next, buf, |
887 | buflen, depth + 1); | 982 | buflen, depth + 1); |
888 | if (depth < 0) | 983 | if (depth < 0) |
889 | goto out; | 984 | goto out; |
@@ -901,9 +996,10 @@ out: | |||
901 | 996 | ||
902 | } | 997 | } |
903 | 998 | ||
904 | static int synthesize_kprobe_trace_arg(struct kprobe_trace_arg *arg, | 999 | static int synthesize_probe_trace_arg(struct probe_trace_arg *arg, |
905 | char *buf, size_t buflen) | 1000 | char *buf, size_t buflen) |
906 | { | 1001 | { |
1002 | struct probe_trace_arg_ref *ref = arg->ref; | ||
907 | int ret, depth = 0; | 1003 | int ret, depth = 0; |
908 | char *tmp = buf; | 1004 | char *tmp = buf; |
909 | 1005 | ||
@@ -917,16 +1013,24 @@ static int synthesize_kprobe_trace_arg(struct kprobe_trace_arg *arg, | |||
917 | buf += ret; | 1013 | buf += ret; |
918 | buflen -= ret; | 1014 | buflen -= ret; |
919 | 1015 | ||
1016 | /* Special case: @XXX */ | ||
1017 | if (arg->value[0] == '@' && arg->ref) | ||
1018 | ref = ref->next; | ||
1019 | |||
920 | /* Dereferencing arguments */ | 1020 | /* Dereferencing arguments */ |
921 | if (arg->ref) { | 1021 | if (ref) { |
922 | depth = __synthesize_kprobe_trace_arg_ref(arg->ref, &buf, | 1022 | depth = __synthesize_probe_trace_arg_ref(ref, &buf, |
923 | &buflen, 1); | 1023 | &buflen, 1); |
924 | if (depth < 0) | 1024 | if (depth < 0) |
925 | return depth; | 1025 | return depth; |
926 | } | 1026 | } |
927 | 1027 | ||
928 | /* Print argument value */ | 1028 | /* Print argument value */ |
929 | ret = e_snprintf(buf, buflen, "%s", arg->value); | 1029 | if (arg->value[0] == '@' && arg->ref) |
1030 | ret = e_snprintf(buf, buflen, "%s%+ld", arg->value, | ||
1031 | arg->ref->offset); | ||
1032 | else | ||
1033 | ret = e_snprintf(buf, buflen, "%s", arg->value); | ||
930 | if (ret < 0) | 1034 | if (ret < 0) |
931 | return ret; | 1035 | return ret; |
932 | buf += ret; | 1036 | buf += ret; |
@@ -951,9 +1055,9 @@ static int synthesize_kprobe_trace_arg(struct kprobe_trace_arg *arg, | |||
951 | return buf - tmp; | 1055 | return buf - tmp; |
952 | } | 1056 | } |
953 | 1057 | ||
954 | char *synthesize_kprobe_trace_command(struct kprobe_trace_event *tev) | 1058 | char *synthesize_probe_trace_command(struct probe_trace_event *tev) |
955 | { | 1059 | { |
956 | struct kprobe_trace_point *tp = &tev->point; | 1060 | struct probe_trace_point *tp = &tev->point; |
957 | char *buf; | 1061 | char *buf; |
958 | int i, len, ret; | 1062 | int i, len, ret; |
959 | 1063 | ||
@@ -969,7 +1073,7 @@ char *synthesize_kprobe_trace_command(struct kprobe_trace_event *tev) | |||
969 | goto error; | 1073 | goto error; |
970 | 1074 | ||
971 | for (i = 0; i < tev->nargs; i++) { | 1075 | for (i = 0; i < tev->nargs; i++) { |
972 | ret = synthesize_kprobe_trace_arg(&tev->args[i], buf + len, | 1076 | ret = synthesize_probe_trace_arg(&tev->args[i], buf + len, |
973 | MAX_CMDLEN - len); | 1077 | MAX_CMDLEN - len); |
974 | if (ret <= 0) | 1078 | if (ret <= 0) |
975 | goto error; | 1079 | goto error; |
@@ -982,7 +1086,7 @@ error: | |||
982 | return NULL; | 1086 | return NULL; |
983 | } | 1087 | } |
984 | 1088 | ||
985 | int convert_to_perf_probe_event(struct kprobe_trace_event *tev, | 1089 | static int convert_to_perf_probe_event(struct probe_trace_event *tev, |
986 | struct perf_probe_event *pev) | 1090 | struct perf_probe_event *pev) |
987 | { | 1091 | { |
988 | char buf[64] = ""; | 1092 | char buf[64] = ""; |
@@ -995,7 +1099,7 @@ int convert_to_perf_probe_event(struct kprobe_trace_event *tev, | |||
995 | return -ENOMEM; | 1099 | return -ENOMEM; |
996 | 1100 | ||
997 | /* Convert trace_point to probe_point */ | 1101 | /* Convert trace_point to probe_point */ |
998 | ret = convert_to_perf_probe_point(&tev->point, &pev->point); | 1102 | ret = kprobe_convert_to_perf_probe(&tev->point, &pev->point); |
999 | if (ret < 0) | 1103 | if (ret < 0) |
1000 | return ret; | 1104 | return ret; |
1001 | 1105 | ||
@@ -1008,7 +1112,7 @@ int convert_to_perf_probe_event(struct kprobe_trace_event *tev, | |||
1008 | if (tev->args[i].name) | 1112 | if (tev->args[i].name) |
1009 | pev->args[i].name = strdup(tev->args[i].name); | 1113 | pev->args[i].name = strdup(tev->args[i].name); |
1010 | else { | 1114 | else { |
1011 | ret = synthesize_kprobe_trace_arg(&tev->args[i], | 1115 | ret = synthesize_probe_trace_arg(&tev->args[i], |
1012 | buf, 64); | 1116 | buf, 64); |
1013 | pev->args[i].name = strdup(buf); | 1117 | pev->args[i].name = strdup(buf); |
1014 | } | 1118 | } |
@@ -1059,9 +1163,9 @@ void clear_perf_probe_event(struct perf_probe_event *pev) | |||
1059 | memset(pev, 0, sizeof(*pev)); | 1163 | memset(pev, 0, sizeof(*pev)); |
1060 | } | 1164 | } |
1061 | 1165 | ||
1062 | void clear_kprobe_trace_event(struct kprobe_trace_event *tev) | 1166 | static void clear_probe_trace_event(struct probe_trace_event *tev) |
1063 | { | 1167 | { |
1064 | struct kprobe_trace_arg_ref *ref, *next; | 1168 | struct probe_trace_arg_ref *ref, *next; |
1065 | int i; | 1169 | int i; |
1066 | 1170 | ||
1067 | if (tev->event) | 1171 | if (tev->event) |
@@ -1122,7 +1226,7 @@ static int open_kprobe_events(bool readwrite) | |||
1122 | } | 1226 | } |
1123 | 1227 | ||
1124 | /* Get raw string list of current kprobe_events */ | 1228 | /* Get raw string list of current kprobe_events */ |
1125 | static struct strlist *get_kprobe_trace_command_rawlist(int fd) | 1229 | static struct strlist *get_probe_trace_command_rawlist(int fd) |
1126 | { | 1230 | { |
1127 | int ret, idx; | 1231 | int ret, idx; |
1128 | FILE *fp; | 1232 | FILE *fp; |
@@ -1190,7 +1294,7 @@ static int show_perf_probe_event(struct perf_probe_event *pev) | |||
1190 | int show_perf_probe_events(void) | 1294 | int show_perf_probe_events(void) |
1191 | { | 1295 | { |
1192 | int fd, ret; | 1296 | int fd, ret; |
1193 | struct kprobe_trace_event tev; | 1297 | struct probe_trace_event tev; |
1194 | struct perf_probe_event pev; | 1298 | struct perf_probe_event pev; |
1195 | struct strlist *rawlist; | 1299 | struct strlist *rawlist; |
1196 | struct str_node *ent; | 1300 | struct str_node *ent; |
@@ -1207,20 +1311,20 @@ int show_perf_probe_events(void) | |||
1207 | if (fd < 0) | 1311 | if (fd < 0) |
1208 | return fd; | 1312 | return fd; |
1209 | 1313 | ||
1210 | rawlist = get_kprobe_trace_command_rawlist(fd); | 1314 | rawlist = get_probe_trace_command_rawlist(fd); |
1211 | close(fd); | 1315 | close(fd); |
1212 | if (!rawlist) | 1316 | if (!rawlist) |
1213 | return -ENOENT; | 1317 | return -ENOENT; |
1214 | 1318 | ||
1215 | strlist__for_each(ent, rawlist) { | 1319 | strlist__for_each(ent, rawlist) { |
1216 | ret = parse_kprobe_trace_command(ent->s, &tev); | 1320 | ret = parse_probe_trace_command(ent->s, &tev); |
1217 | if (ret >= 0) { | 1321 | if (ret >= 0) { |
1218 | ret = convert_to_perf_probe_event(&tev, &pev); | 1322 | ret = convert_to_perf_probe_event(&tev, &pev); |
1219 | if (ret >= 0) | 1323 | if (ret >= 0) |
1220 | ret = show_perf_probe_event(&pev); | 1324 | ret = show_perf_probe_event(&pev); |
1221 | } | 1325 | } |
1222 | clear_perf_probe_event(&pev); | 1326 | clear_perf_probe_event(&pev); |
1223 | clear_kprobe_trace_event(&tev); | 1327 | clear_probe_trace_event(&tev); |
1224 | if (ret < 0) | 1328 | if (ret < 0) |
1225 | break; | 1329 | break; |
1226 | } | 1330 | } |
@@ -1230,20 +1334,19 @@ int show_perf_probe_events(void) | |||
1230 | } | 1334 | } |
1231 | 1335 | ||
1232 | /* Get current perf-probe event names */ | 1336 | /* Get current perf-probe event names */ |
1233 | static struct strlist *get_kprobe_trace_event_names(int fd, bool include_group) | 1337 | static struct strlist *get_probe_trace_event_names(int fd, bool include_group) |
1234 | { | 1338 | { |
1235 | char buf[128]; | 1339 | char buf[128]; |
1236 | struct strlist *sl, *rawlist; | 1340 | struct strlist *sl, *rawlist; |
1237 | struct str_node *ent; | 1341 | struct str_node *ent; |
1238 | struct kprobe_trace_event tev; | 1342 | struct probe_trace_event tev; |
1239 | int ret = 0; | 1343 | int ret = 0; |
1240 | 1344 | ||
1241 | memset(&tev, 0, sizeof(tev)); | 1345 | memset(&tev, 0, sizeof(tev)); |
1242 | 1346 | rawlist = get_probe_trace_command_rawlist(fd); | |
1243 | rawlist = get_kprobe_trace_command_rawlist(fd); | ||
1244 | sl = strlist__new(true, NULL); | 1347 | sl = strlist__new(true, NULL); |
1245 | strlist__for_each(ent, rawlist) { | 1348 | strlist__for_each(ent, rawlist) { |
1246 | ret = parse_kprobe_trace_command(ent->s, &tev); | 1349 | ret = parse_probe_trace_command(ent->s, &tev); |
1247 | if (ret < 0) | 1350 | if (ret < 0) |
1248 | break; | 1351 | break; |
1249 | if (include_group) { | 1352 | if (include_group) { |
@@ -1253,7 +1356,7 @@ static struct strlist *get_kprobe_trace_event_names(int fd, bool include_group) | |||
1253 | ret = strlist__add(sl, buf); | 1356 | ret = strlist__add(sl, buf); |
1254 | } else | 1357 | } else |
1255 | ret = strlist__add(sl, tev.event); | 1358 | ret = strlist__add(sl, tev.event); |
1256 | clear_kprobe_trace_event(&tev); | 1359 | clear_probe_trace_event(&tev); |
1257 | if (ret < 0) | 1360 | if (ret < 0) |
1258 | break; | 1361 | break; |
1259 | } | 1362 | } |
@@ -1266,13 +1369,13 @@ static struct strlist *get_kprobe_trace_event_names(int fd, bool include_group) | |||
1266 | return sl; | 1369 | return sl; |
1267 | } | 1370 | } |
1268 | 1371 | ||
1269 | static int write_kprobe_trace_event(int fd, struct kprobe_trace_event *tev) | 1372 | static int write_probe_trace_event(int fd, struct probe_trace_event *tev) |
1270 | { | 1373 | { |
1271 | int ret = 0; | 1374 | int ret = 0; |
1272 | char *buf = synthesize_kprobe_trace_command(tev); | 1375 | char *buf = synthesize_probe_trace_command(tev); |
1273 | 1376 | ||
1274 | if (!buf) { | 1377 | if (!buf) { |
1275 | pr_debug("Failed to synthesize kprobe trace event.\n"); | 1378 | pr_debug("Failed to synthesize probe trace event.\n"); |
1276 | return -EINVAL; | 1379 | return -EINVAL; |
1277 | } | 1380 | } |
1278 | 1381 | ||
@@ -1325,12 +1428,12 @@ static int get_new_event_name(char *buf, size_t len, const char *base, | |||
1325 | return ret; | 1428 | return ret; |
1326 | } | 1429 | } |
1327 | 1430 | ||
1328 | static int __add_kprobe_trace_events(struct perf_probe_event *pev, | 1431 | static int __add_probe_trace_events(struct perf_probe_event *pev, |
1329 | struct kprobe_trace_event *tevs, | 1432 | struct probe_trace_event *tevs, |
1330 | int ntevs, bool allow_suffix) | 1433 | int ntevs, bool allow_suffix) |
1331 | { | 1434 | { |
1332 | int i, fd, ret; | 1435 | int i, fd, ret; |
1333 | struct kprobe_trace_event *tev = NULL; | 1436 | struct probe_trace_event *tev = NULL; |
1334 | char buf[64]; | 1437 | char buf[64]; |
1335 | const char *event, *group; | 1438 | const char *event, *group; |
1336 | struct strlist *namelist; | 1439 | struct strlist *namelist; |
@@ -1339,7 +1442,7 @@ static int __add_kprobe_trace_events(struct perf_probe_event *pev, | |||
1339 | if (fd < 0) | 1442 | if (fd < 0) |
1340 | return fd; | 1443 | return fd; |
1341 | /* Get current event names */ | 1444 | /* Get current event names */ |
1342 | namelist = get_kprobe_trace_event_names(fd, false); | 1445 | namelist = get_probe_trace_event_names(fd, false); |
1343 | if (!namelist) { | 1446 | if (!namelist) { |
1344 | pr_debug("Failed to get current event list.\n"); | 1447 | pr_debug("Failed to get current event list.\n"); |
1345 | return -EIO; | 1448 | return -EIO; |
@@ -1374,7 +1477,7 @@ static int __add_kprobe_trace_events(struct perf_probe_event *pev, | |||
1374 | ret = -ENOMEM; | 1477 | ret = -ENOMEM; |
1375 | break; | 1478 | break; |
1376 | } | 1479 | } |
1377 | ret = write_kprobe_trace_event(fd, tev); | 1480 | ret = write_probe_trace_event(fd, tev); |
1378 | if (ret < 0) | 1481 | if (ret < 0) |
1379 | break; | 1482 | break; |
1380 | /* Add added event name to namelist */ | 1483 | /* Add added event name to namelist */ |
@@ -1411,21 +1514,21 @@ static int __add_kprobe_trace_events(struct perf_probe_event *pev, | |||
1411 | return ret; | 1514 | return ret; |
1412 | } | 1515 | } |
1413 | 1516 | ||
1414 | static int convert_to_kprobe_trace_events(struct perf_probe_event *pev, | 1517 | static int convert_to_probe_trace_events(struct perf_probe_event *pev, |
1415 | struct kprobe_trace_event **tevs, | 1518 | struct probe_trace_event **tevs, |
1416 | int max_tevs) | 1519 | int max_tevs) |
1417 | { | 1520 | { |
1418 | struct symbol *sym; | 1521 | struct symbol *sym; |
1419 | int ret = 0, i; | 1522 | int ret = 0, i; |
1420 | struct kprobe_trace_event *tev; | 1523 | struct probe_trace_event *tev; |
1421 | 1524 | ||
1422 | /* Convert perf_probe_event with debuginfo */ | 1525 | /* Convert perf_probe_event with debuginfo */ |
1423 | ret = try_to_find_kprobe_trace_events(pev, tevs, max_tevs); | 1526 | ret = try_to_find_probe_trace_events(pev, tevs, max_tevs); |
1424 | if (ret != 0) | 1527 | if (ret != 0) |
1425 | return ret; | 1528 | return ret; |
1426 | 1529 | ||
1427 | /* Allocate trace event buffer */ | 1530 | /* Allocate trace event buffer */ |
1428 | tev = *tevs = zalloc(sizeof(struct kprobe_trace_event)); | 1531 | tev = *tevs = zalloc(sizeof(struct probe_trace_event)); |
1429 | if (tev == NULL) | 1532 | if (tev == NULL) |
1430 | return -ENOMEM; | 1533 | return -ENOMEM; |
1431 | 1534 | ||
@@ -1438,7 +1541,7 @@ static int convert_to_kprobe_trace_events(struct perf_probe_event *pev, | |||
1438 | tev->point.offset = pev->point.offset; | 1541 | tev->point.offset = pev->point.offset; |
1439 | tev->nargs = pev->nargs; | 1542 | tev->nargs = pev->nargs; |
1440 | if (tev->nargs) { | 1543 | if (tev->nargs) { |
1441 | tev->args = zalloc(sizeof(struct kprobe_trace_arg) | 1544 | tev->args = zalloc(sizeof(struct probe_trace_arg) |
1442 | * tev->nargs); | 1545 | * tev->nargs); |
1443 | if (tev->args == NULL) { | 1546 | if (tev->args == NULL) { |
1444 | ret = -ENOMEM; | 1547 | ret = -ENOMEM; |
@@ -1479,7 +1582,7 @@ static int convert_to_kprobe_trace_events(struct perf_probe_event *pev, | |||
1479 | 1582 | ||
1480 | return 1; | 1583 | return 1; |
1481 | error: | 1584 | error: |
1482 | clear_kprobe_trace_event(tev); | 1585 | clear_probe_trace_event(tev); |
1483 | free(tev); | 1586 | free(tev); |
1484 | *tevs = NULL; | 1587 | *tevs = NULL; |
1485 | return ret; | 1588 | return ret; |
@@ -1487,7 +1590,7 @@ error: | |||
1487 | 1590 | ||
1488 | struct __event_package { | 1591 | struct __event_package { |
1489 | struct perf_probe_event *pev; | 1592 | struct perf_probe_event *pev; |
1490 | struct kprobe_trace_event *tevs; | 1593 | struct probe_trace_event *tevs; |
1491 | int ntevs; | 1594 | int ntevs; |
1492 | }; | 1595 | }; |
1493 | 1596 | ||
@@ -1510,7 +1613,7 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs, | |||
1510 | for (i = 0; i < npevs; i++) { | 1613 | for (i = 0; i < npevs; i++) { |
1511 | pkgs[i].pev = &pevs[i]; | 1614 | pkgs[i].pev = &pevs[i]; |
1512 | /* Convert with or without debuginfo */ | 1615 | /* Convert with or without debuginfo */ |
1513 | ret = convert_to_kprobe_trace_events(pkgs[i].pev, | 1616 | ret = convert_to_probe_trace_events(pkgs[i].pev, |
1514 | &pkgs[i].tevs, max_tevs); | 1617 | &pkgs[i].tevs, max_tevs); |
1515 | if (ret < 0) | 1618 | if (ret < 0) |
1516 | goto end; | 1619 | goto end; |
@@ -1519,24 +1622,24 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs, | |||
1519 | 1622 | ||
1520 | /* Loop 2: add all events */ | 1623 | /* Loop 2: add all events */ |
1521 | for (i = 0; i < npevs && ret >= 0; i++) | 1624 | for (i = 0; i < npevs && ret >= 0; i++) |
1522 | ret = __add_kprobe_trace_events(pkgs[i].pev, pkgs[i].tevs, | 1625 | ret = __add_probe_trace_events(pkgs[i].pev, pkgs[i].tevs, |
1523 | pkgs[i].ntevs, force_add); | 1626 | pkgs[i].ntevs, force_add); |
1524 | end: | 1627 | end: |
1525 | /* Loop 3: cleanup trace events */ | 1628 | /* Loop 3: cleanup trace events */ |
1526 | for (i = 0; i < npevs; i++) | 1629 | for (i = 0; i < npevs; i++) |
1527 | for (j = 0; j < pkgs[i].ntevs; j++) | 1630 | for (j = 0; j < pkgs[i].ntevs; j++) |
1528 | clear_kprobe_trace_event(&pkgs[i].tevs[j]); | 1631 | clear_probe_trace_event(&pkgs[i].tevs[j]); |
1529 | 1632 | ||
1530 | return ret; | 1633 | return ret; |
1531 | } | 1634 | } |
1532 | 1635 | ||
1533 | static int __del_trace_kprobe_event(int fd, struct str_node *ent) | 1636 | static int __del_trace_probe_event(int fd, struct str_node *ent) |
1534 | { | 1637 | { |
1535 | char *p; | 1638 | char *p; |
1536 | char buf[128]; | 1639 | char buf[128]; |
1537 | int ret; | 1640 | int ret; |
1538 | 1641 | ||
1539 | /* Convert from perf-probe event to trace-kprobe event */ | 1642 | /* Convert from perf-probe event to trace-probe event */ |
1540 | ret = e_snprintf(buf, 128, "-:%s", ent->s); | 1643 | ret = e_snprintf(buf, 128, "-:%s", ent->s); |
1541 | if (ret < 0) | 1644 | if (ret < 0) |
1542 | goto error; | 1645 | goto error; |
@@ -1562,7 +1665,7 @@ error: | |||
1562 | return ret; | 1665 | return ret; |
1563 | } | 1666 | } |
1564 | 1667 | ||
1565 | static int del_trace_kprobe_event(int fd, const char *group, | 1668 | static int del_trace_probe_event(int fd, const char *group, |
1566 | const char *event, struct strlist *namelist) | 1669 | const char *event, struct strlist *namelist) |
1567 | { | 1670 | { |
1568 | char buf[128]; | 1671 | char buf[128]; |
@@ -1579,7 +1682,7 @@ static int del_trace_kprobe_event(int fd, const char *group, | |||
1579 | strlist__for_each_safe(ent, n, namelist) | 1682 | strlist__for_each_safe(ent, n, namelist) |
1580 | if (strglobmatch(ent->s, buf)) { | 1683 | if (strglobmatch(ent->s, buf)) { |
1581 | found++; | 1684 | found++; |
1582 | ret = __del_trace_kprobe_event(fd, ent); | 1685 | ret = __del_trace_probe_event(fd, ent); |
1583 | if (ret < 0) | 1686 | if (ret < 0) |
1584 | break; | 1687 | break; |
1585 | strlist__remove(namelist, ent); | 1688 | strlist__remove(namelist, ent); |
@@ -1588,7 +1691,7 @@ static int del_trace_kprobe_event(int fd, const char *group, | |||
1588 | ent = strlist__find(namelist, buf); | 1691 | ent = strlist__find(namelist, buf); |
1589 | if (ent) { | 1692 | if (ent) { |
1590 | found++; | 1693 | found++; |
1591 | ret = __del_trace_kprobe_event(fd, ent); | 1694 | ret = __del_trace_probe_event(fd, ent); |
1592 | if (ret >= 0) | 1695 | if (ret >= 0) |
1593 | strlist__remove(namelist, ent); | 1696 | strlist__remove(namelist, ent); |
1594 | } | 1697 | } |
@@ -1612,7 +1715,7 @@ int del_perf_probe_events(struct strlist *dellist) | |||
1612 | return fd; | 1715 | return fd; |
1613 | 1716 | ||
1614 | /* Get current event names */ | 1717 | /* Get current event names */ |
1615 | namelist = get_kprobe_trace_event_names(fd, true); | 1718 | namelist = get_probe_trace_event_names(fd, true); |
1616 | if (namelist == NULL) | 1719 | if (namelist == NULL) |
1617 | return -EINVAL; | 1720 | return -EINVAL; |
1618 | 1721 | ||
@@ -1633,7 +1736,7 @@ int del_perf_probe_events(struct strlist *dellist) | |||
1633 | event = str; | 1736 | event = str; |
1634 | } | 1737 | } |
1635 | pr_debug("Group: %s, Event: %s\n", group, event); | 1738 | pr_debug("Group: %s, Event: %s\n", group, event); |
1636 | ret = del_trace_kprobe_event(fd, group, event, namelist); | 1739 | ret = del_trace_probe_event(fd, group, event, namelist); |
1637 | free(str); | 1740 | free(str); |
1638 | if (ret < 0) | 1741 | if (ret < 0) |
1639 | break; | 1742 | break; |