mirror of https://gitee.com/openkylin/linux.git
tracing: Add hist_field_name() accessor
In preparation for hist_fields that won't be strictly based on trace_event_fields, add a new hist_field_name() accessor to allow that flexibility and update associated users. Link: http://lkml.kernel.org/r/5b5a2d36dde067cbbe2434b10f06daac27b7dbd5.1506105045.git.tom.zanussi@linux.intel.com Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
parent
0d7a8325bf
commit
85013256cf
|
@ -146,6 +146,23 @@ struct hist_trigger_data {
|
||||||
struct tracing_map *map;
|
struct tracing_map *map;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char *hist_field_name(struct hist_field *field,
|
||||||
|
unsigned int level)
|
||||||
|
{
|
||||||
|
const char *field_name = "";
|
||||||
|
|
||||||
|
if (level > 1)
|
||||||
|
return field_name;
|
||||||
|
|
||||||
|
if (field->field)
|
||||||
|
field_name = field->field->name;
|
||||||
|
|
||||||
|
if (field_name == NULL)
|
||||||
|
field_name = "";
|
||||||
|
|
||||||
|
return field_name;
|
||||||
|
}
|
||||||
|
|
||||||
static hist_field_fn_t select_value_fn(int field_size, int field_is_signed)
|
static hist_field_fn_t select_value_fn(int field_size, int field_is_signed)
|
||||||
{
|
{
|
||||||
hist_field_fn_t fn = NULL;
|
hist_field_fn_t fn = NULL;
|
||||||
|
@ -653,7 +670,6 @@ static int is_descending(const char *str)
|
||||||
static int create_sort_keys(struct hist_trigger_data *hist_data)
|
static int create_sort_keys(struct hist_trigger_data *hist_data)
|
||||||
{
|
{
|
||||||
char *fields_str = hist_data->attrs->sort_key_str;
|
char *fields_str = hist_data->attrs->sort_key_str;
|
||||||
struct ftrace_event_field *field = NULL;
|
|
||||||
struct tracing_map_sort_key *sort_key;
|
struct tracing_map_sort_key *sort_key;
|
||||||
int descending, ret = 0;
|
int descending, ret = 0;
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
@ -670,7 +686,9 @@ static int create_sort_keys(struct hist_trigger_data *hist_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < TRACING_MAP_SORT_KEYS_MAX; i++) {
|
for (i = 0; i < TRACING_MAP_SORT_KEYS_MAX; i++) {
|
||||||
|
struct hist_field *hist_field;
|
||||||
char *field_str, *field_name;
|
char *field_str, *field_name;
|
||||||
|
const char *test_name;
|
||||||
|
|
||||||
sort_key = &hist_data->sort_keys[i];
|
sort_key = &hist_data->sort_keys[i];
|
||||||
|
|
||||||
|
@ -703,8 +721,10 @@ static int create_sort_keys(struct hist_trigger_data *hist_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 1; j < hist_data->n_fields; j++) {
|
for (j = 1; j < hist_data->n_fields; j++) {
|
||||||
field = hist_data->fields[j]->field;
|
hist_field = hist_data->fields[j];
|
||||||
if (field && (strcmp(field_name, field->name) == 0)) {
|
test_name = hist_field_name(hist_field, 0);
|
||||||
|
|
||||||
|
if (strcmp(field_name, test_name) == 0) {
|
||||||
sort_key->field_idx = j;
|
sort_key->field_idx = j;
|
||||||
descending = is_descending(field_str);
|
descending = is_descending(field_str);
|
||||||
if (descending < 0) {
|
if (descending < 0) {
|
||||||
|
@ -952,6 +972,7 @@ hist_trigger_entry_print(struct seq_file *m,
|
||||||
struct hist_field *key_field;
|
struct hist_field *key_field;
|
||||||
char str[KSYM_SYMBOL_LEN];
|
char str[KSYM_SYMBOL_LEN];
|
||||||
bool multiline = false;
|
bool multiline = false;
|
||||||
|
const char *field_name;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
u64 uval;
|
u64 uval;
|
||||||
|
|
||||||
|
@ -963,26 +984,27 @@ hist_trigger_entry_print(struct seq_file *m,
|
||||||
if (i > hist_data->n_vals)
|
if (i > hist_data->n_vals)
|
||||||
seq_puts(m, ", ");
|
seq_puts(m, ", ");
|
||||||
|
|
||||||
|
field_name = hist_field_name(key_field, 0);
|
||||||
|
|
||||||
if (key_field->flags & HIST_FIELD_FL_HEX) {
|
if (key_field->flags & HIST_FIELD_FL_HEX) {
|
||||||
uval = *(u64 *)(key + key_field->offset);
|
uval = *(u64 *)(key + key_field->offset);
|
||||||
seq_printf(m, "%s: %llx",
|
seq_printf(m, "%s: %llx", field_name, uval);
|
||||||
key_field->field->name, uval);
|
|
||||||
} else if (key_field->flags & HIST_FIELD_FL_SYM) {
|
} else if (key_field->flags & HIST_FIELD_FL_SYM) {
|
||||||
uval = *(u64 *)(key + key_field->offset);
|
uval = *(u64 *)(key + key_field->offset);
|
||||||
sprint_symbol_no_offset(str, uval);
|
sprint_symbol_no_offset(str, uval);
|
||||||
seq_printf(m, "%s: [%llx] %-45s",
|
seq_printf(m, "%s: [%llx] %-45s", field_name,
|
||||||
key_field->field->name, uval, str);
|
uval, str);
|
||||||
} else if (key_field->flags & HIST_FIELD_FL_SYM_OFFSET) {
|
} else if (key_field->flags & HIST_FIELD_FL_SYM_OFFSET) {
|
||||||
uval = *(u64 *)(key + key_field->offset);
|
uval = *(u64 *)(key + key_field->offset);
|
||||||
sprint_symbol(str, uval);
|
sprint_symbol(str, uval);
|
||||||
seq_printf(m, "%s: [%llx] %-55s",
|
seq_printf(m, "%s: [%llx] %-55s", field_name,
|
||||||
key_field->field->name, uval, str);
|
uval, str);
|
||||||
} else if (key_field->flags & HIST_FIELD_FL_EXECNAME) {
|
} else if (key_field->flags & HIST_FIELD_FL_EXECNAME) {
|
||||||
char *comm = elt->private_data;
|
char *comm = elt->private_data;
|
||||||
|
|
||||||
uval = *(u64 *)(key + key_field->offset);
|
uval = *(u64 *)(key + key_field->offset);
|
||||||
seq_printf(m, "%s: %-16s[%10llu]",
|
seq_printf(m, "%s: %-16s[%10llu]", field_name,
|
||||||
key_field->field->name, comm, uval);
|
comm, uval);
|
||||||
} else if (key_field->flags & HIST_FIELD_FL_SYSCALL) {
|
} else if (key_field->flags & HIST_FIELD_FL_SYSCALL) {
|
||||||
const char *syscall_name;
|
const char *syscall_name;
|
||||||
|
|
||||||
|
@ -991,8 +1013,8 @@ hist_trigger_entry_print(struct seq_file *m,
|
||||||
if (!syscall_name)
|
if (!syscall_name)
|
||||||
syscall_name = "unknown_syscall";
|
syscall_name = "unknown_syscall";
|
||||||
|
|
||||||
seq_printf(m, "%s: %-30s[%3llu]",
|
seq_printf(m, "%s: %-30s[%3llu]", field_name,
|
||||||
key_field->field->name, syscall_name, uval);
|
syscall_name, uval);
|
||||||
} else if (key_field->flags & HIST_FIELD_FL_STACKTRACE) {
|
} else if (key_field->flags & HIST_FIELD_FL_STACKTRACE) {
|
||||||
seq_puts(m, "stacktrace:\n");
|
seq_puts(m, "stacktrace:\n");
|
||||||
hist_trigger_stacktrace_print(m,
|
hist_trigger_stacktrace_print(m,
|
||||||
|
@ -1000,15 +1022,14 @@ hist_trigger_entry_print(struct seq_file *m,
|
||||||
HIST_STACKTRACE_DEPTH);
|
HIST_STACKTRACE_DEPTH);
|
||||||
multiline = true;
|
multiline = true;
|
||||||
} else if (key_field->flags & HIST_FIELD_FL_LOG2) {
|
} else if (key_field->flags & HIST_FIELD_FL_LOG2) {
|
||||||
seq_printf(m, "%s: ~ 2^%-2llu", key_field->field->name,
|
seq_printf(m, "%s: ~ 2^%-2llu", field_name,
|
||||||
*(u64 *)(key + key_field->offset));
|
*(u64 *)(key + key_field->offset));
|
||||||
} else if (key_field->flags & HIST_FIELD_FL_STRING) {
|
} else if (key_field->flags & HIST_FIELD_FL_STRING) {
|
||||||
seq_printf(m, "%s: %-50s", key_field->field->name,
|
seq_printf(m, "%s: %-50s", field_name,
|
||||||
(char *)(key + key_field->offset));
|
(char *)(key + key_field->offset));
|
||||||
} else {
|
} else {
|
||||||
uval = *(u64 *)(key + key_field->offset);
|
uval = *(u64 *)(key + key_field->offset);
|
||||||
seq_printf(m, "%s: %10llu", key_field->field->name,
|
seq_printf(m, "%s: %10llu", field_name, uval);
|
||||||
uval);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1021,13 +1042,13 @@ hist_trigger_entry_print(struct seq_file *m,
|
||||||
tracing_map_read_sum(elt, HITCOUNT_IDX));
|
tracing_map_read_sum(elt, HITCOUNT_IDX));
|
||||||
|
|
||||||
for (i = 1; i < hist_data->n_vals; i++) {
|
for (i = 1; i < hist_data->n_vals; i++) {
|
||||||
|
field_name = hist_field_name(hist_data->fields[i], 0);
|
||||||
|
|
||||||
if (hist_data->fields[i]->flags & HIST_FIELD_FL_HEX) {
|
if (hist_data->fields[i]->flags & HIST_FIELD_FL_HEX) {
|
||||||
seq_printf(m, " %s: %10llx",
|
seq_printf(m, " %s: %10llx", field_name,
|
||||||
hist_data->fields[i]->field->name,
|
|
||||||
tracing_map_read_sum(elt, i));
|
tracing_map_read_sum(elt, i));
|
||||||
} else {
|
} else {
|
||||||
seq_printf(m, " %s: %10llu",
|
seq_printf(m, " %s: %10llu", field_name,
|
||||||
hist_data->fields[i]->field->name,
|
|
||||||
tracing_map_read_sum(elt, i));
|
tracing_map_read_sum(elt, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1140,7 +1161,9 @@ static const char *get_hist_field_flags(struct hist_field *hist_field)
|
||||||
|
|
||||||
static void hist_field_print(struct seq_file *m, struct hist_field *hist_field)
|
static void hist_field_print(struct seq_file *m, struct hist_field *hist_field)
|
||||||
{
|
{
|
||||||
seq_printf(m, "%s", hist_field->field->name);
|
const char *field_name = hist_field_name(hist_field, 0);
|
||||||
|
|
||||||
|
seq_printf(m, "%s", field_name);
|
||||||
if (hist_field->flags) {
|
if (hist_field->flags) {
|
||||||
const char *flags_str = get_hist_field_flags(hist_field);
|
const char *flags_str = get_hist_field_flags(hist_field);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue