aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2009-03-24 01:51:48 +0000
committerJoel Brobecker <brobecker@gnat.com>2009-03-24 01:51:48 +0000
commit872c8b510d28a23a3a49157fcb7323fd8052b8c1 (patch)
tree45926667709fe25bd6ef7d7059ea491b305620cb /gdb/ada-lang.c
parentdcb626be9b9ad95a4a7f545779664bd09ae4889d (diff)
downloadgdb-872c8b510d28a23a3a49157fcb7323fd8052b8c1.zip
gdb-872c8b510d28a23a3a49157fcb7323fd8052b8c1.tar.gz
gdb-872c8b510d28a23a3a49157fcb7323fd8052b8c1.tar.bz2
* ada-lang.c (ada_get_field_index): Add handling of the case
when TYPE is a typedef of a struct.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 0800454..b4e1eb9 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -411,25 +411,28 @@ field_name_match (const char *field_name, const char *target)
}
-/* Assuming TYPE is a TYPE_CODE_STRUCT, find the field whose name matches
- FIELD_NAME, and return its index. This function also handles fields
- whose name have ___ suffixes because the compiler sometimes alters
- their name by adding such a suffix to represent fields with certain
- constraints. If the field could not be found, return a negative
- number if MAYBE_MISSING is set. Otherwise raise an error. */
+/* Assuming TYPE is a TYPE_CODE_STRUCT or a TYPE_CODE_TYPDEF to
+ a TYPE_CODE_STRUCT, find the field whose name matches FIELD_NAME,
+ and return its index. This function also handles fields whose name
+ have ___ suffixes because the compiler sometimes alters their name
+ by adding such a suffix to represent fields with certain constraints.
+ If the field could not be found, return a negative number if
+ MAYBE_MISSING is set. Otherwise raise an error. */
int
ada_get_field_index (const struct type *type, const char *field_name,
int maybe_missing)
{
int fieldno;
- for (fieldno = 0; fieldno < TYPE_NFIELDS (type); fieldno++)
- if (field_name_match (TYPE_FIELD_NAME (type, fieldno), field_name))
+ struct type *struct_type = check_typedef ((struct type *) type);
+
+ for (fieldno = 0; fieldno < TYPE_NFIELDS (struct_type); fieldno++)
+ if (field_name_match (TYPE_FIELD_NAME (struct_type, fieldno), field_name))
return fieldno;
if (!maybe_missing)
error (_("Unable to find field %s in struct %s. Aborting"),
- field_name, TYPE_NAME (type));
+ field_name, TYPE_NAME (struct_type));
return -1;
}