* [C++ RFC] Debug info for anonymous aggregates
@ 2005-07-22 0:58 Devang Patel
2005-07-24 3:44 ` Mark Mitchell
0 siblings, 1 reply; 3+ messages in thread
From: Devang Patel @ 2005-07-22 0:58 UTC (permalink / raw)
To: GCC Development
C++ does not generate debug info for anonymous aggregates in cases
like :
class A
{
public:
typedef struct
{
int d;
} mystruct;
mystruct data;
};
This is because FE sets DECL_IGNORED_P bit. This causes debug info
generator to
skip debug info when invoked through rest_of_type_compilation(). The
fix I am
testing over night is to reset DECL_IGNORED_P bit when real name is
assigned
to anonymous aggregates and invoke debug_hooks again.
Is this the right approach? If yes then based on gcc and gdb dejagnu
results
I'll prepare actual patch.
Thanks,
-
Devang
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1364.2.6
diff -Idpatel.pbxuser -c -3 -p -r1.1364.2.6 decl.c
*** decl.c 9 Jul 2005 22:07:00 -0000 1.1364.2.6
--- decl.c 22 Jul 2005 00:51:45 -0000
*************** grokdeclarator (const cp_declarator *dec
*** 7706,7712 ****
/* Replace the anonymous name with the real name
everywhere. */
for (t = TYPE_MAIN_VARIANT (type); t; t =
TYPE_NEXT_VARIANT (t))
if (TYPE_NAME (t) == oldname)
! TYPE_NAME (t) = decl;
if (TYPE_LANG_SPECIFIC (type))
TYPE_WAS_ANONYMOUS (type) = 1;
--- 7706,7722 ----
/* Replace the anonymous name with the real name
everywhere. */
for (t = TYPE_MAIN_VARIANT (type); t; t =
TYPE_NEXT_VARIANT (t))
if (TYPE_NAME (t) == oldname)
! {
! TYPE_NAME (t) = decl;
!
! /* Debug info was not generated earlier for anonymous
aggregates.
! Now is the time generate debug info for such
types. */
! if (ANON_AGGRNAME_P (DECL_NAME(oldname)))
! {
! DECL_IGNORED_P (TYPE_STUB_DECL (t)) = 0;
! debug_hooks->type_decl (TYPE_STUB_DECL (t),
LOCAL_CLASS_P (t));
! }
! }
if (TYPE_LANG_SPECIFIC (type))
TYPE_WAS_ANONYMOUS (type) = 1;
Index: name-lookup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/name-lookup.c,v
retrieving revision 1.109.2.2
diff -Idpatel.pbxuser -c -3 -p -r1.109.2.2 name-lookup.c
*** name-lookup.c 9 Jul 2005 22:07:03 -0000 1.109.2.2
--- name-lookup.c 22 Jul 2005 00:51:45 -0000
*************** pushtag (tree name, tree type, tag_scope
*** 4675,4681 ****
else
d = pushdecl_with_scope (d, b);
! /* FIXME what if it gets a name from typedef? */
if (ANON_AGGRNAME_P (name))
DECL_IGNORED_P (d) = 1;
--- 4675,4682 ----
else
d = pushdecl_with_scope (d, b);
! /* If it gets a name from typedef, reset DECL_IGNORED_P flag
! and invoke debug_hooks again. */
if (ANON_AGGRNAME_P (name))
DECL_IGNORED_P (d) = 1;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [C++ RFC] Debug info for anonymous aggregates
2005-07-22 0:58 [C++ RFC] Debug info for anonymous aggregates Devang Patel
@ 2005-07-24 3:44 ` Mark Mitchell
2005-07-25 21:59 ` Devang Patel
0 siblings, 1 reply; 3+ messages in thread
From: Mark Mitchell @ 2005-07-24 3:44 UTC (permalink / raw)
To: Devang Patel; +Cc: GCC Development
Devang Patel wrote:
> C++ does not generate debug info for anonymous aggregates in cases like :
>
> class A
> {
> public:
> typedef struct
> {
> int d;
> } mystruct;
> mystruct data;
> };
>
> This is because FE sets DECL_IGNORED_P bit. This causes debug info
> generator to
> skip debug info when invoked through rest_of_type_compilation(). The
> fix I am
> testing over night is to reset DECL_IGNORED_P bit when real name is
> assigned
> to anonymous aggregates and invoke debug_hooks again.
>
> Is this the right approach? If yes then based on gcc and gdb dejagnu
> results
> I'll prepare actual patch.
Actually, I think the best fix would be just not to set DECL_IGNORED_P
in the first place, and let the debug-generators sort it out. They
should learn about anonymous unions (and anonymous structures). Real
debugging formats (e.g., DWARF 2) support that; if stabs doesn't, then
the debug generator can work around that by skipping the type if it so
pleases.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-07-25 21:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-22 0:58 [C++ RFC] Debug info for anonymous aggregates Devang Patel
2005-07-24 3:44 ` Mark Mitchell
2005-07-25 21:59 ` Devang Patel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).