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>
This commit is contained in:
Hyeoncheol Lee 2012-09-12 16:57:45 +09:00 committed by Arnaldo Carvalho de Melo
parent 26f45274af
commit 7b0295b3db

View file

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