Sourceware Bugzilla – Attachment 11762 Details for
Bug 24509
eu-readelf does not know how to dissect DW_AT_discr_list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
discr_list patch that handles signed/unsigned variant_part types
discr_list.patch (text/plain), 4.26 KB, created by
Mark Wielaard
on 2019-05-02 21:48:20 UTC
(
hide
)
Description:
discr_list patch that handles signed/unsigned variant_part types
Filename:
MIME Type:
Creator:
Mark Wielaard
Created:
2019-05-02 21:48:20 UTC
Size:
4.26 KB
patch
obsolete
>diff --git a/src/readelf.c b/src/readelf.c >index c346e1f8a..4898bf950 100644 >--- a/src/readelf.c >+++ b/src/readelf.c >@@ -6930,7 +6930,7 @@ struct attrcb_args > { > Dwfl_Module *dwflmod; > Dwarf *dbg; >- Dwarf_Die *die; >+ Dwarf_Die *dies; > int level; > bool silent; > bool is_split; >@@ -6946,7 +6946,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) > { > struct attrcb_args *cbargs = (struct attrcb_args *) arg; > const int level = cbargs->level; >- Dwarf_Die *die = cbargs->die; >+ Dwarf_Die *die = &cbargs->dies[level]; > bool is_split = cbargs->is_split; > > unsigned int attr = dwarf_whatattr (attrp); >@@ -7290,9 +7290,6 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) > case DW_AT_ordering: > valuestr = dwarf_ordering_name (num); > break; >- case DW_AT_discr_list: >- valuestr = dwarf_discr_list_name (num); >- break; > case DW_AT_decl_file: > case DW_AT_call_file: > { >@@ -7347,7 +7344,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) > /* When highpc is in constant form it is relative to lowpc. > In that case also show the address. */ > Dwarf_Addr highpc; >- if (attr == DW_AT_high_pc && dwarf_highpc (cbargs->die, &highpc) == 0) >+ if (attr == DW_AT_high_pc && dwarf_highpc (die, &highpc) == 0) > { > printf (" %*s%-20s (%s) %" PRIuMAX " (", > (int) (level * 2), "", dwarf_attr_name (attr), >@@ -7369,7 +7366,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) > bool is_signed; > int bytes = 0; > if (attr == DW_AT_const_value) >- die_type_sign_bytes (cbargs->die, &is_signed, &bytes); >+ die_type_sign_bytes (die, &is_signed, &bytes); > else > is_signed = (form == DW_FORM_sdata > || form == DW_FORM_implicit_const); >@@ -7524,6 +7521,87 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) > else > print_block (block.length, block.data); > break; >+ >+ case DW_AT_discr_list: >+ if (form != DW_FORM_data16) >+ { >+ const unsigned char *readp = block.data; >+ const unsigned char *readendp = readp + block.length; >+ >+ /* See if we are dealing with a signed or unsigned >+ values. If the parent of this variant DIE is a >+ variant_part then it will either have a discriminator >+ which points to the member which type is the >+ discriminator type. Or the variant_part itself has a >+ type representing the discriminator. */ >+ bool is_signed = false; >+ if (level > 0) >+ { >+ Dwarf_Die *parent = &cbargs->dies[level - 1]; >+ if (dwarf_tag (die) == DW_TAG_variant >+ && dwarf_tag (parent) == DW_TAG_variant_part) >+ { >+ Dwarf_Die member; >+ Dwarf_Attribute discr_attr; >+ int bytes; >+ if (dwarf_formref_die (dwarf_attr (parent, >+ DW_AT_discr, >+ &discr_attr), >+ &member) != NULL) >+ die_type_sign_bytes (&member, &is_signed, &bytes); >+ else >+ die_type_sign_bytes (parent, &is_signed, &bytes); >+ } >+ } >+ while (readp < readendp) >+ { >+ int d = (int) *readp++; >+ printf ("%s ", dwarf_discr_list_name (d)); >+ Dwarf_Word val; >+ Dwarf_Sword sval; >+ if (d == DW_DSC_label) >+ { >+ if (is_signed) >+ { >+ get_sleb128 (sval, readp, readendp); >+ printf ("%" PRId64 "", sval); >+ } >+ else >+ { >+ get_uleb128 (val, readp, readendp); >+ printf ("%" PRIu64 "", val); >+ } >+ } >+ else if (d == DW_DSC_range) >+ { >+ if (is_signed) >+ { >+ get_sleb128 (sval, readp, readendp); >+ printf ("%" PRId64 "..", sval); >+ get_sleb128 (sval, readp, readendp); >+ printf ("%" PRId64 "", sval); >+ } >+ else >+ { >+ get_uleb128 (val, readp, readendp); >+ printf ("%" PRIu64 "..", val); >+ get_uleb128 (val, readp, readendp); >+ printf ("%" PRIu64 "", val); >+ } >+ } >+ else >+ { >+ print_block (readendp - readp, readp); >+ break; >+ } >+ if (readp < readendp) >+ printf (", "); >+ } >+ putchar ('\n'); >+ } >+ else >+ print_block (block.length, block.data); >+ break; > } > break; > >@@ -7724,7 +7802,7 @@ print_debug_units (Dwfl_Module *dwflmod, > > /* Print the attribute values. */ > args.level = level; >- args.die = &dies[level]; >+ args.dies = dies; > (void) dwarf_getattrs (&dies[level], attr_callback, &args, 0); > > /* Make room for the next level's DIE. */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 24509
:
11760
| 11762