* [rfc] Ada simplification: ada_find_any_type
@ 2009-05-14 11:38 Ulrich Weigand
2009-05-15 15:14 ` Joel Brobecker
0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2009-05-14 11:38 UTC (permalink / raw)
To: gdb-patches, brobecker
Hello,
this is the last of the Ada patches. A recent change introduced a use of
current_gdbarch into ada_find_any_type, which is somewhat hard to eliminate.
However, it seems to me that for all but one callers of ada_find_any_type,
the check for primitive types isn't really necessary, as they are always
passed Ada-specific types that can never be primitive types.
The one exception is to_fixed_range_type, which indeed should check for
primitive types. The following patch therefore moves the check into this
routine. While this still used current_gdbarch, that instance turns out
to be more straightforward to eliminate here than it would have been in
the generic ada_find_any_type routine ...
Joel, would this be OK?
Bye,
Ulrich
ChangeLog:
* ada-lang.c (ada_find_any_type): Move check for primitive types ...
(to_fixed_range_type): ... to here.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -6487,16 +6487,11 @@ struct type *
ada_find_any_type (const char *name)
{
struct symbol *sym = ada_find_any_symbol (name);
- struct type *type = NULL;
if (sym != NULL)
- type = SYMBOL_TYPE (sym);
+ return SYMBOL_TYPE (sym);
- if (type == NULL)
- type = language_lookup_primitive_type_by_name
- (language_def (language_ada), current_gdbarch, name);
-
- return type;
+ return NULL;
}
/* Given NAME and an associated BLOCK, search all symbols for
@@ -9451,6 +9446,11 @@ to_fixed_range_type (char *name, struct
struct type *base_type;
char *subtype_info;
+ /* Also search primitive types if type symbol could not be found. */
+ if (raw_type == NULL)
+ raw_type = language_lookup_primitive_type_by_name
+ (language_def (language_ada), current_gdbarch, name);
+
if (raw_type == NULL)
base_type = builtin_type_int32;
else if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rfc] Ada simplification: ada_find_any_type
2009-05-14 11:38 [rfc] Ada simplification: ada_find_any_type Ulrich Weigand
@ 2009-05-15 15:14 ` Joel Brobecker
2009-05-18 14:01 ` Ulrich Weigand
0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2009-05-15 15:14 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
>
> * ada-lang.c (ada_find_any_type): Move check for primitive types ...
> (to_fixed_range_type): ... to here.
Looks OK as well.
Would you mind extending the description of ada_find_any_type to
say that it does not search the primitive types? Otherwise, I'm afraid
that we might come across a situation one day where we want to search
the primitive types after a call to that function, and add it back
in that function because we weren't paying attention...
Thanks a lot,
--
Joel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rfc] Ada simplification: ada_find_any_type
2009-05-15 15:14 ` Joel Brobecker
@ 2009-05-18 14:01 ` Ulrich Weigand
0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Weigand @ 2009-05-18 14:01 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> >
> > * ada-lang.c (ada_find_any_type): Move check for primitive types ...
> > (to_fixed_range_type): ... to here.
>
> Looks OK as well.
>
> Would you mind extending the description of ada_find_any_type to
> say that it does not search the primitive types? Otherwise, I'm afraid
> that we might come across a situation one day where we want to search
> the primitive types after a call to that function, and add it back
> in that function because we weren't paying attention...
Certainly -- here's what I checked in.
Thanks,
Ulrich
ChangeLog:
* ada-lang.c (ada_find_any_type): Move check for primitive types ...
(to_fixed_range_type): ... to here.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -6481,22 +6481,19 @@ ada_find_any_symbol (const char *name)
return sym;
}
-/* Find a type named NAME. Ignores ambiguity. */
+/* Find a type named NAME. Ignores ambiguity. This routine will look
+ solely for types defined by debug info, it will not search the GDB
+ primitive types. */
struct type *
ada_find_any_type (const char *name)
{
struct symbol *sym = ada_find_any_symbol (name);
- struct type *type = NULL;
if (sym != NULL)
- type = SYMBOL_TYPE (sym);
+ return SYMBOL_TYPE (sym);
- if (type == NULL)
- type = language_lookup_primitive_type_by_name
- (language_def (language_ada), current_gdbarch, name);
-
- return type;
+ return NULL;
}
/* Given NAME and an associated BLOCK, search all symbols for
@@ -9451,6 +9448,11 @@ to_fixed_range_type (char *name, struct
struct type *base_type;
char *subtype_info;
+ /* Also search primitive types if type symbol could not be found. */
+ if (raw_type == NULL)
+ raw_type = language_lookup_primitive_type_by_name
+ (language_def (language_ada), current_gdbarch, name);
+
if (raw_type == NULL)
base_type = builtin_type_int32;
else if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-18 14:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-14 11:38 [rfc] Ada simplification: ada_find_any_type Ulrich Weigand
2009-05-15 15:14 ` Joel Brobecker
2009-05-18 14:01 ` Ulrich Weigand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox