* Re: [commit] Use true boolean types in Ada
@ 2008-08-19 10:41 Paul Hilfinger
2008-08-19 18:42 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Paul Hilfinger @ 2008-08-19 10:41 UTC (permalink / raw)
To: gdb-patches
Updated NEWS entry for my last check-in.
Paul Hilfinger
Index: gdb/NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.284
diff -u -p -r1.284 NEWS
--- gdb/NEWS 12 Aug 2008 15:18:30 -0000 1.284
+++ gdb/NEWS 19 Aug 2008 10:34:47 -0000
@@ -58,6 +58,8 @@ list of section offsets.
conditions handling signals delivered during attach or thread creation
have also been fixed.
+* GDB now supports the use of DWARF boolean types for Ada's type Boolean.
+
* New features in the GDB remote stub, gdbserver
- The "--wrapper" command-line argument tells gdbserver to use a
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [commit] Use true boolean types in Ada
2008-08-19 10:41 [commit] Use true boolean types in Ada Paul Hilfinger
@ 2008-08-19 18:42 ` Eli Zaretskii
0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2008-08-19 18:42 UTC (permalink / raw)
To: Hilfinger; +Cc: gdb-patches
> From: Paul Hilfinger <Hilfinger@adacore.com>
> Date: Tue, 19 Aug 2008 06:40:34 -0400 (EDT)
>
>
> Updated NEWS entry for my last check-in.
>
> Paul Hilfinger
>
> Index: gdb/NEWS
> ===================================================================
> RCS file: /cvs/src/src/gdb/NEWS,v
> retrieving revision 1.284
> diff -u -p -r1.284 NEWS
> --- gdb/NEWS 12 Aug 2008 15:18:30 -0000 1.284
> +++ gdb/NEWS 19 Aug 2008 10:34:47 -0000
> @@ -58,6 +58,8 @@ list of section offsets.
> conditions handling signals delivered during attach or thread creation
> have also been fixed.
>
> +* GDB now supports the use of DWARF boolean types for Ada's type Boolean.
> +
Is there any reasonable way of stating the effect of this on
user-level features? If so, I'd prefer to at least mention them, if
not replace the above with them.
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [commit] Use true boolean types in Ada
2008-08-20 15:38 ` Eli Zaretskii
@ 2008-08-21 9:16 ` Paul Hilfinger
0 siblings, 0 replies; 7+ messages in thread
From: Paul Hilfinger @ 2008-08-21 9:16 UTC (permalink / raw)
To: eliz; +Cc: Hilfinger, gdb-patches
Eli Zaretskii <eliz@gnu.org> wrote,
> > > Can you suggest a write-up for the manual nonetheless? I'd like to
> > > see how obscure is "obscure" in this case.
> >
> > > Is there any reasonable way of stating the effect of this on
> > > user-level features? If so, I'd prefer to at least mention them, if
> > > not replace the above with them.
> >
> > Is this more what you have in mind? If so, I'll commit it:
>
> Yes, this sounds good. Please commit.
OK, I have committed the following:
src/gdb/ChangeLog
2008-08-21 Paul N. Hilfinger <hilfingr@syracuse.mckusick.com>
* NEWS: Amplify last entry on boolean types in Ada.
src/gdb/doc/ChangeLog
2008-08-21 Paul N. Hilfinger <hilfingr@syracuse.mckusick.com>
* gdb.texinfo (Omissions from Ada): Describe new treatment of True
and False.
Index: src/gdb/NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.286
diff -u -p -r1.286 NEWS
--- src/gdb/NEWS 20 Aug 2008 04:58:34 -0000 1.286
+++ src/gdb/NEWS 21 Aug 2008 08:57:15 -0000
@@ -59,6 +59,8 @@ conditions handling signals delivered du
have also been fixed.
* GDB now supports the use of DWARF boolean types for Ada's type Boolean.
+From the user's standpoint, all unqualified instances of True and False
+are treated as the standard definitions, regardless of context.
* New features in the GDB remote stub, gdbserver
Index: src/gdb/doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.518
diff -u -p -r1.518 gdb.texinfo
--- src/gdb/doc/gdb.texinfo 20 Aug 2008 04:57:32 -0000 1.518
+++ src/gdb/doc/gdb.texinfo 21 Aug 2008 08:57:30 -0000
@@ -11218,6 +11218,14 @@ formats are not supported.
@item
It is not possible to slice a packed array.
+
+@item
+The names @code{True} and @code{False}, when not part of a qualified name,
+are interpreted as if implicitly prefixed by @code{Standard}, regardless of
+context.
+Should your program
+redefine these names in a package or procedure (at best a dubious practice),
+you will have to use fully qualified names to access their new definitions.
@end itemize
@node Additions to Ada
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [commit] Use true boolean types in Ada
2008-08-20 7:56 ` Paul Hilfinger
@ 2008-08-20 15:38 ` Eli Zaretskii
2008-08-21 9:16 ` Paul Hilfinger
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2008-08-20 15:38 UTC (permalink / raw)
To: Hilfinger; +Cc: gdb-patches
> From: Paul Hilfinger <Hilfinger@adacore.com>
> CC: gdb-patches@sourceware.org
> Date: Wed, 20 Aug 2008 03:55:48 -0400 (EDT)
>
> > Can you suggest a write-up for the manual nonetheless? I'd like to
> > see how obscure is "obscure" in this case.
>
> > Is there any reasonable way of stating the effect of this on
> > user-level features? If so, I'd prefer to at least mention them, if
> > not replace the above with them.
>
> Is this more what you have in mind? If so, I'll commit it:
Yes, this sounds good. Please commit.
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [commit] Use true boolean types in Ada
[not found] <200808200249.m7K2nRJq016841@tully.CS.Berkeley.EDU>
@ 2008-08-20 7:56 ` Paul Hilfinger
2008-08-20 15:38 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Paul Hilfinger @ 2008-08-20 7:56 UTC (permalink / raw)
To: eliz; +Cc: gdb-patches
Eli,
> Can you suggest a write-up for the manual nonetheless? I'd like to
> see how obscure is "obscure" in this case.
> Is there any reasonable way of stating the effect of this on
> user-level features? If so, I'd prefer to at least mention them, if
> not replace the above with them.
Is this more what you have in mind? If so, I'll commit it:
Index: gdb/NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.286
diff -u -p -r1.286 NEWS
--- gdb/NEWS 20 Aug 2008 04:58:34 -0000 1.286
+++ gdb/NEWS 20 Aug 2008 06:47:18 -0000
@@ -59,6 +59,8 @@ conditions handling signals delivered du
have also been fixed.
* GDB now supports the use of DWARF boolean types for Ada's type Boolean.
+From the user's standpoint, all unqualified instances of True and False
+are treated as the standard definitions, regardless of context.
* New features in the GDB remote stub, gdbserver
Index: gdb/doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.518
diff -u -p -r1.518 gdb.texinfo
--- gdb/doc/gdb.texinfo 20 Aug 2008 04:57:32 -0000 1.518
+++ gdb/doc/gdb.texinfo 20 Aug 2008 06:47:31 -0000
@@ -11218,6 +11218,14 @@ formats are not supported.
@item
It is not possible to slice a packed array.
+
+@item
+The names @code{True} and @code{False}, when not part of a qualified name,
+are interpreted as if implicitly prefixed by @code{Standard}, regardless of
+context.
+Should your program
+redefine these names in a package or procedure (at best a dubious practice),
+you will have to use fully qualified names to access their new definitions.
@end itemize
@node Additions to Ada
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [commit] Use true boolean types in Ada
2008-08-19 10:24 Paul Hilfinger
@ 2008-08-19 18:41 ` Eli Zaretskii
0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2008-08-19 18:41 UTC (permalink / raw)
To: Hilfinger; +Cc: gdb-patches
> From: Paul Hilfinger <Hilfinger@adacore.com>
> Date: Tue, 19 Aug 2008 06:23:39 -0400 (EDT)
>
> the user-visible portion of the change is so obscure (having to do with
> cases where one (re)defines True and False in one's program) that I am
> reluctant to add it to the manual.
Can you suggest a write-up for the manual nonetheless? I'd like to
see how obscure is "obscure" in this case.
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [commit] Use true boolean types in Ada
@ 2008-08-19 10:24 Paul Hilfinger
2008-08-19 18:41 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Paul Hilfinger @ 2008-08-19 10:24 UTC (permalink / raw)
To: gdb-patches
I have committed the following patch (posted 8/8, modified according to
suggestions from Bauermann).
Eli, Oops! I had overlooked your message. I'll add something to NEWS, but
the user-visible portion of the change is so obscure (having to do with
cases where one (re)defines True and False in one's program) that I am
reluctant to add it to the manual.
Paul Hilfinger
2008-08-19 Paul N. Hilfinger <hilfinger@adacore.com>
* ada-lang.c (discrete_type_high_bound,discrete_type_low_bound): Change
API to return LONGEST values rather than struct values.
(ada_evaluate_subexp): Change to use new API of discrete_type_low_bound
and discrete_type_high_bound.
(to_fixed_range_type): Create a range type in cases where
argument is base type and its limits are representable as ints.
(ada_is_modular_type): Correct so that base type must be integral.
* ada-lex.l (TRUEKEYWORD,FALSEKEYWORD): Make 'true' and 'false'
keywords when they appear alone, since we are phasing out
direct representation of these identifiers in ebugging data.
* ada-exp.y: Define 'true' and 'false' as primaries.
(type_boolean): New function.
(type_int,type_long,type_long_long,type_floattype_double)
(type_long_double): Remove uses of current_gdbarch for consistency
with type_boolean.
(write_int): Change comment to indicate that it might write boolean
constant as well.
* ada-typeprint.c (ada_print_type): Print '(false, true)' for boolean
type, since will no longer be represented as enumerated type in
debugging data.
* ada-valprint.c (print_optional_low_bound): Handle boolean case
as well.
Index: gdb/ada-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/ada-exp.y,v
retrieving revision 1.28
diff -u -p -r1.28 ada-exp.y
--- gdb/ada-exp.y 27 May 2008 19:29:51 -0000 1.28
+++ gdb/ada-exp.y 19 Aug 2008 10:03:08 -0000
@@ -153,6 +153,8 @@ static struct type *type_long_double (vo
static struct type *type_char (void);
+static struct type *type_boolean (void);
+
static struct type *type_system_address (void);
%}
@@ -180,6 +182,7 @@ static struct type *type_system_address
%token <typed_val> INT NULL_PTR CHARLIT
%token <typed_val_float> FLOAT
+%token TRUEKEYWORD FALSEKEYWORD
%token COLONCOLON
%token <sval> STRING NAME DOT_ID
%type <bval> block
@@ -602,6 +605,12 @@ primary : STRING
}
;
+primary : TRUEKEYWORD
+ { write_int (1, type_boolean ()); }
+ | FALSEKEYWORD
+ { write_int (0, type_boolean ()); }
+ ;
+
primary : NEW NAME
{ error (_("NEW not implemented.")); }
;
@@ -820,7 +829,7 @@ write_var_from_sym (struct block *orig_l
write_exp_elt_opcode (OP_VAR_VALUE);
}
-/* Write integer constant ARG of type TYPE. */
+/* Write integer or boolean constant ARG of type TYPE. */
static void
write_int (LONGEST arg, struct type *type)
@@ -1455,37 +1464,37 @@ convert_char_literal (struct type *type,
static struct type *
type_int (void)
{
- return builtin_type (current_gdbarch)->builtin_int;
+ return builtin_type_int;
}
static struct type *
type_long (void)
{
- return builtin_type (current_gdbarch)->builtin_long;
+ return builtin_type_long;
}
static struct type *
type_long_long (void)
{
- return builtin_type (current_gdbarch)->builtin_long_long;
+ return builtin_type_long_long;
}
static struct type *
type_float (void)
{
- return builtin_type (current_gdbarch)->builtin_float;
+ return builtin_type_float;
}
static struct type *
type_double (void)
{
- return builtin_type (current_gdbarch)->builtin_double;
+ return builtin_type_double;
}
static struct type *
type_long_double (void)
{
- return builtin_type (current_gdbarch)->builtin_long_double;
+ return builtin_type_long_double;
}
static struct type *
@@ -1495,6 +1504,12 @@ type_char (void)
}
static struct type *
+type_boolean (void)
+{
+ return builtin_type_bool;
+}
+
+static struct type *
type_system_address (void)
{
struct type *type
Index: gdb/ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.152
diff -u -p -r1.152 ada-lang.c
--- gdb/ada-lang.c 16 Aug 2008 09:26:25 -0000 1.152
+++ gdb/ada-lang.c 19 Aug 2008 10:03:13 -0000
@@ -621,39 +621,40 @@ min_of_type (struct type *t)
}
/* The largest value in the domain of TYPE, a discrete type, as an integer. */
-static struct value *
+static LONGEST
discrete_type_high_bound (struct type *type)
{
switch (TYPE_CODE (type))
{
case TYPE_CODE_RANGE:
- return value_from_longest (TYPE_TARGET_TYPE (type),
- TYPE_HIGH_BOUND (type));
+ return TYPE_HIGH_BOUND (type);
case TYPE_CODE_ENUM:
- return
- value_from_longest (type,
- TYPE_FIELD_BITPOS (type,
- TYPE_NFIELDS (type) - 1));
+ return TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1);
+ case TYPE_CODE_BOOL:
+ return 1;
+ case TYPE_CODE_CHAR:
case TYPE_CODE_INT:
- return value_from_longest (type, max_of_type (type));
+ return max_of_type (type);
default:
error (_("Unexpected type in discrete_type_high_bound."));
}
}
/* The largest value in the domain of TYPE, a discrete type, as an integer. */
-static struct value *
+static LONGEST
discrete_type_low_bound (struct type *type)
{
switch (TYPE_CODE (type))
{
case TYPE_CODE_RANGE:
- return value_from_longest (TYPE_TARGET_TYPE (type),
- TYPE_LOW_BOUND (type));
+ return TYPE_LOW_BOUND (type);
case TYPE_CODE_ENUM:
- return value_from_longest (type, TYPE_FIELD_BITPOS (type, 0));
+ return TYPE_FIELD_BITPOS (type, 0);
+ case TYPE_CODE_BOOL:
+ return 0;
+ case TYPE_CODE_CHAR:
case TYPE_CODE_INT:
- return value_from_longest (type, min_of_type (type));
+ return min_of_type (type);
default:
error (_("Unexpected type in discrete_type_low_bound."));
}
@@ -8977,9 +8978,11 @@ ada_evaluate_subexp (struct type *expect
default:
error (_("unexpected attribute encountered"));
case OP_ATR_FIRST:
- return discrete_type_low_bound (range_type);
+ return value_from_longest
+ (range_type, discrete_type_low_bound (range_type));
case OP_ATR_LAST:
- return discrete_type_high_bound (range_type);
+ return value_from_longest
+ (range_type, discrete_type_high_bound (range_type));
case OP_ATR_LENGTH:
error (_("the 'length attribute applies only to array types"));
}
@@ -9500,7 +9503,16 @@ to_fixed_range_type (char *name, struct
subtype_info = strstr (name, "___XD");
if (subtype_info == NULL)
- return raw_type;
+ {
+ LONGEST L = discrete_type_low_bound (raw_type);
+ LONGEST U = discrete_type_high_bound (raw_type);
+ if (L < INT_MIN || U > INT_MAX)
+ return raw_type;
+ else
+ return create_range_type (alloc_type (objfile), raw_type,
+ discrete_type_low_bound (raw_type),
+ discrete_type_high_bound (raw_type));
+ }
else
{
static char *name_buf = NULL;
@@ -9587,7 +9599,7 @@ ada_is_modular_type (struct type *type)
struct type *subranged_type = base_type (type);
return (subranged_type != NULL && TYPE_CODE (type) == TYPE_CODE_RANGE
- && TYPE_CODE (subranged_type) != TYPE_CODE_ENUM
+ && TYPE_CODE (subranged_type) == TYPE_CODE_INT
&& TYPE_UNSIGNED (subranged_type));
}
Index: gdb/ada-lex.l
===================================================================
RCS file: /cvs/src/src/gdb/ada-lex.l,v
retrieving revision 1.21
diff -u -p -r1.21 ada-lex.l
--- gdb/ada-lex.l 9 Jan 2008 19:27:15 -0000 1.21
+++ gdb/ada-lex.l 19 Aug 2008 10:03:13 -0000
@@ -178,6 +178,16 @@ rem { return REM; }
then { return THEN; }
xor { return XOR; }
+ /* BOOLEAN "KEYWORDS" */
+
+ /* True and False are not keywords in Ada, but rather enumeration constants.
+ However, the boolean type is no longer represented as an enum, so True
+ and False are no longer defined in symbol tables. We compromise by
+ making them keywords (when bare). */
+
+true { return TRUEKEYWORD; }
+false { return FALSEKEYWORD; }
+
/* ATTRIBUTES */
{TICK}[a-zA-Z][a-zA-Z]+ { return processAttribute (yytext+1); }
Index: gdb/ada-typeprint.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-typeprint.c,v
retrieving revision 1.19
diff -u -p -r1.19 ada-typeprint.c
--- gdb/ada-typeprint.c 4 Jan 2008 20:45:05 -0000 1.19
+++ gdb/ada-typeprint.c 19 Aug 2008 10:03:13 -0000
@@ -813,6 +813,9 @@ ada_print_type (struct type *type0, char
case TYPE_CODE_ARRAY:
print_array_type (type, stream, show, level);
break;
+ case TYPE_CODE_BOOL:
+ fprintf_filtered (stream, "(false, true)");
+ break;
case TYPE_CODE_INT:
if (ada_is_fixed_point_type (type))
print_fixed_point_type (type, stream);
Index: gdb/ada-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-valprint.c,v
retrieving revision 1.37
diff -u -p -r1.37 ada-valprint.c
--- gdb/ada-valprint.c 23 May 2008 18:13:35 -0000 1.37
+++ gdb/ada-valprint.c 19 Aug 2008 10:03:14 -0000
@@ -112,6 +112,10 @@ print_optional_low_bound (struct ui_file
switch (TYPE_CODE (index_type))
{
+ case TYPE_CODE_BOOL:
+ if (low_bound == 0)
+ return 0;
+ break;
case TYPE_CODE_ENUM:
if (low_bound == TYPE_FIELD_BITPOS (index_type, 0))
return 0;
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-08-21 9:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-19 10:41 [commit] Use true boolean types in Ada Paul Hilfinger
2008-08-19 18:42 ` Eli Zaretskii
[not found] <200808200249.m7K2nRJq016841@tully.CS.Berkeley.EDU>
2008-08-20 7:56 ` Paul Hilfinger
2008-08-20 15:38 ` Eli Zaretskii
2008-08-21 9:16 ` Paul Hilfinger
-- strict thread matches above, loose matches on Subject: below --
2008-08-19 10:24 Paul Hilfinger
2008-08-19 18:41 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox