This is the mail archive of the dwarf2@corp.sgi.com mailing list for the dwarf2 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PROPOSAL: Add DW_ATE_wchar_t base type for C++


There is a bit of confusion here between base types and encodings.  The DW_ATE_*
attributes represent encodings, not base types.  

As the comment quoted from section 5.1 says, each language has a number of
base types.  These are defined using the attributes described in section 5.1.
See the comment at the bottom of page 37 which describes how to define "int".
"wchar_t" is one of these base types, not an encoding.

Whether on not C or C++ considers it fundamental or a keyword, in Dwarf 2 it is 
not.  It is a distinct integer type, just as "long int" is a distinct type from 
"short int" or "int".  All are represented in Dwarf 2 as a base type which has a 
DW_ATE_signed_integer attribute.

Note that Dwarf 2 does not define the encoding used by DW_ATE_(un)signed_char.
I think that a good case can be made for describing "wchar_t" in Dwarf 2 as
a DW_ATE_(un)signed_char with a size of 2 or 4.  In this case, like the 
definition of "signed char", the exact encoding used is not defined, but the
debugger is expected to be able to interpret it correctly.

If you want to describe encodings for characters, then appropriate encodings
would be DW_ATE_ascii, DW_ATE_ebcdic, DW_ATE_iso_whatever).  

Ron 603-884-2088 wrote:
> 
> Proposal:  Add DW_ATE_wchar_t per ISO C++
> 
> Current Specification
> ---------------------
> 
> Not mentioned or addressed.
> 
> Proposed Modifications to the Document
> --------------------------------------
> 
> Page 37, Sec 5.1 Base Type Entries
> 
> Add in Figure 10:
> 
>     DW_ATE_wchar_t      C++ wide character type
> 
> Immediately following Figure 10, add italicized text as in:
> 
>     <i>The DW_ATE_wchar_t base type is included specifically
>     for C++ which defines type wchar_t as a "distinct" and "fundamental"
>     type (unlike C and C99 where wchar_t is "an integer type" defined in
>     stddef.h, presumably by a typedef).</i>
> 
> Page 75, Figure 24
> 
> Add
>     DW_ATE_wchar_t      0x0a
> 
> Discussion
> ----------
> 
> The introduction to DWARF V2 section 5.1 is
> 
>    <i>A base type is a data tyupe that is not defined in terms of other
>    data types. Each programming language has a set of base types that are
>    considered to be built into that language.</i>
> 
> wchar_t is such a type for C++ (but not for C). So much so that it is
> even a keyword (just like int) in C++, (but not for C).
> 
> --------------------------------------------------------------------------------
> >From ISO/IEC FDIS 14882:1998
> 
> 2.11 - Keywords
> ...
> -1- The identifiers shown in Table ?? are reserved for use as keywords...
> ...
> [In the table is listed wchar_t...]
> 
> 3.9.1 - Fundamental types
> ...
> -5- Type wchar_t is a distinct type whose values can represent distinct codes
> for all members of the largest extended character set specified among the
> supported locales (lib.locale). Type wchar_t shall have the same size,
> signedness, and alignment requirements (basic.types) as one of the other
> integral types, called its underlying type.
> ...
> -7- Types bool, char, wchar_t, and the signed and unsigned integer types are
> collectively called integral types.*
> ...
> 
> 4.2 - Array-to-pointer conversion [conv.array]
> ...
> -2- A string literal (lex.string) that is not a wide string literal can be
> converted to an rvalue of type ``pointer to char''; a wide string literal can
> be converted to an rvalue of type ``pointer to wchar_t''. In either case, the
> result is a pointer to the first element of the array...
> ...
> 
> 4.5 - Integral promotions [conv.prom]
> ...
> -2- An rvalue of type wchar_t (basic.fundamental) or an enumeration type
> (dcl.enum) can be converted to an rvalue of the first of the following types
> that can represent all the values of its underlying type: int, unsigned int,
> long, or unsigned long.
> ...
> 
> 5.3.3 - Sizeof [expr.sizeof]
> ...
> ...[Note: in particular, sizeof(bool) and sizeof(wchar_t) are implementation-
> defined.]...
> ...


-- 
Michael Eager	 Eager Consulting     eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]