perf util: Move debugfs/tracing helper functions to util.c
authorNamhyung Kim <namhyung.kim@lge.com>
Wed, 26 Jun 2013 07:14:04 +0000 (16:14 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 12 Jul 2013 16:46:00 +0000 (13:46 -0300)
Since they're generic helpers move them to util.c so that they can be
used by others.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1372230862-15861-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/trace-event-info.c
tools/perf/util/util.c
tools/perf/util/util.h

index 3917eb9a8479f7a4b11e6bd1f6e39f146f159523..615c0628678bd98f5b67aa1cc14eebdccf18da1e 100644 (file)
 static int output_fd;
 
 
-static const char *find_debugfs(void)
-{
-       const char *path = perf_debugfs_mount(NULL);
-
-       if (!path)
-               pr_debug("Your kernel does not support the debugfs filesystem");
-
-       return path;
-}
-
-/*
- * Finds the path to the debugfs/tracing
- * Allocates the string and stores it.
- */
-static const char *find_tracing_dir(void)
-{
-       static char *tracing;
-       static int tracing_found;
-       const char *debugfs;
-
-       if (tracing_found)
-               return tracing;
-
-       debugfs = find_debugfs();
-       if (!debugfs)
-               return NULL;
-
-       tracing = malloc(strlen(debugfs) + 9);
-       if (!tracing)
-               return NULL;
-
-       sprintf(tracing, "%s/tracing", debugfs);
-
-       tracing_found = 1;
-       return tracing;
-}
-
-static char *get_tracing_file(const char *name)
-{
-       const char *tracing;
-       char *file;
-
-       tracing = find_tracing_dir();
-       if (!tracing)
-               return NULL;
-
-       file = malloc(strlen(tracing) + strlen(name) + 2);
-       if (!file)
-               return NULL;
-
-       sprintf(file, "%s/%s", tracing, name);
-       return file;
-}
-
-static void put_tracing_file(char *file)
-{
-       free(file);
-}
-
 int bigendian(void)
 {
        unsigned char str[] = { 0x1, 0x2, 0x3, 0x4, 0x0, 0x0, 0x0, 0x0};
index 59d868add275d4cc5d23800c691f7e4e758a9a3d..9a0658405760e1158d1ca1f51ead1472b651058c 100644 (file)
@@ -269,3 +269,62 @@ void perf_debugfs_set_path(const char *mntpt)
        snprintf(debugfs_mountpoint, strlen(debugfs_mountpoint), "%s", mntpt);
        set_tracing_events_path(mntpt);
 }
+
+static const char *find_debugfs(void)
+{
+       const char *path = perf_debugfs_mount(NULL);
+
+       if (!path)
+               fprintf(stderr, "Your kernel does not support the debugfs filesystem");
+
+       return path;
+}
+
+/*
+ * Finds the path to the debugfs/tracing
+ * Allocates the string and stores it.
+ */
+const char *find_tracing_dir(void)
+{
+       static char *tracing;
+       static int tracing_found;
+       const char *debugfs;
+
+       if (tracing_found)
+               return tracing;
+
+       debugfs = find_debugfs();
+       if (!debugfs)
+               return NULL;
+
+       tracing = malloc(strlen(debugfs) + 9);
+       if (!tracing)
+               return NULL;
+
+       sprintf(tracing, "%s/tracing", debugfs);
+
+       tracing_found = 1;
+       return tracing;
+}
+
+char *get_tracing_file(const char *name)
+{
+       const char *tracing;
+       char *file;
+
+       tracing = find_tracing_dir();
+       if (!tracing)
+               return NULL;
+
+       file = malloc(strlen(tracing) + strlen(name) + 2);
+       if (!file)
+               return NULL;
+
+       sprintf(file, "%s/%s", tracing, name);
+       return file;
+}
+
+void put_tracing_file(char *file)
+{
+       free(file);
+}
index 2732fad039088ab97369bbe6e727b950ef6a0dcb..cc1574edcd9abbe2554c5f3d986af7427c255485 100644 (file)
@@ -80,6 +80,9 @@ extern char buildid_dir[];
 extern char tracing_events_path[];
 extern void perf_debugfs_set_path(const char *mountpoint);
 const char *perf_debugfs_mount(const char *mountpoint);
+const char *find_tracing_dir(void);
+char *get_tracing_file(const char *name);
+void put_tracing_file(char *file);
 
 /* On most systems <limits.h> would have given us this, but
  * not on some systems (e.g. GNU/Hurd).