From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22486 invoked by alias); 31 Dec 2007 04:28:58 -0000 Received: (qmail 22477 invoked by uid 22791); 31 Dec 2007 04:28:58 -0000 X-Spam-Check-By: sourceware.org Received: from intrepid.intrepid.com (HELO mail.intrepid.com) (74.95.8.113) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 31 Dec 2007 04:28:46 +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 lBV4SinO009567 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 30 Dec 2007 20:28:45 -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 lBV4Si6B030451 for ; Sun, 30 Dec 2007 20:28:44 -0800 Received: (from gary@localhost) by screamer.intrepid.com (8.13.8/8.13.8/Submit) id lBV4Si0g030449 for gdb@sources.redhat.com; Sun, 30 Dec 2007 20:28:44 -0800 Date: Mon, 31 Dec 2007 04:28:00 -0000 From: Gary Funck To: GDB List Subject: how to search for a global type? Message-ID: <20071231042844.GA18814@intrepid.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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: 2007-12/txt/msg00192.txt.bz2 To support UPC debugging, we need to be able to look up runtime information. Case in point, we need to query the structure of the target's shared pointer representation. At preent, we're implmenting this query with the following code (within gdb): static int lookup_type_by_name (const char *type_name) { const struct symbol *sym; const struct type *type; int type_id; sym = lookup_symbol_global (type_name, NULL, TYPES_DOMAIN, NULL); if (!sym) sym = lookup_symbol_global (type_name, NULL, STRUCT_DOMAIN, NULL); if (!sym) return 0; type_id = get_type_id (SYMBOL_TYPE (sym)); return type_id; } This code doesn't find the type in question, in spite of the fact that GDB has no problem finding the type from the command line. For example, (gdb) ptype upc_shared_ptr_t type = struct shared_ptr_struct { long unsigned int phase : 48; short unsigned int thread : 16; void *vaddr; } and (gdb) info type upc_shared_ptr_t All types matching regular expression "upc_shared_ptr_t": File /upc/gcc-upc-4/src/libupc/smp/upc_access.c: typedef shared_ptr_struct upc_shared_ptr_t; File /upc/gcc-upc-4/src/libupc/smp/upc_barrier.c: typedef shared_ptr_struct upc_shared_ptr_t; [...] I've added some simple debugging output to lookup_symbol_global, to confirm that it is being called with the expected parameters: lookup_symbol_global(upc_shared_ptr_t, NULL, 6, NULL) called. lookup_symbol_global(upc_shared_ptr_t, NULL, 2, NULL) called. In both cases, the type can't be found. What's the recommended way to perform this type lookup? Thanks, - Gary configuration: x86_64, FC5, dwarf2 debugging info.