From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25723 invoked by alias); 12 Nov 2014 07:01:18 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 25713 invoked by uid 89); 12 Nov 2014 07:01:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vc0-f171.google.com Received: from mail-vc0-f171.google.com (HELO mail-vc0-f171.google.com) (209.85.220.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 12 Nov 2014 07:01:16 +0000 Received: by mail-vc0-f171.google.com with SMTP id id10so1797288vcb.16 for ; Tue, 11 Nov 2014 23:01:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=L5AGpkfo78/YgUzIOxGW9NPdePJYs3of4IY2e4rBXb8=; b=L7o4KLwFaeEWvtvaCK9Euv0z+iH5s7D7bl6nlDNIFqrf4IshecyRmIH/4H3Vi8gWl2 WYVTGrgrcrlZ+hzweyQIkJMA/XUgKITwlx5NKkLTblzZlJiHBng0/eIFGMOX/8MQ7RBn 9BFwWQRfpwQK/fMJpy1+4n1Cdh1L64C8XcXOtzbD/z4jKPdeyru8aM1tqRSsMD7yvsk6 u6WWabLeWGgEx6cc6kQ58M/5PmYvFgthJp2IqkN4Z3UlEuZpGGxemaNTI6ShFjM7VE9l SbKigUsnw5u9Fyhsi1hhuKlBsu3huK+ZJiVcI+2od9xjQlKNjpX648WEHG4CC5H4BxVR t+rQ== X-Gm-Message-State: ALoCoQk1CT1NWC4FhoUQfMs0637QUt6lP5PdWyPXqP2UukTaKWvYDy4tIzWTmB4tZ7O5R2ue3+QX MIME-Version: 1.0 X-Received: by 10.52.82.103 with SMTP id h7mr26992869vdy.27.1415775674487; Tue, 11 Nov 2014 23:01:14 -0800 (PST) Received: by 10.52.114.101 with HTTP; Tue, 11 Nov 2014 23:01:14 -0800 (PST) In-Reply-To: <87fvdqijal.fsf@codesourcery.com> References: <1414195968-3333-1-git-send-email-yao@codesourcery.com> <1414195968-3333-3-git-send-email-yao@codesourcery.com> <21593.22575.941029.980760@ruffy2.mtv.corp.google.com> <87fvdypgap.fsf@codesourcery.com> <87k333izfm.fsf@codesourcery.com> <87fvdqijal.fsf@codesourcery.com> Date: Wed, 12 Nov 2014 07:01:00 -0000 Message-ID: Subject: Re: [PATCH 2/6] DW attribute macro MACRO_AT_func and MACRO_AT_range From: Doug Evans To: Yao Qi Cc: gdb-patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-11/txt/msg00200.txt.bz2 On Mon, Nov 10, 2014 at 6:05 PM, Yao Qi wrote: > [...] > 2014-11-10 Yao Qi > > * 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.