summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2017-04-17 16:23:22 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-04-19 13:01:50 -0300
commitfea013928cdcf81fbe0bfbf9e2eed1c7da2d62c2 (patch)
tree92335965a80f1ceeebdfd6d4b231abbbd117dc85 /tools/perf
parenta12a4e023a55f058178afea1ada3ce7bf4db94c3 (diff)
downloadlinux-stable-fea013928cdcf81fbe0bfbf9e2eed1c7da2d62c2.tar.gz
linux-stable-fea013928cdcf81fbe0bfbf9e2eed1c7da2d62c2.tar.bz2
linux-stable-fea013928cdcf81fbe0bfbf9e2eed1c7da2d62c2.zip
perf tools: Move print_binary definitions to separate files
Continuing the split of util.[ch] into more manageable bits. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-5eu367rwcwnvvn7fz09l7xpb@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-script.c1
-rw-r--r--tools/perf/builtin-trace.c1
-rw-r--r--tools/perf/tests/is_printable_array.c2
-rw-r--r--tools/perf/util/Build1
-rw-r--r--tools/perf/util/debug.c1
-rw-r--r--tools/perf/util/print_binary.c55
-rw-r--r--tools/perf/util/print_binary.h28
-rw-r--r--tools/perf/util/python-ext-sources1
-rw-r--r--tools/perf/util/python.c1
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c1
-rw-r--r--tools/perf/util/util.c54
-rw-r--r--tools/perf/util/util.h23
12 files changed, 91 insertions, 78 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 5afd9a62360a..5f4e36a4c444 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -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>
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 0b00d8ac5226..9a8b9e6f47f7 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -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"
diff --git a/tools/perf/tests/is_printable_array.c b/tools/perf/tests/is_printable_array.c
index a008e5c2d980..a5192f6a20d7 100644
--- a/tools/perf/tests/is_printable_array.c
+++ b/tools/perf/tests/is_printable_array.c
@@ -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)
{
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 5c0ea11a8f0a..f0b9e5d0e2fc 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -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
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 41aa7c63e037..6e1d7e159649 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -13,6 +13,7 @@
#include "color.h"
#include "event.h"
#include "debug.h"
+#include "print_binary.h"
#include "util.h"
#include "target.h"
diff --git a/tools/perf/util/print_binary.c b/tools/perf/util/print_binary.c
new file mode 100644
index 000000000000..e908177b9976
--- /dev/null
+++ b/tools/perf/util/print_binary.c
@@ -0,0 +1,55 @@
+#include "print_binary.h"
+#include <linux/log2.h>
+#include "sane_ctype.h"
+
+void print_binary(unsigned char *data, size_t len,
+ size_t bytes_per_line, print_binary_t printer,
+ void *extra)
+{
+ size_t i, j, mask;
+
+ if (!printer)
+ return;
+
+ bytes_per_line = roundup_pow_of_two(bytes_per_line);
+ mask = bytes_per_line - 1;
+
+ printer(BINARY_PRINT_DATA_BEGIN, 0, extra);
+ for (i = 0; i < len; i++) {
+ if ((i & mask) == 0) {
+ printer(BINARY_PRINT_LINE_BEGIN, -1, extra);
+ printer(BINARY_PRINT_ADDR, i, extra);
+ }
+
+ printer(BINARY_PRINT_NUM_DATA, data[i], extra);
+
+ if (((i & mask) == mask) || i == len - 1) {
+ for (j = 0; j < mask-(i & mask); j++)
+ printer(BINARY_PRINT_NUM_PAD, -1, extra);
+
+ printer(BINARY_PRINT_SEP, i, extra);
+ for (j = i & ~mask; j <= i; j++)
+ printer(BINARY_PRINT_CHAR_DATA, data[j], extra);
+ for (j = 0; j < mask-(i & mask); j++)
+ printer(BINARY_PRINT_CHAR_PAD, i, extra);
+ printer(BINARY_PRINT_LINE_END, -1, extra);
+ }
+ }
+ printer(BINARY_PRINT_DATA_END, -1, extra);
+}
+
+int is_printable_array(char *p, unsigned int len)
+{
+ unsigned int i;
+
+ if (!p || !len || p[len - 1] != 0)
+ return 0;
+
+ len--;
+
+ for (i = 0; i < len; i++) {
+ if (!isprint(p[i]) && !isspace(p[i]))
+ return 0;
+ }
+ return 1;
+}
diff --git a/tools/perf/util/print_binary.h b/tools/perf/util/print_binary.h
new file mode 100644
index 000000000000..da0427263d2d
--- /dev/null
+++ b/tools/perf/util/print_binary.h
@@ -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 */
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources
index 0546a4304347..7d3927447fba 100644
--- a/tools/perf/util/python-ext-sources
+++ b/tools/perf/util/python-ext-sources
@@ -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
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index a5fbc012e3df..0533711af44d 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -7,6 +7,7 @@
#include "evsel.h"
#include "event.h"
#include "cpumap.h"
+#include "print_binary.h"
#include "thread_map.h"
/*
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index dd61213e7a3c..9d92af7d0718 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -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);
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 717541e72999..4fb8ee552a31 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -21,8 +21,6 @@
#include "callchain.h"
#include "strlist.h"
-#include "sane_ctype.h"
-
#define CALLCHAIN_PARAM_DEFAULT \
.mode = CHAIN_GRAPH_ABS, \
.min_percent = 0.5, \
@@ -742,58 +740,6 @@ int fetch_current_timestamp(char *buf, size_t sz)
return 0;
}
-void print_binary(unsigned char *data, size_t len,
- size_t bytes_per_line, print_binary_t printer,
- void *extra)
-{
- size_t i, j, mask;
-
- if (!printer)
- return;
-
- bytes_per_line = roundup_pow_of_two(bytes_per_line);
- mask = bytes_per_line - 1;
-
- printer(BINARY_PRINT_DATA_BEGIN, 0, extra);
- for (i = 0; i < len; i++) {
- if ((i & mask) == 0) {
- printer(BINARY_PRINT_LINE_BEGIN, -1, extra);
- printer(BINARY_PRINT_ADDR, i, extra);
- }
-
- printer(BINARY_PRINT_NUM_DATA, data[i], extra);
-
- if (((i & mask) == mask) || i == len - 1) {
- for (j = 0; j < mask-(i & mask); j++)
- printer(BINARY_PRINT_NUM_PAD, -1, extra);
-
- printer(BINARY_PRINT_SEP, i, extra);
- for (j = i & ~mask; j <= i; j++)
- printer(BINARY_PRINT_CHAR_DATA, data[j], extra);
- for (j = 0; j < mask-(i & mask); j++)
- printer(BINARY_PRINT_CHAR_PAD, i, extra);
- printer(BINARY_PRINT_LINE_END, -1, extra);
- }
- }
- printer(BINARY_PRINT_DATA_END, -1, extra);
-}
-
-int is_printable_array(char *p, unsigned int len)
-{
- unsigned int i;
-
- if (!p || !len || p[len - 1] != 0)
- return 0;
-
- len--;
-
- for (i = 0; i < len; i++) {
- if (!isprint(p[i]) && !isspace(p[i]))
- return 0;
- }
- return 1;
-}
-
int unit_number__scnprintf(char *buf, size_t size, u64 n)
{
char unit[4] = "BKMG";
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index f7e1ead50f47..4d9069ab569a 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -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);