public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Ada character types : tree code and DW_AT_encoding
@ 2005-07-05 10:53 Jerome Guitton
  2005-08-11  1:57 ` James E Wilson
  0 siblings, 1 reply; 9+ messages in thread
From: Jerome Guitton @ 2005-07-05 10:53 UTC (permalink / raw)
  To: gcc

Hello,

dwarf2out.c reads:

[...]
    case CHAR_TYPE:
      /* GNU Pascal/Ada CHAR type.  Not used in C.  */
      if (TREE_UNSIGNED (type))
        encoding = DW_ATE_unsigned_char;
      else
        encoding = DW_ATE_signed_char;
      break;
[...]

The comment is wrong. In Ada, the tree code for a character type is
INTEGER_TYPE. That means that a wrong value is generated for the tag
DW_AT_encoding.

Two solutions : we can either change the tree code to CHAR_TYPE or add a test
to detect Ada character types in the INTEGER_TYPE case, like it is done for
C:

[...]
    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 == char_type_node   
                 || ! strcmp (type_name, "signed char")
                 || ! strcmp (type_name, "unsigned char"))))
        {
          if (TREE_UNSIGNED (type))
            encoding = DW_ATE_unsigned;
          else
            encoding = DW_ATE_signed;
          break;
        }
[...]

The first solution would probably be cleaner, but it would mean that
Ada would be the only supported langage to use CHAR_TYPE. The second
one would be safer.

Opinions/thoughts?

Thanks in advance,
Jerome

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada character types : tree code and DW_AT_encoding
  2005-07-05 10:53 Ada character types : tree code and DW_AT_encoding Jerome Guitton
@ 2005-08-11  1:57 ` James E Wilson
  2005-08-11  2:13   ` Tom Tromey
  2005-08-11  9:05   ` Jerome Guitton
  0 siblings, 2 replies; 9+ messages in thread
From: James E Wilson @ 2005-08-11  1:57 UTC (permalink / raw)
  To: Jerome Guitton; +Cc: gcc

Jerome Guitton wrote:
> Two solutions : we can either change the tree code to CHAR_TYPE or add a test
> to detect Ada character types in the INTEGER_TYPE case, like it is done for
> C:
> ...
> The first solution would probably be cleaner, but it would mean that
> Ada would be the only supported langage to use CHAR_TYPE. The second
> one would be safer.

Belatedly following up on this...

Java uses CHAR_TYPE.  So Ada would not be the only supported language 
using it if you switched to it.

The C support isn't quite right.  There is no attempt to handle wchar_t 
here, which is obviously a character type.  We would need more 
exceptions to get this right.

I think it would be better if the language front ends switched to using 
CHAR_TYPE for character types.  Otherwise the debug output routines need 
a lot of code to tell which integer types are actually character types, 
and this is going to be hard to get right.  It is easier if the language 
front ends choose the right type to begin with.

This still may not solve the C front end problem though, as the C 
language doesn't actually have distinct character types separate from 
integer types.  We don't need the C hacks here for gdb, as gdb knows 
that single byte integer types are sometimes used for holding 
characters.  This stuff still might be useful for other debuggers though.

Looking at the gdb code in dwarf2read.c, it looks like the distinction 
between DW_ATE_unsigned and DW_ATE_unsigned_char is irrelevant as it 
handles them the same.  So unless you are planning to do some gdb work, 
it doesn't matter which one gcc emits.  Or maybe you are using a 
different debugger that does care?
-- 
Jim Wilson, GNU Tools Support, http://www.specifix.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada character types : tree code and DW_AT_encoding
  2005-08-11  1:57 ` James E Wilson
@ 2005-08-11  2:13   ` Tom Tromey
  2005-08-11 10:23     ` Andrew Haley
  2005-08-11  9:05   ` Jerome Guitton
  1 sibling, 1 reply; 9+ messages in thread
From: Tom Tromey @ 2005-08-11  2:13 UTC (permalink / raw)
  To: James E Wilson; +Cc: gcc

>>>>> "Jim" == James E Wilson <wilson@specifix.com> writes:

Jim> Java uses CHAR_TYPE.  So Ada would not be the only supported language
Jim> using it if you switched to it.

I was under the impression that CHAR_TYPE was deprecated, so I
purposely avoided it in gcjx.  I'm not sure where I got that
impression though.

Jim> I think it would be better if the language front ends switched to
Jim> using CHAR_TYPE for character types.  Otherwise the debug output
Jim> routines need a lot of code to tell which integer types are actually
Jim> character types, and this is going to be hard to get right.

Interesting.  Good thing to document somewhere.

Tom

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada character types : tree code and DW_AT_encoding
  2005-08-11  1:57 ` James E Wilson
  2005-08-11  2:13   ` Tom Tromey
@ 2005-08-11  9:05   ` Jerome Guitton
  1 sibling, 0 replies; 9+ messages in thread
From: Jerome Guitton @ 2005-08-11  9:05 UTC (permalink / raw)
  To: James E Wilson; +Cc: gcc

Jim,

Thank you for your answer !

James E Wilson (wilson@specifix.com):

> I think it would be better if the language front ends switched to using 
> CHAR_TYPE for character types.  Otherwise the debug output routines need 
> a lot of code to tell which integer types are actually character types, 
> and this is going to be hard to get right.  It is easier if the language 
> front ends choose the right type to begin with.

Anyway, I will test this approach for Ada. It really seems to be the right way
to go.

> Looking at the gdb code in dwarf2read.c, it looks like the distinction 
> between DW_ATE_unsigned and DW_ATE_unsigned_char is irrelevant as it 
> handles them the same.  So unless you are planning to do some gdb work, 
> it doesn't matter which one gcc emits.  Or maybe you are using a 
> different debugger that does care?

Yes, I am using a different debugger. I do not know if it does care, though.

I will keep you informed !
Jerome

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada character types : tree code and DW_AT_encoding
  2005-08-11  2:13   ` Tom Tromey
@ 2005-08-11 10:23     ` Andrew Haley
  2005-08-11 19:48       ` James E Wilson
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Haley @ 2005-08-11 10:23 UTC (permalink / raw)
  To: Tom Tromey; +Cc: James E Wilson, gcc

Tom Tromey writes:
 > >>>>> "Jim" == James E Wilson <wilson@specifix.com> writes:
 > 
 > Jim> Java uses CHAR_TYPE.  So Ada would not be the only supported language
 > Jim> using it if you switched to it.
 > 
 > I was under the impression that CHAR_TYPE was deprecated, so I
 > purposely avoided it in gcjx.  I'm not sure where I got that
 > impression though.

I can't remember the context either, but I agree with your memory.  I
think it was discussed a little while ago: the idea was entirely to
eliminate CHAR_TYPE from the compiler, and that FEs were doing so.

 > Jim> I think it would be better if the language front ends switched to
 > Jim> using CHAR_TYPE for character types.

Instead of switching away!  Right, I guess we need to have the disussion.

Andrew.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada character types : tree code and DW_AT_encoding
  2005-08-11 10:23     ` Andrew Haley
@ 2005-08-11 19:48       ` James E Wilson
  2005-08-12 18:04         ` Tom Tromey
  2005-08-13 15:01         ` Paul Brook
  0 siblings, 2 replies; 9+ messages in thread
From: James E Wilson @ 2005-08-11 19:48 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc

Andrew Haley wrote:
> Tom Tromey writes:
>  > I was under the impression that CHAR_TYPE was deprecated, so I
>  > purposely avoided it in gcjx.  I'm not sure where I got that
>  > impression though.
> I can't remember the context either, but I agree with your memory.  I
> think it was discussed a little while ago: the idea was entirely to
> eliminate CHAR_TYPE from the compiler, and that FEs were doing so.

I don't recall the discussion.  I probably didn't realize it was 
relevant to debugger issues at the time.  I don't see anything in the 
source code that says CHAR_TYPE is deprecated.

I see that Nathan posted a patch last December to try to remove some 
CHAR_TYPE support.
     http://gcc.gnu.org/ml/gcc-patches/2004-12/msg00689.html

If people want to do this, it seems reasonable.  However, we are losing 
info potentially valuable to the debugger, because the debugger should 
be printing character types differently than integer types. 
Particularly in languages, unlike C, that have character types distinct 
from the integer types.  It would be nice if this info could be retained 
somehow.

A possible way to solve this problem is to add a single-bit flag to 
INTEGER_TYPE nodes that indicates whether this is actually a character 
type.  Then dwarf2out.c could just check the flag to determine what 
debug info to emit.  It looks like we have a number of flag bits that 
aren't being used in type nodes.  This is much better than trying to do 
string matches against type names to determine what is a character type.
-- 
Jim Wilson, GNU Tools Support, http://www.specifix.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada character types : tree code and DW_AT_encoding
  2005-08-11 19:48       ` James E Wilson
@ 2005-08-12 18:04         ` Tom Tromey
  2005-08-13 15:01         ` Paul Brook
  1 sibling, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2005-08-12 18:04 UTC (permalink / raw)
  To: James E Wilson; +Cc: gcc

>>>>> "Jim" == James E Wilson <wilson@specifix.com> writes:

Jim> I see that Nathan posted a patch last December to try to remove some
Jim> CHAR_TYPE support.
Jim>      http://gcc.gnu.org/ml/gcc-patches/2004-12/msg00689.html

Yeah, that must be what I remember.

Jim> A possible way to solve this problem is to add a single-bit flag to
Jim> INTEGER_TYPE nodes that indicates whether this is actually a character
Jim> type.

For my purposes, it doesn't matter exactly what approach we take, as
long as we just pick one and document it.  I think the affected code
in gcjx is just a single line.  If/when the CHAR_TYPE removal resumes,
handling debug info properly ought to be a new requirement on the
solution.

Tom

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada character types : tree code and DW_AT_encoding
  2005-08-11 19:48       ` James E Wilson
  2005-08-12 18:04         ` Tom Tromey
@ 2005-08-13 15:01         ` Paul Brook
  2005-08-13 20:25           ` James E Wilson
  1 sibling, 1 reply; 9+ messages in thread
From: Paul Brook @ 2005-08-13 15:01 UTC (permalink / raw)
  To: gcc; +Cc: James E Wilson, Andrew Haley

> A possible way to solve this problem is to add a single-bit flag to
> INTEGER_TYPE nodes that indicates whether this is actually a character
> type.  Then dwarf2out.c could just check the flag to determine what
> debug info to emit.  It looks like we have a number of flag bits that
> aren't being used in type nodes.  This is much better than trying to do
> string matches against type names to determine what is a character type.

We already have TYPE_STRING_FLAG used on array types. Maybe it would it make 
sense to use that?

Paul

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ada character types : tree code and DW_AT_encoding
  2005-08-13 15:01         ` Paul Brook
@ 2005-08-13 20:25           ` James E Wilson
  0 siblings, 0 replies; 9+ messages in thread
From: James E Wilson @ 2005-08-13 20:25 UTC (permalink / raw)
  To: Paul Brook; +Cc: Andrew Haley, gcc

Paul Brook wrote:
> We already have TYPE_STRING_FLAG used on array types. Maybe it would it make 
> sense to use that?

That sounds like an excellent choice.  dbxout.c and dwarf2out.c already 
check TYPE_STRING_FLAG to distinguish strings from arrays.
-- 
Jim Wilson, GNU Tools Support, http://www.specifix.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-08-13 20:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-05 10:53 Ada character types : tree code and DW_AT_encoding Jerome Guitton
2005-08-11  1:57 ` James E Wilson
2005-08-11  2:13   ` Tom Tromey
2005-08-11 10:23     ` Andrew Haley
2005-08-11 19:48       ` James E Wilson
2005-08-12 18:04         ` Tom Tromey
2005-08-13 15:01         ` Paul Brook
2005-08-13 20:25           ` James E Wilson
2005-08-11  9:05   ` Jerome Guitton

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).