Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312318
b: refs/heads/master
c: e080e6f
h: refs/heads/master
v: v3
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Jun 29, 2012
1 parent d71d975 commit e1b0e4a
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b700807196ac8d87e00fed9fda80ab89b7f56db6
refs/heads/master: e080e6f1c863242ff709046d0486d09c46dc484a
75 changes: 74 additions & 1 deletion trunk/tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,10 @@ static void free_arg(struct print_arg *arg)
free_arg(arg->symbol.field);
free_flag_sym(arg->symbol.symbols);
break;
case PRINT_HEX:
free_arg(arg->hex.field);
free_arg(arg->hex.size);
break;
case PRINT_TYPE:
free(arg->typecast.type);
free_arg(arg->typecast.item);
Expand Down Expand Up @@ -2259,6 +2263,45 @@ process_symbols(struct event_format *event, struct print_arg *arg, char **tok)
return EVENT_ERROR;
}

static enum event_type
process_hex(struct event_format *event, struct print_arg *arg, char **tok)
{
struct print_arg *field;
enum event_type type;
char *token;

memset(arg, 0, sizeof(*arg));
arg->type = PRINT_HEX;

field = alloc_arg();
type = process_arg(event, field, &token);

if (test_type_token(type, token, EVENT_DELIM, ","))
goto out_free;

arg->hex.field = field;

free_token(token);

field = alloc_arg();
type = process_arg(event, field, &token);

if (test_type_token(type, token, EVENT_DELIM, ")"))
goto out_free;

arg->hex.size = field;

free_token(token);
type = read_token_item(tok);
return type;

out_free:
free_arg(field);
free_token(token);
*tok = NULL;
return EVENT_ERROR;
}

static enum event_type
process_dynamic_array(struct event_format *event, struct print_arg *arg, char **tok)
{
Expand Down Expand Up @@ -2488,6 +2531,10 @@ process_function(struct event_format *event, struct print_arg *arg,
is_symbolic_field = 1;
return process_symbols(event, arg, tok);
}
if (strcmp(token, "__print_hex") == 0) {
free_token(token);
return process_hex(event, arg, tok);
}
if (strcmp(token, "__get_str") == 0) {
free_token(token);
return process_str(event, arg, tok);
Expand Down Expand Up @@ -2995,6 +3042,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
break;
case PRINT_FLAGS:
case PRINT_SYMBOL:
case PRINT_HEX:
break;
case PRINT_TYPE:
val = eval_num_arg(data, size, event, arg->typecast.item);
Expand Down Expand Up @@ -3218,8 +3266,9 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
unsigned long long val, fval;
unsigned long addr;
char *str;
unsigned char *hex;
int print;
int len;
int i, len;

switch (arg->type) {
case PRINT_NULL:
Expand Down Expand Up @@ -3284,6 +3333,23 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
}
}
break;
case PRINT_HEX:
field = arg->hex.field->field.field;
if (!field) {
str = arg->hex.field->field.name;
field = pevent_find_any_field(event, str);
if (!field)
die("field %s not found", str);
arg->hex.field->field.field = field;
}
hex = data + field->offset;
len = eval_num_arg(data, size, event, arg->hex.size);
for (i = 0; i < len; i++) {
if (i)
trace_seq_putc(s, ' ');
trace_seq_printf(s, "%02x", hex[i]);
}
break;

case PRINT_TYPE:
break;
Expand Down Expand Up @@ -4294,6 +4360,13 @@ static void print_args(struct print_arg *args)
trace_seq_destroy(&s);
printf(")");
break;
case PRINT_HEX:
printf("__print_hex(");
print_args(args->hex.field);
printf(", ");
print_args(args->hex.size);
printf(")");
break;
case PRINT_STRING:
case PRINT_BSTRING:
printf("__get_str(%s)", args->string.string);
Expand Down
7 changes: 7 additions & 0 deletions trunk/tools/lib/traceevent/event-parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ struct print_arg_symbol {
struct print_flag_sym *symbols;
};

struct print_arg_hex {
struct print_arg *field;
struct print_arg *size;
};

struct print_arg_dynarray {
struct format_field *field;
struct print_arg *index;
Expand Down Expand Up @@ -253,6 +258,7 @@ enum print_arg_type {
PRINT_FIELD,
PRINT_FLAGS,
PRINT_SYMBOL,
PRINT_HEX,
PRINT_TYPE,
PRINT_STRING,
PRINT_BSTRING,
Expand All @@ -270,6 +276,7 @@ struct print_arg {
struct print_arg_typecast typecast;
struct print_arg_flags flags;
struct print_arg_symbol symbol;
struct print_arg_hex hex;
struct print_arg_func func;
struct print_arg_string string;
struct print_arg_op op;
Expand Down
4 changes: 4 additions & 0 deletions trunk/tools/perf/util/scripting-engines/trace-event-perl.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ static void define_event_symbols(struct event_format *event,
define_symbolic_values(args->symbol.symbols, ev_name,
cur_field_name);
break;
case PRINT_HEX:
define_event_symbols(event, ev_name, args->hex.field);
define_event_symbols(event, ev_name, args->hex.size);
break;
case PRINT_BSTRING:
case PRINT_DYNAMIC_ARRAY:
case PRINT_STRING:
Expand Down
4 changes: 4 additions & 0 deletions trunk/tools/perf/util/scripting-engines/trace-event-python.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ static void define_event_symbols(struct event_format *event,
define_values(PRINT_SYMBOL, args->symbol.symbols, ev_name,
cur_field_name);
break;
case PRINT_HEX:
define_event_symbols(event, ev_name, args->hex.field);
define_event_symbols(event, ev_name, args->hex.size);
break;
case PRINT_STRING:
break;
case PRINT_TYPE:
Expand Down

0 comments on commit e1b0e4a

Please sign in to comment.