From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31972 invoked by alias); 23 Aug 2002 22:35:56 -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 31944 invoked from network); 23 Aug 2002 22:35:55 -0000 Received: from unknown (HELO mail.cdt.org) (206.112.85.61) by sources.redhat.com with SMTP; 23 Aug 2002 22:35:55 -0000 Received: from www.dberlin.org (pool-138-88-153-3.esr.east.verizon.net [138.88.153.3]) by mail.cdt.org (Postfix) with ESMTP id 0DFEE490052; Fri, 23 Aug 2002 18:15:22 -0400 (EDT) Received: by www.dberlin.org (Postfix, from userid 503) id EBF6C1869F78; Fri, 23 Aug 2002 18:35:50 -0400 (EDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by www.dberlin.org (Postfix) with ESMTP id 348201828161; Fri, 23 Aug 2002 18:35:50 -0400 (EDT) Date: Fri, 23 Aug 2002 15:35:00 -0000 From: Daniel Berlin Reply-To: dberlin@dberlin.org To: Petr Sorfa Cc: David Carlton , gdb , Subject: Re: adding namespace support to GDB In-Reply-To: <3D668F10.C739D3F5@caldera.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,EMAIL_ATTRIBUTION,IN_REP_TO,PATCH_CONTEXT_DIFF, SPAM_PHRASE_00_01,USER_AGENT_PINE version=2.40 X-Spam-Level: X-SW-Source: 2002-08/txt/msg00312.txt.bz2 On Fri, 23 Aug 2002, Petr Sorfa wrote: > Hi Daniel, > > Well, let me or John Wolfe submit a patch with the imported declaration > support next week. It will at least be some kind of comparison. My gcc patch already includes this. I've rediffed against current gcc sources, and pasted it below. Index: dwarf2out.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v retrieving revision 1.379.2.3 diff -c -3 -p -w -B -b -r1.379.2.3 dwarf2out.c *** dwarf2out.c 19 Aug 2002 01:30:33 -0000 1.379.2.3 --- dwarf2out.c 23 Aug 2002 22:33:11 -0000 *************** static void gen_tagged_type_instantiatio *** 3648,3654 **** --- 3648,3656 ---- static void gen_block_die PARAMS ((tree, dw_die_ref, int)); static void decls_for_scope PARAMS ((tree, dw_die_ref, int)); static int is_redundant_typedef PARAMS ((tree)); + static void gen_namespace_die PARAMS ((tree, dw_die_ref)); static void gen_decl_die PARAMS ((tree, dw_die_ref)); + static dw_die_ref force_out_decl PARAMS ((tree, dw_die_ref)); static unsigned lookup_filename PARAMS ((const char *)); static void init_file_table PARAMS ((void)); static void retry_incomplete_types PARAMS ((void)); *************** dwarf_tag_name (tag) *** 3905,3910 **** --- 3907,3914 ---- return "DW_TAG_namelist"; case DW_TAG_namelist_item: return "DW_TAG_namelist_item"; + case DW_TAG_namespace: + return "DW_TAG_namespace"; case DW_TAG_packed_type: return "DW_TAG_packed_type"; case DW_TAG_subprogram: *************** scope_die_for (t, context_die) *** 9540,9548 **** containing_scope = TYPE_CONTEXT (t); ! /* Ignore namespaces for the moment. */ if (containing_scope && TREE_CODE (containing_scope) == NAMESPACE_DECL) ! containing_scope = NULL_TREE; /* Ignore function type "scopes" from the C frontend. They mean that a tagged type is local to a parmlist of a function declarator, but --- 9544,9563 ---- containing_scope = TYPE_CONTEXT (t); ! /* Handle namespaces properly */ if (containing_scope && TREE_CODE (containing_scope) == NAMESPACE_DECL) ! { ! dw_die_ref newcontext = lookup_decl_die (containing_scope); ! ! if (!newcontext) ! { ! gen_decl_die (containing_scope, context_die); ! newcontext = lookup_decl_die (containing_scope); ! if (!newcontext) ! abort(); ! } ! context_die = newcontext; ! } /* Ignore function type "scopes" from the C frontend. They mean that a tagged type is local to a parmlist of a function declarator, but *************** is_redundant_typedef (decl) *** 11374,11379 **** --- 11389,11453 ---- return 0; } + static dw_die_ref + force_out_decl (decl, context_die) + tree decl; + dw_die_ref context_die; + { + /* Force out the namespace. */ + if (DECL_CONTEXT (decl) && TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL) + { + dw_die_ref newcontext; + newcontext = lookup_decl_die (DECL_CONTEXT (decl)); + if (!newcontext) + { + gen_decl_die (DECL_CONTEXT (decl), context_die); + newcontext = lookup_decl_die (DECL_CONTEXT (decl)); + if (!newcontext) + abort(); + } + context_die = newcontext; + } + return context_die; + } + + /* Generate a DIE for a namespace or namespace alias */ + static void + gen_namespace_die (decl, context_die) + register tree decl; + register dw_die_ref context_die; + { + /* Namespace aliases have a DECL_ABSTRACT_ORIGIN of the namespace + they are an alias of.*/ + if (DECL_ABSTRACT_ORIGIN (decl) == NULL) + { + /* Output a real namespace */ + dw_die_ref namespace_die = new_die (DW_TAG_namespace, context_die, decl); + add_name_and_src_coords_attributes (namespace_die, decl); + equate_decl_number_to_die (decl, namespace_die); + } + else + { + /* Output a namespace alias */ + dw_die_ref namespace_die; + + /* Force out the namespace we are an alias of, if necessary */ + dw_die_ref origin_die = lookup_decl_die (DECL_ABSTRACT_ORIGIN (decl)); + if (!origin_die) + { + /* Attempt to force out origin. */ + dwarf2out_decl (DECL_ABSTRACT_ORIGIN (decl)); + origin_die = lookup_decl_die (DECL_ABSTRACT_ORIGIN (decl)); + if (!origin_die) + abort(); + } + /* Now create the namespace alias DIE. */ + namespace_die = new_die (DW_TAG_imported_declaration, context_die, decl); + add_name_and_src_coords_attributes (namespace_die, decl); + add_AT_die_ref (namespace_die, DW_AT_import, origin_die); + equate_decl_number_to_die (decl, namespace_die); + } + } /* Generate Dwarf debug information for a decl described by DECL. */ *************** gen_decl_die (decl, context_die) *** 11424,11429 **** --- 11498,11505 ---- /* Otherwise we're emitting the primary DIE for this decl. */ else if (debug_info_level > DINFO_LEVEL_TERSE) { + context_die = force_out_decl (decl, context_die); + /* Before we describe the FUNCTION_DECL itself, make sure that we have described its return type. */ gen_type_die (TREE_TYPE (TREE_TYPE (decl)), context_die); *************** gen_decl_die (decl, context_die) *** 11447,11453 **** actual typedefs. */ if (debug_info_level <= DINFO_LEVEL_TERSE) break; ! /* In the special case of a TYPE_DECL node representing the declaration of some type tag, if the given TYPE_DECL is marked as having been instantiated from some other (original) TYPE_DECL node (e.g. one which --- 11523,11529 ---- actual typedefs. */ if (debug_info_level <= DINFO_LEVEL_TERSE) break; ! context_die = force_out_decl (decl, context_die); /* In the special case of a TYPE_DECL node representing the declaration of some type tag, if the given TYPE_DECL is marked as having been instantiated from some other (original) TYPE_DECL node (e.g. one which *************** gen_decl_die (decl, context_die) *** 11477,11482 **** --- 11553,11559 ---- variable declarations or definitions. */ if (debug_info_level <= DINFO_LEVEL_TERSE) break; + context_die = force_out_decl (decl, context_die); /* Output any DIEs that are needed to specify the type of this data object. */ *************** gen_decl_die (decl, context_die) *** 11504,11509 **** --- 11581,11587 ---- if (DECL_NAME (decl) != NULL_TREE || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE) { + context_die = force_out_decl (decl, context_die); gen_type_die (member_declared_type (decl), context_die); gen_field_die (decl, context_die); } *************** gen_decl_die (decl, context_die) *** 11515,11521 **** break; case NAMESPACE_DECL: ! /* Ignore for now. */ break; default: --- 11593,11600 ---- break; case NAMESPACE_DECL: ! context_die = force_out_decl (decl, context_die); ! gen_namespace_die (decl, context_die); break; default: *************** dwarf2out_decl (decl) *** 11668,11673 **** --- 11747,11759 ---- /* If we are in terse mode, don't generate any DIEs for types. */ if (debug_info_level <= DINFO_LEVEL_TERSE) + case NAMESPACE_DECL: + if (debug_info_level <= DINFO_LEVEL_TERSE) + return; + if (lookup_decl_die (decl) != NULL) + return; + break; + return; /* If we're a function-scope tag, initially use a parent of NULL;