aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>2015-07-15 05:14:00 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-07-20 16:49:49 -0400
commita3c9de6280b8d196ab89ca7fad143bfa2a949790 (patch)
treefeb865fda9d44ac269cce3fdc150865b252d1032 /tools/perf/util
parent4ba1faa19fa5f415bd69b1d7c366028332468bca (diff)
perf probe: Simplify __add_probe_trace_events code
Simplify the __add_probe_trace_events() code by taking out the probe_trace_event__set_name() and updating show_perf_probe_event() Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: Hemant Kumar <hemant@linux.vnet.ibm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20150715091400.8915.85501.stgit@localhost.localdomain Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/probe-event.c70
1 files changed, 43 insertions, 27 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 7abaac4ec866..54a91d765791 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2478,16 +2478,54 @@ out:
2478 free(buf); 2478 free(buf);
2479} 2479}
2480 2480
2481/* Set new name from original perf_probe_event and namelist */
2482static int probe_trace_event__set_name(struct probe_trace_event *tev,
2483 struct perf_probe_event *pev,
2484 struct strlist *namelist,
2485 bool allow_suffix)
2486{
2487 const char *event, *group;
2488 char buf[64];
2489 int ret;
2490
2491 if (pev->event)
2492 event = pev->event;
2493 else
2494 if (pev->point.function && !strisglob(pev->point.function))
2495 event = pev->point.function;
2496 else
2497 event = tev->point.realname;
2498 if (pev->group)
2499 group = pev->group;
2500 else
2501 group = PERFPROBE_GROUP;
2502
2503 /* Get an unused new event name */
2504 ret = get_new_event_name(buf, 64, event,
2505 namelist, allow_suffix);
2506 if (ret < 0)
2507 return ret;
2508
2509 event = buf;
2510
2511 tev->event = strdup(event);
2512 tev->group = strdup(group);
2513 if (tev->event == NULL || tev->group == NULL)
2514 return -ENOMEM;
2515
2516 /* Add added event name to namelist */
2517 strlist__add(namelist, event);
2518 return 0;
2519}
2520
2481static int __add_probe_trace_events(struct perf_probe_event *pev, 2521static int __add_probe_trace_events(struct perf_probe_event *pev,
2482 struct probe_trace_event *tevs, 2522 struct probe_trace_event *tevs,
2483 int ntevs, bool allow_suffix) 2523 int ntevs, bool allow_suffix)
2484{ 2524{
2485 int i, fd, ret; 2525 int i, fd, ret;
2486 struct probe_trace_event *tev = NULL; 2526 struct probe_trace_event *tev = NULL;
2487 char buf[64];
2488 const char *event = NULL, *group = NULL; 2527 const char *event = NULL, *group = NULL;
2489 struct strlist *namelist; 2528 struct strlist *namelist;
2490 bool safename;
2491 2529
2492 if (pev->uprobes) 2530 if (pev->uprobes)
2493 fd = open_uprobe_events(true); 2531 fd = open_uprobe_events(true);
@@ -2507,7 +2545,6 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
2507 goto close_out; 2545 goto close_out;
2508 } 2546 }
2509 2547
2510 safename = (pev->point.function && !strisglob(pev->point.function));
2511 ret = 0; 2548 ret = 0;
2512 pr_info("Added new event%s\n", (ntevs > 1) ? "s:" : ":"); 2549 pr_info("Added new event%s\n", (ntevs > 1) ? "s:" : ":");
2513 for (i = 0; i < ntevs; i++) { 2550 for (i = 0; i < ntevs; i++) {
@@ -2516,36 +2553,15 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
2516 if (!tev->point.symbol) 2553 if (!tev->point.symbol)
2517 continue; 2554 continue;
2518 2555
2519 if (pev->event) 2556 /* Set new name for tev (and update namelist) */
2520 event = pev->event; 2557 ret = probe_trace_event__set_name(tev, pev, namelist,
2521 else 2558 allow_suffix);
2522 if (safename)
2523 event = pev->point.function;
2524 else
2525 event = tev->point.realname;
2526 if (pev->group)
2527 group = pev->group;
2528 else
2529 group = PERFPROBE_GROUP;
2530
2531 /* Get an unused new event name */
2532 ret = get_new_event_name(buf, 64, event,
2533 namelist, allow_suffix);
2534 if (ret < 0) 2559 if (ret < 0)
2535 break; 2560 break;
2536 event = buf;
2537 2561
2538 tev->event = strdup(event);
2539 tev->group = strdup(group);
2540 if (tev->event == NULL || tev->group == NULL) {
2541 ret = -ENOMEM;
2542 break;
2543 }
2544 ret = write_probe_trace_event(fd, tev); 2562 ret = write_probe_trace_event(fd, tev);
2545 if (ret < 0) 2563 if (ret < 0)
2546 break; 2564 break;
2547 /* Add added event name to namelist */
2548 strlist__add(namelist, event);
2549 2565
2550 /* We use tev's name for showing new events */ 2566 /* We use tev's name for showing new events */
2551 show_perf_probe_event(tev->group, tev->event, pev, 2567 show_perf_probe_event(tev->group, tev->event, pev,