]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
perf probe: Add union member access support
authorHyeoncheol Lee <hyc.lee@gmail.com>
Wed, 12 Sep 2012 07:57:45 +0000 (16:57 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 14 Sep 2012 18:48:08 +0000 (15:48 -0300)
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>
tools/perf/util/probe-finder.c

index 526ba56e720b39bc0817e011914bc3a8fac63c29..1daf5c14e751bf954e5665e1caa179b191cbd361 100644 (file)
@@ -525,8 +525,10 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
                        return -ENOENT;
                }
                /* Verify it is a data structure  */
-               if (dwarf_tag(&type) != DW_TAG_structure_type) {
-                       pr_warning("%s is not a data structure.\n", varname);
+               tag = dwarf_tag(&type);
+               if (tag != DW_TAG_structure_type && tag != DW_TAG_union_type) {
+                       pr_warning("%s is not a data structure nor an union.\n",
+                                  varname);
                        return -EINVAL;
                }
 
@@ -539,8 +541,9 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
                        *ref_ptr = ref;
        } else {
                /* Verify it is a data structure  */
-               if (tag != DW_TAG_structure_type) {
-                       pr_warning("%s is not a data structure.\n", varname);
+               if (tag != DW_TAG_structure_type && tag != DW_TAG_union_type) {
+                       pr_warning("%s is not a data structure nor an union.\n",
+                                  varname);
                        return -EINVAL;
                }
                if (field->name[0] == '[') {
@@ -567,10 +570,15 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
        }
 
        /* Get the offset of the field */
-       ret = die_get_data_member_location(die_mem, &offs);
-       if (ret < 0) {
-               pr_warning("Failed to get the offset of %s.\n", field->name);
-               return ret;
+       if (tag == DW_TAG_union_type) {
+               offs = 0;
+       } else {
+               ret = die_get_data_member_location(die_mem, &offs);
+               if (ret < 0) {
+                       pr_warning("Failed to get the offset of %s.\n",
+                                  field->name);
+                       return ret;
+               }
        }
        ref->offset += (long)offs;