Skip to contentSkip to conversation

perf tools: Move print_binary definitions to separate files

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Apr 20, 2017 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  fea013928cdcf81fbe0bfbf9e2eed1c7da2d62c2
Gitweb:     http://git.kernel.org/tip/fea013928cdcf81fbe0bfbf9e2eed1c7da2d62c2
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Mon, 17 Apr 2017 16:23:22 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 19 Apr 2017 13:01:50 -0300

perf tools: Move print_binary definitions to separate files

Continuing the split of util.[ch] into more manageable bits.

---
 tools/perf/builtin-script.c                        |  1 +
 tools/perf/builtin-trace.c                         |  1 +
 tools/perf/tests/is_printable_array.c              |  2 +-
 tools/perf/util/Build                              |  1 +
 tools/perf/util/debug.c                            |  1 +
 tools/perf/util/print_binary.c                     | 55 ++++++++++++++++++++++
 tools/perf/util/print_binary.h                     | 28 +++++++++++
 tools/perf/util/python-ext-sources                 |  1 +
 tools/perf/util/python.c                           |  1 +
 .../util/scripting-engines/trace-event-python.c    |  1 +
 tools/perf/util/util.c                             | 54 ---------------------
 tools/perf/util/util.h                             | 23 ---------
 12 files changed, 91 insertions(+), 78 deletions(-)
tools/perf/builtin-script.c +1 -0
index 5afd9a6..5f4e36a 100644
@@ -23,6 +23,7 @@
 #include "util/stat.h"
 #include "util/thread-stack.h"
 #include "util/time-utils.h"
+#include "print_binary.h"
 #include <linux/bitmap.h>
 #include <linux/kernel.h>
 #include <linux/stringify.h>
tools/perf/builtin-trace.c +1 -0
index 0b00d8a..9a8b9e6 100644
@@ -36,6 +36,7 @@
 #include "util/parse-events.h"
 #include "util/bpf-loader.h"
 #include "callchain.h"
+#include "print_binary.h"
 #include "syscalltbl.h"
 #include "rb_resort.h"
 
tools/perf/tests/is_printable_array.c +1 -1
index a008e5c..a5192f6 100644
@@ -2,7 +2,7 @@
 #include <linux/kernel.h>
 #include "tests.h"
 #include "debug.h"
-#include "util.h"
+#include "print_binary.h"
 
 int test__is_printable_array(int subtest __maybe_unused)
 {
tools/perf/util/Build +1 -0
index 5c0ea11..f0b9e5d 100644
@@ -16,6 +16,7 @@ libperf-y += llvm-utils.o
 libperf-y += parse-events.o
 libperf-y += perf_regs.o
 libperf-y += path.o
+libperf-y += print_binary.o
 libperf-y += rbtree.o
 libperf-y += libstring.o
 libperf-y += bitmap.o
tools/perf/util/debug.c +1 -0
index 41aa7c6..6e1d7e1 100644
@@ -13,6 +13,7 @@
 #include "color.h"
 #include "event.h"
 #include "debug.h"
+#include "print_binary.h"
 #include "util.h"
 #include "target.h"
 
tools/perf/util/print_binary.c new file +55 -0

55 lines not on this page · raw message

tools/perf/util/print_binary.h new file +28 -0
new file mode 100644
index 0000000..da04272
@@ -0,0 +1,28 @@
+#ifndef PERF_PRINT_BINARY_H
+#define PERF_PRINT_BINARY_H
+
+#include <stddef.h>
+
+enum binary_printer_ops {
+	BINARY_PRINT_DATA_BEGIN,
+	BINARY_PRINT_LINE_BEGIN,
+	BINARY_PRINT_ADDR,
+	BINARY_PRINT_NUM_DATA,
+	BINARY_PRINT_NUM_PAD,
+	BINARY_PRINT_SEP,
+	BINARY_PRINT_CHAR_DATA,
+	BINARY_PRINT_CHAR_PAD,
+	BINARY_PRINT_LINE_END,
+	BINARY_PRINT_DATA_END,
+};
+
+typedef void (*print_binary_t)(enum binary_printer_ops op,
+			       unsigned int val, void *extra);
+
+void print_binary(unsigned char *data, size_t len,
+		  size_t bytes_per_line, print_binary_t printer,
+		  void *extra);
+
+int is_printable_array(char *p, unsigned int len);
+
+#endif /* PERF_PRINT_BINARY_H */
tools/perf/util/python-ext-sources +1 -0
index 0546a43..7d39274 100644
@@ -21,6 +21,7 @@ util/cgroup.c
 util/parse-branch-options.c
 util/rblist.c
 util/counts.c
+util/print_binary.c
 util/strlist.c
 util/trace-event.c
 ../lib/rbtree.c
tools/perf/util/python.c +1 -0
index a5fbc01..0533711 100644
@@ -7,6 +7,7 @@
 #include "evsel.h"
 #include "event.h"
 #include "cpumap.h"
+#include "print_binary.h"
 #include "thread_map.h"
 
 /*
tools/perf/util/scripting-engines/trace-event-python.c +1 -0
index dd61213..9d92af7 100644
@@ -46,6 +46,7 @@
 #include "../call-path.h"
 #include "thread_map.h"
 #include "cpumap.h"
+#include "print_binary.h"
 #include "stat.h"
 
 PyMODINIT_FUNC initperf_trace_context(void);
tools/perf/util/util.c +0 -54

66 lines not on this page · raw message

tools/perf/util/util.h +0 -23
index f7e1ead..4d9069a 100644
@@ -213,33 +213,10 @@ const char *perf_tip(const char *dirpath);
 bool is_regular_file(const char *file);
 int fetch_current_timestamp(char *buf, size_t sz);
 
-enum binary_printer_ops {
-	BINARY_PRINT_DATA_BEGIN,
-	BINARY_PRINT_LINE_BEGIN,
-	BINARY_PRINT_ADDR,
-	BINARY_PRINT_NUM_DATA,
-	BINARY_PRINT_NUM_PAD,
-	BINARY_PRINT_SEP,
-	BINARY_PRINT_CHAR_DATA,
-	BINARY_PRINT_CHAR_PAD,
-	BINARY_PRINT_LINE_END,
-	BINARY_PRINT_DATA_END,
-};
-
-typedef void (*print_binary_t)(enum binary_printer_ops,
-			       unsigned int val,
-			       void *extra);
-
-void print_binary(unsigned char *data, size_t len,
-		  size_t bytes_per_line, print_binary_t printer,
-		  void *extra);
-
 #ifndef HAVE_SCHED_GETCPU_SUPPORT
 int sched_getcpu(void);
 #endif
 
-int is_printable_array(char *p, unsigned int len);
-
 int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz);
 
 int unit_number__scnprintf(char *buf, size_t size, u64 n);