diff options
Diffstat (limited to 'parse-events.c')
-rw-r--r-- | parse-events.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/parse-events.c b/parse-events.c index 8fd93ec..53dc8ad 100644 --- a/parse-events.c +++ b/parse-events.c | |||
@@ -4421,6 +4421,91 @@ int pevent_parse_event(struct pevent *pevent, | |||
4421 | return -1; | 4421 | return -1; |
4422 | } | 4422 | } |
4423 | 4423 | ||
4424 | int get_field_val(struct trace_seq *s, struct format_field *field, | ||
4425 | const char *name, struct record *record, | ||
4426 | unsigned long long *val, int err) | ||
4427 | { | ||
4428 | if (!field) { | ||
4429 | if (err) | ||
4430 | trace_seq_printf(s, "<CANT FIND FIELD %s>", name); | ||
4431 | return -1; | ||
4432 | } | ||
4433 | |||
4434 | if (pevent_read_number_field(field, record->data, val)) { | ||
4435 | if (err) | ||
4436 | trace_seq_printf(s, " %s=INVALID", name); | ||
4437 | return -1; | ||
4438 | } | ||
4439 | |||
4440 | return 0; | ||
4441 | } | ||
4442 | |||
4443 | /** | ||
4444 | * pevent_get_field_val - find a field and return its value | ||
4445 | * @s: The seq to print to on error | ||
4446 | * @event: the event that the field is for | ||
4447 | * @name: The name of the field | ||
4448 | * @record: The record with the field name. | ||
4449 | * @val: place to store the value of the field. | ||
4450 | * @err: print default error if failed. | ||
4451 | * | ||
4452 | * Returns 0 on success -1 on field not found. | ||
4453 | */ | ||
4454 | int pevent_get_field_val(struct trace_seq *s, struct event_format *event, | ||
4455 | const char *name, struct record *record, | ||
4456 | unsigned long long *val, int err) | ||
4457 | { | ||
4458 | struct format_field *field; | ||
4459 | |||
4460 | field = pevent_find_field(event, name); | ||
4461 | |||
4462 | return get_field_val(s, field, name, record, val, err); | ||
4463 | } | ||
4464 | |||
4465 | /** | ||
4466 | * pevent_get_common_field_val - find a common field and return its value | ||
4467 | * @s: The seq to print to on error | ||
4468 | * @event: the event that the field is for | ||
4469 | * @name: The name of the field | ||
4470 | * @record: The record with the field name. | ||
4471 | * @val: place to store the value of the field. | ||
4472 | * @err: print default error if failed. | ||
4473 | * | ||
4474 | * Returns 0 on success -1 on field not found. | ||
4475 | */ | ||
4476 | int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event, | ||
4477 | const char *name, struct record *record, | ||
4478 | unsigned long long *val, int err) | ||
4479 | { | ||
4480 | struct format_field *field; | ||
4481 | |||
4482 | field = pevent_find_common_field(event, name); | ||
4483 | |||
4484 | return get_field_val(s, field, name, record, val, err); | ||
4485 | } | ||
4486 | |||
4487 | /** | ||
4488 | * pevent_get_any_field_val - find a any field and return its value | ||
4489 | * @s: The seq to print to on error | ||
4490 | * @event: the event that the field is for | ||
4491 | * @name: The name of the field | ||
4492 | * @record: The record with the field name. | ||
4493 | * @val: place to store the value of the field. | ||
4494 | * @err: print default error if failed. | ||
4495 | * | ||
4496 | * Returns 0 on success -1 on field not found. | ||
4497 | */ | ||
4498 | int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event, | ||
4499 | const char *name, struct record *record, | ||
4500 | unsigned long long *val, int err) | ||
4501 | { | ||
4502 | struct format_field *field; | ||
4503 | |||
4504 | field = pevent_find_any_field(event, name); | ||
4505 | |||
4506 | return get_field_val(s, field, name, record, val, err); | ||
4507 | } | ||
4508 | |||
4424 | /** | 4509 | /** |
4425 | * pevent_print_num_field - print a field and a format | 4510 | * pevent_print_num_field - print a field and a format |
4426 | * @s: The seq to print to | 4511 | * @s: The seq to print to |