Blame view

tools/perf/builtin-probe.c 18.5 KB
1a59d1b8e   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-or-later
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
2
3
4
5
6
7
  /*
   * builtin-probe.c
   *
   * Builtin probe command: Set up probe events by C expression
   *
   * Written by Masami Hiramatsu <mhiramat@redhat.com>
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
8
   */
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
9
10
11
12
13
14
15
16
17
  #include <sys/utsname.h>
  #include <sys/types.h>
  #include <sys/stat.h>
  #include <fcntl.h>
  #include <errno.h>
  #include <stdio.h>
  #include <unistd.h>
  #include <stdlib.h>
  #include <string.h>
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
18
  #include "builtin.h"
40f3b2d20   Arnaldo Carvalho de Melo   perf namespaces: ...
19
  #include "namespaces.h"
b1d1b094f   Arnaldo Carvalho de Melo   perf symbols: Mov...
20
  #include "util/build-id.h"
fa28244d1   Masami Hiramatsu   perf probe: Suppo...
21
  #include "util/strlist.h"
bd09d7b5e   Masami Hiramatsu   perf probe: Add v...
22
  #include "util/strfilter.h"
afce8c482   Arnaldo Carvalho de Melo   perf probe: No ne...
23
  #include "util/symbol_conf.h"
89c69c0ee   Masami Hiramatsu   perf: Use eprintf...
24
  #include "util/debug.h"
4b6ab94ea   Josh Poimboeuf   perf subcmd: Crea...
25
  #include <subcmd/parse-options.h>
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
26
  #include "util/probe-finder.h"
50656eec8   Masami Hiramatsu   perf probe: Move ...
27
  #include "util/probe-event.h"
e607f1426   Namhyung Kim   perf probe: Print...
28
  #include "util/probe-file.h"
8520a98db   Arnaldo Carvalho de Melo   perf debug: Remov...
29
  #include <linux/string.h>
7f7c536f2   Arnaldo Carvalho de Melo   tools lib: Adopt ...
30
  #include <linux/zalloc.h>
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
31

bd09d7b5e   Masami Hiramatsu   perf probe: Add v...
32
  #define DEFAULT_VAR_FILTER "!__k???tab_* & !__crc_*"
3c42258c9   Masami Hiramatsu   perf probe: Add f...
33
  #define DEFAULT_FUNC_FILTER "!_*"
1f3736c9c   Masami Hiramatsu   perf probe: Show ...
34
  #define DEFAULT_LIST_FILTER "*"
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
35
36
37
  
  /* Session management structure */
  static struct {
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
38
  	int command;	/* Command short_name */
fac13fd54   Masami Hiramatsu   perf probe: Clean...
39
  	bool list_events;
225466f1c   Srikar Dronamraju   perf probe: Provi...
40
  	bool uprobes;
5e17b28f1   Masami Hiramatsu   perf probe: Add -...
41
  	bool quiet;
8cb0aa4c2   Masami Hiramatsu   perf probe: Check...
42
  	bool target_used;
4235b0454   Masami Hiramatsu   perf probe: Intro...
43
44
  	int nevents;
  	struct perf_probe_event events[MAX_PROBES];
631c9def8   Masami Hiramatsu   perf probe: Suppo...
45
  	struct line_range line_range;
e53b00d38   Masami Hiramatsu   perf probe: Relea...
46
  	char *target;
bd09d7b5e   Masami Hiramatsu   perf probe: Add v...
47
  	struct strfilter *filter;
544abd44c   Krister Johansen   perf probe: Allow...
48
  	struct nsinfo *nsi;
12a1fadb4   Masami Hiramatsu   perf probe: Renam...
49
  } params;
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
50

253977b0d   Masami Hiramatsu   perf/probes: Impr...
51
  /* Parse an event definition. Note that any error must die. */
146a14394   Masami Hiramatsu   perf probe: Remov...
52
  static int parse_probe_event(const char *str)
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
53
  {
4235b0454   Masami Hiramatsu   perf probe: Intro...
54
  	struct perf_probe_event *pev = &params.events[params.nevents];
146a14394   Masami Hiramatsu   perf probe: Remov...
55
  	int ret;
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
56

4235b0454   Masami Hiramatsu   perf probe: Intro...
57
58
  	pr_debug("probe-definition(%d): %s
  ", params.nevents, str);
8a7ddad8e   Arnaldo Carvalho de Melo   perf probe: Don't...
59
60
61
62
  	if (++params.nevents == MAX_PROBES) {
  		pr_err("Too many probes (> %d) were specified.", MAX_PROBES);
  		return -1;
  	}
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
63

225466f1c   Srikar Dronamraju   perf probe: Provi...
64
  	pev->uprobes = params.uprobes;
7afb3fab3   Masami Hiramatsu   perf probe: Suppo...
65
66
67
68
  	if (params.target) {
  		pev->target = strdup(params.target);
  		if (!pev->target)
  			return -ENOMEM;
8cb0aa4c2   Masami Hiramatsu   perf probe: Check...
69
  		params.target_used = true;
7afb3fab3   Masami Hiramatsu   perf probe: Suppo...
70
  	}
225466f1c   Srikar Dronamraju   perf probe: Provi...
71

362379aad   Arnaldo Carvalho de Melo   perf tools: No ne...
72
  	pev->nsi = nsinfo__get(params.nsi);
544abd44c   Krister Johansen   perf probe: Allow...
73

4235b0454   Masami Hiramatsu   perf probe: Intro...
74
  	/* Parse a perf-probe command into event */
146a14394   Masami Hiramatsu   perf probe: Remov...
75
  	ret = parse_perf_probe_command(str, pev);
4235b0454   Masami Hiramatsu   perf probe: Intro...
76
77
  	pr_debug("%d arguments
  ", pev->nargs);
146a14394   Masami Hiramatsu   perf probe: Remov...
78
79
  
  	return ret;
46ab49267   Masami Hiramatsu   perf/probes: Impr...
80
  }
b6a896438   Masami Hiramatsu   perf probe: Accep...
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  static int params_add_filter(const char *str)
  {
  	const char *err = NULL;
  	int ret = 0;
  
  	pr_debug2("Add filter: %s
  ", str);
  	if (!params.filter) {
  		params.filter = strfilter__new(str, &err);
  		if (!params.filter)
  			ret = err ? -EINVAL : -ENOMEM;
  	} else
  		ret = strfilter__or(params.filter, str, &err);
  
  	if (ret == -EINVAL) {
  		pr_err("Filter parse error at %td.
  ", err - str + 1);
  		pr_err("Source: \"%s\"
  ", str);
  		pr_err("         %*c
  ", (int)(err - str + 1), '^');
  	}
  
  	return ret;
  }
73eff9f56   Srikar Dronamraju   perf probe: Detec...
106
107
108
109
110
111
112
113
114
115
116
117
118
  static int set_target(const char *ptr)
  {
  	int found = 0;
  	const char *buf;
  
  	/*
  	 * The first argument after options can be an absolute path
  	 * to an executable / library or kernel module.
  	 *
  	 * TODO: Support relative path, and $PATH, $LD_LIBRARY_PATH,
  	 * short module name.
  	 */
  	if (!params.target && ptr && *ptr == '/') {
e53b00d38   Masami Hiramatsu   perf probe: Relea...
119
120
121
  		params.target = strdup(ptr);
  		if (!params.target)
  			return -ENOMEM;
8cb0aa4c2   Masami Hiramatsu   perf probe: Check...
122
  		params.target_used = false;
e53b00d38   Masami Hiramatsu   perf probe: Relea...
123

73eff9f56   Srikar Dronamraju   perf probe: Detec...
124
125
126
127
128
129
130
131
132
133
  		found = 1;
  		buf = ptr + (strlen(ptr) - 3);
  
  		if (strcmp(buf, ".ko"))
  			params.uprobes = true;
  
  	}
  
  	return found;
  }
146a14394   Masami Hiramatsu   perf probe: Remov...
134
  static int parse_probe_event_argv(int argc, const char **argv)
d1bde3f75   Masami Hiramatsu   perf probe: Fix a...
135
  {
73eff9f56   Srikar Dronamraju   perf probe: Detec...
136
  	int i, len, ret, found_target;
d1bde3f75   Masami Hiramatsu   perf probe: Fix a...
137
  	char *buf;
73eff9f56   Srikar Dronamraju   perf probe: Detec...
138
  	found_target = set_target(argv[0]);
e53b00d38   Masami Hiramatsu   perf probe: Relea...
139
140
  	if (found_target < 0)
  		return found_target;
73eff9f56   Srikar Dronamraju   perf probe: Detec...
141
142
  	if (found_target && argc == 1)
  		return 0;
d1bde3f75   Masami Hiramatsu   perf probe: Fix a...
143
144
  	/* Bind up rest arguments */
  	len = 0;
73eff9f56   Srikar Dronamraju   perf probe: Detec...
145
146
147
  	for (i = 0; i < argc; i++) {
  		if (i == 0 && found_target)
  			continue;
d1bde3f75   Masami Hiramatsu   perf probe: Fix a...
148
  		len += strlen(argv[i]) + 1;
73eff9f56   Srikar Dronamraju   perf probe: Detec...
149
  	}
8a7ddad8e   Arnaldo Carvalho de Melo   perf probe: Don't...
150
151
152
  	buf = zalloc(len + 1);
  	if (buf == NULL)
  		return -ENOMEM;
d1bde3f75   Masami Hiramatsu   perf probe: Fix a...
153
  	len = 0;
73eff9f56   Srikar Dronamraju   perf probe: Detec...
154
155
156
  	for (i = 0; i < argc; i++) {
  		if (i == 0 && found_target)
  			continue;
d1bde3f75   Masami Hiramatsu   perf probe: Fix a...
157
  		len += sprintf(&buf[len], "%s ", argv[i]);
73eff9f56   Srikar Dronamraju   perf probe: Detec...
158
  	}
146a14394   Masami Hiramatsu   perf probe: Remov...
159
  	ret = parse_probe_event(buf);
d1bde3f75   Masami Hiramatsu   perf probe: Fix a...
160
  	free(buf);
146a14394   Masami Hiramatsu   perf probe: Remov...
161
  	return ret;
d1bde3f75   Masami Hiramatsu   perf probe: Fix a...
162
  }
225466f1c   Srikar Dronamraju   perf probe: Provi...
163
  static int opt_set_target(const struct option *opt, const char *str,
1d037ca16   Irina Tirdea   perf tools: Use _...
164
  			int unset __maybe_unused)
225466f1c   Srikar Dronamraju   perf probe: Provi...
165
166
  {
  	int ret = -ENOENT;
8a613d40e   Masami Hiramatsu   perf probe: Expan...
167
  	char *tmp;
225466f1c   Srikar Dronamraju   perf probe: Provi...
168

7afb3fab3   Masami Hiramatsu   perf probe: Suppo...
169
  	if  (str) {
225466f1c   Srikar Dronamraju   perf probe: Provi...
170
171
  		if (!strcmp(opt->long_name, "exec"))
  			params.uprobes = true;
225466f1c   Srikar Dronamraju   perf probe: Provi...
172
173
  		else if (!strcmp(opt->long_name, "module"))
  			params.uprobes = false;
225466f1c   Srikar Dronamraju   perf probe: Provi...
174
175
  		else
  			return ret;
8a613d40e   Masami Hiramatsu   perf probe: Expan...
176
177
  		/* Expand given path to absolute path, except for modulename */
  		if (params.uprobes || strchr(str, '/')) {
544abd44c   Krister Johansen   perf probe: Allow...
178
  			tmp = nsinfo__realpath(str, params.nsi);
8a613d40e   Masami Hiramatsu   perf probe: Expan...
179
180
181
182
183
184
185
186
187
188
  			if (!tmp) {
  				pr_warning("Failed to get the absolute path of %s: %m
  ", str);
  				return ret;
  			}
  		} else {
  			tmp = strdup(str);
  			if (!tmp)
  				return -ENOMEM;
  		}
7afb3fab3   Masami Hiramatsu   perf probe: Suppo...
189
  		free(params.target);
8a613d40e   Masami Hiramatsu   perf probe: Expan...
190
  		params.target = tmp;
8cb0aa4c2   Masami Hiramatsu   perf probe: Check...
191
  		params.target_used = false;
225466f1c   Srikar Dronamraju   perf probe: Provi...
192
193
194
195
196
  		ret = 0;
  	}
  
  	return ret;
  }
544abd44c   Krister Johansen   perf probe: Allow...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
  static int opt_set_target_ns(const struct option *opt __maybe_unused,
  			     const char *str, int unset __maybe_unused)
  {
  	int ret = -ENOENT;
  	pid_t ns_pid;
  	struct nsinfo *nsip;
  
  	if (str) {
  		errno = 0;
  		ns_pid = (pid_t)strtol(str, NULL, 10);
  		if (errno != 0) {
  			ret = -errno;
  			pr_warning("Failed to parse %s as a pid: %s
  ", str,
  				   strerror(errno));
  			return ret;
  		}
  		nsip = nsinfo__new(ns_pid);
  		if (nsip && nsip->need_setns)
  			params.nsi = nsinfo__get(nsip);
  		nsinfo__put(nsip);
  
  		ret = 0;
  	}
  
  	return ret;
  }
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
224
  /* Command option callbacks */
89fe808ae   Ingo Molnar   tools/perf: Stand...
225
  #ifdef HAVE_DWARF_SUPPORT
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
226
  static int opt_show_lines(const struct option *opt,
1d037ca16   Irina Tirdea   perf tools: Use _...
227
  			  const char *str, int unset __maybe_unused)
0eda7385d   Hitoshi Mitake   perf probe: Fix b...
228
  {
146a14394   Masami Hiramatsu   perf probe: Remov...
229
  	int ret = 0;
13e27d768   Masami Hiramatsu   perf probe: Warn ...
230
231
  	if (!str)
  		return 0;
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
232
  	if (params.command == 'L') {
13e27d768   Masami Hiramatsu   perf probe: Warn ...
233
234
235
236
237
  		pr_warning("Warning: more than one --line options are"
  			   " detected. Only the first one is valid.
  ");
  		return 0;
  	}
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
238
  	params.command = opt->short_name;
13e27d768   Masami Hiramatsu   perf probe: Warn ...
239
  	ret = parse_line_range_desc(str, &params.line_range);
146a14394   Masami Hiramatsu   perf probe: Remov...
240
241
  
  	return ret;
0eda7385d   Hitoshi Mitake   perf probe: Fix b...
242
  }
cf6eb489e   Masami Hiramatsu   perf probe: Show ...
243

b1019d5e6   Masami Hiramatsu   perf probe: Clean...
244
  static int opt_show_vars(const struct option *opt,
1d037ca16   Irina Tirdea   perf tools: Use _...
245
  			 const char *str, int unset __maybe_unused)
cf6eb489e   Masami Hiramatsu   perf probe: Show ...
246
247
248
249
250
251
252
253
254
255
256
257
258
  {
  	struct perf_probe_event *pev = &params.events[params.nevents];
  	int ret;
  
  	if (!str)
  		return 0;
  
  	ret = parse_probe_event(str);
  	if (!ret && pev->nargs != 0) {
  		pr_err("  Error: '--vars' doesn't accept arguments.
  ");
  		return -EINVAL;
  	}
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
259
  	params.command = opt->short_name;
cf6eb489e   Masami Hiramatsu   perf probe: Show ...
260
261
262
  
  	return ret;
  }
48e1cab1b   Wang Nan   perf tools: Make ...
263
264
265
  #else
  # define opt_show_lines NULL
  # define opt_show_vars NULL
3c42258c9   Masami Hiramatsu   perf probe: Add f...
266
  #endif
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
267
268
269
270
271
272
273
274
275
276
277
278
279
  static int opt_add_probe_event(const struct option *opt,
  			      const char *str, int unset __maybe_unused)
  {
  	if (str) {
  		params.command = opt->short_name;
  		return parse_probe_event(str);
  	}
  
  	return 0;
  }
  
  static int opt_set_filter_with_command(const struct option *opt,
  				       const char *str, int unset)
9f7811d08   Masami Hiramatsu   perf probe: Accep...
280
281
  {
  	if (!unset)
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
282
  		params.command = opt->short_name;
9f7811d08   Masami Hiramatsu   perf probe: Accep...
283
284
285
286
287
288
  
  	if (str)
  		return params_add_filter(str);
  
  	return 0;
  }
bd09d7b5e   Masami Hiramatsu   perf probe: Add v...
289

1d037ca16   Irina Tirdea   perf tools: Use _...
290
291
  static int opt_set_filter(const struct option *opt __maybe_unused,
  			  const char *str, int unset __maybe_unused)
bd09d7b5e   Masami Hiramatsu   perf probe: Add v...
292
  {
b6a896438   Masami Hiramatsu   perf probe: Accep...
293
294
  	if (str)
  		return params_add_filter(str);
bd09d7b5e   Masami Hiramatsu   perf probe: Add v...
295

b6a896438   Masami Hiramatsu   perf probe: Accep...
296
  	return 0;
bd09d7b5e   Masami Hiramatsu   perf probe: Add v...
297
  }
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
298

5a62257a3   Masami Hiramatsu   perf probe: Repla...
299
  static int init_params(void)
e53b00d38   Masami Hiramatsu   perf probe: Relea...
300
  {
5a62257a3   Masami Hiramatsu   perf probe: Repla...
301
  	return line_range__init(&params.line_range);
e53b00d38   Masami Hiramatsu   perf probe: Relea...
302
303
304
305
306
307
308
309
  }
  
  static void cleanup_params(void)
  {
  	int i;
  
  	for (i = 0; i < params.nevents; i++)
  		clear_perf_probe_event(params.events + i);
e53b00d38   Masami Hiramatsu   perf probe: Relea...
310
311
  	line_range__clear(&params.line_range);
  	free(params.target);
200802a4a   Markus Elfring   perf probe: Delet...
312
  	strfilter__delete(params.filter);
544abd44c   Krister Johansen   perf probe: Allow...
313
  	nsinfo__put(params.nsi);
e53b00d38   Masami Hiramatsu   perf probe: Relea...
314
315
  	memset(&params, 0, sizeof(params));
  }
b4bf1130c   Masami Hiramatsu   perf probe: Show ...
316
317
  static void pr_err_with_code(const char *msg, int err)
  {
5f03cba41   Masami Hiramatsu   perf probe: Make ...
318
  	char sbuf[STRERR_BUFSIZE];
b4bf1130c   Masami Hiramatsu   perf probe: Show ...
319
  	pr_err("%s", msg);
5f03cba41   Masami Hiramatsu   perf probe: Make ...
320
  	pr_debug(" Reason: %s (Code: %d)",
c8b5f2c96   Arnaldo Carvalho de Melo   tools: Introduce ...
321
  		 str_error_r(-err, sbuf, sizeof(sbuf)), err);
b4bf1130c   Masami Hiramatsu   perf probe: Show ...
322
323
324
  	pr_err("
  ");
  }
b02137cc6   Namhyung Kim   perf probe: Move ...
325
326
327
328
329
  static int perf_add_probe_events(struct perf_probe_event *pevs, int npevs)
  {
  	int ret;
  	int i, k;
  	const char *event = NULL, *group = NULL;
9bae1e8c3   Namhyung Kim   perf probe: Expor...
330
331
332
  	ret = init_probe_symbol_maps(pevs->uprobes);
  	if (ret < 0)
  		return ret;
b02137cc6   Namhyung Kim   perf probe: Move ...
333
334
335
  	ret = convert_perf_probe_events(pevs, npevs);
  	if (ret < 0)
  		goto out_cleanup;
1c20b1d15   Masami Hiramatsu   perf probe: Show ...
336
337
338
339
  	if (params.command == 'D') {	/* it shows definition */
  		ret = show_probe_trace_events(pevs, npevs);
  		goto out_cleanup;
  	}
b02137cc6   Namhyung Kim   perf probe: Move ...
340
341
342
343
344
345
346
347
348
349
350
351
352
353
  	ret = apply_perf_probe_events(pevs, npevs);
  	if (ret < 0)
  		goto out_cleanup;
  
  	for (i = k = 0; i < npevs; i++)
  		k += pevs[i].ntevs;
  
  	pr_info("Added new event%s
  ", (k > 1) ? "s:" : ":");
  	for (i = 0; i < npevs; i++) {
  		struct perf_probe_event *pev = &pevs[i];
  
  		for (k = 0; k < pev->ntevs; k++) {
  			struct probe_trace_event *tev = &pev->tevs[k];
f41ebe9de   Masami Hiramatsu   perf probe: Do no...
354
355
356
  			/* Skipped events have no event name */
  			if (!tev->event)
  				continue;
b02137cc6   Namhyung Kim   perf probe: Move ...
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
  
  			/* We use tev's name for showing new events */
  			show_perf_probe_event(tev->group, tev->event, pev,
  					      tev->point.module, false);
  
  			/* Save the last valid name */
  			event = tev->event;
  			group = tev->group;
  		}
  	}
  
  	/* Note that it is possible to skip all events because of blacklist */
  	if (event) {
  		/* Show how to use the event. */
  		pr_info("
  You can now use it in all perf tools, such as:
  
  ");
  		pr_info("\tperf record -e %s:%s -aR sleep 1
  
  ", group, event);
  	}
  
  out_cleanup:
  	cleanup_perf_probe_events(pevs, npevs);
9bae1e8c3   Namhyung Kim   perf probe: Expor...
382
  	exit_probe_symbol_maps();
b02137cc6   Namhyung Kim   perf probe: Move ...
383
384
  	return ret;
  }
4a0f65c10   Masami Hiramatsu   perf probe: Remov...
385
386
387
388
389
390
  static int del_perf_probe_caches(struct strfilter *filter)
  {
  	struct probe_cache *cache;
  	struct strlist *bidlist;
  	struct str_node *nd;
  	int ret;
c3492a3a4   Masami Hiramatsu   perf probe: Make ...
391
  	bidlist = build_id_cache__list_all(false);
4a0f65c10   Masami Hiramatsu   perf probe: Remov...
392
393
394
395
396
397
398
399
  	if (!bidlist) {
  		ret = -errno;
  		pr_debug("Failed to get buildids: %d
  ", ret);
  		return ret ?: -ENOMEM;
  	}
  
  	strlist__for_each_entry(nd, bidlist) {
f045b8c4b   Krister Johansen   perf buildid-cach...
400
  		cache = probe_cache__new(nd->s, NULL);
4a0f65c10   Masami Hiramatsu   perf probe: Remov...
401
402
403
404
405
406
407
408
409
410
  		if (!cache)
  			continue;
  		if (probe_cache__filter_purge(cache, filter) < 0 ||
  		    probe_cache__commit(cache) < 0)
  			pr_warning("Failed to remove entries for %s
  ", nd->s);
  		probe_cache__delete(cache);
  	}
  	return 0;
  }
e607f1426   Namhyung Kim   perf probe: Print...
411
412
413
414
415
416
417
418
419
420
421
422
  static int perf_del_probe_events(struct strfilter *filter)
  {
  	int ret, ret2, ufd = -1, kfd = -1;
  	char *str = strfilter__string(filter);
  	struct strlist *klist = NULL, *ulist = NULL;
  	struct str_node *ent;
  
  	if (!str)
  		return -EINVAL;
  
  	pr_debug("Delete filter: \'%s\'
  ", str);
4a0f65c10   Masami Hiramatsu   perf probe: Remov...
423
424
  	if (probe_conf.cache)
  		return del_perf_probe_caches(filter);
e607f1426   Namhyung Kim   perf probe: Print...
425
426
427
428
429
430
  	/* Get current event names */
  	ret = probe_file__open_both(&kfd, &ufd, PF_FL_RW);
  	if (ret < 0)
  		goto out;
  
  	klist = strlist__new(NULL, NULL);
0fb185534   Masami Hiramatsu   perf probe: Fix a...
431
432
433
434
435
  	ulist = strlist__new(NULL, NULL);
  	if (!klist || !ulist) {
  		ret = -ENOMEM;
  		goto out;
  	}
e607f1426   Namhyung Kim   perf probe: Print...
436
437
438
  
  	ret = probe_file__get_events(kfd, filter, klist);
  	if (ret == 0) {
602a1f4da   Arnaldo Carvalho de Melo   perf tools: Renam...
439
  		strlist__for_each_entry(ent, klist)
e607f1426   Namhyung Kim   perf probe: Print...
440
441
442
443
444
445
  			pr_info("Removed event: %s
  ", ent->s);
  
  		ret = probe_file__del_strlist(kfd, klist);
  		if (ret < 0)
  			goto error;
bd862b1d8   He Zhe   perf probe: Check...
446
447
  	} else if (ret == -ENOMEM)
  		goto error;
e607f1426   Namhyung Kim   perf probe: Print...
448
449
450
  
  	ret2 = probe_file__get_events(ufd, filter, ulist);
  	if (ret2 == 0) {
602a1f4da   Arnaldo Carvalho de Melo   perf tools: Renam...
451
  		strlist__for_each_entry(ent, ulist)
e607f1426   Namhyung Kim   perf probe: Print...
452
453
454
455
456
457
  			pr_info("Removed event: %s
  ", ent->s);
  
  		ret2 = probe_file__del_strlist(ufd, ulist);
  		if (ret2 < 0)
  			goto error;
bd862b1d8   He Zhe   perf probe: Check...
458
459
  	} else if (ret2 == -ENOMEM)
  		goto error;
e607f1426   Namhyung Kim   perf probe: Print...
460
461
  
  	if (ret == -ENOENT && ret2 == -ENOENT)
70946723e   Kefeng Wang   perf probe: Retur...
462
463
464
465
  		pr_warning("\"%s\" does not hit any event.
  ", str);
  	else
  		ret = 0;
e607f1426   Namhyung Kim   perf probe: Print...
466
467
468
469
470
471
472
473
474
475
476
477
478
  
  error:
  	if (kfd >= 0)
  		close(kfd);
  	if (ufd >= 0)
  		close(ufd);
  out:
  	strlist__delete(klist);
  	strlist__delete(ulist);
  	free(str);
  
  	return ret;
  }
1c20b1d15   Masami Hiramatsu   perf probe: Show ...
479
480
481
482
483
484
  #ifdef HAVE_DWARF_SUPPORT
  #define PROBEDEF_STR	\
  	"[EVENT=]FUNC[@SRC][+OFF|%return|:RL|;PT]|SRC:AL|SRC;PT [[NAME=]ARG ...]"
  #else
  #define PROBEDEF_STR	"[EVENT=]FUNC[+OFF|%return] [[NAME=]ARG ...]"
  #endif
e53b00d38   Masami Hiramatsu   perf probe: Relea...
485
  static int
b0ad8ea66   Arnaldo Carvalho de Melo   perf tools: Remov...
486
  __cmd_probe(int argc, const char **argv)
11c4e4a32   Arnaldo Carvalho de Melo   perf probe: Don't...
487
488
489
490
491
  {
  	const char * const probe_usage[] = {
  		"perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]",
  		"perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]",
  		"perf probe [<options>] --del '[GROUP:]EVENT' ...",
b6a896438   Masami Hiramatsu   perf probe: Accep...
492
  		"perf probe --list [GROUP:]EVENT ...",
89fe808ae   Ingo Molnar   tools/perf: Stand...
493
  #ifdef HAVE_DWARF_SUPPORT
11c4e4a32   Arnaldo Carvalho de Melo   perf probe: Don't...
494
495
  		"perf probe [<options>] --line 'LINEDESC'",
  		"perf probe [<options>] --vars 'PROBEPOINT'",
f3ab481ca   Masami Hiramatsu   perf probe: Do no...
496
  #endif
b3ac032b7   Masami Hiramatsu   perf probe: Make ...
497
  		"perf probe [<options>] --funcs",
11c4e4a32   Arnaldo Carvalho de Melo   perf probe: Don't...
498
  		NULL
b6a896438   Masami Hiramatsu   perf probe: Accep...
499
  	};
13dcbbc02   Namhyung Kim   perf probe: Use P...
500
  	struct option options[] = {
c05556421   Ian Munsie   perf: Fix endiann...
501
  	OPT_INCR('v', "verbose", &verbose,
89c69c0ee   Masami Hiramatsu   perf: Use eprintf...
502
  		    "be more verbose (show parsed arguments, etc)"),
5e17b28f1   Masami Hiramatsu   perf probe: Add -...
503
  	OPT_BOOLEAN('q', "quiet", &params.quiet,
0a95160ed   Masanari Iida   treewide: Fix typ...
504
  		    "be quiet (do not show any messages)"),
b6a896438   Masami Hiramatsu   perf probe: Accep...
505
  	OPT_CALLBACK_DEFAULT('l', "list", NULL, "[GROUP:]EVENT",
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
506
507
  			     "list up probe events",
  			     opt_set_filter_with_command, DEFAULT_LIST_FILTER),
fa28244d1   Masami Hiramatsu   perf probe: Suppo...
508
  	OPT_CALLBACK('d', "del", NULL, "[GROUP:]EVENT", "delete a probe event.",
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
509
  		     opt_set_filter_with_command),
1c20b1d15   Masami Hiramatsu   perf probe: Show ...
510
  	OPT_CALLBACK('a', "add", NULL, PROBEDEF_STR,
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
511
512
  		"probe point definition, where
  "
af663d75a   Masami Hiramatsu   perf probe: Suppo...
513
514
515
516
  		"\t\tGROUP:\tGroup name (optional)
  "
  		"\t\tEVENT:\tEvent name
  "
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
517
518
  		"\t\tFUNC:\tFunction name
  "
2a9c8c360   Masami Hiramatsu   perf probe: Add l...
519
520
  		"\t\tOFF:\tOffset from function entry (in byte)
  "
253977b0d   Masami Hiramatsu   perf/probes: Impr...
521
522
  		"\t\t%return:\tPut the probe at function return
  "
89fe808ae   Ingo Molnar   tools/perf: Stand...
523
  #ifdef HAVE_DWARF_SUPPORT
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
524
525
  		"\t\tSRC:\tSource code path
  "
2a9c8c360   Masami Hiramatsu   perf probe: Add l...
526
527
528
529
530
531
  		"\t\tRL:\tRelative line number from function entry.
  "
  		"\t\tAL:\tAbsolute line number in file.
  "
  		"\t\tPT:\tLazy expression of line code.
  "
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
532
533
  		"\t\tARG:\tProbe argument (local variable name or
  "
50656eec8   Masami Hiramatsu   perf probe: Move ...
534
535
  		"\t\t\tkprobe-tracer argument format.)
  ",
4b4da7f76   Masami Hiramatsu   perf probe: Clean...
536
537
538
539
  #else
  		"\t\tARG:\tProbe argument (kprobe-tracer argument format.)
  ",
  #endif
253977b0d   Masami Hiramatsu   perf/probes: Impr...
540
  		opt_add_probe_event),
1c20b1d15   Masami Hiramatsu   perf probe: Show ...
541
542
543
  	OPT_CALLBACK('D', "definition", NULL, PROBEDEF_STR,
  		"Show trace event definition of given traceevent for k/uprobe_events.",
  		opt_add_probe_event),
ddb2f58f9   Masami Hiramatsu   perf probe: Intro...
544
  	OPT_BOOLEAN('f', "force", &probe_conf.force_add, "forcibly add events"
d761b08bf   Masami Hiramatsu   perf probe: Rejec...
545
  		    " with existing name"),
631c9def8   Masami Hiramatsu   perf probe: Suppo...
546
  	OPT_CALLBACK('L', "line", NULL,
085ea739a   Masami Hiramatsu   perf probe: Fix -...
547
  		     "FUNC[:RLN[+NUM|-RLN2]]|SRC:ALN[+NUM|-ALN2]",
631c9def8   Masami Hiramatsu   perf probe: Suppo...
548
  		     "Show source code lines.", opt_show_lines),
cf6eb489e   Masami Hiramatsu   perf probe: Show ...
549
550
551
  	OPT_CALLBACK('V', "vars", NULL,
  		     "FUNC[@SRC][+OFF|%return|:RL|;PT]|SRC:AL|SRC;PT",
  		     "Show accessible variables on PROBEDEF", opt_show_vars),
ddb2f58f9   Masami Hiramatsu   perf probe: Intro...
552
  	OPT_BOOLEAN('\0', "externs", &probe_conf.show_ext_vars,
fb8c5a56c   Masami Hiramatsu   perf probe: Show ...
553
  		    "Show external variables too (with --vars only)"),
349e8d261   He Kuang   perf probe: Add -...
554
555
  	OPT_BOOLEAN('\0', "range", &probe_conf.show_location_range,
  		"Show variables location range in scope (with --vars only)"),
4b4da7f76   Masami Hiramatsu   perf probe: Clean...
556
557
  	OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
  		   "file", "vmlinux pathname"),
9ed7e1b85   Chase Douglas   perf probe: Add k...
558
559
  	OPT_STRING('s', "source", &symbol_conf.source_prefix,
  		   "directory", "path to kernel source"),
6cfd1f680   Masami Hiramatsu   perf probe: Add -...
560
561
  	OPT_BOOLEAN('\0', "no-inlines", &probe_conf.no_inlines,
  		"Don't search inlined functions"),
f4d7da499   Masami Hiramatsu   perf probe: Add -...
562
  	OPT__DRY_RUN(&probe_event_dry_run),
ddb2f58f9   Masami Hiramatsu   perf probe: Intro...
563
  	OPT_INTEGER('\0', "max-probes", &probe_conf.max_probes,
ef4a35657   Masami Hiramatsu   perf probe: Add -...
564
  		 "Set how many probe points can be found for a probe."),
9f7811d08   Masami Hiramatsu   perf probe: Accep...
565
566
  	OPT_CALLBACK_DEFAULT('F', "funcs", NULL, "[FILTER]",
  			     "Show potential probe-able functions.",
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
567
  			     opt_set_filter_with_command, DEFAULT_FUNC_FILTER),
3c42258c9   Masami Hiramatsu   perf probe: Add f...
568
569
570
571
572
573
574
  	OPT_CALLBACK('\0', "filter", NULL,
  		     "[!]FILTER", "Set a filter (with --vars/funcs only)
  "
  		     "\t\t\t(default: \"" DEFAULT_VAR_FILTER "\" for --vars,
  "
  		     "\t\t\t \"" DEFAULT_FUNC_FILTER "\" for --funcs)",
  		     opt_set_filter),
225466f1c   Srikar Dronamraju   perf probe: Provi...
575
576
  	OPT_CALLBACK('x', "exec", NULL, "executable|path",
  			"target executable name or path", opt_set_target),
1a8ac29cb   Masami Hiramatsu   perf probe: Allow...
577
578
579
  	OPT_CALLBACK('m', "module", NULL, "modname|path",
  		"target module name (for online) or path (for offline)",
  		opt_set_target),
35e17b245   Azat Khuzhin   perf probe: Add '...
580
  	OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
4cdcc33db   Masami Hiramatsu   perf probe: Trivi...
581
  		    "Enable symbol demangling"),
763122ade   Avi Kivity   perf tools: Disab...
582
583
  	OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
  		    "Enable kernel symbol demangling"),
2fd457a34   Masami Hiramatsu   perf probe: Add -...
584
  	OPT_BOOLEAN(0, "cache", &probe_conf.cache, "Manipulate probe cache"),
d5c3a937e   Uwe Kleine-König   perf probe: Add o...
585
586
  	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
  		   "Look for files with symbols relative to this directory"),
544abd44c   Krister Johansen   perf probe: Allow...
587
588
  	OPT_CALLBACK(0, "target-ns", NULL, "pid",
  		     "target pid for namespace contexts", opt_set_target_ns),
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
589
  	OPT_END()
11c4e4a32   Arnaldo Carvalho de Melo   perf probe: Don't...
590
  	};
146a14394   Masami Hiramatsu   perf probe: Remov...
591
  	int ret;
13dcbbc02   Namhyung Kim   perf probe: Use P...
592
593
  	set_option_flag(options, 'a', "add", PARSE_OPT_EXCLUSIVE);
  	set_option_flag(options, 'd', "del", PARSE_OPT_EXCLUSIVE);
1c20b1d15   Masami Hiramatsu   perf probe: Show ...
594
  	set_option_flag(options, 'D', "definition", PARSE_OPT_EXCLUSIVE);
13dcbbc02   Namhyung Kim   perf probe: Use P...
595
596
597
598
  	set_option_flag(options, 'l', "list", PARSE_OPT_EXCLUSIVE);
  #ifdef HAVE_DWARF_SUPPORT
  	set_option_flag(options, 'L', "line", PARSE_OPT_EXCLUSIVE);
  	set_option_flag(options, 'V', "vars", PARSE_OPT_EXCLUSIVE);
48e1cab1b   Wang Nan   perf tools: Make ...
599
600
601
602
603
604
605
606
607
608
  #else
  # define set_nobuild(s, l, c) set_option_nobuild(options, s, l, "NO_DWARF=1", c)
  	set_nobuild('L', "line", false);
  	set_nobuild('V', "vars", false);
  	set_nobuild('\0', "externs", false);
  	set_nobuild('\0', "range", false);
  	set_nobuild('k', "vmlinux", true);
  	set_nobuild('s', "source", true);
  	set_nobuild('\0', "no-inlines", true);
  # undef set_nobuild
13dcbbc02   Namhyung Kim   perf probe: Use P...
609
  #endif
b3ac032b7   Masami Hiramatsu   perf probe: Make ...
610
  	set_option_flag(options, 'F', "funcs", PARSE_OPT_EXCLUSIVE);
13dcbbc02   Namhyung Kim   perf probe: Use P...
611

4ea42b181   Masami Hiramatsu   perf: Add perf pr...
612
  	argc = parse_options(argc, argv, options, probe_usage,
46ab49267   Masami Hiramatsu   perf/probes: Impr...
613
  			     PARSE_OPT_STOP_AT_NON_OPTION);
ce11a603a   Masami Hiramatsu   perf probe: Check...
614
615
  	if (argc > 0) {
  		if (strcmp(argv[0], "-") == 0) {
c71183697   Namhyung Kim   perf tools: Intro...
616
617
618
  			usage_with_options_msg(probe_usage, options,
  				"'-' is not supported.
  ");
ce11a603a   Masami Hiramatsu   perf probe: Check...
619
  		}
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
620
  		if (params.command && params.command != 'a') {
c71183697   Namhyung Kim   perf tools: Intro...
621
622
623
  			usage_with_options_msg(probe_usage, options,
  				"another command except --add is set.
  ");
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
624
  		}
146a14394   Masami Hiramatsu   perf probe: Remov...
625
626
  		ret = parse_probe_event_argv(argc, argv);
  		if (ret < 0) {
b4bf1130c   Masami Hiramatsu   perf probe: Show ...
627
  			pr_err_with_code("  Error: Command Parse Error.", ret);
146a14394   Masami Hiramatsu   perf probe: Remov...
628
629
  			return ret;
  		}
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
630
  		params.command = 'a';
ce11a603a   Masami Hiramatsu   perf probe: Check...
631
  	}
46ab49267   Masami Hiramatsu   perf/probes: Impr...
632

5e17b28f1   Masami Hiramatsu   perf probe: Add -...
633
634
635
636
637
638
639
640
  	if (params.quiet) {
  		if (verbose != 0) {
  			pr_err("  Error: -v and -q are exclusive.
  ");
  			return -EINVAL;
  		}
  		verbose = -1;
  	}
ddb2f58f9   Masami Hiramatsu   perf probe: Intro...
641
642
  	if (probe_conf.max_probes == 0)
  		probe_conf.max_probes = MAX_PROBES;
ef4a35657   Masami Hiramatsu   perf probe: Add -...
643

fd930ff91   Franck Bui-Huu   perf probe: Fix u...
644
645
646
647
  	/*
  	 * Only consider the user's kernel image path if given.
  	 */
  	symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
e50243bbe   Masami Hiramatsu   perf probe: Ignor...
648
649
650
651
652
653
654
  	/*
  	 * Except for --list, --del and --add, other command doesn't depend
  	 * nor change running kernel. So if user gives offline vmlinux,
  	 * ignore its buildid.
  	 */
  	if (!strchr("lda", params.command) && symbol_conf.vmlinux_name)
  		symbol_conf.ignore_vmlinux_buildid = true;
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
655
656
  	switch (params.command) {
  	case 'l':
225466f1c   Srikar Dronamraju   perf probe: Provi...
657
  		if (params.uprobes) {
c71183697   Namhyung Kim   perf tools: Intro...
658
659
660
661
662
  			pr_err("  Error: Don't use --list with --exec.
  ");
  			parse_options_usage(probe_usage, options, "l", true);
  			parse_options_usage(NULL, options, "x", true);
  			return -EINVAL;
225466f1c   Srikar Dronamraju   perf probe: Provi...
663
  		}
b6a896438   Masami Hiramatsu   perf probe: Accep...
664
  		ret = show_perf_probe_events(params.filter);
146a14394   Masami Hiramatsu   perf probe: Remov...
665
  		if (ret < 0)
b4bf1130c   Masami Hiramatsu   perf probe: Show ...
666
  			pr_err_with_code("  Error: Failed to show event list.", ret);
146a14394   Masami Hiramatsu   perf probe: Remov...
667
  		return ret;
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
668
  	case 'F':
544abd44c   Krister Johansen   perf probe: Allow...
669
670
  		ret = show_available_funcs(params.target, params.nsi,
  					   params.filter, params.uprobes);
e80711ca8   Masami Hiramatsu   perf probe: Add -...
671
  		if (ret < 0)
b4bf1130c   Masami Hiramatsu   perf probe: Show ...
672
  			pr_err_with_code("  Error: Failed to show functions.", ret);
e80711ca8   Masami Hiramatsu   perf probe: Add -...
673
  		return ret;
89fe808ae   Ingo Molnar   tools/perf: Stand...
674
  #ifdef HAVE_DWARF_SUPPORT
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
675
  	case 'L':
2b394bc44   Masami Hiramatsu   perf probe: Do no...
676
  		ret = show_line_range(&params.line_range, params.target,
544abd44c   Krister Johansen   perf probe: Allow...
677
  				      params.nsi, params.uprobes);
146a14394   Masami Hiramatsu   perf probe: Remov...
678
  		if (ret < 0)
b4bf1130c   Masami Hiramatsu   perf probe: Show ...
679
  			pr_err_with_code("  Error: Failed to show lines.", ret);
146a14394   Masami Hiramatsu   perf probe: Remov...
680
  		return ret;
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
681
  	case 'V':
bd09d7b5e   Masami Hiramatsu   perf probe: Add v...
682
683
684
  		if (!params.filter)
  			params.filter = strfilter__new(DEFAULT_VAR_FILTER,
  						       NULL);
cf6eb489e   Masami Hiramatsu   perf probe: Show ...
685
  		ret = show_available_vars(params.events, params.nevents,
ddb2f58f9   Masami Hiramatsu   perf probe: Intro...
686
  					  params.filter);
cf6eb489e   Masami Hiramatsu   perf probe: Show ...
687
  		if (ret < 0)
b4bf1130c   Masami Hiramatsu   perf probe: Show ...
688
  			pr_err_with_code("  Error: Failed to show vars.", ret);
cf6eb489e   Masami Hiramatsu   perf probe: Show ...
689
  		return ret;
631c9def8   Masami Hiramatsu   perf probe: Suppo...
690
  #endif
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
691
  	case 'd':
e607f1426   Namhyung Kim   perf probe: Print...
692
  		ret = perf_del_probe_events(params.filter);
146a14394   Masami Hiramatsu   perf probe: Remov...
693
  		if (ret < 0) {
b4bf1130c   Masami Hiramatsu   perf probe: Show ...
694
  			pr_err_with_code("  Error: Failed to delete events.", ret);
146a14394   Masami Hiramatsu   perf probe: Remov...
695
696
  			return ret;
  		}
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
697
  		break;
1c20b1d15   Masami Hiramatsu   perf probe: Show ...
698
  	case 'D':
428aff82e   Masami Hiramatsu   perf probe: Ignor...
699
  	case 'a':
8cb0aa4c2   Masami Hiramatsu   perf probe: Check...
700
701
  		/* Ensure the last given target is used */
  		if (params.target && !params.target_used) {
c71183697   Namhyung Kim   perf tools: Intro...
702
703
704
705
706
  			pr_err("  Error: -x/-m must follow the probe definitions.
  ");
  			parse_options_usage(probe_usage, options, "m", true);
  			parse_options_usage(NULL, options, "x", true);
  			return -EINVAL;
8cb0aa4c2   Masami Hiramatsu   perf probe: Check...
707
  		}
b02137cc6   Namhyung Kim   perf probe: Move ...
708
  		ret = perf_add_probe_events(params.events, params.nevents);
146a14394   Masami Hiramatsu   perf probe: Remov...
709
  		if (ret < 0) {
d95daf5ac   Arnaldo Carvalho de Melo   perf probe: Avoid...
710
711
712
713
714
715
716
717
718
719
  
  			/*
  			 * When perf_add_probe_events() fails it calls
  			 * cleanup_perf_probe_events(pevs, npevs), i.e.
  			 * cleanup_perf_probe_events(params.events, params.nevents), which
  			 * will call clear_perf_probe_event(), so set nevents to zero
  			 * to avoid cleanup_params() to call clear_perf_probe_event() again
  			 * on the same pevs.
  			 */
  			params.nevents = 0;
b4bf1130c   Masami Hiramatsu   perf probe: Show ...
720
  			pr_err_with_code("  Error: Failed to add events.", ret);
146a14394   Masami Hiramatsu   perf probe: Remov...
721
722
  			return ret;
  		}
b1019d5e6   Masami Hiramatsu   perf probe: Clean...
723
724
725
  		break;
  	default:
  		usage_with_options(probe_usage, options);
146a14394   Masami Hiramatsu   perf probe: Remov...
726
  	}
4ea42b181   Masami Hiramatsu   perf: Add perf pr...
727
728
  	return 0;
  }
e53b00d38   Masami Hiramatsu   perf probe: Relea...
729

b0ad8ea66   Arnaldo Carvalho de Melo   perf tools: Remov...
730
  int cmd_probe(int argc, const char **argv)
e53b00d38   Masami Hiramatsu   perf probe: Relea...
731
732
  {
  	int ret;
5a62257a3   Masami Hiramatsu   perf probe: Repla...
733
734
  	ret = init_params();
  	if (!ret) {
b0ad8ea66   Arnaldo Carvalho de Melo   perf tools: Remov...
735
  		ret = __cmd_probe(argc, argv);
5a62257a3   Masami Hiramatsu   perf probe: Repla...
736
737
  		cleanup_params();
  	}
e53b00d38   Masami Hiramatsu   perf probe: Relea...
738

9bc9f3b68   Masami Hiramatsu   perf probe: Fix t...
739
  	return ret < 0 ? ret : 0;
e53b00d38   Masami Hiramatsu   perf probe: Relea...
740
  }