Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 1 | /* |
| 2 | * builtin-probe.c |
| 3 | * |
| 4 | * Builtin probe command: Set up probe events by C expression |
| 5 | * |
| 6 | * Written by Masami Hiramatsu <mhiramat@redhat.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 21 | * |
| 22 | */ |
| 23 | #define _GNU_SOURCE |
| 24 | #include <sys/utsname.h> |
| 25 | #include <sys/types.h> |
| 26 | #include <sys/stat.h> |
| 27 | #include <fcntl.h> |
| 28 | #include <errno.h> |
| 29 | #include <stdio.h> |
| 30 | #include <unistd.h> |
| 31 | #include <stdlib.h> |
| 32 | #include <string.h> |
| 33 | |
| 34 | #undef _GNU_SOURCE |
| 35 | #include "perf.h" |
| 36 | #include "builtin.h" |
| 37 | #include "util/util.h" |
Masami Hiramatsu | fa28244 | 2009-12-08 17:03:23 -0500 | [diff] [blame] | 38 | #include "util/strlist.h" |
Masami Hiramatsu | 89c69c0 | 2009-10-16 20:08:10 -0400 | [diff] [blame] | 39 | #include "util/event.h" |
| 40 | #include "util/debug.h" |
Masami Hiramatsu | a128168 | 2009-12-15 10:32:33 -0500 | [diff] [blame^] | 41 | #include "util/symbol.h" |
| 42 | #include "util/thread.h" |
| 43 | #include "util/session.h" |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 44 | #include "util/parse-options.h" |
| 45 | #include "util/parse-events.h" /* For debugfs_path */ |
| 46 | #include "util/probe-finder.h" |
Masami Hiramatsu | 50656ee | 2009-11-30 19:19:58 -0500 | [diff] [blame] | 47 | #include "util/probe-event.h" |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 48 | |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 49 | #define MAX_PATH_LEN 256 |
| 50 | #define MAX_PROBES 128 |
| 51 | |
| 52 | /* Session management structure */ |
| 53 | static struct { |
Masami Hiramatsu | fac13fd | 2009-12-15 10:31:14 -0500 | [diff] [blame] | 54 | bool need_dwarf; |
| 55 | bool list_events; |
Masami Hiramatsu | d761b08 | 2009-12-15 10:32:25 -0500 | [diff] [blame] | 56 | bool force_add; |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 57 | int nr_probe; |
| 58 | struct probe_point probes[MAX_PROBES]; |
Masami Hiramatsu | fa28244 | 2009-12-08 17:03:23 -0500 | [diff] [blame] | 59 | struct strlist *dellist; |
Masami Hiramatsu | a128168 | 2009-12-15 10:32:33 -0500 | [diff] [blame^] | 60 | struct symbol_conf conf; |
| 61 | struct perf_session *psession; |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 62 | } session; |
| 63 | |
Masami Hiramatsu | 4de189f | 2009-11-30 19:20:17 -0500 | [diff] [blame] | 64 | |
Masami Hiramatsu | 253977b | 2009-10-27 16:43:10 -0400 | [diff] [blame] | 65 | /* Parse an event definition. Note that any error must die. */ |
| 66 | static void parse_probe_event(const char *str) |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 67 | { |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 68 | struct probe_point *pp = &session.probes[session.nr_probe]; |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 69 | |
Arnaldo Carvalho de Melo | b7cb10e | 2009-10-21 17:34:06 -0200 | [diff] [blame] | 70 | pr_debug("probe-definition(%d): %s\n", session.nr_probe, str); |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 71 | if (++session.nr_probe == MAX_PROBES) |
Masami Hiramatsu | 50656ee | 2009-11-30 19:19:58 -0500 | [diff] [blame] | 72 | die("Too many probes (> %d) are specified.", MAX_PROBES); |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 73 | |
Masami Hiramatsu | 50656ee | 2009-11-30 19:19:58 -0500 | [diff] [blame] | 74 | /* Parse perf-probe event into probe_point */ |
Masami Hiramatsu | fac13fd | 2009-12-15 10:31:14 -0500 | [diff] [blame] | 75 | parse_perf_probe_event(str, pp, &session.need_dwarf); |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 76 | |
Arnaldo Carvalho de Melo | b7cb10e | 2009-10-21 17:34:06 -0200 | [diff] [blame] | 77 | pr_debug("%d arguments\n", pp->nr_args); |
Masami Hiramatsu | 46ab492 | 2009-10-27 16:43:02 -0400 | [diff] [blame] | 78 | } |
| 79 | |
Masami Hiramatsu | d1bde3f | 2009-12-08 17:02:54 -0500 | [diff] [blame] | 80 | static void parse_probe_event_argv(int argc, const char **argv) |
| 81 | { |
| 82 | int i, len; |
| 83 | char *buf; |
| 84 | |
| 85 | /* Bind up rest arguments */ |
| 86 | len = 0; |
| 87 | for (i = 0; i < argc; i++) |
| 88 | len += strlen(argv[i]) + 1; |
| 89 | buf = zalloc(len + 1); |
| 90 | if (!buf) |
| 91 | die("Failed to allocate memory for binding arguments."); |
| 92 | len = 0; |
| 93 | for (i = 0; i < argc; i++) |
| 94 | len += sprintf(&buf[len], "%s ", argv[i]); |
| 95 | parse_probe_event(buf); |
| 96 | free(buf); |
| 97 | } |
| 98 | |
Masami Hiramatsu | 253977b | 2009-10-27 16:43:10 -0400 | [diff] [blame] | 99 | static int opt_add_probe_event(const struct option *opt __used, |
Masami Hiramatsu | 46ab492 | 2009-10-27 16:43:02 -0400 | [diff] [blame] | 100 | const char *str, int unset __used) |
| 101 | { |
| 102 | if (str) |
Masami Hiramatsu | 253977b | 2009-10-27 16:43:10 -0400 | [diff] [blame] | 103 | parse_probe_event(str); |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 104 | return 0; |
| 105 | } |
| 106 | |
Masami Hiramatsu | fa28244 | 2009-12-08 17:03:23 -0500 | [diff] [blame] | 107 | static int opt_del_probe_event(const struct option *opt __used, |
| 108 | const char *str, int unset __used) |
| 109 | { |
| 110 | if (str) { |
| 111 | if (!session.dellist) |
| 112 | session.dellist = strlist__new(true, NULL); |
| 113 | strlist__add(session.dellist, str); |
| 114 | } |
| 115 | return 0; |
| 116 | } |
| 117 | |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 118 | #ifndef NO_LIBDWARF |
Masami Hiramatsu | a128168 | 2009-12-15 10:32:33 -0500 | [diff] [blame^] | 119 | static int open_vmlinux(void) |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 120 | { |
Masami Hiramatsu | a128168 | 2009-12-15 10:32:33 -0500 | [diff] [blame^] | 121 | struct map *kmap; |
| 122 | kmap = map_groups__find_by_name(&session.psession->kmaps, |
| 123 | MAP__FUNCTION, "[kernel.kallsyms]"); |
| 124 | if (!kmap) { |
| 125 | pr_debug("Could not find kernel map.\n"); |
| 126 | return -ENOENT; |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 127 | } |
Masami Hiramatsu | a128168 | 2009-12-15 10:32:33 -0500 | [diff] [blame^] | 128 | if (map__load(kmap, session.psession, NULL) < 0) { |
| 129 | pr_debug("Failed to load kernel map.\n"); |
| 130 | return -EINVAL; |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 131 | } |
Masami Hiramatsu | a128168 | 2009-12-15 10:32:33 -0500 | [diff] [blame^] | 132 | pr_debug("Try to open %s\n", kmap->dso->long_name); |
| 133 | return open(kmap->dso->long_name, O_RDONLY); |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 134 | } |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 135 | #endif |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 136 | |
| 137 | static const char * const probe_usage[] = { |
Masami Hiramatsu | 46ab492 | 2009-10-27 16:43:02 -0400 | [diff] [blame] | 138 | "perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]", |
| 139 | "perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]", |
Masami Hiramatsu | fa28244 | 2009-12-08 17:03:23 -0500 | [diff] [blame] | 140 | "perf probe [<options>] --del '[GROUP:]EVENT' ...", |
Masami Hiramatsu | 4de189f | 2009-11-30 19:20:17 -0500 | [diff] [blame] | 141 | "perf probe --list", |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 142 | NULL |
| 143 | }; |
| 144 | |
| 145 | static const struct option options[] = { |
Masami Hiramatsu | 89c69c0 | 2009-10-16 20:08:10 -0400 | [diff] [blame] | 146 | OPT_BOOLEAN('v', "verbose", &verbose, |
| 147 | "be more verbose (show parsed arguments, etc)"), |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 148 | #ifndef NO_LIBDWARF |
Masami Hiramatsu | a128168 | 2009-12-15 10:32:33 -0500 | [diff] [blame^] | 149 | OPT_STRING('k', "vmlinux", &session.conf.vmlinux_name, |
| 150 | "file", "vmlinux pathname"), |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 151 | #endif |
Masami Hiramatsu | fac13fd | 2009-12-15 10:31:14 -0500 | [diff] [blame] | 152 | OPT_BOOLEAN('l', "list", &session.list_events, |
| 153 | "list up current probe events"), |
Masami Hiramatsu | fa28244 | 2009-12-08 17:03:23 -0500 | [diff] [blame] | 154 | OPT_CALLBACK('d', "del", NULL, "[GROUP:]EVENT", "delete a probe event.", |
| 155 | opt_del_probe_event), |
Masami Hiramatsu | 46ab492 | 2009-10-27 16:43:02 -0400 | [diff] [blame] | 156 | OPT_CALLBACK('a', "add", NULL, |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 157 | #ifdef NO_LIBDWARF |
Masami Hiramatsu | af663d7 | 2009-12-15 10:32:18 -0500 | [diff] [blame] | 158 | "[EVENT=]FUNC[+OFFS|%return] [ARG ...]", |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 159 | #else |
Masami Hiramatsu | af663d7 | 2009-12-15 10:32:18 -0500 | [diff] [blame] | 160 | "[EVENT=]FUNC[+OFFS|%return|:RLN][@SRC]|SRC:ALN [ARG ...]", |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 161 | #endif |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 162 | "probe point definition, where\n" |
Masami Hiramatsu | af663d7 | 2009-12-15 10:32:18 -0500 | [diff] [blame] | 163 | "\t\tGROUP:\tGroup name (optional)\n" |
| 164 | "\t\tEVENT:\tEvent name\n" |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 165 | "\t\tFUNC:\tFunction name\n" |
| 166 | "\t\tOFFS:\tOffset from function entry (in byte)\n" |
Masami Hiramatsu | 253977b | 2009-10-27 16:43:10 -0400 | [diff] [blame] | 167 | "\t\t%return:\tPut the probe at function return\n" |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 168 | #ifdef NO_LIBDWARF |
| 169 | "\t\tARG:\tProbe argument (only \n" |
| 170 | #else |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 171 | "\t\tSRC:\tSource code path\n" |
Masami Hiramatsu | b0ef073 | 2009-10-27 16:43:19 -0400 | [diff] [blame] | 172 | "\t\tRLN:\tRelative line number from function entry.\n" |
| 173 | "\t\tALN:\tAbsolute line number in file.\n" |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 174 | "\t\tARG:\tProbe argument (local variable name or\n" |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 175 | #endif |
Masami Hiramatsu | 50656ee | 2009-11-30 19:19:58 -0500 | [diff] [blame] | 176 | "\t\t\tkprobe-tracer argument format.)\n", |
Masami Hiramatsu | 253977b | 2009-10-27 16:43:10 -0400 | [diff] [blame] | 177 | opt_add_probe_event), |
Masami Hiramatsu | d761b08 | 2009-12-15 10:32:25 -0500 | [diff] [blame] | 178 | OPT_BOOLEAN('f', "force", &session.force_add, "forcibly add events" |
| 179 | " with existing name"), |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 180 | OPT_END() |
| 181 | }; |
| 182 | |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 183 | int cmd_probe(int argc, const char **argv, const char *prefix __used) |
| 184 | { |
Masami Hiramatsu | d1bde3f | 2009-12-08 17:02:54 -0500 | [diff] [blame] | 185 | int i, ret; |
Xiao Guangrong | bdad0db | 2009-12-02 16:08:41 +0800 | [diff] [blame] | 186 | #ifndef NO_LIBDWARF |
| 187 | int fd; |
| 188 | #endif |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 189 | struct probe_point *pp; |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 190 | |
| 191 | argc = parse_options(argc, argv, options, probe_usage, |
Masami Hiramatsu | 46ab492 | 2009-10-27 16:43:02 -0400 | [diff] [blame] | 192 | PARSE_OPT_STOP_AT_NON_OPTION); |
Masami Hiramatsu | ce11a60 | 2009-12-15 10:31:28 -0500 | [diff] [blame] | 193 | if (argc > 0) { |
| 194 | if (strcmp(argv[0], "-") == 0) { |
| 195 | pr_warning(" Error: '-' is not supported.\n"); |
| 196 | usage_with_options(probe_usage, options); |
| 197 | } |
Masami Hiramatsu | d1bde3f | 2009-12-08 17:02:54 -0500 | [diff] [blame] | 198 | parse_probe_event_argv(argc, argv); |
Masami Hiramatsu | ce11a60 | 2009-12-15 10:31:28 -0500 | [diff] [blame] | 199 | } |
Masami Hiramatsu | 46ab492 | 2009-10-27 16:43:02 -0400 | [diff] [blame] | 200 | |
Masami Hiramatsu | fac13fd | 2009-12-15 10:31:14 -0500 | [diff] [blame] | 201 | if ((!session.nr_probe && !session.dellist && !session.list_events)) |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 202 | usage_with_options(probe_usage, options); |
| 203 | |
Masami Hiramatsu | fac13fd | 2009-12-15 10:31:14 -0500 | [diff] [blame] | 204 | if (session.list_events) { |
Masami Hiramatsu | fa28244 | 2009-12-08 17:03:23 -0500 | [diff] [blame] | 205 | if (session.nr_probe != 0 || session.dellist) { |
| 206 | pr_warning(" Error: Don't use --list with" |
| 207 | " --add/--del.\n"); |
| 208 | usage_with_options(probe_usage, options); |
| 209 | } |
Masami Hiramatsu | 4de189f | 2009-11-30 19:20:17 -0500 | [diff] [blame] | 210 | show_perf_probe_events(); |
| 211 | return 0; |
| 212 | } |
| 213 | |
Masami Hiramatsu | fa28244 | 2009-12-08 17:03:23 -0500 | [diff] [blame] | 214 | if (session.dellist) { |
| 215 | del_trace_kprobe_events(session.dellist); |
| 216 | strlist__delete(session.dellist); |
| 217 | if (session.nr_probe == 0) |
| 218 | return 0; |
| 219 | } |
| 220 | |
Masami Hiramatsu | a128168 | 2009-12-15 10:32:33 -0500 | [diff] [blame^] | 221 | /* Initialize symbol maps for vmlinux */ |
| 222 | if (session.conf.vmlinux_name == NULL) |
| 223 | session.conf.try_vmlinux_path = true; |
| 224 | if (symbol__init(&session.conf) < 0) |
| 225 | die("Failed to init symbol map."); |
| 226 | session.psession = perf_session__new(NULL, O_WRONLY, false, |
| 227 | &session.conf); |
| 228 | if (session.psession == NULL) |
| 229 | die("Failed to init perf_session."); |
| 230 | |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 231 | if (session.need_dwarf) |
Masami Hiramatsu | a225a1d | 2009-11-03 19:12:30 -0500 | [diff] [blame] | 232 | #ifdef NO_LIBDWARF |
Masami Hiramatsu | 50656ee | 2009-11-30 19:19:58 -0500 | [diff] [blame] | 233 | die("Debuginfo-analysis is not supported"); |
Masami Hiramatsu | a225a1d | 2009-11-03 19:12:30 -0500 | [diff] [blame] | 234 | #else /* !NO_LIBDWARF */ |
Masami Hiramatsu | f41b1e4 | 2009-11-30 19:19:27 -0500 | [diff] [blame] | 235 | pr_debug("Some probes require debuginfo.\n"); |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 236 | |
Masami Hiramatsu | a128168 | 2009-12-15 10:32:33 -0500 | [diff] [blame^] | 237 | fd = open_vmlinux(); |
Masami Hiramatsu | a225a1d | 2009-11-03 19:12:30 -0500 | [diff] [blame] | 238 | if (fd < 0) { |
| 239 | if (session.need_dwarf) |
Masami Hiramatsu | f984f03 | 2009-12-08 17:03:09 -0500 | [diff] [blame] | 240 | die("Could not open debuginfo file."); |
Masami Hiramatsu | a225a1d | 2009-11-03 19:12:30 -0500 | [diff] [blame] | 241 | |
Masami Hiramatsu | d3a2dbf | 2009-12-07 12:00:59 -0500 | [diff] [blame] | 242 | pr_debug("Could not open vmlinux/module file." |
| 243 | " Try to use symbols.\n"); |
Masami Hiramatsu | a225a1d | 2009-11-03 19:12:30 -0500 | [diff] [blame] | 244 | goto end_dwarf; |
| 245 | } |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 246 | |
| 247 | /* Searching probe points */ |
Masami Hiramatsu | d1bde3f | 2009-12-08 17:02:54 -0500 | [diff] [blame] | 248 | for (i = 0; i < session.nr_probe; i++) { |
| 249 | pp = &session.probes[i]; |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 250 | if (pp->found) |
| 251 | continue; |
| 252 | |
| 253 | lseek(fd, SEEK_SET, 0); |
| 254 | ret = find_probepoint(fd, pp); |
Masami Hiramatsu | 411edfe | 2009-12-15 10:31:35 -0500 | [diff] [blame] | 255 | if (ret > 0) |
| 256 | continue; |
Masami Hiramatsu | a225a1d | 2009-11-03 19:12:30 -0500 | [diff] [blame] | 257 | if (ret == 0) /* No error but failed to find probe point. */ |
| 258 | die("No probe point found."); |
Masami Hiramatsu | 411edfe | 2009-12-15 10:31:35 -0500 | [diff] [blame] | 259 | /* Error path */ |
| 260 | if (session.need_dwarf) { |
| 261 | if (ret == -ENOENT) |
| 262 | pr_warning("No dwarf info found in the vmlinux - please rebuild with CONFIG_DEBUG_INFO=y.\n"); |
| 263 | die("Could not analyze debuginfo."); |
| 264 | } |
| 265 | pr_debug("An error occurred in debuginfo analysis." |
| 266 | " Try to use symbols.\n"); |
| 267 | break; |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 268 | } |
| 269 | close(fd); |
| 270 | |
Masami Hiramatsu | a225a1d | 2009-11-03 19:12:30 -0500 | [diff] [blame] | 271 | end_dwarf: |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 272 | #endif /* !NO_LIBDWARF */ |
| 273 | |
Masami Hiramatsu | a225a1d | 2009-11-03 19:12:30 -0500 | [diff] [blame] | 274 | /* Synthesize probes without dwarf */ |
Masami Hiramatsu | d1bde3f | 2009-12-08 17:02:54 -0500 | [diff] [blame] | 275 | for (i = 0; i < session.nr_probe; i++) { |
| 276 | pp = &session.probes[i]; |
Masami Hiramatsu | a225a1d | 2009-11-03 19:12:30 -0500 | [diff] [blame] | 277 | if (pp->found) /* This probe is already found. */ |
| 278 | continue; |
| 279 | |
Masami Hiramatsu | 50656ee | 2009-11-30 19:19:58 -0500 | [diff] [blame] | 280 | ret = synthesize_trace_kprobe_event(pp); |
Masami Hiramatsu | a225a1d | 2009-11-03 19:12:30 -0500 | [diff] [blame] | 281 | if (ret == -E2BIG) |
Masami Hiramatsu | 50656ee | 2009-11-30 19:19:58 -0500 | [diff] [blame] | 282 | die("probe point definition becomes too long."); |
Masami Hiramatsu | a225a1d | 2009-11-03 19:12:30 -0500 | [diff] [blame] | 283 | else if (ret < 0) |
| 284 | die("Failed to synthesize a probe point."); |
| 285 | } |
| 286 | |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 287 | /* Settng up probe points */ |
Masami Hiramatsu | d761b08 | 2009-12-15 10:32:25 -0500 | [diff] [blame] | 288 | add_trace_kprobe_events(session.probes, session.nr_probe, |
| 289 | session.force_add); |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 290 | return 0; |
| 291 | } |
| 292 | |