From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124513 invoked by alias); 13 Oct 2016 22:34:02 -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 124484 invoked by uid 89); 13 Oct 2016 22:33:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=73,6, name_len, Hx-languages-length:3039, Record X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Oct 2016 22:33:58 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6BBF83D965; Thu, 13 Oct 2016 22:33:57 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9DMXuZa011629; Thu, 13 Oct 2016 18:33:56 -0400 Subject: Re: [RFA v2 06/17] Record minimal symbols directly in reader. To: Tom Tromey , gdb-patches@sourceware.org References: <1476393012-29987-1-git-send-email-tom@tromey.com> <1476393012-29987-7-git-send-email-tom@tromey.com> From: Pedro Alves Message-ID: Date: Thu, 13 Oct 2016 22:34:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1476393012-29987-7-git-send-email-tom@tromey.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-10/txt/msg00415.txt.bz2 On 10/13/2016 10:10 PM, Tom Tromey wrote: > This patch changes minimal symbol creation in two ways. First, it > removes global variables in favor of members of minimal_symbol_reader. > Second, it changes functions like prim_record_minimal_symbol to be > member functions of minimal_symbol_reader. > Awesome, thanks. > struct minimal_symbol * > -prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name, > - CORE_ADDR address, > - enum minimal_symbol_type ms_type, > - int section, > - struct objfile *objfile) > +minimal_symbol_reader::record_full (const char *name, int name_len, > + int copy_name, Can you make this bool while at it? > + CORE_ADDR address, > + enum minimal_symbol_type ms_type, > + int section) > explicit minimal_symbol_reader (struct objfile *); > > @@ -73,6 +74,56 @@ class minimal_symbol_reader > > void install (); > > + /* Record a new minimal symbol. This is the "full" entry point; > + simpler convenience entry points are also provided below. > + > + This returns a new minimal symbol. It is ok to modify the returned > + minimal symbol (though generally not necessary). It is not ok, > + though, to stash the pointer anywhere; as minimal symbols may be > + moved after creation. The memory for the returned minimal symbol > + is still owned by the minsyms.c code, and should not be freed. > + > + Arguments are: > + > + NAME - the symbol's name > + NAME_LEN - the length of the name > + COPY_NAME - if true, the minsym code must make a copy of NAME. If > + false, then NAME must be NUL-terminated, and must have a lifetime > + that is at least as long as OBJFILE's lifetime. > + ADDRESS - the address of the symbol > + MS_TYPE - the type of the symbol > + SECTION - the symbol's section > + appropriate obj_section for the minimal symbol. This can be NULL. Hmm, preexisting, but, this parameter's type is actually int. Not sure that comment makes sense as is. > + OBJFILE - the objfile associated with the minimal symbol. */ ENOSUCHPARAMETER. > + > + struct minimal_symbol *record_full (const char *name, > + int name_len, > + int copy_name, Use "bool" for copy_name ? > + CORE_ADDR address, > + enum minimal_symbol_type ms_type, > + int section); > + > + /* Like record_full, but: > + - uses strlen to compute NAME_LEN, > + - passes COPY_NAME = 1, "= true". > + - and passes a default SECTION, depending on the type > + > + This variant does not return the new symbol. */ > + > + void record (const char *, CORE_ADDR, enum minimal_symbol_type); I think it may be a good idea to give names to the parameters. > + > + /* Like record_full, but: > + - uses strlen to compute NAME_LEN, > + - passes COPY_NAME = 1. */ = true. > + > + struct minimal_symbol *record_with_info (const char *name, > + CORE_ADDR address, > + enum minimal_symbol_type ms_type, > + int section) > + { > + return record_full (name, strlen (name), 1, address, ms_type, section); s/1/true/. LGTM with those changes. Thanks, Pedro Alves