perf tools: Make binary data printer code in trace_event public available

Move code printing binray data from trace_event() to utils.c and allows
passing different printer. Further commits will use this logic to print
bpf output event.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1456312845-111583-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Wang Nan
2016-02-24 11:20:44 +00:00
committed by Arnaldo Carvalho de Melo
parent c19ac91245
commit c339b1a90e
3 changed files with 105 additions and 27 deletions

View File

@@ -345,4 +345,24 @@ 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);
#endif /* GIT_COMPAT_UTIL_H */