[PATCH v4 4/7] perf/sdt: Clean uprobe_events when event(out of multiple events) parsing fails

From: Ravi Bangoria
Date: Mon Mar 06 2017 - 11:35:27 EST


User may ask for multiple events in the same record command like,

perf record -a -e sdt_1:* -e sdt_2:*

If sdt_1:* events are already added to uprobe_events and sdt_2:*
event parsing fails, clean sdt_1:* events from uprobe_events.

Signed-off-by: Ravi Bangoria <ravi.bangoria@xxxxxxxxxxxxxxxxxx>
---
tools/perf/builtin-record.c | 7 +++----
tools/perf/perf.h | 1 +
tools/perf/util/probe-file.c | 4 +++-
3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index e87b19b..46d447e 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1517,11 +1517,10 @@ bool is_cmd_record(void)
return (record.evlist != NULL);
}

-static void
-sdt_event_list__remove(struct list_head *sdt_event_list __maybe_unused)
+void sdt_event_list__remove(void)
{
#ifdef HAVE_LIBELF_SUPPORT
- return remove_sdt_event_list(sdt_event_list);
+ return remove_sdt_event_list(&record.sdt_event_list);
#endif
}

@@ -1864,7 +1863,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
perf_evlist__delete(rec->evlist);
symbol__exit();
auxtrace_record__free(rec->itr);
- sdt_event_list__remove(&rec->sdt_event_list);
+ sdt_event_list__remove();
return err;
}

diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 9d8e5fe..8a411f1 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -77,4 +77,5 @@ struct option;
extern const char * const *record_usage;
extern struct option *record_options;
bool is_cmd_record(void);
+void sdt_event_list__remove(void);
#endif
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index 47b624a..358ca98 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -1192,8 +1192,10 @@ int add_sdt_event(char *event, struct list_head *sdt_evlist)
ret = 0;

free_pev:
- if (ret < 0)
+ if (ret < 0) {
free_sdt_list(sdt_evlist);
+ sdt_event_list__remove();
+ }
cleanup_perf_probe_events(pev, 1);
clear_probe_trace_events(exst_tevs, exst_ntevs);
free(pev);
--
2.9.3