Commit 59c1baee authored by Tzvetomir Stoyanov (VMware)'s avatar Tzvetomir Stoyanov (VMware) Committed by Arnaldo Carvalho de Melo

tools lib traceevent, perf tools: Rename pevent_read_number_* APIs

In order to make libtraceevent into a proper library, variables, data
structures and functions require a unique prefix to prevent name space
conflicts. That prefix will be "tep_" and not "pevent_". This changes
APIs: pevent_read_number, pevent_read_number_field
Signed-off-by: default avatarTzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Link: http://lkml.kernel.org/r/20180808180700.804271434@goodmis.orgSigned-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 6a48dc29
...@@ -3329,7 +3329,7 @@ tep_find_any_field(struct event_format *event, const char *name) ...@@ -3329,7 +3329,7 @@ tep_find_any_field(struct event_format *event, const char *name)
} }
/** /**
* pevent_read_number - read a number from data * tep_read_number - read a number from data
* @pevent: handle for the pevent * @pevent: handle for the pevent
* @ptr: the raw data * @ptr: the raw data
* @size: the size of the data that holds the number * @size: the size of the data that holds the number
...@@ -3337,8 +3337,8 @@ tep_find_any_field(struct event_format *event, const char *name) ...@@ -3337,8 +3337,8 @@ tep_find_any_field(struct event_format *event, const char *name)
* Returns the number (converted to host) from the * Returns the number (converted to host) from the
* raw data. * raw data.
*/ */
unsigned long long pevent_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)
{ {
switch (size) { switch (size) {
case 1: case 1:
...@@ -3356,7 +3356,7 @@ unsigned long long pevent_read_number(struct tep_handle *pevent, ...@@ -3356,7 +3356,7 @@ unsigned long long pevent_read_number(struct tep_handle *pevent,
} }
/** /**
* pevent_read_number_field - read a number from data * tep_read_number_field - read a number from data
* @field: a handle to the field * @field: a handle to the field
* @data: the raw data to read * @data: the raw data to read
* @value: the value to place the number in * @value: the value to place the number in
...@@ -3366,8 +3366,8 @@ unsigned long long pevent_read_number(struct tep_handle *pevent, ...@@ -3366,8 +3366,8 @@ unsigned long long pevent_read_number(struct tep_handle *pevent,
* *
* Returns 0 on success, -1 otherwise. * Returns 0 on success, -1 otherwise.
*/ */
int pevent_read_number_field(struct format_field *field, const void *data, int tep_read_number_field(struct format_field *field, const void *data,
unsigned long long *value) unsigned long long *value)
{ {
if (!field) if (!field)
return -1; return -1;
...@@ -3376,8 +3376,8 @@ int pevent_read_number_field(struct format_field *field, const void *data, ...@@ -3376,8 +3376,8 @@ int pevent_read_number_field(struct format_field *field, const void *data,
case 2: case 2:
case 4: case 4:
case 8: case 8:
*value = pevent_read_number(field->event->pevent, *value = tep_read_number(field->event->pevent,
data + field->offset, field->size); data + field->offset, field->size);
return 0; return 0;
default: default:
return -1; return -1;
...@@ -3420,7 +3420,7 @@ static int __parse_common(struct tep_handle *pevent, void *data, ...@@ -3420,7 +3420,7 @@ static int __parse_common(struct tep_handle *pevent, void *data,
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
return pevent_read_number(pevent, data + *offset, *size); return tep_read_number(pevent, data + *offset, *size);
} }
static int trace_parse_common_type(struct tep_handle *pevent, void *data) static int trace_parse_common_type(struct tep_handle *pevent, void *data)
...@@ -3559,8 +3559,8 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg ...@@ -3559,8 +3559,8 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
} }
/* must be a number */ /* must be a number */
val = pevent_read_number(pevent, data + arg->field.field->offset, val = tep_read_number(pevent, data + arg->field.field->offset,
arg->field.field->size); arg->field.field->size);
break; break;
case PRINT_FLAGS: case PRINT_FLAGS:
case PRINT_SYMBOL: case PRINT_SYMBOL:
...@@ -3603,7 +3603,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg ...@@ -3603,7 +3603,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
switch (larg->type) { switch (larg->type) {
case PRINT_DYNAMIC_ARRAY: case PRINT_DYNAMIC_ARRAY:
offset = pevent_read_number(pevent, offset = tep_read_number(pevent,
data + larg->dynarray.field->offset, data + larg->dynarray.field->offset,
larg->dynarray.field->size); larg->dynarray.field->size);
if (larg->dynarray.field->elementsize) if (larg->dynarray.field->elementsize)
...@@ -3632,8 +3632,8 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg ...@@ -3632,8 +3632,8 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
default: default:
goto default_op; /* oops, all bets off */ goto default_op; /* oops, all bets off */
} }
val = pevent_read_number(pevent, val = tep_read_number(pevent,
data + offset, field_size); data + offset, field_size);
if (typearg) if (typearg)
val = eval_type(val, typearg, 1); val = eval_type(val, typearg, 1);
break; break;
...@@ -3733,9 +3733,9 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg ...@@ -3733,9 +3733,9 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
} }
break; break;
case PRINT_DYNAMIC_ARRAY_LEN: case PRINT_DYNAMIC_ARRAY_LEN:
offset = pevent_read_number(pevent, offset = tep_read_number(pevent,
data + arg->dynarray.field->offset, data + arg->dynarray.field->offset,
arg->dynarray.field->size); arg->dynarray.field->size);
/* /*
* The total allocated length of the dynamic array is * The total allocated length of the dynamic array is
* stored in the top half of the field, and the offset * stored in the top half of the field, and the offset
...@@ -3745,9 +3745,9 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg ...@@ -3745,9 +3745,9 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
break; break;
case PRINT_DYNAMIC_ARRAY: case PRINT_DYNAMIC_ARRAY:
/* Without [], we pass the address to the dynamic data */ /* Without [], we pass the address to the dynamic data */
offset = pevent_read_number(pevent, offset = tep_read_number(pevent,
data + arg->dynarray.field->offset, data + arg->dynarray.field->offset,
arg->dynarray.field->size); arg->dynarray.field->size);
/* /*
* The total allocated length of the dynamic array is * The total allocated length of the dynamic array is
* stored in the top half of the field, and the offset * stored in the top half of the field, and the offset
...@@ -3992,7 +3992,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, ...@@ -3992,7 +3992,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
case PRINT_HEX_STR: case PRINT_HEX_STR:
if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) { if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) {
unsigned long offset; unsigned long offset;
offset = pevent_read_number(pevent, offset = tep_read_number(pevent,
data + arg->hex.field->dynarray.field->offset, data + arg->hex.field->dynarray.field->offset,
arg->hex.field->dynarray.field->size); arg->hex.field->dynarray.field->size);
hex = data + (offset & 0xffff); hex = data + (offset & 0xffff);
...@@ -4023,9 +4023,9 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, ...@@ -4023,9 +4023,9 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
unsigned long offset; unsigned long offset;
struct format_field *field = struct format_field *field =
arg->int_array.field->dynarray.field; arg->int_array.field->dynarray.field;
offset = pevent_read_number(pevent, offset = tep_read_number(pevent,
data + field->offset, data + field->offset,
field->size); field->size);
num = data + (offset & 0xffff); num = data + (offset & 0xffff);
} else { } else {
field = arg->int_array.field->field.field; field = arg->int_array.field->field.field;
...@@ -4253,7 +4253,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc ...@@ -4253,7 +4253,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
pevent->bprint_ip_field = ip_field; pevent->bprint_ip_field = ip_field;
} }
ip = pevent_read_number(pevent, data + ip_field->offset, ip_field->size); ip = tep_read_number(pevent, data + ip_field->offset, ip_field->size);
/* /*
* The first arg is the IP pointer. * The first arg is the IP pointer.
...@@ -4347,7 +4347,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc ...@@ -4347,7 +4347,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
/* the pointers are always 4 bytes aligned */ /* the pointers are always 4 bytes aligned */
bptr = (void *)(((unsigned long)bptr + 3) & bptr = (void *)(((unsigned long)bptr + 3) &
~3); ~3);
val = pevent_read_number(pevent, bptr, vsize); val = tep_read_number(pevent, bptr, vsize);
bptr += vsize; bptr += vsize;
arg = alloc_arg(); arg = alloc_arg();
if (!arg) { if (!arg) {
...@@ -4421,7 +4421,7 @@ get_bprint_format(void *data, int size __maybe_unused, ...@@ -4421,7 +4421,7 @@ get_bprint_format(void *data, int size __maybe_unused,
pevent->bprint_fmt_field = field; pevent->bprint_fmt_field = field;
} }
addr = pevent_read_number(pevent, data + field->offset, field->size); addr = tep_read_number(pevent, data + field->offset, field->size);
printk = find_printk(pevent, addr); printk = find_printk(pevent, addr);
if (!printk) { if (!printk) {
...@@ -4811,7 +4811,7 @@ void tep_print_field(struct trace_seq *s, void *data, ...@@ -4811,7 +4811,7 @@ void tep_print_field(struct trace_seq *s, void *data,
offset = field->offset; offset = field->offset;
len = field->size; len = field->size;
if (field->flags & FIELD_IS_DYNAMIC) { if (field->flags & FIELD_IS_DYNAMIC) {
val = pevent_read_number(pevent, data + offset, len); val = tep_read_number(pevent, data + offset, len);
offset = val; offset = val;
len = offset >> 16; len = offset >> 16;
offset &= 0xffff; offset &= 0xffff;
...@@ -4831,8 +4831,8 @@ void tep_print_field(struct trace_seq *s, void *data, ...@@ -4831,8 +4831,8 @@ void tep_print_field(struct trace_seq *s, void *data,
field->flags &= ~FIELD_IS_STRING; field->flags &= ~FIELD_IS_STRING;
} }
} else { } else {
val = pevent_read_number(pevent, data + field->offset, val = tep_read_number(pevent, data + field->offset,
field->size); field->size);
if (field->flags & FIELD_IS_POINTER) { if (field->flags & FIELD_IS_POINTER) {
trace_seq_printf(s, "0x%llx", val); trace_seq_printf(s, "0x%llx", val);
} else if (field->flags & FIELD_IS_SIGNED) { } else if (field->flags & FIELD_IS_SIGNED) {
...@@ -6253,7 +6253,7 @@ int get_field_val(struct trace_seq *s, struct format_field *field, ...@@ -6253,7 +6253,7 @@ int get_field_val(struct trace_seq *s, struct format_field *field,
return -1; return -1;
} }
if (pevent_read_number_field(field, record->data, val)) { if (tep_read_number_field(field, record->data, val)) {
if (err) if (err)
trace_seq_printf(s, " %s=INVALID", name); trace_seq_printf(s, " %s=INVALID", name);
return -1; return -1;
...@@ -6302,7 +6302,7 @@ void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event, ...@@ -6302,7 +6302,7 @@ void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event,
offset = field->offset; offset = field->offset;
if (field->flags & FIELD_IS_DYNAMIC) { if (field->flags & FIELD_IS_DYNAMIC) {
offset = pevent_read_number(event->pevent, offset = tep_read_number(event->pevent,
data + offset, field->size); data + offset, field->size);
*len = offset >> 16; *len = offset >> 16;
offset &= 0xffff; offset &= 0xffff;
...@@ -6408,7 +6408,7 @@ int tep_print_num_field(struct trace_seq *s, const char *fmt, ...@@ -6408,7 +6408,7 @@ int tep_print_num_field(struct trace_seq *s, const char *fmt,
if (!field) if (!field)
goto failed; goto failed;
if (pevent_read_number_field(field, record->data, &val)) if (tep_read_number_field(field, record->data, &val))
goto failed; goto failed;
return trace_seq_printf(s, fmt, val); return trace_seq_printf(s, fmt, val);
...@@ -6443,7 +6443,7 @@ int tep_print_func_field(struct trace_seq *s, const char *fmt, ...@@ -6443,7 +6443,7 @@ int tep_print_func_field(struct trace_seq *s, const char *fmt,
if (!field) if (!field)
goto failed; goto failed;
if (pevent_read_number_field(field, record->data, &val)) if (tep_read_number_field(field, record->data, &val))
goto failed; goto failed;
func = find_func(pevent, val); func = find_func(pevent, val);
......
...@@ -693,9 +693,9 @@ struct format_field *tep_find_any_field(struct event_format *event, const char * ...@@ -693,9 +693,9 @@ struct format_field *tep_find_any_field(struct event_format *event, const char *
const char *pevent_find_function(struct tep_handle *pevent, unsigned long long addr); const char *pevent_find_function(struct tep_handle *pevent, unsigned long long addr);
unsigned long long unsigned long long
pevent_find_function_address(struct tep_handle *pevent, unsigned long long addr); pevent_find_function_address(struct tep_handle *pevent, unsigned long long addr);
unsigned long long pevent_read_number(struct tep_handle *pevent, const void *ptr, int size); unsigned long long tep_read_number(struct tep_handle *pevent, const void *ptr, int size);
int pevent_read_number_field(struct format_field *field, const void *data, int tep_read_number_field(struct format_field *field, const void *data,
unsigned long long *value); unsigned long long *value);
struct event_format *tep_find_event(struct tep_handle *pevent, int id); struct event_format *tep_find_event(struct tep_handle *pevent, int id);
......
...@@ -1728,7 +1728,7 @@ get_value(struct event_format *event, ...@@ -1728,7 +1728,7 @@ get_value(struct event_format *event,
if (field == &cpu) if (field == &cpu)
return record->cpu; return record->cpu;
pevent_read_number_field(field, record->data, &val); tep_read_number_field(field, record->data, &val);
if (!(field->flags & FIELD_IS_SIGNED)) if (!(field->flags & FIELD_IS_SIGNED))
return val; return val;
......
...@@ -35,7 +35,7 @@ static int call_site_handler(struct trace_seq *s, struct tep_record *record, ...@@ -35,7 +35,7 @@ static int call_site_handler(struct trace_seq *s, struct tep_record *record,
if (!field) if (!field)
return 1; return 1;
if (pevent_read_number_field(field, data, &val)) if (tep_read_number_field(field, data, &val))
return 1; return 1;
func = pevent_find_function(event->pevent, val); func = pevent_find_function(event->pevent, val);
......
...@@ -42,7 +42,7 @@ static void print_string(struct trace_seq *s, struct event_format *event, ...@@ -42,7 +42,7 @@ static void print_string(struct trace_seq *s, struct event_format *event,
if (!strncmp(f->type, "__data_loc", 10)) { if (!strncmp(f->type, "__data_loc", 10)) {
unsigned long long v; unsigned long long v;
if (pevent_read_number_field(f, data, &v)) { if (tep_read_number_field(f, data, &v)) {
trace_seq_printf(s, "invalid_data_loc"); trace_seq_printf(s, "invalid_data_loc");
return; return;
} }
......
...@@ -310,8 +310,8 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, ...@@ -310,8 +310,8 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
if (flags & FIELD_IS_DYNAMIC) { if (flags & FIELD_IS_DYNAMIC) {
unsigned long long tmp_val; unsigned long long tmp_val;
tmp_val = pevent_read_number(fmtf->event->pevent, tmp_val = tep_read_number(fmtf->event->pevent,
data + offset, len); data + offset, len);
offset = tmp_val; offset = tmp_val;
len = offset >> 16; len = offset >> 16;
offset &= 0xffff; offset &= 0xffff;
...@@ -353,7 +353,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, ...@@ -353,7 +353,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
else { else {
unsigned long long value_int; unsigned long long value_int;
value_int = pevent_read_number( value_int = tep_read_number(
fmtf->event->pevent, fmtf->event->pevent,
data + offset + i * len, len); data + offset + i * len, len);
......
...@@ -351,7 +351,7 @@ tracepoint_field(struct pyrf_event *pe, struct format_field *field) ...@@ -351,7 +351,7 @@ tracepoint_field(struct pyrf_event *pe, struct format_field *field)
offset = field->offset; offset = field->offset;
len = field->size; len = field->size;
if (field->flags & FIELD_IS_DYNAMIC) { if (field->flags & FIELD_IS_DYNAMIC) {
val = pevent_read_number(pevent, data + offset, len); val = tep_read_number(pevent, data + offset, len);
offset = val; offset = val;
len = offset >> 16; len = offset >> 16;
offset &= 0xffff; offset &= 0xffff;
...@@ -364,8 +364,8 @@ tracepoint_field(struct pyrf_event *pe, struct format_field *field) ...@@ -364,8 +364,8 @@ tracepoint_field(struct pyrf_event *pe, struct format_field *field)
field->flags &= ~FIELD_IS_STRING; field->flags &= ~FIELD_IS_STRING;
} }
} else { } else {
val = pevent_read_number(pevent, data + field->offset, val = tep_read_number(pevent, data + field->offset,
field->size); field->size);
if (field->flags & FIELD_IS_POINTER) if (field->flags & FIELD_IS_POINTER)
ret = PyLong_FromUnsignedLong((unsigned long) val); ret = PyLong_FromUnsignedLong((unsigned long) val);
else if (field->flags & FIELD_IS_SIGNED) else if (field->flags & FIELD_IS_SIGNED)
......
...@@ -871,8 +871,8 @@ static void python_process_tracepoint(struct perf_sample *sample, ...@@ -871,8 +871,8 @@ static void python_process_tracepoint(struct perf_sample *sample,
offset = field->offset; offset = field->offset;
len = field->size; len = field->size;
if (field->flags & FIELD_IS_DYNAMIC) { if (field->flags & FIELD_IS_DYNAMIC) {
val = pevent_read_number(scripting_context->pevent, val = tep_read_number(scripting_context->pevent,
data + offset, len); data + offset, len);
offset = val; offset = val;
len = offset >> 16; len = offset >> 16;
offset &= 0xffff; offset &= 0xffff;
......
...@@ -2074,7 +2074,7 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt, ...@@ -2074,7 +2074,7 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
if (field->flags & FIELD_IS_DYNAMIC) { if (field->flags & FIELD_IS_DYNAMIC) {
unsigned long long dyn; unsigned long long dyn;
pevent_read_number_field(field, a->raw_data, &dyn); tep_read_number_field(field, a->raw_data, &dyn);
offset = dyn & 0xffff; offset = dyn & 0xffff;
size = (dyn >> 16) & 0xffff; size = (dyn >> 16) & 0xffff;
......
...@@ -48,7 +48,7 @@ static int get_common_field(struct scripting_context *context, ...@@ -48,7 +48,7 @@ static int get_common_field(struct scripting_context *context,
*size = field->size; *size = field->size;
} }
return pevent_read_number(pevent, context->event_data + *offset, *size); return tep_read_number(pevent, context->event_data + *offset, *size);
} }
int common_lock_depth(struct scripting_context *context) int common_lock_depth(struct scripting_context *context)
...@@ -103,14 +103,14 @@ raw_field_value(struct event_format *event, const char *name, void *data) ...@@ -103,14 +103,14 @@ raw_field_value(struct event_format *event, const char *name, void *data)
if (!field) if (!field)
return 0ULL; return 0ULL;
pevent_read_number_field(field, data, &val); tep_read_number_field(field, data, &val);
return val; return val;
} }
unsigned long long read_size(struct event_format *event, void *ptr, int size) unsigned long long read_size(struct event_format *event, void *ptr, int size)
{ {
return pevent_read_number(event->pevent, ptr, size); return tep_read_number(event->pevent, ptr, size);
} }
void event_format__fprintf(struct event_format *event, void event_format__fprintf(struct event_format *event,
......
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