trace-cmd: Record the file name of plugins in plugin list

Keep the file name of plugins in the plugin list in case we need
to debug a plugin.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
diff --git a/trace-util.c b/trace-util.c
index d6c1948..41c4f9b 100644
--- a/trace-util.c
+++ b/trace-util.c
@@ -26,6 +26,7 @@
 
 struct plugin_list {
 	struct plugin_list	*next;
+	char			*name;
 	void			*handle;
 };
 
@@ -175,25 +176,28 @@
 	if (!handle) {
 		warning("cound not load plugin '%s'\n%s\n",
 			plugin, dlerror());
-		goto out;
+		goto out_free;
 	}
 
-	list = malloc_or_die(sizeof(*list));
-	list->next = plugin_list;
-	list->handle = handle;
-	plugin_list = list;
-
 	func = dlsym(handle, PEVENT_PLUGIN_LOADER_NAME);
 	if (!func) {
 		warning("cound not find func '%s' in plugin '%s'\n%s\n",
 			PEVENT_PLUGIN_LOADER_NAME, plugin, dlerror());
-		goto out;
+		goto out_free;
 	}
 
+	list = malloc_or_die(sizeof(*list));
+	list->next = plugin_list;
+	list->handle = handle;
+	list->name = plugin;
+	plugin_list = list;
+
 	printf("registering plugin: %s\n", plugin);
 	ret = func(pevent);
 
- out:
+	return plugin_list;
+
+ out_free:
 	free(plugin);
 
 	return plugin_list;
@@ -315,6 +319,7 @@
 		if (func)
 			func();
 		dlclose(list->handle);
+		free(list->name);
 		free(list);
 	}
 }