From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1210 invoked by alias); 2 Jan 2008 17:46:46 -0000 Received: (qmail 1187 invoked by uid 22791); 2 Jan 2008 17:46:45 -0000 X-Spam-Check-By: sourceware.org Received: from mail.intrepid.com (HELO mail.intrepid.com) (74.95.8.113) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 02 Jan 2008 17:42:05 +0000 Received: from screamer.intrepid.com (screamer.intrepid.com [10.10.1.2]) by mail.intrepid.com (8.13.8/8.13.8) with ESMTP id m02HfwSw023223 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 2 Jan 2008 09:41:59 -0800 Received: from screamer.intrepid.com (screamer.intrepid.com [127.0.0.1]) by screamer.intrepid.com (8.13.8/8.13.8) with ESMTP id m02HfwlV000360; Wed, 2 Jan 2008 09:41:58 -0800 Received: (from gary@localhost) by screamer.intrepid.com (8.13.8/8.13.8/Submit) id m02HfwJM000358; Wed, 2 Jan 2008 09:41:58 -0800 Date: Wed, 02 Jan 2008 17:46:00 -0000 From: Gary Funck To: GDB List Cc: Daniel Jacobowitz Subject: Re: how to search for a global type? Message-ID: <20080102174158.GH30197@intrepid.com> References: <20071231042844.GA18814@intrepid.com> <20080102031750.GA27872@caradoc.them.org> <20080102051626.GB1259@intrepid.com> <20080102130630.GA31874@caradoc.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080102130630.GA31874@caradoc.them.org> User-Agent: Mutt/1.4.2.1i X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-01/txt/msg00004.txt.bz2 On 01/02/08 08:06:30, Daniel Jacobowitz wrote: > On Tue, Jan 01, 2008 at 09:16:26PM -0800, Gary Funck wrote: > > The typedef appears to be in inner block. Does that make it static? > > Block 0 is the global symbols; block 1 is the file static symbols. > Later blocks are the bodies of functions, et cetera. > > It makes sense for types to be static if you think about it from the > right perspective, since types do not (generally) have linker > visibility; the linker can't patch up your code to reference a type > declared in another file. > > In short, try just lookup_symbol? I did try lookup_symbol() as well, no go. I'm currently using this approach: static int lookup_type_by_name (const char *type_name) { const struct symbol *sym; const struct type *type; int type_id; struct symbol_search *matches; /* FIXME: add ^$ anchors to front/back of type_name, so that the regex matches only the desired type name. */ search_symbols ((char *)type_name, TYPES_DOMAIN, 0 /* nfiles */, NULL /* files */, &matches); if (!matches) return 0; /* Arbitrarily use the first match. */ sym = matches->symbol; free_search_symbols (matches); type_id = get_type_id (SYMBOL_TYPE (sym)); return type_id; } Search_symbols() finds the type definition that we're interested in. I think one difficulty is that the current file doesn't define the type. It is defined in the runtime files. I haven't tried following the logic, but could you briefly explain the raltionship between block vectors and symbol tables? thanks, - Gary