Commit | Line | Data |
---|---|---|
f3ed775e DG |
1 | /* |
2 | * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public License | |
82a3637f DG |
6 | * as published by the Free Software Foundation; only version 2 |
7 | * of the License. | |
f3ed775e DG |
8 | * |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, write to the Free Software | |
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | */ | |
18 | ||
19 | #define _GNU_SOURCE | |
20 | #include <popt.h> | |
21 | #include <stdio.h> | |
22 | #include <stdlib.h> | |
23 | #include <string.h> | |
24 | #include <sys/stat.h> | |
25 | #include <sys/types.h> | |
26 | #include <unistd.h> | |
5a0de755 | 27 | #include <inttypes.h> |
8f0d098b | 28 | #include <ctype.h> |
f3ed775e | 29 | |
c399183f | 30 | #include "../command.h" |
f3ed775e DG |
31 | |
32 | static char *opt_event_list; | |
33 | static int opt_event_type; | |
0cda4f28 MD |
34 | static const char *opt_loglevel; |
35 | static int opt_loglevel_type; | |
6181537c | 36 | static int opt_kernel; |
5440dc42 | 37 | static char *opt_session_name; |
f3ed775e DG |
38 | static int opt_userspace; |
39 | static int opt_enable_all; | |
cf0e5467 | 40 | static char *opt_probe; |
8f0d098b MD |
41 | static char *opt_function; |
42 | static char *opt_function_entry_symbol; | |
f3ed775e | 43 | static char *opt_channel_name; |
d78d6610 DG |
44 | #if 0 |
45 | /* Not implemented yet */ | |
46 | static char *opt_cmd_name; | |
47 | static pid_t opt_pid; | |
48 | #endif | |
f3ed775e DG |
49 | |
50 | enum { | |
51 | OPT_HELP = 1, | |
f3ed775e | 52 | OPT_TRACEPOINT, |
cf0e5467 | 53 | OPT_PROBE, |
f3ed775e | 54 | OPT_FUNCTION, |
8f0d098b | 55 | OPT_FUNCTION_ENTRY, |
a54bd42d | 56 | OPT_SYSCALL, |
eeac7d46 | 57 | OPT_USERSPACE, |
0cda4f28 MD |
58 | OPT_LOGLEVEL, |
59 | OPT_LOGLEVEL_ONLY, | |
679b4943 | 60 | OPT_LIST_OPTIONS, |
f3ed775e DG |
61 | }; |
62 | ||
cd80958d DG |
63 | static struct lttng_handle *handle; |
64 | ||
f3ed775e DG |
65 | static struct poptOption long_options[] = { |
66 | /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */ | |
67 | {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0}, | |
5440dc42 | 68 | {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0}, |
e14f64a8 | 69 | {"all", 'a', POPT_ARG_VAL, &opt_enable_all, 1, 0, 0}, |
f3ed775e DG |
70 | {"channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0}, |
71 | {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0}, | |
d78d6610 DG |
72 | #if 0 |
73 | /* Not implemented yet */ | |
40e9d5d3 | 74 | {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_cmd_name, OPT_USERSPACE, 0, 0}, |
f3ed775e | 75 | {"pid", 'p', POPT_ARG_INT, &opt_pid, 0, 0, 0}, |
d78d6610 DG |
76 | #else |
77 | {"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0}, | |
78 | #endif | |
f3ed775e | 79 | {"tracepoint", 0, POPT_ARG_NONE, 0, OPT_TRACEPOINT, 0, 0}, |
7ebae521 | 80 | {"probe", 0, POPT_ARG_STRING, &opt_probe, OPT_PROBE, 0, 0}, |
40e9d5d3 | 81 | {"function", 0, POPT_ARG_STRING, &opt_function, OPT_FUNCTION, 0, 0}, |
b213d387 MD |
82 | #if 0 |
83 | /* | |
84 | * Currently removed from lttng kernel tracer. Removed from | |
85 | * lttng UI to discourage its use. | |
86 | */ | |
40e9d5d3 | 87 | {"function:entry", 0, POPT_ARG_STRING, &opt_function_entry_symbol, OPT_FUNCTION_ENTRY, 0, 0}, |
b213d387 | 88 | #endif |
7ebae521 | 89 | {"syscall", 0, POPT_ARG_NONE, 0, OPT_SYSCALL, 0, 0}, |
0cda4f28 MD |
90 | {"loglevel", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL, 0, 0}, |
91 | {"loglevel-only", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL_ONLY, 0, 0}, | |
679b4943 | 92 | {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL}, |
f3ed775e DG |
93 | {0, 0, 0, 0, 0, 0, 0} |
94 | }; | |
95 | ||
96 | /* | |
97 | * usage | |
98 | */ | |
99 | static void usage(FILE *ofp) | |
100 | { | |
101 | fprintf(ofp, "usage: lttng enable-event NAME[,NAME2,...] [options] [event_options]\n"); | |
102 | fprintf(ofp, "\n"); | |
103 | fprintf(ofp, " -h, --help Show this help\n"); | |
679b4943 | 104 | fprintf(ofp, " --list-options Simple listing of options\n"); |
27221701 DG |
105 | fprintf(ofp, " -s, --session Apply to session name\n"); |
106 | fprintf(ofp, " -c, --channel Apply to this channel\n"); | |
e14f64a8 | 107 | fprintf(ofp, " -a, --all Enable all tracepoints\n"); |
f3ed775e | 108 | fprintf(ofp, " -k, --kernel Apply for the kernel tracer\n"); |
d78d6610 | 109 | #if 0 |
27221701 | 110 | fprintf(ofp, " -u, --userspace [CMD] Apply to the user-space tracer\n"); |
e14f64a8 DG |
111 | fprintf(ofp, " If no CMD, the domain used is UST global\n"); |
112 | fprintf(ofp, " or else the domain is UST EXEC_NAME\n"); | |
113 | fprintf(ofp, " -p, --pid PID If -u, apply to specific PID (domain: UST PID)\n"); | |
d78d6610 | 114 | #else |
27221701 | 115 | fprintf(ofp, " -u, --userspace Apply to the user-space tracer\n"); |
d78d6610 | 116 | #endif |
f3ed775e DG |
117 | fprintf(ofp, "\n"); |
118 | fprintf(ofp, "Event options:\n"); | |
119 | fprintf(ofp, " --tracepoint Tracepoint event (default)\n"); | |
be49af1e MD |
120 | fprintf(ofp, " - userspace tracer supports wildcards at end of string.\n"); |
121 | fprintf(ofp, " Don't forget to quote to deal with bash expansion.\n"); | |
122 | fprintf(ofp, " e.g.:\n"); | |
123 | fprintf(ofp, " \"*\"\n"); | |
124 | fprintf(ofp, " \"app_component:na*\"\n"); | |
0cda4f28 MD |
125 | fprintf(ofp, " --loglevel name\n"); |
126 | fprintf(ofp, " Tracepoint loglevel (range: 0 to loglevel)\n"); | |
127 | fprintf(ofp, " --loglevel-only name\n"); | |
128 | fprintf(ofp, " Tracepoint loglevel (only this loglevel)\n"); | |
8f0d098b | 129 | fprintf(ofp, " --probe [addr | symbol | symbol+offset]\n"); |
cf0e5467 MD |
130 | fprintf(ofp, " Dynamic probe.\n"); |
131 | fprintf(ofp, " Addr and offset can be octal (0NNN...),\n"); | |
132 | fprintf(ofp, " decimal (NNN...) or hexadecimal (0xNNN...)\n"); | |
8f0d098b MD |
133 | fprintf(ofp, " --function [addr | symbol | symbol+offset]\n"); |
134 | fprintf(ofp, " Dynamic function entry/return probe.\n"); | |
135 | fprintf(ofp, " Addr and offset can be octal (0NNN...),\n"); | |
136 | fprintf(ofp, " decimal (NNN...) or hexadecimal (0xNNN...)\n"); | |
b213d387 | 137 | #if 0 |
8f0d098b MD |
138 | fprintf(ofp, " --function:entry symbol\n"); |
139 | fprintf(ofp, " Function tracer event\n"); | |
b213d387 | 140 | #endif |
a54bd42d | 141 | fprintf(ofp, " --syscall System call event\n"); |
f3ed775e DG |
142 | fprintf(ofp, "\n"); |
143 | } | |
144 | ||
0d63dd19 | 145 | /* |
6181537c | 146 | * Parse probe options. |
0d63dd19 | 147 | */ |
cf0e5467 | 148 | static int parse_probe_opts(struct lttng_event *ev, char *opt) |
0d63dd19 DG |
149 | { |
150 | int ret; | |
8ff0bbd0 | 151 | char s_hex[19]; |
0d63dd19 DG |
152 | char name[LTTNG_SYMBOL_NAME_LEN]; |
153 | ||
154 | if (opt == NULL) { | |
155 | ret = -1; | |
8f0d098b | 156 | goto end; |
0d63dd19 DG |
157 | } |
158 | ||
159 | /* Check for symbol+offset */ | |
8ff0bbd0 | 160 | ret = sscanf(opt, "%[^'+']+%s", name, s_hex); |
0d63dd19 | 161 | if (ret == 2) { |
7d29a247 | 162 | strncpy(ev->attr.probe.symbol_name, name, LTTNG_SYMBOL_NAME_LEN); |
99497cd0 | 163 | ev->attr.probe.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; |
cf0e5467 | 164 | DBG("probe symbol %s", ev->attr.probe.symbol_name); |
8ff0bbd0 DG |
165 | if (strlen(s_hex) == 0) { |
166 | ERR("Invalid probe offset %s", s_hex); | |
0d63dd19 | 167 | ret = -1; |
8f0d098b | 168 | goto end; |
0d63dd19 | 169 | } |
8ff0bbd0 | 170 | ev->attr.probe.offset = strtoul(s_hex, NULL, 0); |
cf0e5467 | 171 | DBG("probe offset %" PRIu64, ev->attr.probe.offset); |
3000dc78 | 172 | ev->attr.probe.addr = 0; |
8f0d098b MD |
173 | goto end; |
174 | } | |
175 | ||
176 | /* Check for symbol */ | |
177 | if (isalpha(name[0])) { | |
178 | ret = sscanf(opt, "%s", name); | |
179 | if (ret == 1) { | |
180 | strncpy(ev->attr.probe.symbol_name, name, LTTNG_SYMBOL_NAME_LEN); | |
99497cd0 | 181 | ev->attr.probe.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; |
8f0d098b MD |
182 | DBG("probe symbol %s", ev->attr.probe.symbol_name); |
183 | ev->attr.probe.offset = 0; | |
184 | DBG("probe offset %" PRIu64, ev->attr.probe.offset); | |
185 | ev->attr.probe.addr = 0; | |
186 | goto end; | |
187 | } | |
0d63dd19 DG |
188 | } |
189 | ||
190 | /* Check for address */ | |
8ff0bbd0 | 191 | ret = sscanf(opt, "%s", s_hex); |
0d63dd19 | 192 | if (ret > 0) { |
8ff0bbd0 DG |
193 | if (strlen(s_hex) == 0) { |
194 | ERR("Invalid probe address %s", s_hex); | |
0d63dd19 | 195 | ret = -1; |
8f0d098b | 196 | goto end; |
0d63dd19 | 197 | } |
8ff0bbd0 | 198 | ev->attr.probe.addr = strtoul(s_hex, NULL, 0); |
cf0e5467 | 199 | DBG("probe addr %" PRIu64, ev->attr.probe.addr); |
3000dc78 DG |
200 | ev->attr.probe.offset = 0; |
201 | memset(ev->attr.probe.symbol_name, 0, LTTNG_SYMBOL_NAME_LEN); | |
8f0d098b | 202 | goto end; |
0d63dd19 DG |
203 | } |
204 | ||
205 | /* No match */ | |
206 | ret = -1; | |
207 | ||
8f0d098b | 208 | end: |
0d63dd19 DG |
209 | return ret; |
210 | } | |
211 | ||
f3ed775e | 212 | /* |
6181537c | 213 | * Enabling event using the lttng API. |
f3ed775e | 214 | */ |
cd80958d | 215 | static int enable_events(char *session_name) |
f3ed775e | 216 | { |
ae856491 | 217 | int err, ret = CMD_SUCCESS, warn = 0; |
b73d0b29 | 218 | char *event_name, *channel_name = NULL; |
f3ed775e | 219 | struct lttng_event ev; |
7d29a247 | 220 | struct lttng_domain dom; |
f3ed775e | 221 | |
7d29a247 DG |
222 | /* Create lttng domain */ |
223 | if (opt_kernel) { | |
224 | dom.type = LTTNG_DOMAIN_KERNEL; | |
d78d6610 | 225 | } else if (opt_userspace) { |
2bdd86d4 | 226 | dom.type = LTTNG_DOMAIN_UST; |
6181537c | 227 | } else { |
e14f64a8 | 228 | ERR("Please specify a tracer (-k/--kernel or -u/--userspace)"); |
d16c1a4c | 229 | ret = CMD_ERROR; |
6181537c | 230 | goto error; |
2bdd86d4 | 231 | } |
7d29a247 | 232 | |
ae856491 DG |
233 | if (opt_channel_name == NULL) { |
234 | err = asprintf(&channel_name, DEFAULT_CHANNEL_NAME); | |
235 | if (err < 0) { | |
236 | ret = CMD_FATAL; | |
237 | goto error; | |
238 | } | |
239 | } else { | |
240 | channel_name = opt_channel_name; | |
241 | } | |
242 | ||
cd80958d DG |
243 | handle = lttng_create_handle(session_name, &dom); |
244 | if (handle == NULL) { | |
245 | ret = -1; | |
246 | goto error; | |
247 | } | |
1aef21b6 | 248 | |
cd80958d | 249 | if (opt_enable_all) { |
8c9ae521 | 250 | /* Default setup for enable all */ |
75e8c5ab MD |
251 | if (opt_kernel) { |
252 | ev.type = opt_event_type; | |
253 | ev.name[0] = '\0'; | |
254 | } else { | |
255 | ev.type = LTTNG_EVENT_TRACEPOINT; | |
256 | strcpy(ev.name, "*"); | |
257 | } | |
8c9ae521 DG |
258 | |
259 | ret = lttng_enable_event(handle, &ev, channel_name); | |
260 | if (ret < 0) { | |
261 | goto error; | |
262 | } | |
263 | ||
0133c199 MD |
264 | switch (opt_event_type) { |
265 | case LTTNG_EVENT_TRACEPOINT: | |
2bdd86d4 MD |
266 | MSG("All %s tracepoints are enabled in channel %s", |
267 | opt_kernel ? "kernel" : "UST", channel_name); | |
0133c199 | 268 | break; |
a54bd42d | 269 | case LTTNG_EVENT_SYSCALL: |
0133c199 | 270 | if (opt_kernel) { |
8c9ae521 DG |
271 | MSG("All kernel system calls are enabled in channel %s", |
272 | channel_name); | |
c93d9daf | 273 | } |
0133c199 | 274 | break; |
7a3d1328 | 275 | case LTTNG_EVENT_ALL: |
2bdd86d4 MD |
276 | MSG("All %s events are enabled in channel %s", |
277 | opt_kernel ? "kernel" : "UST", channel_name); | |
7a3d1328 | 278 | break; |
0133c199 | 279 | default: |
8c9ae521 | 280 | /* |
6181537c DG |
281 | * We should not be here since lttng_enable_event should have |
282 | * failed on the event type. | |
8c9ae521 | 283 | */ |
f3ed775e DG |
284 | goto error; |
285 | } | |
8c9ae521 | 286 | goto end; |
f3ed775e DG |
287 | } |
288 | ||
289 | /* Strip event list */ | |
290 | event_name = strtok(opt_event_list, ","); | |
291 | while (event_name != NULL) { | |
6181537c DG |
292 | /* Copy name and type of the event */ |
293 | strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN); | |
294 | ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; | |
295 | ev.type = opt_event_type; | |
296 | ||
f3ed775e DG |
297 | /* Kernel tracer action */ |
298 | if (opt_kernel) { | |
299 | DBG("Enabling kernel event %s for channel %s", | |
300 | event_name, channel_name); | |
f3ed775e DG |
301 | |
302 | switch (opt_event_type) { | |
7a3d1328 MD |
303 | case LTTNG_EVENT_ALL: /* Default behavior is tracepoint */ |
304 | ev.type = LTTNG_EVENT_TRACEPOINT; | |
305 | /* Fall-through */ | |
e6ddca71 | 306 | case LTTNG_EVENT_TRACEPOINT: |
f3ed775e | 307 | break; |
7d29a247 | 308 | case LTTNG_EVENT_PROBE: |
cf0e5467 | 309 | ret = parse_probe_opts(&ev, opt_probe); |
0d63dd19 | 310 | if (ret < 0) { |
cf0e5467 | 311 | ERR("Unable to parse probe options"); |
0d63dd19 DG |
312 | ret = 0; |
313 | goto error; | |
314 | } | |
f3ed775e DG |
315 | break; |
316 | case LTTNG_EVENT_FUNCTION: | |
8f0d098b MD |
317 | ret = parse_probe_opts(&ev, opt_function); |
318 | if (ret < 0) { | |
319 | ERR("Unable to parse function probe options"); | |
320 | ret = 0; | |
321 | goto error; | |
322 | } | |
323 | break; | |
324 | case LTTNG_EVENT_FUNCTION_ENTRY: | |
6181537c DG |
325 | strncpy(ev.attr.ftrace.symbol_name, opt_function_entry_symbol, |
326 | LTTNG_SYMBOL_NAME_LEN); | |
99497cd0 | 327 | ev.attr.ftrace.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; |
f3ed775e | 328 | break; |
a54bd42d | 329 | case LTTNG_EVENT_SYSCALL: |
6181537c DG |
330 | MSG("per-syscall selection not supported yet. Use \"-a\" " |
331 | "for all syscalls."); | |
f3ed775e | 332 | default: |
1ab1ea0b | 333 | ret = CMD_UNDEFINED; |
f3ed775e DG |
334 | goto error; |
335 | } | |
0cda4f28 | 336 | |
ed7f4083 | 337 | if (opt_loglevel) { |
0cda4f28 MD |
338 | MSG("Kernel loglevels are not supported."); |
339 | ret = CMD_UNDEFINED; | |
340 | goto error; | |
341 | } | |
342 | ||
343 | /* kernel loglevels not implemented */ | |
344 | ev.loglevel_type = opt_loglevel_type; | |
345 | ev.loglevel[0] = '\0'; | |
f3ed775e | 346 | } else if (opt_userspace) { /* User-space tracer action */ |
d78d6610 | 347 | #if 0 |
e14f64a8 DG |
348 | if (opt_cmd_name != NULL || opt_pid) { |
349 | MSG("Only supporting tracing all UST processes (-u) for now."); | |
1ab1ea0b | 350 | ret = CMD_UNDEFINED; |
2bdd86d4 MD |
351 | goto error; |
352 | } | |
d78d6610 | 353 | #endif |
6181537c DG |
354 | |
355 | DBG("Enabling UST event %s for channel %s", event_name, | |
356 | channel_name); | |
2bdd86d4 MD |
357 | |
358 | switch (opt_event_type) { | |
359 | case LTTNG_EVENT_ALL: /* Default behavior is tracepoint */ | |
2bdd86d4 MD |
360 | /* Fall-through */ |
361 | case LTTNG_EVENT_TRACEPOINT: | |
e4baff1e MD |
362 | /* Copy name and type of the event */ |
363 | ev.type = LTTNG_EVENT_TRACEPOINT; | |
364 | strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN); | |
365 | ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; | |
2bdd86d4 MD |
366 | break; |
367 | case LTTNG_EVENT_PROBE: | |
368 | case LTTNG_EVENT_FUNCTION: | |
369 | case LTTNG_EVENT_FUNCTION_ENTRY: | |
370 | case LTTNG_EVENT_SYSCALL: | |
371 | default: | |
cc62c0c0 | 372 | ERR("Event type not available for user-space tracing"); |
1ab1ea0b | 373 | ret = CMD_UNDEFINED; |
2bdd86d4 MD |
374 | goto error; |
375 | } | |
0cda4f28 MD |
376 | |
377 | ev.loglevel_type = opt_loglevel_type; | |
ed7f4083 MD |
378 | if (opt_loglevel) { |
379 | strncpy(ev.loglevel, opt_loglevel, LTTNG_SYMBOL_NAME_LEN); | |
380 | ev.loglevel[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; | |
381 | } else { | |
382 | ev.loglevel[0] = '\0'; | |
383 | } | |
f3ed775e | 384 | } else { |
e14f64a8 | 385 | ERR("Please specify a tracer (-k/--kernel or -u/--userspace)"); |
f3ed775e DG |
386 | goto error; |
387 | } | |
388 | ||
6181537c | 389 | ret = lttng_enable_event(handle, &ev, channel_name); |
ae856491 DG |
390 | if (ret < 0) { |
391 | ERR("Event %s: %s (channel %s, session %s)", event_name, | |
392 | lttng_strerror(ret), channel_name, session_name); | |
393 | warn = 1; | |
394 | } else { | |
6181537c DG |
395 | MSG("%s event %s created in channel %s", |
396 | opt_kernel ? "kernel": "UST", event_name, channel_name); | |
397 | } | |
398 | ||
f3ed775e DG |
399 | /* Next event */ |
400 | event_name = strtok(NULL, ","); | |
401 | } | |
402 | ||
8c9ae521 | 403 | end: |
f3ed775e | 404 | error: |
ae856491 DG |
405 | if (warn) { |
406 | ret = CMD_WARNING; | |
407 | } | |
b73d0b29 MD |
408 | if (opt_channel_name == NULL) { |
409 | free(channel_name); | |
410 | } | |
cd80958d DG |
411 | lttng_destroy_handle(handle); |
412 | ||
f3ed775e DG |
413 | return ret; |
414 | } | |
415 | ||
416 | /* | |
6181537c | 417 | * Add event to trace session |
f3ed775e DG |
418 | */ |
419 | int cmd_enable_events(int argc, const char **argv) | |
420 | { | |
ca1c3607 | 421 | int opt, ret = CMD_SUCCESS; |
f3ed775e | 422 | static poptContext pc; |
cd80958d | 423 | char *session_name = NULL; |
f3ed775e DG |
424 | |
425 | pc = poptGetContext(NULL, argc, argv, long_options, 0); | |
426 | poptReadDefaultConfig(pc, 0); | |
427 | ||
428 | /* Default event type */ | |
7a3d1328 | 429 | opt_event_type = LTTNG_EVENT_ALL; |
f3ed775e DG |
430 | |
431 | while ((opt = poptGetNextOpt(pc)) != -1) { | |
432 | switch (opt) { | |
433 | case OPT_HELP: | |
ca1c3607 | 434 | usage(stdout); |
f3ed775e | 435 | goto end; |
f3ed775e | 436 | case OPT_TRACEPOINT: |
e6ddca71 | 437 | opt_event_type = LTTNG_EVENT_TRACEPOINT; |
f3ed775e | 438 | break; |
cf0e5467 | 439 | case OPT_PROBE: |
7d29a247 | 440 | opt_event_type = LTTNG_EVENT_PROBE; |
f3ed775e DG |
441 | break; |
442 | case OPT_FUNCTION: | |
443 | opt_event_type = LTTNG_EVENT_FUNCTION; | |
8f0d098b MD |
444 | break; |
445 | case OPT_FUNCTION_ENTRY: | |
446 | opt_event_type = LTTNG_EVENT_FUNCTION_ENTRY; | |
f3ed775e | 447 | break; |
a54bd42d MD |
448 | case OPT_SYSCALL: |
449 | opt_event_type = LTTNG_EVENT_SYSCALL; | |
0133c199 | 450 | break; |
eeac7d46 MD |
451 | case OPT_USERSPACE: |
452 | opt_userspace = 1; | |
eeac7d46 | 453 | break; |
0cda4f28 MD |
454 | case OPT_LOGLEVEL: |
455 | opt_loglevel_type = LTTNG_EVENT_LOGLEVEL; | |
456 | opt_loglevel = poptGetOptArg(pc); | |
457 | break; | |
458 | case OPT_LOGLEVEL_ONLY: | |
459 | opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_ONLY; | |
460 | opt_loglevel = poptGetOptArg(pc); | |
13dce3b7 | 461 | break; |
679b4943 SM |
462 | case OPT_LIST_OPTIONS: |
463 | list_cmd_options(stdout, long_options); | |
679b4943 | 464 | goto end; |
f3ed775e DG |
465 | default: |
466 | usage(stderr); | |
467 | ret = CMD_UNDEFINED; | |
468 | goto end; | |
469 | } | |
470 | } | |
471 | ||
472 | opt_event_list = (char*) poptGetArg(pc); | |
473 | if (opt_event_list == NULL && opt_enable_all == 0) { | |
474 | ERR("Missing event name(s).\n"); | |
475 | usage(stderr); | |
ca1c3607 | 476 | ret = CMD_ERROR; |
f3ed775e DG |
477 | goto end; |
478 | } | |
479 | ||
cd80958d DG |
480 | if (!opt_session_name) { |
481 | session_name = get_session_name(); | |
482 | if (session_name == NULL) { | |
ca1c3607 | 483 | ret = CMD_ERROR; |
cd80958d DG |
484 | goto end; |
485 | } | |
486 | } else { | |
487 | session_name = opt_session_name; | |
488 | } | |
489 | ||
490 | ret = enable_events(session_name); | |
f3ed775e DG |
491 | |
492 | end: | |
cd80958d DG |
493 | if (opt_session_name == NULL) { |
494 | free(session_name); | |
495 | } | |
496 | ||
ca1c3607 | 497 | poptFreeContext(pc); |
f3ed775e DG |
498 | return ret; |
499 | } |