This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/6] DW attribute macro MACRO_AT_func and MACRO_AT_range


On Mon, Nov 10, 2014 at 6:05 PM, Yao Qi <yao@codesourcery.com> wrote:
> [...]
> 2014-11-10  Yao Qi  <yao@codesourcery.com>
>
>         * lib/dwarf.exp (function_range): New procedure.
>         (Dwarf::_handle_macro_at_func): New procedure.
>         (Dwarf::_handle_macro_at_range): New procedure.
>         (Dwarf): Handle MACRO_AT_func and MACRO_AT_range.

LGTM, with one nit that can be left for later.

> +
> +           if { [string equal "MACRO_AT_func" $attr_name] } {
> +               _handle_macro_at_func $attr_value
> +           } elseif { [string equal "MACRO_AT_range" $attr_name] } {
> +               _handle_macro_at_range $attr_value
>             } else {
> -               set attr_form [_guess_form $attr_value attr_value]
> -           }
> -           set attr_form [_map_name $attr_form _FORM]
> +               if {[llength $attr] > 2} {
> +                   set attr_form [lindex $attr 2]
> +               } else {
> +                   set attr_form [_guess_form $attr_value attr_value]
> +               }
> +               set attr_form [_map_name $attr_form _FORM]
>
> -           _handle_attribute $attr_name $attr_value $attr_form
> +               _handle_attribute $attr_name $attr_value $attr_form
> +           }
>         }
>
>         _defer_output $_abbrev_section {

The sequence of ifs to test for each macro name is akin to the switch
statement we removed.
It's less code of course, but it still involves continual additions
for each new macro.
I was thinking of still having a wrapper function that checks for macros,
but it could do "info proc _handle_$attr_name" or some such and
call(via eval?) the function if it exists or flag an error if it
doesn't.  We don't have to go down this road though until we need to.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]