diff options
author | Hyeoncheol Lee <hyc.lee@gmail.com> | 2012-09-12 03:57:45 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-09-14 14:48:08 -0400 |
commit | 7b0295b3db20a89b3296673871858b9ab6b68404 (patch) | |
tree | ee80c82c96738eb83624c0917216a25dd9717959 /tools/perf/util/probe-finder.c | |
parent | 26f45274afd938d82463816a12ec67448513294a (diff) |
perf probe: Add union member access support
Union members can be accessed with '.' or '->' like data structure
member access
Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/CANFS6baeuSBxPGQ8SUZWZErJ2bWs-Nojg+FSo138E1QK8bJJig@mail.gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/probe-finder.c')
-rw-r--r-- | tools/perf/util/probe-finder.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 526ba56e720b..1daf5c14e751 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -525,8 +525,10 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname, | |||
525 | return -ENOENT; | 525 | return -ENOENT; |
526 | } | 526 | } |
527 | /* Verify it is a data structure */ | 527 | /* Verify it is a data structure */ |
528 | if (dwarf_tag(&type) != DW_TAG_structure_type) { | 528 | tag = dwarf_tag(&type); |
529 | pr_warning("%s is not a data structure.\n", varname); | 529 | if (tag != DW_TAG_structure_type && tag != DW_TAG_union_type) { |
530 | pr_warning("%s is not a data structure nor an union.\n", | ||
531 | varname); | ||
530 | return -EINVAL; | 532 | return -EINVAL; |
531 | } | 533 | } |
532 | 534 | ||
@@ -539,8 +541,9 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname, | |||
539 | *ref_ptr = ref; | 541 | *ref_ptr = ref; |
540 | } else { | 542 | } else { |
541 | /* Verify it is a data structure */ | 543 | /* Verify it is a data structure */ |
542 | if (tag != DW_TAG_structure_type) { | 544 | if (tag != DW_TAG_structure_type && tag != DW_TAG_union_type) { |
543 | pr_warning("%s is not a data structure.\n", varname); | 545 | pr_warning("%s is not a data structure nor an union.\n", |
546 | varname); | ||
544 | return -EINVAL; | 547 | return -EINVAL; |
545 | } | 548 | } |
546 | if (field->name[0] == '[') { | 549 | if (field->name[0] == '[') { |
@@ -567,10 +570,15 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname, | |||
567 | } | 570 | } |
568 | 571 | ||
569 | /* Get the offset of the field */ | 572 | /* Get the offset of the field */ |
570 | ret = die_get_data_member_location(die_mem, &offs); | 573 | if (tag == DW_TAG_union_type) { |
571 | if (ret < 0) { | 574 | offs = 0; |
572 | pr_warning("Failed to get the offset of %s.\n", field->name); | 575 | } else { |
573 | return ret; | 576 | ret = die_get_data_member_location(die_mem, &offs); |
577 | if (ret < 0) { | ||
578 | pr_warning("Failed to get the offset of %s.\n", | ||
579 | field->name); | ||
580 | return ret; | ||
581 | } | ||
574 | } | 582 | } |
575 | ref->offset += (long)offs; | 583 | ref->offset += (long)offs; |
576 | 584 | ||