This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
macro debugging info: always include space after macro name
- From: Jim Blandy <jimb at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 18 Mar 2002 18:08:08 -0500
- Subject: macro debugging info: always include space after macro name
gcc -gdwarf-2 -g3 emits DW_MACINFO_define entries for macros whose
replacement list contains no tokens that lack a space after the macro
name. The Dwarf spec says:
In the case of a "normal" (i.e., non-function-like) macro
definition, exactly one space character should separate the name of
the defined macro from the following definition text.
I'm not sure the patch below is the best fix, for several reasons:
- Shouldn't meeting picayune requirements of the Dwarf format be
handled in dwarf2out? (Although, in the absence of guarantees from
the caller, that code would have to scan each definition to see
whether it needed an extra space...)
- Shouldn't the Dwarf spec be relaxed to allow generators to omit the
space when the macro's replacement list is empty? (Although this is
the kind of minor variation that is appropriate for user input, but
not so welcome in machine-readable formats...)
- If the `define' member of `struct gcc_debug_hooks' really requires
that its `text' argument be in strict Dwarf 2 form, shouldn't that
be documented?
Anyway, I'm happy with whatever solution folks want --- changing GCC,
GDB, or the Dwarf spec. The only thing I don't want is for GCC and
GDB to be tacitly agreeing on a form forbidden by the spec.
2002-03-18 Jim Blandy <jimb@redhat.com>
* cppmacro.c (cpp_macro_definition): Emit a space after the macro
name, even if the replacement list contains no tokens, as required
by Dwarf.
Index: gcc/cppmacro.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v
retrieving revision 1.94
diff -c -r1.94 cppmacro.c
*** gcc/cppmacro.c 2002/03/14 18:17:12 1.94
--- gcc/cppmacro.c 2002/03/18 22:34:19
***************
*** 1561,1570 ****
*buffer++ = ')';
}
/* Expansion tokens. */
if (macro->count)
{
- *buffer++ = ' ';
for (i = 0; i < macro->count; i++)
{
cpp_token *token = ¯o->expansion[i];
--- 1561,1573 ----
*buffer++ = ')';
}
+ /* The Dwarf spec requires a space after the macro name, even if the
+ definition is the empty string. */
+ *buffer++ = ' ';
+
/* Expansion tokens. */
if (macro->count)
{
for (i = 0; i < macro->count; i++)
{
cpp_token *token = ¯o->expansion[i];