* [RFA] Add type support for Ada
@ 2002-09-25 20:00 Aidan Skinner
2002-09-26 19:24 ` Andrew Cagney
0 siblings, 1 reply; 7+ messages in thread
From: Aidan Skinner @ 2002-09-25 20:00 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 5552 bytes --]
This patch adds some stuff to gdbtypes.h, parse.c, parser-defs.h and
valarith.c to support the ada-* files, and provide the infrastructure
needed for some of the more intrusive changes that are needed.
ChangeLog:
* gdbtypes.h (TYPE_FLAG_FIXED_INSTANCE, TYPE_FIXED_INSTANCE) New
definitions.
(base_type): Declare.
* parser-defs.h (add_name_string_cleanup): Declare.
* parse.c (name_list): New type.
(temp_name_list): New variable.
(add_name_string_cleanup): New function.
* valarith.c (base_type): New function.
Patch:
Index: gdbtypes.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.h,v
retrieving revision 1.36
diff -u -r1.36 gdbtypes.h
--- gdbtypes.h 14 Sep 2002 02:09:39 -0000 1.36
+++ gdbtypes.h 26 Sep 2002 02:35:55 -0000
@@ -197,7 +197,6 @@
#define TYPE_FLAG_VOLATILE (1 << 6)
#define TYPE_VOLATILE(t) (TYPE_INSTANCE_FLAGS (t) & TYPE_FLAG_VOLATILE)
-
/* This is a function type which appears to have a prototype. We need this
for function calls in order to tell us if it's necessary to coerce the args,
or to just do the standard conversions. This is used with a short field. */
@@ -253,6 +252,13 @@
#define TYPE_FLAG_VECTOR (1 << 12)
#define TYPE_VECTOR(t) (TYPE_FLAGS (t) & TYPE_FLAG_VECTOR)
+/* Marks a type that has been created from a template for a
+ dynamically sized type (e.g., GNAT arrays whose bounds are runtime
+ quantities). Optionally marks an ordinary, fixed-size GDB type. */
+
+#define TYPE_FLAG_FIXED_INSTANCE (1 << 13)
+#define TYPE_FIXED_INSTANCE(t) (TYPE_FLAGS (t) & TYPE_FLAG_FIXED_INSTANCE)
+
struct main_type
{
/* Code for kind of type */
@@ -335,6 +341,9 @@
For a function or method type, describes the type of the return value.
For a range type, describes the type of the full range.
For a complex type, describes the type of each coordinate.
+ For a special record or union type encoding a dynamic-sized type
+ in GNAT, a memoized pointer to a corresponding static version of
+ the type.
Unused otherwise. */
struct type *target_type;
@@ -394,7 +403,10 @@
says how many bytes the field occupies.
A value of -1 or -2 indicates a static field; -1 means the location
is specified by the label loc.physname; -2 means that loc.physaddr
- specifies the actual address. */
+ specifies the actual address.
+ If non-zero in an array type, indicates the element size in
+ bits (used only in Ada at the moment).
+ */
int bitsize;
@@ -1249,5 +1261,8 @@
extern int is_integral_type (struct type *);
extern void maintenance_print_type (char *, int);
+/* valarith.c */
+
+extern struct type* base_type (struct type*);
#endif /* GDBTYPES_H */
Index: parse.c
===================================================================
RCS file: /cvs/src/src/gdb/parse.c,v
retrieving revision 1.28
diff -u -r1.28 parse.c
--- parse.c 25 Sep 2002 20:30:37 -0000 1.28
+++ parse.c 26 Sep 2002 02:35:58 -0000
@@ -105,6 +105,15 @@
static struct funcall *funcall_chain;
+/* List of strings. */
+
+struct name_list {
+ struct name_list* next;
+ char* name;
+};
+
+static struct name_list *temp_name_list;
+
/* Begin counting arguments for a function call,
saving the data about any containing call. */
@@ -396,6 +405,20 @@
write_exp_elt_opcode (UNOP_MEMVAL);
}
\f
+
+/* Add S to the list of strings that will eventually have to be
+ released after parsing and must also be released on error. */
+void
+add_name_string_cleanup (char *s)
+{
+ struct name_list* elt =
+ (struct name_list*) xmalloc (sizeof (struct name_list));
+
+ elt -> name = s;
+ elt -> next = temp_name_list;
+ temp_name_list = elt;
+}
+
/* Recognize tokens that start with '$'. These include:
$regname A native register name or a "standard
Index: parser-defs.h
===================================================================
RCS file: /cvs/src/src/gdb/parser-defs.h,v
retrieving revision 1.14
diff -u -r1.14 parser-defs.h
--- parser-defs.h 25 Sep 2002 20:30:37 -0000 1.14
+++ parser-defs.h 26 Sep 2002 02:35:58 -0000
@@ -101,6 +101,8 @@
extern union type_stack_elt *type_stack;
extern int type_stack_depth, type_stack_size;
+extern void add_name_string_cleanup (char*);
+
extern void write_exp_elt (union exp_element);
extern void write_exp_elt_opcode (enum exp_opcode);
Index: valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.16
diff -u -r1.16 valarith.c
--- valarith.c 1 Aug 2002 17:18:33 -0000 1.16
+++ valarith.c 26 Sep 2002 02:36:00 -0000
@@ -1162,6 +1162,22 @@
return val;
}
\f
+/* The identity on non-range types. For range types, the underlying */
+/* non-range scalar type. */
+
+struct type*
+base_type (struct type* type)
+{
+ while (type != NULL && TYPE_CODE (type) == TYPE_CODE_RANGE)
+ {
+ if (type == TYPE_TARGET_TYPE (type)
+ || TYPE_TARGET_TYPE (type) == NULL)
+ return type;
+ type = TYPE_TARGET_TYPE (type);
+ }
+ return type;
+}
+
/* Simulate the C operator ! -- return 1 if ARG1 contains zero. */
int
- Aidan
--
aidan@velvet.net http://www.velvet.net/~aidan/ aim:aidans42
http://www.livejournal.com/users/aidan_skinner/
finger for pgp key: 01AA 1594 2DB0 09E3 B850 C2D0 9A2C 4CC9 3EC4 75E1
[-- Attachment #2: Type: application/pgp-signature, Size: 230 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFA] Add type support for Ada
2002-09-25 20:00 [RFA] Add type support for Ada Aidan Skinner
@ 2002-09-26 19:24 ` Andrew Cagney
2002-09-27 13:08 ` Jim Blandy
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Cagney @ 2002-09-26 19:24 UTC (permalink / raw)
To: Aidan Skinner, Daniel Jacobowitz, Per Bothner, Anthony Green,
Pierre Muller, Jim blandy
Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 137 bytes --]
To do a blatant side step, I think this should be reviewed by a
language maintainer. (I know sufficient Ada to be dangerous).
Andrew
[-- Attachment #2: mailbox-message://ac131313@movemail/fsf/gdb/patches#12870314 --]
[-- Type: message/rfc822, Size: 9039 bytes --]
[-- Attachment #2.1.1: Type: text/plain, Size: 5552 bytes --]
This patch adds some stuff to gdbtypes.h, parse.c, parser-defs.h and
valarith.c to support the ada-* files, and provide the infrastructure
needed for some of the more intrusive changes that are needed.
ChangeLog:
* gdbtypes.h (TYPE_FLAG_FIXED_INSTANCE, TYPE_FIXED_INSTANCE) New
definitions.
(base_type): Declare.
* parser-defs.h (add_name_string_cleanup): Declare.
* parse.c (name_list): New type.
(temp_name_list): New variable.
(add_name_string_cleanup): New function.
* valarith.c (base_type): New function.
Patch:
Index: gdbtypes.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.h,v
retrieving revision 1.36
diff -u -r1.36 gdbtypes.h
--- gdbtypes.h 14 Sep 2002 02:09:39 -0000 1.36
+++ gdbtypes.h 26 Sep 2002 02:35:55 -0000
@@ -197,7 +197,6 @@
#define TYPE_FLAG_VOLATILE (1 << 6)
#define TYPE_VOLATILE(t) (TYPE_INSTANCE_FLAGS (t) & TYPE_FLAG_VOLATILE)
-
/* This is a function type which appears to have a prototype. We need this
for function calls in order to tell us if it's necessary to coerce the args,
or to just do the standard conversions. This is used with a short field. */
@@ -253,6 +252,13 @@
#define TYPE_FLAG_VECTOR (1 << 12)
#define TYPE_VECTOR(t) (TYPE_FLAGS (t) & TYPE_FLAG_VECTOR)
+/* Marks a type that has been created from a template for a
+ dynamically sized type (e.g., GNAT arrays whose bounds are runtime
+ quantities). Optionally marks an ordinary, fixed-size GDB type. */
+
+#define TYPE_FLAG_FIXED_INSTANCE (1 << 13)
+#define TYPE_FIXED_INSTANCE(t) (TYPE_FLAGS (t) & TYPE_FLAG_FIXED_INSTANCE)
+
struct main_type
{
/* Code for kind of type */
@@ -335,6 +341,9 @@
For a function or method type, describes the type of the return value.
For a range type, describes the type of the full range.
For a complex type, describes the type of each coordinate.
+ For a special record or union type encoding a dynamic-sized type
+ in GNAT, a memoized pointer to a corresponding static version of
+ the type.
Unused otherwise. */
struct type *target_type;
@@ -394,7 +403,10 @@
says how many bytes the field occupies.
A value of -1 or -2 indicates a static field; -1 means the location
is specified by the label loc.physname; -2 means that loc.physaddr
- specifies the actual address. */
+ specifies the actual address.
+ If non-zero in an array type, indicates the element size in
+ bits (used only in Ada at the moment).
+ */
int bitsize;
@@ -1249,5 +1261,8 @@
extern int is_integral_type (struct type *);
extern void maintenance_print_type (char *, int);
+/* valarith.c */
+
+extern struct type* base_type (struct type*);
#endif /* GDBTYPES_H */
Index: parse.c
===================================================================
RCS file: /cvs/src/src/gdb/parse.c,v
retrieving revision 1.28
diff -u -r1.28 parse.c
--- parse.c 25 Sep 2002 20:30:37 -0000 1.28
+++ parse.c 26 Sep 2002 02:35:58 -0000
@@ -105,6 +105,15 @@
static struct funcall *funcall_chain;
+/* List of strings. */
+
+struct name_list {
+ struct name_list* next;
+ char* name;
+};
+
+static struct name_list *temp_name_list;
+
/* Begin counting arguments for a function call,
saving the data about any containing call. */
@@ -396,6 +405,20 @@
write_exp_elt_opcode (UNOP_MEMVAL);
}
\f
+
+/* Add S to the list of strings that will eventually have to be
+ released after parsing and must also be released on error. */
+void
+add_name_string_cleanup (char *s)
+{
+ struct name_list* elt =
+ (struct name_list*) xmalloc (sizeof (struct name_list));
+
+ elt -> name = s;
+ elt -> next = temp_name_list;
+ temp_name_list = elt;
+}
+
/* Recognize tokens that start with '$'. These include:
$regname A native register name or a "standard
Index: parser-defs.h
===================================================================
RCS file: /cvs/src/src/gdb/parser-defs.h,v
retrieving revision 1.14
diff -u -r1.14 parser-defs.h
--- parser-defs.h 25 Sep 2002 20:30:37 -0000 1.14
+++ parser-defs.h 26 Sep 2002 02:35:58 -0000
@@ -101,6 +101,8 @@
extern union type_stack_elt *type_stack;
extern int type_stack_depth, type_stack_size;
+extern void add_name_string_cleanup (char*);
+
extern void write_exp_elt (union exp_element);
extern void write_exp_elt_opcode (enum exp_opcode);
Index: valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.16
diff -u -r1.16 valarith.c
--- valarith.c 1 Aug 2002 17:18:33 -0000 1.16
+++ valarith.c 26 Sep 2002 02:36:00 -0000
@@ -1162,6 +1162,22 @@
return val;
}
\f
+/* The identity on non-range types. For range types, the underlying */
+/* non-range scalar type. */
+
+struct type*
+base_type (struct type* type)
+{
+ while (type != NULL && TYPE_CODE (type) == TYPE_CODE_RANGE)
+ {
+ if (type == TYPE_TARGET_TYPE (type)
+ || TYPE_TARGET_TYPE (type) == NULL)
+ return type;
+ type = TYPE_TARGET_TYPE (type);
+ }
+ return type;
+}
+
/* Simulate the C operator ! -- return 1 if ARG1 contains zero. */
int
- Aidan
--
aidan@velvet.net http://www.velvet.net/~aidan/ aim:aidans42
http://www.livejournal.com/users/aidan_skinner/
finger for pgp key: 01AA 1594 2DB0 09E3 B850 C2D0 9A2C 4CC9 3EC4 75E1
[-- Attachment #2.1.2: Type: application/pgp-signature, Size: 230 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFA] Add type support for Ada
2002-09-26 19:24 ` Andrew Cagney
@ 2002-09-27 13:08 ` Jim Blandy
2002-09-28 2:24 ` Paul N. Hilfinger
0 siblings, 1 reply; 7+ messages in thread
From: Jim Blandy @ 2002-09-27 13:08 UTC (permalink / raw)
To: Andrew Cagney
Cc: Aidan Skinner, Daniel Jacobowitz, Per Bothner, Anthony Green,
Pierre Muller, gdb-patches
Andrew Cagney <ac131313@redhat.com> writes:
> To do a blatant side step, I think this should be reviewed by a
> language maintainer. (I know sufficient Ada to be dangerous).
I can take a shot...
It looks to me as if the string cleanup stuff is distinct from the
fixed instance stuff. These should be submitted as separate patches.
Is a `fixed instance' a feature of the language's type system itself?
That is, is it something that an Ada programmer actually knows about?
Or is it something used internally within GDB, or internally by some
implementations of Ada?
Should base_type use the tortoise-and-hare algorithm to detect cycles?
When it detects a direct cycle, should it really just return the type,
or should that be an internal error? When the base type of a range
type is null, should that be an internal error?
>
> Andrew
> From: Aidan Skinner <aidan@velvet.net>
> Subject: [RFA] Add type support for Ada
> To: gdb-patches@sources.redhat.com
> Date: Thu, 26 Sep 2002 04:00:44 +0100
>
> This patch adds some stuff to gdbtypes.h, parse.c, parser-defs.h and
> valarith.c to support the ada-* files, and provide the infrastructure
> needed for some of the more intrusive changes that are needed.
>
> ChangeLog:
>
> * gdbtypes.h (TYPE_FLAG_FIXED_INSTANCE, TYPE_FIXED_INSTANCE) New
> definitions.
> (base_type): Declare.
> * parser-defs.h (add_name_string_cleanup): Declare.
> * parse.c (name_list): New type.
> (temp_name_list): New variable.
> (add_name_string_cleanup): New function.
> * valarith.c (base_type): New function.
>
> Patch:
>
> Index: gdbtypes.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbtypes.h,v
> retrieving revision 1.36
> diff -u -r1.36 gdbtypes.h
> --- gdbtypes.h 14 Sep 2002 02:09:39 -0000 1.36
> +++ gdbtypes.h 26 Sep 2002 02:35:55 -0000
> @@ -197,7 +197,6 @@
> #define TYPE_FLAG_VOLATILE (1 << 6)
> #define TYPE_VOLATILE(t) (TYPE_INSTANCE_FLAGS (t) & TYPE_FLAG_VOLATILE)
>
> -
> /* This is a function type which appears to have a prototype. We need this
> for function calls in order to tell us if it's necessary to coerce the args,
> or to just do the standard conversions. This is used with a short field. */
> @@ -253,6 +252,13 @@
> #define TYPE_FLAG_VECTOR (1 << 12)
> #define TYPE_VECTOR(t) (TYPE_FLAGS (t) & TYPE_FLAG_VECTOR)
>
> +/* Marks a type that has been created from a template for a
> + dynamically sized type (e.g., GNAT arrays whose bounds are runtime
> + quantities). Optionally marks an ordinary, fixed-size GDB type. */
> +
> +#define TYPE_FLAG_FIXED_INSTANCE (1 << 13)
> +#define TYPE_FIXED_INSTANCE(t) (TYPE_FLAGS (t) & TYPE_FLAG_FIXED_INSTANCE)
> +
> struct main_type
> {
> /* Code for kind of type */
> @@ -335,6 +341,9 @@
> For a function or method type, describes the type of the return value.
> For a range type, describes the type of the full range.
> For a complex type, describes the type of each coordinate.
> + For a special record or union type encoding a dynamic-sized type
> + in GNAT, a memoized pointer to a corresponding static version of
> + the type.
> Unused otherwise. */
>
> struct type *target_type;
> @@ -394,7 +403,10 @@
> says how many bytes the field occupies.
> A value of -1 or -2 indicates a static field; -1 means the location
> is specified by the label loc.physname; -2 means that loc.physaddr
> - specifies the actual address. */
> + specifies the actual address.
> + If non-zero in an array type, indicates the element size in
> + bits (used only in Ada at the moment).
> + */
>
> int bitsize;
>
> @@ -1249,5 +1261,8 @@
> extern int is_integral_type (struct type *);
>
> extern void maintenance_print_type (char *, int);
> +/* valarith.c */
> +
> +extern struct type* base_type (struct type*);
>
> #endif /* GDBTYPES_H */
> Index: parse.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/parse.c,v
> retrieving revision 1.28
> diff -u -r1.28 parse.c
> --- parse.c 25 Sep 2002 20:30:37 -0000 1.28
> +++ parse.c 26 Sep 2002 02:35:58 -0000
> @@ -105,6 +105,15 @@
>
> static struct funcall *funcall_chain;
>
> +/* List of strings. */
> +
> +struct name_list {
> + struct name_list* next;
> + char* name;
> +};
> +
> +static struct name_list *temp_name_list;
> +
> /* Begin counting arguments for a function call,
> saving the data about any containing call. */
>
> @@ -396,6 +405,20 @@
> write_exp_elt_opcode (UNOP_MEMVAL);
> }
> \f
> +
> +/* Add S to the list of strings that will eventually have to be
> + released after parsing and must also be released on error. */
> +void
> +add_name_string_cleanup (char *s)
> +{
> + struct name_list* elt =
> + (struct name_list*) xmalloc (sizeof (struct name_list));
> +
> + elt -> name = s;
> + elt -> next = temp_name_list;
> + temp_name_list = elt;
> +}
> +
> /* Recognize tokens that start with '$'. These include:
>
> $regname A native register name or a "standard
> Index: parser-defs.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/parser-defs.h,v
> retrieving revision 1.14
> diff -u -r1.14 parser-defs.h
> --- parser-defs.h 25 Sep 2002 20:30:37 -0000 1.14
> +++ parser-defs.h 26 Sep 2002 02:35:58 -0000
> @@ -101,6 +101,8 @@
> extern union type_stack_elt *type_stack;
> extern int type_stack_depth, type_stack_size;
>
> +extern void add_name_string_cleanup (char*);
> +
> extern void write_exp_elt (union exp_element);
>
> extern void write_exp_elt_opcode (enum exp_opcode);
> Index: valarith.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/valarith.c,v
> retrieving revision 1.16
> diff -u -r1.16 valarith.c
> --- valarith.c 1 Aug 2002 17:18:33 -0000 1.16
> +++ valarith.c 26 Sep 2002 02:36:00 -0000
> @@ -1162,6 +1162,22 @@
> return val;
> }
> \f
> +/* The identity on non-range types. For range types, the underlying */
> +/* non-range scalar type. */
> +
> +struct type*
> +base_type (struct type* type)
> +{
> + while (type != NULL && TYPE_CODE (type) == TYPE_CODE_RANGE)
> + {
> + if (type == TYPE_TARGET_TYPE (type)
> + || TYPE_TARGET_TYPE (type) == NULL)
> + return type;
> + type = TYPE_TARGET_TYPE (type);
> + }
> + return type;
> +}
> +
> /* Simulate the C operator ! -- return 1 if ARG1 contains zero. */
>
> int
>
> - Aidan
>
> --
> aidan@velvet.net http://www.velvet.net/~aidan/ aim:aidans42
> http://www.livejournal.com/users/aidan_skinner/
> finger for pgp key: 01AA 1594 2DB0 09E3 B850 C2D0 9A2C 4CC9 3EC4 75E1
> ----------
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFA] Add type support for Ada
2002-09-27 13:08 ` Jim Blandy
@ 2002-09-28 2:24 ` Paul N. Hilfinger
2002-09-30 20:17 ` Aidan Skinner
2002-10-02 11:57 ` Jim Blandy
0 siblings, 2 replies; 7+ messages in thread
From: Paul N. Hilfinger @ 2002-09-28 2:24 UTC (permalink / raw)
To: jimb; +Cc: ac131313, aidan, drow, per, green, muller, gdb-patches
> It looks to me as if the string cleanup stuff is distinct from the
> fixed instance stuff. These should be submitted as separate patches.
They definitely are logically separate changes.
> Is a `fixed instance' a feature of the language's type system itself?
> That is, is it something that an Ada programmer actually knows about?
> Or is it something used internally within GDB, or internally by some
> implementations of Ada?
It is not a language feature, but rather an optimization. The original
problem was that STABS and also GDB's internal type representation
was not adequate for representing "dynamic" Ada types---i.e., those that,
unlike C types, have data-dependent sizes. The scheme we hit on (in
retrospect perhaps not the best) was to encode a bunch of auxiliary
information into our type names, and to introduce additional types
carrying additional (encoded) information.
When Ada evaluation routines discover that a quantity has an encoded
type, they know to compute a conventional, fixed-sized GDB type based on the
data, and to attach this type to the value they are producing.
Unfortunately, the computations involved are expensive---involving type
lookups in some cases---and we don't want to repeat them unnecessarily.
Hence the flag.
> Should base_type use the tortoise-and-hare algorithm to detect cycles?
An interesting suggestion. However, there is at least one existing
place where GDB doesn't bother. Compare with the following (non-Ada-
related) code from evaluate_subexp_standard in eval.c:
/* get targettype of elementtype */
while (TYPE_CODE (check_type) == TYPE_CODE_RANGE ||
TYPE_CODE (check_type) == TYPE_CODE_TYPEDEF)
check_type = TYPE_TARGET_TYPE (check_type);
> When it detects a direct cycle, should it really just return the type,
> or should that be an internal error? When the base type of a range
> type is null, should that be an internal error?
Umm. Interesting questions. As I recall, I had the impression that
a self-referencing range type COULD occur legitimately, but given that was
4 years ago, my memory could be faulty. I suspect these tests were simply
bullet-(or segfault)-proofing. Replacing the NULL check at least with
an error would probably be a worthy experiment.
Paul
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFA] Add type support for Ada
2002-09-28 2:24 ` Paul N. Hilfinger
@ 2002-09-30 20:17 ` Aidan Skinner
2002-10-02 11:59 ` Jim Blandy
2002-10-02 11:57 ` Jim Blandy
1 sibling, 1 reply; 7+ messages in thread
From: Aidan Skinner @ 2002-09-30 20:17 UTC (permalink / raw)
To: Hilfinger; +Cc: jimb, ac131313, aidan, drow, per, green, muller, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1631 bytes --]
On Sat, Sep 28, 2002 at 02:25:59AM -0700, Paul N. Hilfinger wrote
Thanks for answering these Paul. :)
> > It looks to me as if the string cleanup stuff is distinct from the
> > fixed instance stuff. These should be submitted as separate patches.
>
> They definitely are logically separate changes.
Yeah, I'll split and resubmit and probably take the opportunity to
include some more string cleanup stuff, rather than just the bits that
ada-* reference...
> > Should base_type use the tortoise-and-hare algorithm to detect cycles?
>
> An interesting suggestion. However, there is at least one existing
> place where GDB doesn't bother. Compare with the following (non-Ada-
I think it's worthwhile doing here, and if it works nicely it can be
stolen for other places. My next revision of this patch will include
this.
> Umm. Interesting questions. As I recall, I had the impression that
> a self-referencing range type COULD occur legitimately, but given that was
I think they can, but my current understanding of the gdb type system
probably bears some resemblence to swiss cheese. ;)
I'll experiment a bit with trying to create one and see what I can find.
> 4 years ago, my memory could be faulty. I suspect these tests were simply
> bullet-(or segfault)-proofing. Replacing the NULL check at least with
> an error would probably be a worthy experiment.
Sounds like a plan.
- Aidan
--
aidan@velvet.net http://www.velvet.net/~aidan/ aim:aidans42
http://www.livejournal.com/users/aidan_skinner/
finger for pgp key: 01AA 1594 2DB0 09E3 B850 C2D0 9A2C 4CC9 3EC4 75E1
[-- Attachment #2: Type: application/pgp-signature, Size: 230 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFA] Add type support for Ada
2002-09-28 2:24 ` Paul N. Hilfinger
2002-09-30 20:17 ` Aidan Skinner
@ 2002-10-02 11:57 ` Jim Blandy
1 sibling, 0 replies; 7+ messages in thread
From: Jim Blandy @ 2002-10-02 11:57 UTC (permalink / raw)
To: Hilfinger; +Cc: ac131313, aidan, drow, per, green, muller, gdb-patches
"Paul N. Hilfinger" <hilfingr@otisco.mckusick.com> writes:
> > It looks to me as if the string cleanup stuff is distinct from the
> > fixed instance stuff. These should be submitted as separate patches.
>
> They definitely are logically separate changes.
>
> > Is a `fixed instance' a feature of the language's type system itself?
> > That is, is it something that an Ada programmer actually knows about?
> > Or is it something used internally within GDB, or internally by some
> > implementations of Ada?
>
> It is not a language feature, but rather an optimization. The original
> problem was that STABS and also GDB's internal type representation
> was not adequate for representing "dynamic" Ada types---i.e., those that,
> unlike C types, have data-dependent sizes. The scheme we hit on (in
> retrospect perhaps not the best) was to encode a bunch of auxiliary
> information into our type names, and to introduce additional types
> carrying additional (encoded) information.
>
> When Ada evaluation routines discover that a quantity has an encoded
> type, they know to compute a conventional, fixed-sized GDB type based on the
> data, and to attach this type to the value they are producing.
>
> Unfortunately, the computations involved are expensive---involving type
> lookups in some cases---and we don't want to repeat them unnecessarily.
> Hence the flag.
Thanks for the explanation. Since this isn't a language feature, but
an implementation detail, the patch needs to add comments that explain
it in full detail. Something like the above, but with the exact Ada
terminology stuck in at the right places, would be a start.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFA] Add type support for Ada
2002-09-30 20:17 ` Aidan Skinner
@ 2002-10-02 11:59 ` Jim Blandy
0 siblings, 0 replies; 7+ messages in thread
From: Jim Blandy @ 2002-10-02 11:59 UTC (permalink / raw)
To: Aidan Skinner; +Cc: Hilfinger, ac131313, drow, per, green, muller, gdb-patches
Aidan Skinner <aidan@velvet.net> writes:
> Thanks for answering these Paul. :)
>
> > > It looks to me as if the string cleanup stuff is distinct from the
> > > fixed instance stuff. These should be submitted as separate patches.
> >
> > They definitely are logically separate changes.
>
> Yeah, I'll split and resubmit and probably take the opportunity to
> include some more string cleanup stuff, rather than just the bits that
> ada-* reference...
Thanks!
> > > Should base_type use the tortoise-and-hare algorithm to detect cycles?
> >
> > An interesting suggestion. However, there is at least one existing
> > place where GDB doesn't bother. Compare with the following (non-Ada-
>
> I think it's worthwhile doing here, and if it works nicely it can be
> stolen for other places. My next revision of this patch will include
> this.
Great.
> > Umm. Interesting questions. As I recall, I had the impression that
> > a self-referencing range type COULD occur legitimately, but given that was
>
> I think they can, but my current understanding of the gdb type system
> probably bears some resemblence to swiss cheese. ;)
>
> I'll experiment a bit with trying to create one and see what I can find.
>
> > 4 years ago, my memory could be faulty. I suspect these tests were simply
> > bullet-(or segfault)-proofing. Replacing the NULL check at least with
> > an error would probably be a worthy experiment.
>
> Sounds like a plan.
Super. I can't tell whether this was the intention in that code, but
I'd much rather see GDB throw an internal error when it finds
something bogus than return some handy plausible value.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-10-02 18:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-25 20:00 [RFA] Add type support for Ada Aidan Skinner
2002-09-26 19:24 ` Andrew Cagney
2002-09-27 13:08 ` Jim Blandy
2002-09-28 2:24 ` Paul N. Hilfinger
2002-09-30 20:17 ` Aidan Skinner
2002-10-02 11:59 ` Jim Blandy
2002-10-02 11:57 ` Jim Blandy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox