aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2008-10-22 20:11:56 +0000
committerJoel Brobecker <brobecker@gnat.com>2008-10-22 20:11:56 +0000
commit4af8819895fd82c3bfad1163e988f9e9fdc689d6 (patch)
tree00a13e97c123eea52e76fd7e0d9f25060b453dcd
parent20924a554d8569f81a83381e50a5c8057f635870 (diff)
downloadgdb-4af8819895fd82c3bfad1163e988f9e9fdc689d6.zip
gdb-4af8819895fd82c3bfad1163e988f9e9fdc689d6.tar.gz
gdb-4af8819895fd82c3bfad1163e988f9e9fdc689d6.tar.bz2
* gdbtypes.c (copy_type): New function.
* gdbtypes.h (copy_type): Add declaration. * ada-lang.c (ada_to_fixed_type_1): If there is a parallel XVZ variable, then use it.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/ada-lang.c40
-rw-r--r--gdb/gdbtypes.c22
-rw-r--r--gdb/gdbtypes.h2
4 files changed, 71 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5892c33..62d8bb9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2008-10-22 Joel brobecker <brobecker@adacore.com>
+
+ * gdbtypes.c (copy_type): New function.
+ * gdbtypes.h (copy_type): Add declaration.
+ * ada-lang.c (ada_to_fixed_type_1): If there is a parallel XVZ
+ variable, then use it.
+
2008-10-22 Joel Brobecker <brobecker@adacore.com>
* target.h (struct target_ops): Add new field to_get_ada_task_ptid.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 60ceacc..cce7da9 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -7357,6 +7357,46 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr,
if (real_type != NULL)
return to_fixed_record_type (real_type, valaddr, address, NULL);
}
+
+ /* Check to see if there is a parallel ___XVZ variable.
+ If there is, then it provides the actual size of our type. */
+ else if (ada_type_name (fixed_record_type) != NULL)
+ {
+ char *name = ada_type_name (fixed_record_type);
+ char *xvz_name = alloca (strlen (name) + 7 /* "___XVZ\0" */);
+ int xvz_found = 0;
+ LONGEST size;
+
+ sprintf (xvz_name, "%s___XVZ", name);
+ size = get_int_var_value (xvz_name, &xvz_found);
+ if (xvz_found && TYPE_LENGTH (fixed_record_type) != size)
+ {
+ fixed_record_type = copy_type (fixed_record_type);
+ TYPE_LENGTH (fixed_record_type) = size;
+
+ /* The FIXED_RECORD_TYPE may have be a stub. We have
+ observed this when the debugging info is STABS, and
+ apparently it is something that is hard to fix.
+
+ In practice, we don't need the actual type definition
+ at all, because the presence of the XVZ variable allows us
+ to assume that there must be a XVS type as well, which we
+ should be able to use later, when we need the actual type
+ definition.
+
+ In the meantime, pretend that the "fixed" type we are
+ returning is NOT a stub, because this can cause trouble
+ when using this type to create new types targeting it.
+ Indeed, the associated creation routines often check
+ whether the target type is a stub and will try to replace
+ it, thus using a type with the wrong size. This, in turn,
+ might cause the new type to have the wrong size too.
+ Consider the case of an array, for instance, where the size
+ of the array is computed from the number of elements in
+ our array multiplied by the size of its element. */
+ TYPE_STUB (fixed_record_type) = 0;
+ }
+ }
return fixed_record_type;
}
case TYPE_CODE_ARRAY:
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 2029d5d..b5a5de0 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3040,6 +3040,28 @@ copy_type_recursive (struct objfile *objfile,
return new_type;
}
+/* Make a copy of the given TYPE, except that the pointer & reference
+ types are not preserved.
+
+ This function assumes that the given type has an associated objfile.
+ This objfile is used to allocate the new type. */
+
+struct type *
+copy_type (const struct type *type)
+{
+ struct type *new_type;
+
+ gdb_assert (TYPE_OBJFILE (type) != NULL);
+
+ new_type = alloc_type (TYPE_OBJFILE (type));
+ TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type);
+ TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
+ memcpy (TYPE_MAIN_TYPE (new_type), TYPE_MAIN_TYPE (type),
+ sizeof (struct main_type));
+
+ return new_type;
+}
+
static struct type *
build_flt (int bit, char *name, const struct floatformat **floatformats)
{
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 0a48db2..2a41c5b 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1261,4 +1261,6 @@ extern struct type *copy_type_recursive (struct objfile *objfile,
struct type *type,
htab_t copied_types);
+extern struct type *copy_type (const struct type *type);
+
#endif /* GDBTYPES_H */