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

tools lib traceevent, perf tools: Rename enum format_flags to enum tep_format_flags

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_". This renames enum format_flags
to enum tep_format_flags and adds prefix TEP_ to all of its members.
Signed-off-by: default avatarTzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Link: http://lkml.kernel.org/r/20180919185722.803127871@goodmis.orgSigned-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2c92f982
...@@ -1301,7 +1301,7 @@ static int event_read_id(void) ...@@ -1301,7 +1301,7 @@ static int event_read_id(void)
static int field_is_string(struct tep_format_field *field) static int field_is_string(struct tep_format_field *field)
{ {
if ((field->flags & FIELD_IS_ARRAY) && if ((field->flags & TEP_FIELD_IS_ARRAY) &&
(strstr(field->type, "char") || strstr(field->type, "u8") || (strstr(field->type, "char") || strstr(field->type, "u8") ||
strstr(field->type, "s8"))) strstr(field->type, "s8")))
return 1; return 1;
...@@ -1328,7 +1328,7 @@ static int field_is_long(struct tep_format_field *field) ...@@ -1328,7 +1328,7 @@ static int field_is_long(struct tep_format_field *field)
static unsigned int type_size(const char *name) static unsigned int type_size(const char *name)
{ {
/* This covers all FIELD_IS_STRING types. */ /* This covers all TEP_FIELD_IS_STRING types. */
static struct { static struct {
const char *type; const char *type;
unsigned int size; unsigned int size;
...@@ -1416,7 +1416,7 @@ static int event_read_fields(struct tep_event_format *event, struct tep_format_f ...@@ -1416,7 +1416,7 @@ static int event_read_fields(struct tep_event_format *event, struct tep_format_f
type == EVENT_OP && strcmp(token, ".") == 0)) { type == EVENT_OP && strcmp(token, ".") == 0)) {
if (strcmp(token, "*") == 0) if (strcmp(token, "*") == 0)
field->flags |= FIELD_IS_POINTER; field->flags |= TEP_FIELD_IS_POINTER;
if (field->type) { if (field->type) {
char *new_type; char *new_type;
...@@ -1455,7 +1455,7 @@ static int event_read_fields(struct tep_event_format *event, struct tep_format_f ...@@ -1455,7 +1455,7 @@ static int event_read_fields(struct tep_event_format *event, struct tep_format_f
char *new_brackets; char *new_brackets;
int len; int len;
field->flags |= FIELD_IS_ARRAY; field->flags |= TEP_FIELD_IS_ARRAY;
type = read_token(&token); type = read_token(&token);
...@@ -1544,11 +1544,11 @@ static int event_read_fields(struct tep_event_format *event, struct tep_format_f ...@@ -1544,11 +1544,11 @@ static int event_read_fields(struct tep_event_format *event, struct tep_format_f
} }
if (field_is_string(field)) if (field_is_string(field))
field->flags |= FIELD_IS_STRING; field->flags |= TEP_FIELD_IS_STRING;
if (field_is_dynamic(field)) if (field_is_dynamic(field))
field->flags |= FIELD_IS_DYNAMIC; field->flags |= TEP_FIELD_IS_DYNAMIC;
if (field_is_long(field)) if (field_is_long(field))
field->flags |= FIELD_IS_LONG; field->flags |= TEP_FIELD_IS_LONG;
if (test_type_token(type, token, EVENT_OP, ";")) if (test_type_token(type, token, EVENT_OP, ";"))
goto fail; goto fail;
...@@ -1597,7 +1597,7 @@ static int event_read_fields(struct tep_event_format *event, struct tep_format_f ...@@ -1597,7 +1597,7 @@ static int event_read_fields(struct tep_event_format *event, struct tep_format_f
goto fail; goto fail;
if (strtoul(token, NULL, 0)) if (strtoul(token, NULL, 0))
field->flags |= FIELD_IS_SIGNED; field->flags |= TEP_FIELD_IS_SIGNED;
free_token(token); free_token(token);
if (read_expected(EVENT_OP, ";") < 0) if (read_expected(EVENT_OP, ";") < 0)
...@@ -1609,14 +1609,14 @@ static int event_read_fields(struct tep_event_format *event, struct tep_format_f ...@@ -1609,14 +1609,14 @@ static int event_read_fields(struct tep_event_format *event, struct tep_format_f
free_token(token); free_token(token);
if (field->flags & FIELD_IS_ARRAY) { if (field->flags & TEP_FIELD_IS_ARRAY) {
if (field->arraylen) if (field->arraylen)
field->elementsize = field->size / field->arraylen; field->elementsize = field->size / field->arraylen;
else if (field->flags & FIELD_IS_DYNAMIC) else if (field->flags & TEP_FIELD_IS_DYNAMIC)
field->elementsize = size_dynamic; field->elementsize = size_dynamic;
else if (field->flags & FIELD_IS_STRING) else if (field->flags & TEP_FIELD_IS_STRING)
field->elementsize = 1; field->elementsize = 1;
else if (field->flags & FIELD_IS_LONG) else if (field->flags & TEP_FIELD_IS_LONG)
field->elementsize = event->pevent ? field->elementsize = event->pevent ?
event->pevent->long_size : event->pevent->long_size :
sizeof(long); sizeof(long);
...@@ -2089,11 +2089,11 @@ process_entry(struct tep_event_format *event __maybe_unused, struct print_arg *a ...@@ -2089,11 +2089,11 @@ process_entry(struct tep_event_format *event __maybe_unused, struct print_arg *a
if (is_flag_field) { if (is_flag_field) {
arg->field.field = tep_find_any_field(event, arg->field.name); arg->field.field = tep_find_any_field(event, arg->field.name);
arg->field.field->flags |= FIELD_IS_FLAG; arg->field.field->flags |= TEP_FIELD_IS_FLAG;
is_flag_field = 0; is_flag_field = 0;
} else if (is_symbolic_field) { } else if (is_symbolic_field) {
arg->field.field = tep_find_any_field(event, arg->field.name); arg->field.field = tep_find_any_field(event, arg->field.name);
arg->field.field->flags |= FIELD_IS_SYMBOLIC; arg->field.field->flags |= TEP_FIELD_IS_SYMBOLIC;
is_symbolic_field = 0; is_symbolic_field = 0;
} }
...@@ -3901,7 +3901,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, ...@@ -3901,7 +3901,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
* and the size is the same as long_size, assume that it * and the size is the same as long_size, assume that it
* is a pointer. * is a pointer.
*/ */
if (!(field->flags & FIELD_IS_ARRAY) && if (!(field->flags & TEP_FIELD_IS_ARRAY) &&
field->size == pevent->long_size) { field->size == pevent->long_size) {
/* Handle heterogeneous recording and processing /* Handle heterogeneous recording and processing
...@@ -4794,16 +4794,16 @@ void tep_print_field(struct trace_seq *s, void *data, ...@@ -4794,16 +4794,16 @@ void tep_print_field(struct trace_seq *s, void *data,
unsigned int offset, len, i; unsigned int offset, len, i;
struct tep_handle *pevent = field->event->pevent; struct tep_handle *pevent = field->event->pevent;
if (field->flags & FIELD_IS_ARRAY) { if (field->flags & TEP_FIELD_IS_ARRAY) {
offset = field->offset; offset = field->offset;
len = field->size; len = field->size;
if (field->flags & FIELD_IS_DYNAMIC) { if (field->flags & TEP_FIELD_IS_DYNAMIC) {
val = tep_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;
} }
if (field->flags & FIELD_IS_STRING && if (field->flags & TEP_FIELD_IS_STRING &&
is_printable_array(data + offset, len)) { is_printable_array(data + offset, len)) {
trace_seq_printf(s, "%s", (char *)data + offset); trace_seq_printf(s, "%s", (char *)data + offset);
} else { } else {
...@@ -4815,21 +4815,21 @@ void tep_print_field(struct trace_seq *s, void *data, ...@@ -4815,21 +4815,21 @@ void tep_print_field(struct trace_seq *s, void *data,
*((unsigned char *)data + offset + i)); *((unsigned char *)data + offset + i));
} }
trace_seq_putc(s, ']'); trace_seq_putc(s, ']');
field->flags &= ~FIELD_IS_STRING; field->flags &= ~TEP_FIELD_IS_STRING;
} }
} else { } else {
val = tep_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 & TEP_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 & TEP_FIELD_IS_SIGNED) {
switch (field->size) { switch (field->size) {
case 4: case 4:
/* /*
* If field is long then print it in hex. * If field is long then print it in hex.
* A long usually stores pointers. * A long usually stores pointers.
*/ */
if (field->flags & FIELD_IS_LONG) if (field->flags & TEP_FIELD_IS_LONG)
trace_seq_printf(s, "0x%x", (int)val); trace_seq_printf(s, "0x%x", (int)val);
else else
trace_seq_printf(s, "%d", (int)val); trace_seq_printf(s, "%d", (int)val);
...@@ -4844,7 +4844,7 @@ void tep_print_field(struct trace_seq *s, void *data, ...@@ -4844,7 +4844,7 @@ void tep_print_field(struct trace_seq *s, void *data,
trace_seq_printf(s, "%lld", val); trace_seq_printf(s, "%lld", val);
} }
} else { } else {
if (field->flags & FIELD_IS_LONG) if (field->flags & TEP_FIELD_IS_LONG)
trace_seq_printf(s, "0x%llx", val); trace_seq_printf(s, "0x%llx", val);
else else
trace_seq_printf(s, "%llu", val); trace_seq_printf(s, "%llu", val);
...@@ -6288,7 +6288,7 @@ void *tep_get_field_raw(struct trace_seq *s, struct tep_event_format *event, ...@@ -6288,7 +6288,7 @@ void *tep_get_field_raw(struct trace_seq *s, struct tep_event_format *event,
len = &dummy; len = &dummy;
offset = field->offset; offset = field->offset;
if (field->flags & FIELD_IS_DYNAMIC) { if (field->flags & TEP_FIELD_IS_DYNAMIC) {
offset = tep_read_number(event->pevent, offset = tep_read_number(event->pevent,
data + offset, field->size); data + offset, field->size);
*len = offset >> 16; *len = offset >> 16;
......
...@@ -130,15 +130,15 @@ struct tep_plugin_option { ...@@ -130,15 +130,15 @@ struct tep_plugin_option {
#define TEP_PLUGIN_OPTIONS_NAME MAKE_STR(TEP_PLUGIN_OPTIONS) #define TEP_PLUGIN_OPTIONS_NAME MAKE_STR(TEP_PLUGIN_OPTIONS)
#define TEP_PLUGIN_ALIAS_NAME MAKE_STR(TEP_PLUGIN_ALIAS) #define TEP_PLUGIN_ALIAS_NAME MAKE_STR(TEP_PLUGIN_ALIAS)
enum format_flags { enum tep_format_flags {
FIELD_IS_ARRAY = 1, TEP_FIELD_IS_ARRAY = 1,
FIELD_IS_POINTER = 2, TEP_FIELD_IS_POINTER = 2,
FIELD_IS_SIGNED = 4, TEP_FIELD_IS_SIGNED = 4,
FIELD_IS_STRING = 8, TEP_FIELD_IS_STRING = 8,
FIELD_IS_DYNAMIC = 16, TEP_FIELD_IS_DYNAMIC = 16,
FIELD_IS_LONG = 32, TEP_FIELD_IS_LONG = 32,
FIELD_IS_FLAG = 64, TEP_FIELD_IS_FLAG = 64,
FIELD_IS_SYMBOLIC = 128, TEP_FIELD_IS_SYMBOLIC = 128,
}; };
struct tep_format_field { struct tep_format_field {
......
...@@ -1716,7 +1716,7 @@ get_value(struct tep_event_format *event, ...@@ -1716,7 +1716,7 @@ get_value(struct tep_event_format *event,
tep_read_number_field(field, record->data, &val); tep_read_number_field(field, record->data, &val);
if (!(field->flags & FIELD_IS_SIGNED)) if (!(field->flags & TEP_FIELD_IS_SIGNED))
return val; return val;
switch (field->size) { switch (field->size) {
...@@ -1867,11 +1867,11 @@ static const char *get_field_str(struct filter_arg *arg, struct tep_record *reco ...@@ -1867,11 +1867,11 @@ static const char *get_field_str(struct filter_arg *arg, struct tep_record *reco
char hex[64]; char hex[64];
/* If the field is not a string convert it */ /* If the field is not a string convert it */
if (arg->str.field->flags & FIELD_IS_STRING) { if (arg->str.field->flags & TEP_FIELD_IS_STRING) {
val = record->data + arg->str.field->offset; val = record->data + arg->str.field->offset;
size = arg->str.field->size; size = arg->str.field->size;
if (arg->str.field->flags & FIELD_IS_DYNAMIC) { if (arg->str.field->flags & TEP_FIELD_IS_DYNAMIC) {
addr = *(unsigned int *)val; addr = *(unsigned int *)val;
val = record->data + (addr & 0xffff); val = record->data + (addr & 0xffff);
size = addr >> 16; size = addr >> 16;
...@@ -1893,7 +1893,7 @@ static const char *get_field_str(struct filter_arg *arg, struct tep_record *reco ...@@ -1893,7 +1893,7 @@ static const char *get_field_str(struct filter_arg *arg, struct tep_record *reco
pevent = event->pevent; pevent = event->pevent;
addr = get_value(event, arg->str.field, record); addr = get_value(event, arg->str.field, record);
if (arg->str.field->flags & (FIELD_IS_POINTER | FIELD_IS_LONG)) if (arg->str.field->flags & (TEP_FIELD_IS_POINTER | TEP_FIELD_IS_LONG))
/* convert to a kernel symbol */ /* convert to a kernel symbol */
val = tep_find_function(pevent, addr); val = tep_find_function(pevent, addr);
......
...@@ -1293,7 +1293,7 @@ static int syscall__set_arg_fmts(struct syscall *sc) ...@@ -1293,7 +1293,7 @@ static int syscall__set_arg_fmts(struct syscall *sc)
strcmp(field->name, "path") == 0 || strcmp(field->name, "path") == 0 ||
strcmp(field->name, "pathname") == 0)) strcmp(field->name, "pathname") == 0))
sc->arg_fmt[idx].scnprintf = SCA_FILENAME; sc->arg_fmt[idx].scnprintf = SCA_FILENAME;
else if (field->flags & FIELD_IS_POINTER) else if (field->flags & TEP_FIELD_IS_POINTER)
sc->arg_fmt[idx].scnprintf = syscall_arg__scnprintf_hex; sc->arg_fmt[idx].scnprintf = syscall_arg__scnprintf_hex;
else if (strcmp(field->type, "pid_t") == 0) else if (strcmp(field->type, "pid_t") == 0)
sc->arg_fmt[idx].scnprintf = SCA_PID; sc->arg_fmt[idx].scnprintf = SCA_PID;
......
...@@ -17,7 +17,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name, ...@@ -17,7 +17,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
return -1; return -1;
} }
is_signed = !!(field->flags | FIELD_IS_SIGNED); is_signed = !!(field->flags | TEP_FIELD_IS_SIGNED);
if (should_be_signed && !is_signed) { if (should_be_signed && !is_signed) {
pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n", pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
evsel->name, name, is_signed, should_be_signed); evsel->name, name, is_signed, should_be_signed);
......
...@@ -186,16 +186,16 @@ get_tracepoint_field_type(struct ctf_writer *cw, struct tep_format_field *field) ...@@ -186,16 +186,16 @@ get_tracepoint_field_type(struct ctf_writer *cw, struct tep_format_field *field)
{ {
unsigned long flags = field->flags; unsigned long flags = field->flags;
if (flags & FIELD_IS_STRING) if (flags & TEP_FIELD_IS_STRING)
return cw->data.string; return cw->data.string;
if (!(flags & FIELD_IS_SIGNED)) { if (!(flags & TEP_FIELD_IS_SIGNED)) {
/* unsigned long are mostly pointers */ /* unsigned long are mostly pointers */
if (flags & FIELD_IS_LONG || flags & FIELD_IS_POINTER) if (flags & TEP_FIELD_IS_LONG || flags & TEP_FIELD_IS_POINTER)
return cw->data.u64_hex; return cw->data.u64_hex;
} }
if (flags & FIELD_IS_SIGNED) { if (flags & TEP_FIELD_IS_SIGNED) {
if (field->size == 8) if (field->size == 8)
return cw->data.s64; return cw->data.s64;
else else
...@@ -304,10 +304,10 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, ...@@ -304,10 +304,10 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
name = fmtf->alias; name = fmtf->alias;
offset = fmtf->offset; offset = fmtf->offset;
len = fmtf->size; len = fmtf->size;
if (flags & FIELD_IS_STRING) if (flags & TEP_FIELD_IS_STRING)
flags &= ~FIELD_IS_ARRAY; flags &= ~TEP_FIELD_IS_ARRAY;
if (flags & FIELD_IS_DYNAMIC) { if (flags & TEP_FIELD_IS_DYNAMIC) {
unsigned long long tmp_val; unsigned long long tmp_val;
tmp_val = tep_read_number(fmtf->event->pevent, tmp_val = tep_read_number(fmtf->event->pevent,
...@@ -317,7 +317,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, ...@@ -317,7 +317,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
offset &= 0xffff; offset &= 0xffff;
} }
if (flags & FIELD_IS_ARRAY) { if (flags & TEP_FIELD_IS_ARRAY) {
type = bt_ctf_event_class_get_field_by_name( type = bt_ctf_event_class_get_field_by_name(
event_class, name); event_class, name);
...@@ -338,7 +338,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, ...@@ -338,7 +338,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
type = get_tracepoint_field_type(cw, fmtf); type = get_tracepoint_field_type(cw, fmtf);
for (i = 0; i < n_items; i++) { for (i = 0; i < n_items; i++) {
if (flags & FIELD_IS_ARRAY) if (flags & TEP_FIELD_IS_ARRAY)
field = bt_ctf_field_array_get_field(array_field, i); field = bt_ctf_field_array_get_field(array_field, i);
else else
field = bt_ctf_field_create(type); field = bt_ctf_field_create(type);
...@@ -348,7 +348,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, ...@@ -348,7 +348,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
return -1; return -1;
} }
if (flags & FIELD_IS_STRING) if (flags & TEP_FIELD_IS_STRING)
ret = string_set_value(field, data + offset + i * len); ret = string_set_value(field, data + offset + i * len);
else { else {
unsigned long long value_int; unsigned long long value_int;
...@@ -357,7 +357,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, ...@@ -357,7 +357,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
fmtf->event->pevent, fmtf->event->pevent,
data + offset + i * len, len); data + offset + i * len, len);
if (!(flags & FIELD_IS_SIGNED)) if (!(flags & TEP_FIELD_IS_SIGNED))
ret = bt_ctf_field_unsigned_integer_set_value( ret = bt_ctf_field_unsigned_integer_set_value(
field, value_int); field, value_int);
else else
...@@ -369,7 +369,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, ...@@ -369,7 +369,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
pr_err("failed to set file value %s\n", name); pr_err("failed to set file value %s\n", name);
goto err_put_field; goto err_put_field;
} }
if (!(flags & FIELD_IS_ARRAY)) { if (!(flags & TEP_FIELD_IS_ARRAY)) {
ret = bt_ctf_event_set_payload(event, name, field); ret = bt_ctf_event_set_payload(event, name, field);
if (ret) { if (ret) {
pr_err("failed to set payload %s\n", name); pr_err("failed to set payload %s\n", name);
...@@ -378,7 +378,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, ...@@ -378,7 +378,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
} }
bt_ctf_field_put(field); bt_ctf_field_put(field);
} }
if (flags & FIELD_IS_ARRAY) { if (flags & TEP_FIELD_IS_ARRAY) {
ret = bt_ctf_event_set_payload(event, name, array_field); ret = bt_ctf_event_set_payload(event, name, array_field);
if (ret) { if (ret) {
pr_err("Failed add payload array %s\n", name); pr_err("Failed add payload array %s\n", name);
...@@ -1030,15 +1030,15 @@ static int add_tracepoint_fields_types(struct ctf_writer *cw, ...@@ -1030,15 +1030,15 @@ static int add_tracepoint_fields_types(struct ctf_writer *cw,
* type and don't care that it is an array. What we don't * type and don't care that it is an array. What we don't
* support is an array of strings. * support is an array of strings.
*/ */
if (flags & FIELD_IS_STRING) if (flags & TEP_FIELD_IS_STRING)
flags &= ~FIELD_IS_ARRAY; flags &= ~TEP_FIELD_IS_ARRAY;
if (flags & FIELD_IS_ARRAY) if (flags & TEP_FIELD_IS_ARRAY)
type = bt_ctf_field_type_array_create(type, field->arraylen); type = bt_ctf_field_type_array_create(type, field->arraylen);
ret = event_class_add_field(event_class, type, field); ret = event_class_add_field(event_class, type, field);
if (flags & FIELD_IS_ARRAY) if (flags & TEP_FIELD_IS_ARRAY)
bt_ctf_field_type_put(type); bt_ctf_field_type_put(type);
if (ret) { if (ret) {
......
...@@ -2698,7 +2698,7 @@ void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample, ...@@ -2698,7 +2698,7 @@ void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample,
offset = field->offset; offset = field->offset;
if (field->flags & FIELD_IS_DYNAMIC) { if (field->flags & TEP_FIELD_IS_DYNAMIC) {
offset = *(int *)(sample->raw_data + field->offset); offset = *(int *)(sample->raw_data + field->offset);
offset &= 0xffff; offset &= 0xffff;
} }
......
...@@ -348,28 +348,28 @@ tracepoint_field(struct pyrf_event *pe, struct tep_format_field *field) ...@@ -348,28 +348,28 @@ tracepoint_field(struct pyrf_event *pe, struct tep_format_field *field)
unsigned long long val; unsigned long long val;
unsigned int offset, len; unsigned int offset, len;
if (field->flags & FIELD_IS_ARRAY) { if (field->flags & TEP_FIELD_IS_ARRAY) {
offset = field->offset; offset = field->offset;
len = field->size; len = field->size;
if (field->flags & FIELD_IS_DYNAMIC) { if (field->flags & TEP_FIELD_IS_DYNAMIC) {
val = tep_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;
} }
if (field->flags & FIELD_IS_STRING && if (field->flags & TEP_FIELD_IS_STRING &&
is_printable_array(data + offset, len)) { is_printable_array(data + offset, len)) {
ret = _PyUnicode_FromString((char *)data + offset); ret = _PyUnicode_FromString((char *)data + offset);
} else { } else {
ret = PyByteArray_FromStringAndSize((const char *) data + offset, len); ret = PyByteArray_FromStringAndSize((const char *) data + offset, len);
field->flags &= ~FIELD_IS_STRING; field->flags &= ~TEP_FIELD_IS_STRING;
} }
} else { } else {
val = tep_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 & TEP_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 & TEP_FIELD_IS_SIGNED)
ret = PyLong_FromLong((long) val); ret = PyLong_FromLong((long) val);
else else
ret = PyLong_FromUnsignedLong((unsigned long) val); ret = PyLong_FromUnsignedLong((unsigned long) val);
......
...@@ -388,9 +388,9 @@ static void perl_process_tracepoint(struct perf_sample *sample, ...@@ -388,9 +388,9 @@ static void perl_process_tracepoint(struct perf_sample *sample,
/* common fields other than pid can be accessed via xsub fns */ /* common fields other than pid can be accessed via xsub fns */
for (field = event->format.fields; field; field = field->next) { for (field = event->format.fields; field; field = field->next) {
if (field->flags & FIELD_IS_STRING) { if (field->flags & TEP_FIELD_IS_STRING) {
int offset; int offset;
if (field->flags & FIELD_IS_DYNAMIC) { if (field->flags & TEP_FIELD_IS_DYNAMIC) {
offset = *(int *)(data + field->offset); offset = *(int *)(data + field->offset);
offset &= 0xffff; offset &= 0xffff;
} else } else
...@@ -399,7 +399,7 @@ static void perl_process_tracepoint(struct perf_sample *sample, ...@@ -399,7 +399,7 @@ static void perl_process_tracepoint(struct perf_sample *sample,
} else { /* FIELD_IS_NUMERIC */ } else { /* FIELD_IS_NUMERIC */
val = read_size(event, data + field->offset, val = read_size(event, data + field->offset,
field->size); field->size);
if (field->flags & FIELD_IS_SIGNED) { if (field->flags & TEP_FIELD_IS_SIGNED) {
XPUSHs(sv_2mortal(newSViv(val))); XPUSHs(sv_2mortal(newSViv(val)));
} else { } else {
XPUSHs(sv_2mortal(newSVuv(val))); XPUSHs(sv_2mortal(newSVuv(val)));
...@@ -646,11 +646,11 @@ sub print_backtrace\n\ ...@@ -646,11 +646,11 @@ sub print_backtrace\n\
count++; count++;
fprintf(ofp, "%s=", f->name); fprintf(ofp, "%s=", f->name);
if (f->flags & FIELD_IS_STRING || if (f->flags & TEP_FIELD_IS_STRING ||
f->flags & FIELD_IS_FLAG || f->flags & TEP_FIELD_IS_FLAG ||
f->flags & FIELD_IS_SYMBOLIC) f->flags & TEP_FIELD_IS_SYMBOLIC)
fprintf(ofp, "%%s"); fprintf(ofp, "%%s");
else if (f->flags & FIELD_IS_SIGNED) else if (f->flags & TEP_FIELD_IS_SIGNED)
fprintf(ofp, "%%d"); fprintf(ofp, "%%d");
else else
fprintf(ofp, "%%u"); fprintf(ofp, "%%u");
...@@ -668,7 +668,7 @@ sub print_backtrace\n\ ...@@ -668,7 +668,7 @@ sub print_backtrace\n\
if (++count % 5 == 0) if (++count % 5 == 0)
fprintf(ofp, "\n\t "); fprintf(ofp, "\n\t ");
if (f->flags & FIELD_IS_FLAG) { if (f->flags & TEP_FIELD_IS_FLAG) {
if ((count - 1) % 5 != 0) { if ((count - 1) % 5 != 0) {
fprintf(ofp, "\n\t "); fprintf(ofp, "\n\t ");
count = 4; count = 4;
...@@ -678,7 +678,7 @@ sub print_backtrace\n\ ...@@ -678,7 +678,7 @@ sub print_backtrace\n\
event->name); event->name);
fprintf(ofp, "\"%s\", $%s)", f->name, fprintf(ofp, "\"%s\", $%s)", f->name,
f->name); f->name);
} else if (f->flags & FIELD_IS_SYMBOLIC) { } else if (f->flags & TEP_FIELD_IS_SYMBOLIC) {
if ((count - 1) % 5 != 0) { if ((count - 1) % 5 != 0) {
fprintf(ofp, "\n\t "); fprintf(ofp, "\n\t ");
count = 4; count = 4;
......
...@@ -335,7 +335,7 @@ static void define_event_symbols(struct tep_event_format *event, ...@@ -335,7 +335,7 @@ static void define_event_symbols(struct tep_event_format *event,
static PyObject *get_field_numeric_entry(struct tep_event_format *event, static PyObject *get_field_numeric_entry(struct tep_event_format *event,
struct tep_format_field *field, void *data) struct tep_format_field *field, void *data)
{ {
bool is_array = field->flags & FIELD_IS_ARRAY; bool is_array = field->flags & TEP_FIELD_IS_ARRAY;
PyObject *obj = NULL, *list = NULL; PyObject *obj = NULL, *list = NULL;
unsigned long long val; unsigned long long val;
unsigned int item_size, n_items, i; unsigned int item_size, n_items, i;
...@@ -353,7 +353,7 @@ static PyObject *get_field_numeric_entry(struct tep_event_format *event, ...@@ -353,7 +353,7 @@ static PyObject *get_field_numeric_entry(struct tep_event_format *event,
val = read_size(event, data + field->offset + i * item_size, val = read_size(event, data + field->offset + i * item_size,
item_size); item_size);
if (field->flags & FIELD_IS_SIGNED) { if (field->flags & TEP_FIELD_IS_SIGNED) {
if ((long long)val >= LONG_MIN && if ((long long)val >= LONG_MIN &&
(long long)val <= LONG_MAX) (long long)val <= LONG_MAX)
obj = _PyLong_FromLong(val); obj = _PyLong_FromLong(val);
...@@ -867,22 +867,22 @@ static void python_process_tracepoint(struct perf_sample *sample, ...@@ -867,22 +867,22 @@ static void python_process_tracepoint(struct perf_sample *sample,
unsigned int offset, len; unsigned int offset, len;
unsigned long long val; unsigned long long val;
if (field->flags & FIELD_IS_ARRAY) { if (field->flags & TEP_FIELD_IS_ARRAY) {
offset = field->offset; offset = field->offset;
len = field->size; len = field->size;
if (field->flags & FIELD_IS_DYNAMIC) { if (field->flags & TEP_FIELD_IS_DYNAMIC) {
val = tep_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;
} }
if (field->flags & FIELD_IS_STRING && if (field->flags & TEP_FIELD_IS_STRING &&
is_printable_array(data + offset, len)) { is_printable_array(data + offset, len)) {
obj = _PyUnicode_FromString((char *) data + offset); obj = _PyUnicode_FromString((char *) data + offset);
} else { } else {
obj = PyByteArray_FromStringAndSize((const char *) data + offset, len); obj = PyByteArray_FromStringAndSize((const char *) data + offset, len);
field->flags &= ~FIELD_IS_STRING; field->flags &= ~TEP_FIELD_IS_STRING;
} }
} else { /* FIELD_IS_NUMERIC */ } else { /* FIELD_IS_NUMERIC */
obj = get_field_numeric_entry(event, field, data); obj = get_field_numeric_entry(event, field, data);
...@@ -1686,12 +1686,12 @@ static int python_generate_script(struct tep_handle *pevent, const char *outfile ...@@ -1686,12 +1686,12 @@ static int python_generate_script(struct tep_handle *pevent, const char *outfile
count++; count++;
fprintf(ofp, "%s=", f->name); fprintf(ofp, "%s=", f->name);
if (f->flags & FIELD_IS_STRING || if (f->flags & TEP_FIELD_IS_STRING ||
f->flags & FIELD_IS_FLAG || f->flags & TEP_FIELD_IS_FLAG ||
f->flags & FIELD_IS_ARRAY || f->flags & TEP_FIELD_IS_ARRAY ||
f->flags & FIELD_IS_SYMBOLIC) f->flags & TEP_FIELD_IS_SYMBOLIC)
fprintf(ofp, "%%s"); fprintf(ofp, "%%s");
else if (f->flags & FIELD_IS_SIGNED) else if (f->flags & TEP_FIELD_IS_SIGNED)
fprintf(ofp, "%%d"); fprintf(ofp, "%%d");
else else
fprintf(ofp, "%%u"); fprintf(ofp, "%%u");
...@@ -1709,7 +1709,7 @@ static int python_generate_script(struct tep_handle *pevent, const char *outfile ...@@ -1709,7 +1709,7 @@ static int python_generate_script(struct tep_handle *pevent, const char *outfile
if (++count % 5 == 0) if (++count % 5 == 0)
fprintf(ofp, "\n\t\t"); fprintf(ofp, "\n\t\t");
if (f->flags & FIELD_IS_FLAG) { if (f->flags & TEP_FIELD_IS_FLAG) {
if ((count - 1) % 5 != 0) { if ((count - 1) % 5 != 0) {
fprintf(ofp, "\n\t\t"); fprintf(ofp, "\n\t\t");
count = 4; count = 4;
...@@ -1719,7 +1719,7 @@ static int python_generate_script(struct tep_handle *pevent, const char *outfile ...@@ -1719,7 +1719,7 @@ static int python_generate_script(struct tep_handle *pevent, const char *outfile
event->name); event->name);
fprintf(ofp, "\"%s\", %s)", f->name, fprintf(ofp, "\"%s\", %s)", f->name,
f->name); f->name);
} else if (f->flags & FIELD_IS_SYMBOLIC) { } else if (f->flags & TEP_FIELD_IS_SYMBOLIC) {
if ((count - 1) % 5 != 0) { if ((count - 1) % 5 != 0) {
fprintf(ofp, "\n\t\t"); fprintf(ofp, "\n\t\t");
count = 4; count = 4;
......
...@@ -1899,7 +1899,7 @@ static int hde_width(struct hpp_dynamic_entry *hde) ...@@ -1899,7 +1899,7 @@ static int hde_width(struct hpp_dynamic_entry *hde)
if (namelen > len) if (namelen > len)
len = namelen; len = namelen;
if (!(hde->field->flags & FIELD_IS_STRING)) { if (!(hde->field->flags & TEP_FIELD_IS_STRING)) {
/* length for print hex numbers */ /* length for print hex numbers */
fieldlen = hde->field->size * 2 + 2; fieldlen = hde->field->size * 2 + 2;
} }
...@@ -2071,7 +2071,7 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt, ...@@ -2071,7 +2071,7 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
} }
field = hde->field; field = hde->field;
if (field->flags & FIELD_IS_DYNAMIC) { if (field->flags & TEP_FIELD_IS_DYNAMIC) {
unsigned long long dyn; unsigned long long dyn;
tep_read_number_field(field, a->raw_data, &dyn); tep_read_number_field(field, a->raw_data, &dyn);
......
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