patch: improve decode-to-name of additional DWARF 2/DWARF 3 codes

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

patch: improve decode-to-name of additional DWARF 2/DWARF 3 codes

Gary Funck

[I'm resubmitting this patch, incorporating Jim Blandy's
suggestions.  I think the copyright assignment issues have
been straightened out.  If not, please let me know off list.]

While debugging GDB, I noticed the routines in dwarf2read.c that
decode DWARF 2 and DWARF 3 codes into their corresponding string
names have not been updated to include the various encodings
that have been added over the past few years.  This primarily
impacts the diagnostic output that assists when debugging GDB.

Attached is a suggested patch (to gdb 6.5), which brings the
various *_name routines up to date with the definitions
in include/elf/dwarf2.h.

There is a small problem in the decoding caused by the
following (in dwarf2.h):

    /* GNU extensions.  */
    DW_OP_GNU_push_tls_address = 0xe0,
    /* HP extensions.  */
    DW_OP_HP_unknown     = 0xe0, /* Ouch, the same as GNU_push_tls_address.
*/

I arbitrarily chose to decode 0xe0 as "DW_OP_GNU_push_tls_address".
Also, I preserved the "#ifdef MIPS" inside dwarf_attr_name(), but
it wasn't clear to me that it is needed.  If it is, then for
consistency, perhaps ifdef's for HP, GNU, DWARF3, and other
extensions to DWARF 2 would also be required.

ChangeLog:

        * dwarf2read.c (dwarf_attr_name, dwarf_cfi_name)
        (dwarf_stack_op_name, dwarf_tag_name)
        (dwarf_type_encoding_name): Decode additional DWARF 2
        and DWARF 3 codes into their corresponding string names.

Diffs attached.

improve-decode-to-name-dwarf2read.c.patch (9K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: patch: improve decode-to-name of additional DWARF 2/DWARF 3 codes

Jim Blandy

"Gary Funck" <[hidden email]> writes:

> [I'm resubmitting this patch, incorporating Jim Blandy's
> suggestions.  I think the copyright assignment issues have
> been straightened out.  If not, please let me know off list.]
>
> While debugging GDB, I noticed the routines in dwarf2read.c that
> decode DWARF 2 and DWARF 3 codes into their corresponding string
> names have not been updated to include the various encodings
> that have been added over the past few years.  This primarily
> impacts the diagnostic output that assists when debugging GDB.
>
> Attached is a suggested patch (to gdb 6.5), which brings the
> various *_name routines up to date with the definitions
> in include/elf/dwarf2.h.

This looks great; please go ahead and commit.  Thanks for all your
patience.

> There is a small problem in the decoding caused by the
> following (in dwarf2.h):
>
>     /* GNU extensions.  */
>     DW_OP_GNU_push_tls_address = 0xe0,
>     /* HP extensions.  */
>     DW_OP_HP_unknown     = 0xe0, /* Ouch, the same as GNU_push_tls_address.
> */
>
> I arbitrarily chose to decode 0xe0 as "DW_OP_GNU_push_tls_address".

I think that's the best we can do in these situations.

What's important is that the name decoded actually match how GDB will
interpret it; since GDB recognizes the push_tls_address operation, but
not the 'HP_unknown', that's the way it should print it.  If GDB ever
did something fancy like look at the compilation unit's producer and
distinguish opcodes on that basis, then the printer would need to do
the same.

> Also, I preserved the "#ifdef MIPS" inside dwarf_attr_name(), but
> it wasn't clear to me that it is needed.  If it is, then for
> consistency, perhaps ifdef's for HP, GNU, DWARF3, and other
> extensions to DWARF 2 would also be required.

If the values don't conflict, I think it's best to go ahead and
recognize all of them.  Where they do conflict, the argument above
applies.
Reply | Threaded
Open this post in threaded view
|

[commit] improve decode-to-name of additional DWARF 2/DWARF 3 codes

Gary Funck
In reply to this post by Gary Funck
2006-12-27  Gary Funck  <[hidden email]>
 
        * dwarf2read.c (dwarf_attr_name, dwarf_cfi_name)
        (dwarf_stack_op_name, dwarf_tag_name)
        (dwarf_type_encoding_name): Decode additional DWARF 2
        and DWARF 3 codes into their corresponding string names.
 
        * MAINTAINERS (Write After Approval): Add myself.

Reply | Threaded
Open this post in threaded view
|

Re: [commit] improve decode-to-name of additional DWARF 2/DWARF 3 codes

Jim Blandy

"Gary Funck" <[hidden email]> writes:
> 2006-12-27  Gary Funck  <[hidden email]>
>  
>         * dwarf2read.c (dwarf_attr_name, dwarf_cfi_name)
>         (dwarf_stack_op_name, dwarf_tag_name)
>         (dwarf_type_encoding_name): Decode additional DWARF 2
>         and DWARF 3 codes into their corresponding string names.
>  
>         * MAINTAINERS (Write After Approval): Add myself.

Just to clarify --- this is a commit of a patch previously approved.