Commit 6cd99d21 authored by Tzvetomir Stoyanov's avatar Tzvetomir Stoyanov Committed by Arnaldo Carvalho de Melo

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: default avatarTzvetomir 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.orgSigned-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent f0bba09c
...@@ -51,7 +51,7 @@ void tep_set_flag(struct tep_handle *tep, int flag) ...@@ -51,7 +51,7 @@ void tep_set_flag(struct tep_handle *tep, int flag)
tep->flags |= flag; tep->flags |= flag;
} }
unsigned short __tep_data2host2(struct tep_handle *pevent, unsigned short data) unsigned short tep_data2host2(struct tep_handle *pevent, unsigned short data)
{ {
unsigned short swap; unsigned short swap;
...@@ -64,7 +64,7 @@ unsigned short __tep_data2host2(struct tep_handle *pevent, unsigned short data) ...@@ -64,7 +64,7 @@ unsigned short __tep_data2host2(struct tep_handle *pevent, unsigned short data)
return swap; return swap;
} }
unsigned int __tep_data2host4(struct tep_handle *pevent, unsigned int data) unsigned int tep_data2host4(struct tep_handle *pevent, unsigned int data)
{ {
unsigned int swap; unsigned int swap;
...@@ -80,7 +80,7 @@ unsigned int __tep_data2host4(struct tep_handle *pevent, unsigned int data) ...@@ -80,7 +80,7 @@ unsigned int __tep_data2host4(struct tep_handle *pevent, unsigned int data)
} }
unsigned long long unsigned long long
__tep_data2host8(struct tep_handle *pevent, unsigned long long data) tep_data2host8(struct tep_handle *pevent, unsigned long long data)
{ {
unsigned long long swap; unsigned long long swap;
......
...@@ -89,4 +89,11 @@ struct tep_handle { ...@@ -89,4 +89,11 @@ struct tep_handle {
char *trace_clock; char *trace_clock;
}; };
void tep_free_event(struct tep_event *event);
void tep_free_format_field(struct tep_format_field *field);
unsigned short tep_data2host2(struct tep_handle *pevent, unsigned short data);
unsigned int tep_data2host4(struct tep_handle *pevent, unsigned int data);
unsigned long long tep_data2host8(struct tep_handle *pevent, unsigned long long data);
#endif /* _PARSE_EVENTS_INT_H */ #endif /* _PARSE_EVENTS_INT_H */
...@@ -3328,15 +3328,18 @@ tep_find_any_field(struct tep_event *event, const char *name) ...@@ -3328,15 +3328,18 @@ tep_find_any_field(struct tep_event *event, const char *name)
unsigned long long tep_read_number(struct tep_handle *pevent, unsigned long long tep_read_number(struct tep_handle *pevent,
const void *ptr, int size) const void *ptr, int size)
{ {
unsigned long long val;
switch (size) { switch (size) {
case 1: case 1:
return *(unsigned char *)ptr; return *(unsigned char *)ptr;
case 2: case 2:
return tep_data2host2(pevent, ptr); return tep_data2host2(pevent, *(unsigned short *)ptr);
case 4: case 4:
return tep_data2host4(pevent, ptr); return tep_data2host4(pevent, *(unsigned int *)ptr);
case 8: case 8:
return tep_data2host8(pevent, ptr); memcpy(&val, (ptr), sizeof(unsigned long long));
return tep_data2host8(pevent, val);
default: default:
/* BUG! */ /* BUG! */
return 0; return 0;
...@@ -4062,7 +4065,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, ...@@ -4062,7 +4065,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
f = tep_find_any_field(event, arg->string.string); f = tep_find_any_field(event, arg->string.string);
arg->string.offset = f->offset; arg->string.offset = f->offset;
} }
str_offset = tep_data2host4(pevent, data + arg->string.offset); str_offset = tep_data2host4(pevent, *(unsigned int *)(data + arg->string.offset));
str_offset &= 0xffff; str_offset &= 0xffff;
print_str_to_seq(s, format, len_arg, ((char *)data) + str_offset); print_str_to_seq(s, format, len_arg, ((char *)data) + str_offset);
break; break;
...@@ -4080,7 +4083,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, ...@@ -4080,7 +4083,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
f = tep_find_any_field(event, arg->bitmask.bitmask); f = tep_find_any_field(event, arg->bitmask.bitmask);
arg->bitmask.offset = f->offset; arg->bitmask.offset = f->offset;
} }
bitmask_offset = tep_data2host4(pevent, data + arg->bitmask.offset); bitmask_offset = tep_data2host4(pevent, *(unsigned int *)(data + arg->bitmask.offset));
bitmask_size = bitmask_offset >> 16; bitmask_size = bitmask_offset >> 16;
bitmask_offset &= 0xffff; bitmask_offset &= 0xffff;
print_bitmask_to_seq(pevent, s, format, len_arg, print_bitmask_to_seq(pevent, s, format, len_arg,
......
...@@ -409,20 +409,6 @@ void tep_print_plugins(struct trace_seq *s, ...@@ -409,20 +409,6 @@ void tep_print_plugins(struct trace_seq *s,
typedef char *(tep_func_resolver_t)(void *priv, typedef char *(tep_func_resolver_t)(void *priv,
unsigned long long *addrp, char **modp); unsigned long long *addrp, char **modp);
void tep_set_flag(struct tep_handle *tep, int flag); void tep_set_flag(struct tep_handle *tep, int flag);
unsigned short __tep_data2host2(struct tep_handle *pevent, unsigned short data);
unsigned int __tep_data2host4(struct tep_handle *pevent, unsigned int data);
unsigned long long
__tep_data2host8(struct tep_handle *pevent, unsigned long long data);
#define tep_data2host2(pevent, ptr) __tep_data2host2(pevent, *(unsigned short *)(ptr))
#define tep_data2host4(pevent, ptr) __tep_data2host4(pevent, *(unsigned int *)(ptr))
#define tep_data2host8(pevent, ptr) \
({ \
unsigned long long __val; \
\
memcpy(&__val, (ptr), sizeof(unsigned long long)); \
__tep_data2host8(pevent, __val); \
})
static inline int tep_host_bigendian(void) static inline int tep_host_bigendian(void)
{ {
...@@ -475,8 +461,6 @@ enum tep_errno tep_parse_format(struct tep_handle *pevent, ...@@ -475,8 +461,6 @@ enum tep_errno tep_parse_format(struct tep_handle *pevent,
struct tep_event **eventp, struct tep_event **eventp,
const char *buf, const char *buf,
unsigned long size, const char *sys); unsigned long size, const char *sys);
void tep_free_event(struct tep_event *event);
void tep_free_format_field(struct tep_format_field *field);
void *tep_get_field_raw(struct trace_seq *s, struct tep_event *event, void *tep_get_field_raw(struct trace_seq *s, struct tep_event *event,
const char *name, struct tep_record *record, const char *name, struct tep_record *record,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment