This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 2/6] DW attribute macro MACRO_AT_func and MACRO_AT_range
- From: Doug Evans <dje at google dot com>
- To: Yao Qi <yao at codesourcery dot com>
- Cc: gdb-patches <gdb-patches at sourceware dot org>
- Date: Tue, 11 Nov 2014 23:01:14 -0800
- Subject: Re: [PATCH 2/6] DW attribute macro MACRO_AT_func and MACRO_AT_range
- Authentication-results: sourceware.org; auth=none
- References: <1414195968-3333-1-git-send-email-yao at codesourcery dot com> <1414195968-3333-3-git-send-email-yao at codesourcery dot com> <21593 dot 22575 dot 941029 dot 980760 at ruffy2 dot mtv dot corp dot google dot com> <87fvdypgap dot fsf at codesourcery dot com> <CADPb22TSAFyEY1VNghhXmL3P27_o0OPPWS0jYSdAvJGS1jE7gg at mail dot gmail dot com> <87k333izfm dot fsf at codesourcery dot com> <CADPb22R5C7Gr_LtM8z=FfzxnYmvcDYN8=rr2gY-1asEYY3Wqug at mail dot gmail dot com> <87fvdqijal dot fsf at codesourcery dot com>
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.