diff options
author | Tzvetomir Stoyanov <tstoyanov@vmware.com> | 2018-11-30 10:44:10 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-12-17 12:56:10 -0500 |
commit | 6cd99d21741dbffb40e28ab7d955b27d09c3352f (patch) | |
tree | 7359bc5e63fce546ad023da30cc81d1977e6477e | |
parent | f0bba09ce3f88ddeef7a3e45f612d26b1e951d5b (diff) |
tools lib traceevent: traceevent API cleanup
In order to make libtraceevent into a proper library, its API should be
straightforward. This patch hides few API functions, intended for
internal usage only:
tep_free_event(), tep_free_format_field(), __tep_data2host2(),
__tep_data2host4() and __tep_data2host8().
The patch also alignes the libtraceevent summary man page with
these API changes.
Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20181130154647.891651290@goodmis.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/lib/traceevent/event-parse-api.c | 6 | ||||
-rw-r--r-- | tools/lib/traceevent/event-parse-local.h | 7 | ||||
-rw-r--r-- | tools/lib/traceevent/event-parse.c | 13 | ||||
-rw-r--r-- | tools/lib/traceevent/event-parse.h | 16 |
4 files changed, 18 insertions, 24 deletions
diff --git a/tools/lib/traceevent/event-parse-api.c b/tools/lib/traceevent/event-parse-api.c index 0dc011154ee9..8b31c0e00ba3 100644 --- a/tools/lib/traceevent/event-parse-api.c +++ b/tools/lib/traceevent/event-parse-api.c | |||
@@ -51,7 +51,7 @@ void tep_set_flag(struct tep_handle *tep, int flag) | |||
51 | tep->flags |= flag; | 51 | tep->flags |= flag; |
52 | } | 52 | } |
53 | 53 | ||
54 | unsigned short __tep_data2host2(struct tep_handle *pevent, unsigned short data) | 54 | unsigned short tep_data2host2(struct tep_handle *pevent, unsigned short data) |
55 | { | 55 | { |
56 | unsigned short swap; | 56 | unsigned short swap; |
57 | 57 | ||
@@ -64,7 +64,7 @@ unsigned short __tep_data2host2(struct tep_handle *pevent, unsigned short data) | |||
64 | return swap; | 64 | return swap; |
65 | } | 65 | } |
66 | 66 | ||
67 | unsigned int __tep_data2host4(struct tep_handle *pevent, unsigned int data) | 67 | unsigned int tep_data2host4(struct tep_handle *pevent, unsigned int data) |
68 | { | 68 | { |
69 | unsigned int swap; | 69 | unsigned int swap; |
70 | 70 | ||
@@ -80,7 +80,7 @@ unsigned int __tep_data2host4(struct tep_handle *pevent, unsigned int data) | |||
80 | } | 80 | } |
81 | 81 | ||
82 | unsigned long long | 82 | unsigned long long |
83 | __tep_data2host8(struct tep_handle *pevent, unsigned long long data) | 83 | tep_data2host8(struct tep_handle *pevent, unsigned long long data) |
84 | { | 84 | { |
85 | unsigned long long swap; | 85 | unsigned long long swap; |
86 | 86 | ||
diff --git a/tools/lib/traceevent/event-parse-local.h b/tools/lib/traceevent/event-parse-local.h index 94746efef433..9a092dd4a86d 100644 --- a/tools/lib/traceevent/event-parse-local.h +++ b/tools/lib/traceevent/event-parse-local.h | |||
@@ -89,4 +89,11 @@ struct tep_handle { | |||
89 | char *trace_clock; | 89 | char *trace_clock; |
90 | }; | 90 | }; |
91 | 91 | ||
92 | void tep_free_event(struct tep_event *event); | ||
93 | void tep_free_format_field(struct tep_format_field *field); | ||
94 | |||
95 | unsigned short tep_data2host2(struct tep_handle *pevent, unsigned short data); | ||
96 | unsigned int tep_data2host4(struct tep_handle *pevent, unsigned int data); | ||
97 | unsigned long long tep_data2host8(struct tep_handle *pevent, unsigned long long data); | ||
98 | |||
92 | #endif /* _PARSE_EVENTS_INT_H */ | 99 | #endif /* _PARSE_EVENTS_INT_H */ |
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index a3e7d0a75e11..ffa656b868a9 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c | |||
@@ -3328,15 +3328,18 @@ tep_find_any_field(struct tep_event *event, const char *name) | |||
3328 | unsigned long long tep_read_number(struct tep_handle *pevent, | 3328 | unsigned long long tep_read_number(struct tep_handle *pevent, |
3329 | const void *ptr, int size) | 3329 | const void *ptr, int size) |
3330 | { | 3330 | { |
3331 | unsigned long long val; | ||
3332 | |||
3331 | switch (size) { | 3333 | switch (size) { |
3332 | case 1: | 3334 | case 1: |
3333 | return *(unsigned char *)ptr; | 3335 | return *(unsigned char *)ptr; |
3334 | case 2: | 3336 | case 2: |
3335 | return tep_data2host2(pevent, ptr); | 3337 | return tep_data2host2(pevent, *(unsigned short *)ptr); |
3336 | case 4: | 3338 | case 4: |
3337 | return tep_data2host4(pevent, ptr); | 3339 | return tep_data2host4(pevent, *(unsigned int *)ptr); |
3338 | case 8: | 3340 | case 8: |
3339 | return tep_data2host8(pevent, ptr); | 3341 | memcpy(&val, (ptr), sizeof(unsigned long long)); |
3342 | return tep_data2host8(pevent, val); | ||
3340 | default: | 3343 | default: |
3341 | /* BUG! */ | 3344 | /* BUG! */ |
3342 | return 0; | 3345 | return 0; |
@@ -4062,7 +4065,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, | |||
4062 | f = tep_find_any_field(event, arg->string.string); | 4065 | f = tep_find_any_field(event, arg->string.string); |
4063 | arg->string.offset = f->offset; | 4066 | arg->string.offset = f->offset; |
4064 | } | 4067 | } |
4065 | str_offset = tep_data2host4(pevent, data + arg->string.offset); | 4068 | str_offset = tep_data2host4(pevent, *(unsigned int *)(data + arg->string.offset)); |
4066 | str_offset &= 0xffff; | 4069 | str_offset &= 0xffff; |
4067 | print_str_to_seq(s, format, len_arg, ((char *)data) + str_offset); | 4070 | print_str_to_seq(s, format, len_arg, ((char *)data) + str_offset); |
4068 | break; | 4071 | break; |
@@ -4080,7 +4083,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, | |||
4080 | f = tep_find_any_field(event, arg->bitmask.bitmask); | 4083 | f = tep_find_any_field(event, arg->bitmask.bitmask); |
4081 | arg->bitmask.offset = f->offset; | 4084 | arg->bitmask.offset = f->offset; |
4082 | } | 4085 | } |
4083 | bitmask_offset = tep_data2host4(pevent, data + arg->bitmask.offset); | 4086 | bitmask_offset = tep_data2host4(pevent, *(unsigned int *)(data + arg->bitmask.offset)); |
4084 | bitmask_size = bitmask_offset >> 16; | 4087 | bitmask_size = bitmask_offset >> 16; |
4085 | bitmask_offset &= 0xffff; | 4088 | bitmask_offset &= 0xffff; |
4086 | print_bitmask_to_seq(pevent, s, format, len_arg, | 4089 | print_bitmask_to_seq(pevent, s, format, len_arg, |
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 950ad185a5c4..35d37087d3c5 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h | |||
@@ -409,20 +409,6 @@ void tep_print_plugins(struct trace_seq *s, | |||
409 | typedef char *(tep_func_resolver_t)(void *priv, | 409 | typedef char *(tep_func_resolver_t)(void *priv, |
410 | unsigned long long *addrp, char **modp); | 410 | unsigned long long *addrp, char **modp); |
411 | void tep_set_flag(struct tep_handle *tep, int flag); | 411 | void tep_set_flag(struct tep_handle *tep, int flag); |
412 | unsigned short __tep_data2host2(struct tep_handle *pevent, unsigned short data); | ||
413 | unsigned int __tep_data2host4(struct tep_handle *pevent, unsigned int data); | ||
414 | unsigned long long | ||
415 | __tep_data2host8(struct tep_handle *pevent, unsigned long long data); | ||
416 | |||
417 | #define tep_data2host2(pevent, ptr) __tep_data2host2(pevent, *(unsigned short *)(ptr)) | ||
418 | #define tep_data2host4(pevent, ptr) __tep_data2host4(pevent, *(unsigned int *)(ptr)) | ||
419 | #define tep_data2host8(pevent, ptr) \ | ||
420 | ({ \ | ||
421 | unsigned long long __val; \ | ||
422 | \ | ||
423 | memcpy(&__val, (ptr), sizeof(unsigned long long)); \ | ||
424 | __tep_data2host8(pevent, __val); \ | ||
425 | }) | ||
426 | 412 | ||
427 | static inline int tep_host_bigendian(void) | 413 | static inline int tep_host_bigendian(void) |
428 | { | 414 | { |
@@ -475,8 +461,6 @@ enum tep_errno tep_parse_format(struct tep_handle *pevent, | |||
475 | struct tep_event **eventp, | 461 | struct tep_event **eventp, |
476 | const char *buf, | 462 | const char *buf, |
477 | unsigned long size, const char *sys); | 463 | unsigned long size, const char *sys); |
478 | void tep_free_event(struct tep_event *event); | ||
479 | void tep_free_format_field(struct tep_format_field *field); | ||
480 | 464 | ||
481 | void *tep_get_field_raw(struct trace_seq *s, struct tep_event *event, | 465 | void *tep_get_field_raw(struct trace_seq *s, struct tep_event *event, |
482 | const char *name, struct tep_record *record, | 466 | const char *name, struct tep_record *record, |