From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3927 invoked by alias); 5 Nov 2014 20:25:55 -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 3915 invoked by uid 89); 5 Nov 2014 20:25:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f170.google.com Received: from mail-pd0-f170.google.com (HELO mail-pd0-f170.google.com) (209.85.192.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 05 Nov 2014 20:25:52 +0000 Received: by mail-pd0-f170.google.com with SMTP id z10so1421014pdj.15 for ; Wed, 05 Nov 2014 12:25:50 -0800 (PST) X-Received: by 10.70.88.165 with SMTP id bh5mr21737348pdb.51.1415219150614; Wed, 05 Nov 2014 12:25:50 -0800 (PST) Received: from seba.sebabeach.org.gmail.com (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by mx.google.com with ESMTPSA id c1sm3987412pbu.23.2014.11.05.12.25.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Nov 2014 12:25:49 -0800 (PST) From: Doug Evans To: Yao Qi Cc: Subject: Re: [PATCH 7/9] Rewrite lookup_static_symbol to use gdbarch routine References: <87d29cvqfu.fsf@codesourcery.com> Date: Wed, 05 Nov 2014 20:25:00 -0000 In-Reply-To: <87d29cvqfu.fsf@codesourcery.com> (Yao Qi's message of "Tue, 28 Oct 2014 11:11:33 +0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-11/txt/msg00102.txt.bz2 Yao Qi writes: > Doug Evans writes: > >> struct symbol * >> lookup_static_symbol_aux (const char *name, const domain_enum domain) >> { >> struct objfile *objfile; >> struct symbol *sym; >> >> sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain); >> if (sym != NULL) >> return sym; >> >> ALL_OBJFILES (objfile) >> { >> sym = lookup_symbol_aux_quick (objfile, STATIC_BLOCK, name, domain); >> if (sym != NULL) >> return sym; >> } >> >> return NULL; >> } >> >> Note what we're doing here. >> First we're searching over all expanded symtabs in all objfiles, >> and then we search partial/gdb_index tables in all objfiles. Eh? >> >> Normally when looking up a symbol in a particular objfile >> we first list in expanded symtabs and then look in partial/gdb_index >> tables. And *then* we try the next objfile. >> >> I can't think of any justification for the current behaviour. >> >> This patch changes things to be consistent, >> but it is a behavioural change. > > Yes, it changes the behavior. Here is an example in my mind, but not > sure it is correct or not, say, we have a static int foo defined in two > objfiles respectively (1.c and 2.c), foo is in the partial table of two > objfiles, but is only expanded to the full symtab of *one* objfile (2.c). > > 1.c 2.c > partial foo foo > full foo Also note that the context is searching across objfiles, so 1.c and 2.c are also 1.so and 2.so. > before your patch, GDB gets foo from 2.c full table, and after it, GDB > gets foo from 1.c partial table. Is it possible? The question isn't whether it is possible, the question is whether this is a behavioural change on which we make some kind of guarantee. For the task at hand, we should be making a guarantee related to library search order before making any kind of guarantee related to internal implementation details (partial vs full syms). [I'm not saying we can or should make search order guarantees, per se. Rather, such things should at least be coherent.] With this patch we now perform a proper full search of libraries in a partcular order (however that order is defined which is a separate discussion). Whereas today we could find foo in the last library in the search order, even if every library has foo, just because someone accessed some other symbol in the last library and caused the symtab with foo to be expanded. > Regarding the change, we also need to update the comments to > iterate_over_objfiles_in_search_order in gdbarch.sh, > > # Iterate over all objfiles in the order that makes the most sense > # for the architecture to make global symbol searches. > ^^^^^^^^^^^^^ Ah, righto. >> The testsuite passes, and any noticeable difference >> by this change would be dependent on the order in which >> symtabs got expanded. Thus I can't think of a reason to not >> apply this change. > > If read this > > correctly, Joel expressed the same intention there. Righto. > Since gdbarch method iterate_over_objfiles_in_search_order was added for > windows target and this patch uses it, we need to test it on windows target. > If you don't have mingw testing env, let me know, I'll see if I can do > the test. I'm going to be making more symtab changes so I might as well get mingw testing going here. Testing in progress.