This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] CHAR_TYPE vs dwarf-2 debug information
- From: Roger Sayle <roger at eyesopen dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: tromey at redhat dot com, <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 30 Jan 2006 16:23:31 -0700 (MST)
- Subject: [PATCH] CHAR_TYPE vs dwarf-2 debug information
On Sat, 28 Jan 2006, Eric Botcazou wrote:
> FWIW we are experimenting with that solution for the debug information
> issue on the Ada side. Preliminary results show that it works quite
> well for us.
The following patch simplifies the logic used in dwarf2out.c that
decides where integer types should be represented using either
DW_ATE_signed/DW_ATE_unsigned (which presumably are displayed
numerically) vs. DW_ATE_signed_char/DW_ATE_unsigned_char (which
presumably are displayed as characters).
The current hack is to either use CHAR_TYPE in the java front-end,
or to explicitly test for char_type_node (and similar strcmp tests)
for the common middle-end "*char_type_node"s. The clean-up below
is to use the TYPE_STRING_FLAG bit, to indicate which form of DIE
should be used in dwarf-2 output to describe a type.
Cleaning this up, allows the removal of the CHAR_TYPE tree nodes from
GCC, and also for finer control of debugging information on wchar_t,
and similar "glyph" types.
Eric, presumably this is the kind of patch the Ada folks had in mind?
The following patch has been tested on x86_64-unknown-linux-gnu with
a full "make bootstrap", all default languages, and regression tested
with a top-level "make -k check" with no new failures.
I'll wait for Eric to reply and/or suggest an alternate solution to
this problem, before proposing this change "for real" for mainline.
Thoughts?
2006-01-30 Roger Sayle <roger@eyesopen.com>
* tree.h (TYPE_STRING_FLAG): Document that this field may be used
on INTEGER_TYPEs to indicate that it denotes a character type.
* tree.c (build_common_tree_nodes): Set TYPE_STRING_FLAG on
signed_char_type_node, unsigned_char_type_node and char_type_node.
* dwarf2out.c (base_type_die): Treat CHAR_TYPE identically to
INTEGER_TYPE. Use TYPE_STRING_FLAG to decide whether to emit
a DW_ATE_[un]signed_char instead of a DW_ATE_[un]signed.
Index: tree.h
===================================================================
*** tree.h (revision 110176)
--- tree.h (working copy)
*************** struct tree_block GTY(())
*** 1884,1890 ****
/* If set in an ARRAY_TYPE, indicates a string type (for languages
that distinguish string from array of char).
! If set in a SET_TYPE, indicates a bitstring type. */
#define TYPE_STRING_FLAG(NODE) (TYPE_CHECK (NODE)->type.string_flag)
/* If non-NULL, this is an upper bound of the size (in bytes) of an
--- 1884,1890 ----
/* If set in an ARRAY_TYPE, indicates a string type (for languages
that distinguish string from array of char).
! If set in a INTEGER_TYPE, indicates a character type. */
#define TYPE_STRING_FLAG(NODE) (TYPE_CHECK (NODE)->type.string_flag)
/* If non-NULL, this is an upper bound of the size (in bytes) of an
Index: tree.c
===================================================================
*** tree.c (revision 110176)
--- tree.c (working copy)
*************** build_common_tree_nodes (bool signed_cha
*** 6254,6260 ****
--- 6254,6262 ----
/* Define both `signed char' and `unsigned char'. */
signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE);
+ TYPE_STRING_FLAG (signed_char_type_node) = 1;
unsigned_char_type_node = make_unsigned_type (CHAR_TYPE_SIZE);
+ TYPE_STRING_FLAG (unsigned_char_type_node) = 1;
/* Define `char', which is like either `signed char' or `unsigned char'
but not the same as either. */
*************** build_common_tree_nodes (bool signed_cha
*** 6262,6267 ****
--- 6264,6270 ----
= (signed_char
? make_signed_type (CHAR_TYPE_SIZE)
: make_unsigned_type (CHAR_TYPE_SIZE));
+ TYPE_STRING_FLAG (char_type_node) = 1;
short_integer_type_node = make_signed_type (SHORT_TYPE_SIZE);
short_unsigned_type_node = make_unsigned_type (SHORT_TYPE_SIZE);
Index: dwarf2out.c
===================================================================
*** dwarf2out.c (revision 110176)
--- dwarf2out.c (working copy)
*************** base_type_die (tree type)
*** 8097,8126 ****
switch (TREE_CODE (type))
{
case INTEGER_TYPE:
! /* Carefully distinguish the C character types, without messing
! up if the language is not C. Note that we check only for the names
! that contain spaces; other names might occur by coincidence in other
! languages. */
! if (! (TYPE_PRECISION (type) == CHAR_TYPE_SIZE
! && (TYPE_MAIN_VARIANT (type) == char_type_node
! || ! strcmp (type_name, "signed char")
! || ! strcmp (type_name, "unsigned char"))))
{
if (TYPE_UNSIGNED (type))
! encoding = DW_ATE_unsigned;
else
! encoding = DW_ATE_signed;
! break;
}
! /* else fall through. */
!
! case CHAR_TYPE:
! /* GNU Pascal/Ada CHAR type. Not used in C. */
! if (TYPE_UNSIGNED (type))
! encoding = DW_ATE_unsigned_char;
else
! encoding = DW_ATE_signed_char;
break;
case REAL_TYPE:
--- 8097,8115 ----
switch (TREE_CODE (type))
{
+ case CHAR_TYPE:
case INTEGER_TYPE:
! if (TYPE_STRING_FLAG (type))
{
if (TYPE_UNSIGNED (type))
! encoding = DW_ATE_unsigned_char;
else
! encoding = DW_ATE_signed_char;
}
! else if (TYPE_UNSIGNED (type))
! encoding = DW_ATE_unsigned;
else
! encoding = DW_ATE_signed;
break;
case REAL_TYPE:
Roger
--