aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/probe-event.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/probe-event.c')
-rw-r--r--tools/perf/util/probe-event.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index b05d532a4e4c..2ca62154f79b 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -249,11 +249,12 @@ void parse_trace_kprobe_event(const char *str, struct probe_point *pp)
249 argv_free(argv); 249 argv_free(argv);
250} 250}
251 251
252int synthesize_perf_probe_event(struct probe_point *pp) 252/* Synthesize only probe point (not argument) */
253int synthesize_perf_probe_point(struct probe_point *pp)
253{ 254{
254 char *buf; 255 char *buf;
255 char offs[64] = "", line[64] = ""; 256 char offs[64] = "", line[64] = "";
256 int i, len, ret; 257 int ret;
257 258
258 pp->probes[0] = buf = zalloc(MAX_CMDLEN); 259 pp->probes[0] = buf = zalloc(MAX_CMDLEN);
259 if (!buf) 260 if (!buf)
@@ -274,10 +275,24 @@ int synthesize_perf_probe_event(struct probe_point *pp)
274 offs, pp->retprobe ? "%return" : "", line); 275 offs, pp->retprobe ? "%return" : "", line);
275 else 276 else
276 ret = e_snprintf(buf, MAX_CMDLEN, "%s%s", pp->file, line); 277 ret = e_snprintf(buf, MAX_CMDLEN, "%s%s", pp->file, line);
277 if (ret <= 0) 278 if (ret <= 0) {
278 goto error; 279error:
279 len = ret; 280 free(pp->probes[0]);
281 pp->probes[0] = NULL;
282 }
283 return ret;
284}
285
286int synthesize_perf_probe_event(struct probe_point *pp)
287{
288 char *buf;
289 int i, len, ret;
280 290
291 len = synthesize_perf_probe_point(pp);
292 if (len < 0)
293 return 0;
294
295 buf = pp->probes[0];
281 for (i = 0; i < pp->nr_args; i++) { 296 for (i = 0; i < pp->nr_args; i++) {
282 ret = e_snprintf(&buf[len], MAX_CMDLEN - len, " %s", 297 ret = e_snprintf(&buf[len], MAX_CMDLEN - len, " %s",
283 pp->args[i]); 298 pp->args[i]);
@@ -290,6 +305,7 @@ int synthesize_perf_probe_event(struct probe_point *pp)
290 return pp->found; 305 return pp->found;
291error: 306error:
292 free(pp->probes[0]); 307 free(pp->probes[0]);
308 pp->probes[0] = NULL;
293 309
294 return ret; 310 return ret;
295} 311}
@@ -319,6 +335,7 @@ int synthesize_trace_kprobe_event(struct probe_point *pp)
319 return pp->found; 335 return pp->found;
320error: 336error:
321 free(pp->probes[0]); 337 free(pp->probes[0]);
338 pp->probes[0] = NULL;
322 339
323 return ret; 340 return ret;
324} 341}
@@ -418,7 +435,7 @@ static void show_perf_probe_event(const char *event, const char *place,
418/* List up current perf-probe events */ 435/* List up current perf-probe events */
419void show_perf_probe_events(void) 436void show_perf_probe_events(void)
420{ 437{
421 int fd, nr; 438 int fd;
422 struct probe_point pp; 439 struct probe_point pp;
423 struct strlist *rawlist; 440 struct strlist *rawlist;
424 struct str_node *ent; 441 struct str_node *ent;
@@ -430,10 +447,7 @@ void show_perf_probe_events(void)
430 strlist__for_each(ent, rawlist) { 447 strlist__for_each(ent, rawlist) {
431 parse_trace_kprobe_event(ent->s, &pp); 448 parse_trace_kprobe_event(ent->s, &pp);
432 /* Synthesize only event probe point */ 449 /* Synthesize only event probe point */
433 nr = pp.nr_args; 450 synthesize_perf_probe_point(&pp);
434 pp.nr_args = 0;
435 synthesize_perf_probe_event(&pp);
436 pp.nr_args = nr;
437 /* Show an event */ 451 /* Show an event */
438 show_perf_probe_event(pp.event, pp.probes[0], &pp); 452 show_perf_probe_event(pp.event, pp.probes[0], &pp);
439 clear_probe_point(&pp); 453 clear_probe_point(&pp);