From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18531 invoked by alias); 23 May 2003 23:48:24 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 18492 invoked from network); 23 May 2003 23:48:23 -0000 Received: from unknown (HELO papaya.bactrian.org) (216.101.126.244) by sources.redhat.com with SMTP; 23 May 2003 23:48:23 -0000 Received: from papaya.bactrian.org (papaya.bactrian.org [127.0.0.1]) by papaya.bactrian.org (8.12.8/8.12.8) with ESMTP id h4NNmJtE014405; Fri, 23 May 2003 16:48:19 -0700 Received: (from carlton@localhost) by papaya.bactrian.org (8.12.8/8.12.8/Submit) id h4NNmEK7014403; Fri, 23 May 2003 16:48:14 -0700 X-Authentication-Warning: papaya.bactrian.org: carlton set sender to carlton@bactrian.org using -f To: gdb Cc: Elena Zannoni , Jim Blandy , Daniel Jacobowitz Subject: [rfc] lookups with natural/linkage names From: David Carlton Date: Fri, 23 May 2003 23:48:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-05/txt/msg00332.txt.bz2 Right now, both lookup_symbol and lookup_minimal_symbol accept either a linkage name or a natural name as an argument. This seems to me to not be very desirable: having spent a lot of time cleaning up the internals of lookup_symbol (and lookup_partial_symbol, and other functions) to get rid of bugs related to this confusion, I'd rather have it as clear as possible within GDB's code when one is expected and when the other is expected, and have as few functions as possible that accept both. My basic attitude is that symbols should normally be accessed via natural names and minimal symbols should normally be accessed via linkage names. (There are exceptions, of course: if you want to find the symbol associated to a minsym, for example, you'll probably be doing a symbol search via a linkage name.) Furthermore, for names that are generated internally to GDB, we should always know whether the name is a natural name or a linkage name, so it's safe to use a lookup function that only accepts one sort of name or the other. But sometimes we have to deal with user-provided names, which are usually natural names but might occasionally be linkage names. Exactly what we should do with those is open to question (which is why this is an RFC!). In all situations (I _think_; certainly most of them) where we look up something from a user-provided name, GDB first tries to look up a symbol and then, if that fails, tries to look up a minsym. So it seems to me that it's a reasonable choice to, when looking up a symbol from a user-provided name, always assume that it's a natural name, but when looking up a minsym, to accept either a natural name or a linkage name. That leads to the following recommendations: * Add a function struct symbol *lookup_symbol_linkage (const char *name); that looks up the symbol whose linkage name is NAME. It only looks up global or static symbols (with preference to the former), and only looks up symbols in VAR_DOMAIN; it doesn't apply any language-specific rules. This will, for example, give us a reliable way to find the symbol associated to a minsym, no matter how complicated C++ lookup rules make things. * Eventually, once lookup_symbol_linkage is being used wherever it's appropriate, have lookup_symbol stop accepting linkage names: only allow natural names. * Provide a function struct minimal_symbol * lookup_minimal_symbol_linkage_or_natural (const char *name); that looks up a minsym via either a natural name or a linkage name. (Yes, the name is ugly; on the other hand, we should never blithely use this function, so an ungainly but descriptive name isn't such a bad idea.) * Eventually, once lookup_minimal_symbol_linkage_or_natural is being used wherever is appropriate, have lookup_minimal_symbol only accept linkage names. I don't believe that there's a need for a version of lookup_minimal_symbol that only accepts natural names: it is my belief that the only calls to lookup_minimal_symbol that might want to accept a natural name are those using user-provide names, where lookup_minimal_symbol_linkage_or_natural is appropriate. I've had these implemented on my branch for a few months, and they seem to work fine. David Carlton carlton@bactrian.org