This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [rfc/rfa] accept DW_TAG_namespace and friends, possibly on 5.3
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: David Carlton <carlton at math dot stanford dot edu>
- Cc: gdb-patches at sources dot redhat dot com,Elena Zannoni <ezannoni at redhat dot com>, Jim Blandy <jimb at redhat dot com>
- Date: Tue, 22 Oct 2002 17:17:49 -0400 (EDT)
- Subject: Re: [rfc/rfa] accept DW_TAG_namespace and friends, possibly on 5.3
On 22 Oct 2002, David Carlton wrote:
> The current situation around C++ namespace debugging info is that GCC
> isn't generating it because, if it were generating it, it would
> produce debugging info that GDB really can't handle. Basically,
> DW_TAG_namespace entries have children that are important, so GDB has
> to know a little bit about those nodes in order not to miss large
> chunks of debugging info. (This is true whether or not GDB wants to
> do anything particularly namespace-specific with that debugging info.)
>
> So it seems to me like it would be a good idea to change GDB as
> quickly as possible to not get confused by DW_TAG_namespace (as well
> as DW_TAG_imported_declaration and DW_TAG_imported_module): we
> shouldn't wait until adding more namespace functionality to GDB. For
> example, if that support makes it into GDB 5.3, then maybe GCC 3.3
> will be able to generate the appropriate debugging info, so when a GDB
> 5.4 (or whatever) rolls around that handles namespaces better, users
> will be able to take advantage of it immediately (instead of having to
> wait for the next GCC release).
>
> Here are some patches to let GDB accept that debugging information: I
> think it would be a good idea to get it into 5.3 as well as mainline,
> if possible. They're quite minimal changes: they make sure that, when
> reading partial symbols, we descend into DW_TAG_namespace entries,
> that when reading full symbols, we read children of DW_TAG_namespace
> entries (but we don't keep around any more namespace information than
> we do currently: e.g. we still get names from
> DW_AT_MIPS_linkage_name), and that we don't complain about the
> presence of DW_TAG_imported_declaration or DW_TAG_imported_module (but
> we also don't do anything useful about that info).
>
> I've tested this using current GCC, using GCC as patched according to
> <http://sources.redhat.com/ml/gdb/2002-08/msg00312.html>, and using
> GCC as patched according to that message plus the following patch:
>
> --- dwarf2out.c-danielb Fri Oct 18 11:39:46 2002
> +++ dwarf2out.c Fri Oct 18 11:38:46 2002
> @@ -11453,7 +11453,11 @@ gen_namespace_die (decl, context_die)
> {
> /* 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);
> + /* Anonymous namespaces shouldn't have a DW_AT_name. */
> + if (strncmp (dwarf2_name (decl, 0), "_GLOBAL__N", 10) == 0)
> + add_src_coords_attributes (namespace_die, decl);
> + else
> + add_name_and_src_coords_attributes (namespace_die, decl);
> equate_decl_number_to_die (decl, namespace_die);
> }
> else
Just FYI, the real fix is to move anonymous_namespace_name from
cp/cp-tree.h to c-common.h, and the actual declaration from cp/decl.c to
c-common.c , and pointer compare DECL_NAME (decl) to anonymous_namespace_name.
>
> In all cases, there are no new regressions. Unfortunately, I don't
> currently have a version of GCC that emits many
> DW_TAG_imported_declarations or any DW_TAG_imported_modules; I hope
> that I'll have one soon (Daniel Berlin is working on it but he's busy;
> maybe I'll try to work on it myself, too),
I should have it done in a few hours, actually.