This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[11/15] Pointer / reference type creation
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 9 Jun 2009 17:20:17 +0200 (CEST)
- Subject: [11/15] Pointer / reference type creation
Hello,
this patch eliminates references to current_gdbarch during pointer/
reference type creation in gdbtypes.c.
The problem is that in order to create a pointer/reference type,
the *size* of that type needs to be known -- and this is an
architecture property.
The patch fixes this by adding a LENGTH argument to all affected
routines:
- make_pointer_type/make_reference_type
- lookup_pointer_type/lookup_reference_type
- smash_to_memberptr_type
- lookup_memberptr_type/lookup_methodptr_type
This is just the length instead of the full architecture in order
to allow use of those functions in some places where we might not
have a full architecture, e.g. when creating a pointer type
corresponding to a reference type (we can simply use the known
length of the reference type to create pointer type of same length).
For those places where we do have a gdbarch, a helper macro
ptr_size is provided for ease of use.
As a side benefit, the patch changes the gdbtypes.c logic to allow
creating (and caching) multiple different pointer types with
different lengths to the same base type.
Bye,
Ulrich
ChangeLog:
* defs.h (ptr_size): New macro.
* gdbtypes.h (make_pointer_type): Add LENGTH argument.
(make_reference_type): Likewise.
(smash_to_memberptr_type): Likewise.
(lookup_pointer_type): Likewise.
(lookup_reference_type): Likewise.
(lookup_memberptr_type): Likewise.
(lookup_methodptr_type): Likewise.
* gdbtypes.c (smash_type): Add LENGTH argument. Keep type
objfile; keep type chain, and propagate length to all prior
element of the type chain.
(make_type_instance): New function, replacing ...
(make_qualified_type): ... this removed function.
(make_pointer_type): Add LENGTH argument, use it instead of
checking current_gdbarch. Use make_type_instance. Update
call to smash_type.
(make_reference_type): Likewise.
(lookup_pointer_type): Add LENGTH argument, pass to make_pointer_type.
(lookup_reference_type): Likewise.
(make_function_type): Update call to smash_type.
(make_type_with_address_space): Call make_type_instance instead
of make_qualified_type.
(make_cv_type): Likewise.
(make_vector_type): Likewise.
(replace_type): Update call to smash_type.
(lookup_memberptr_type): Add LENGTH argument, pass to
smash_to_memberptr_type.
(lookup_methodptr_type): Add LENGTH argument, use it instead
of calling cplus_method_ptr_size.
(smash_to_memberptr_type): Add LENGTH argument, use it instead
of calling cplus_member_ptr_size. Update call to smash_type.
(smash_to_method_type): Update call to smash_type.
Update calls to make_pointer_type, make_reference_type,
smash_to_memberptr_type, lookup_pointer_type, lookup_reference_type,
lookup_memberptr_type, lookup_methodptr_type to pass in pointer size:
* ada-exp.y: Update.
* ada-lang.c (thin_data_pntr, desc_bounds, ada_type_of_array,
ada_value_ptr_subscript, ada_tag_name_2, ada_evaluate_subexp,
ada_language_arch_info): Update.
* ada-valprint.c (ada_val_print_1): Update.
* alpha-tdep.c (alpha_push_dummy_call): Update.
* ax-gdb.c (gen_usual_unary, gen_address_of): Update.
* c-valprint.c (c_value_print): Update.
* coffread.c (decode_type): Update.
* dwarf2read.c (quirk_gcc_member_function_pointer,
read_tag_pointer_type, read_tag_reference_type,
read_tag_ptr_to_member_type): Update.
* eval.c (evaluate_subexp_standard, evaluate_subexp_for_address,
evaluate_subexp_with_coercion): Update.
* f-exp.y: Update.
* findvar.c (read_var_value): Update.
* gdbtypes.c (check_stub_method, gdbtypes_post_init): Update.
* gnu-v2-abi.c (gnuv2_virtual_fn_field): Update.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn,
gnuv3_method_ptr_to_value): Update.
* infcall.c (value_arg_coerce, call_function_by_hand): Update.
* jv-exp.y: Update.
* jv-lang.c (type_from_class, java_link_class_type,
evaluate_subexp_java): Update.
* jv-valprint.c (java_value_print): Update.
* linux-tdep.c (linux_get_siginfo_type): Update.
* mdebugread.c (parse_symbol, upgrade_type): Update.
* objc-lang.c (value_nsstring): Update.
* p-exp.y: Update.
* parse.c (follow_types): Update.
* printcmd.c (x_command): Update.
* sparc-tdep.c (sparc32_store_arguments): Update.
* sparc64-tdep.c (sparc64_store_arguments): Update.
* stabsread.c (define_symbol, read_type): Update.
* typeprint.c (whatis_exp): Update.
* valops.c (find_function_in_inferior, address_of_variable,
value_coerce_array, value_coerce_function, value_addr, value_ref,
value_struct_elt_for_reference): Update.
* value.c (value_fn_field): Update.
* python/python-type.c (typy_pointer, typy_reference,
typy_lookup_type): Update.
* ax-gdb.c (gen_address_of): Add EXP parameter.
(gen_expr): Pass expression to gen_address_of.
* dwarf2read.c: Include "cp-abi.h".
(is_vtable_name): Rename to ...
(dwarf2_is_vtable_name): ... this.
(read_structure_type): Update call site.
Index: gdb-head/gdb/gdbtypes.c
===================================================================
--- gdb-head.orig/gdb/gdbtypes.c
+++ gdb-head/gdb/gdbtypes.c
@@ -207,17 +207,96 @@ alloc_type_instance (struct type *oldtyp
return type;
}
-/* Clear all remnants of the previous type at TYPE, in preparation for
- replacing it with something else. */
+/* Prepare for replacing the contents of TYPE with something else.
+
+ This clears the contents of TYPE_MAIN_TYPE (TYPE), and propagates
+ the new LENGTH to all types in the TYPE_CHAIN.
+
+ This is supported only if all types in the TYPE_CHAIN previously
+ had the same length. This is the case for all symbol readers
+ that want to replace types in-place. */
+
static void
-smash_type (struct type *type)
+smash_type (struct type *type, int length)
{
+ struct objfile *objfile = TYPE_OBJFILE (type);
+ int old_length = TYPE_LENGTH (type);
+ struct type *chain;
+
memset (TYPE_MAIN_TYPE (type), 0, sizeof (struct main_type));
- /* For now, delete the rings. */
- TYPE_CHAIN (type) = type;
+ /* Keep the objfile pointer; the type remains allocated there. */
+ TYPE_OBJFILE (type) = objfile;
- /* For now, leave the pointer/reference types alone. */
+ /* The type length is not a part of the main type. Update it for
+ each type on the variant chain. */
+ chain = type;
+ do {
+ gdb_assert (TYPE_LENGTH (chain) == old_length);
+ TYPE_LENGTH (chain) = length;
+ chain = TYPE_CHAIN (chain);
+ } while (type != chain);
+}
+
+/* Create a new type with length NEW_LENGTH and instance flags
+ NEW_FLAGS, based on TYPE.
+
+ If STORAGE is non-NULL, create the new type instance there.
+ STORAGE must be in the same obstack as TYPE. */
+
+static struct type *
+make_type_instance (struct type *type, int new_length, int new_flags,
+ struct type *storage)
+{
+ struct type *ntype;
+
+ ntype = type;
+ do
+ {
+ if (TYPE_LENGTH (ntype) == new_length
+ && TYPE_INSTANCE_FLAGS (ntype) == new_flags)
+ return ntype;
+ ntype = TYPE_CHAIN (ntype);
+ }
+ while (ntype != type);
+
+ /* Create a new type instance. */
+ if (storage == NULL)
+ ntype = alloc_type_instance (type);
+ else
+ {
+ /* If STORAGE was provided, it had better be in the same objfile
+ as TYPE. Otherwise, we can't link it into TYPE's cv chain:
+ if one objfile is freed and the other kept, we'd have
+ dangling pointers. */
+ gdb_assert (TYPE_OBJFILE (type) == TYPE_OBJFILE (storage));
+
+ /* Unlink STORAGE from its previous TYPE_CHAIN. */
+ ntype = storage;
+ while (TYPE_CHAIN (ntype) != storage)
+ ntype = TYPE_CHAIN (ntype);
+
+ TYPE_CHAIN (ntype) = TYPE_CHAIN (storage);
+ TYPE_CHAIN (storage) = storage;
+
+ ntype = storage;
+ TYPE_MAIN_TYPE (ntype) = TYPE_MAIN_TYPE (type);
+ }
+
+ /* Pointers or references to the original type are not relevant to
+ the new type. */
+ TYPE_POINTER_TYPE (ntype) = (struct type *) 0;
+ TYPE_REFERENCE_TYPE (ntype) = (struct type *) 0;
+
+ /* Chain the new qualified type to the old type. */
+ TYPE_CHAIN (ntype) = TYPE_CHAIN (type);
+ TYPE_CHAIN (type) = ntype;
+
+ /* Now set the length and instance flags and return the new type. */
+ TYPE_LENGTH (ntype) = new_length;
+ TYPE_INSTANCE_FLAGS (ntype) = new_flags;
+
+ return ntype;
}
/* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points
@@ -226,50 +305,38 @@ smash_type (struct type *type)
We allocate new memory if needed. */
struct type *
-make_pointer_type (struct type *type, struct type **typeptr)
+make_pointer_type (struct type *type, struct type **typeptr, int length)
{
struct type *ntype; /* New type */
- struct objfile *objfile;
- struct type *chain;
ntype = TYPE_POINTER_TYPE (type);
if (ntype)
{
- if (typeptr == 0)
- return ntype; /* Don't care about alloc,
- and have new type. */
- else if (*typeptr == 0)
- {
- *typeptr = ntype; /* Tracking alloc, and have new type. */
- return ntype;
- }
+ ntype = make_type_instance (ntype, length, 0,
+ typeptr ? *typeptr : NULL);
+ if (typeptr != NULL)
+ *typeptr = ntype;
+
+ return ntype;
}
if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
{
ntype = alloc_type (TYPE_OBJFILE (type));
+ TYPE_LENGTH (ntype) = length;
if (typeptr)
*typeptr = ntype;
}
else /* We have storage, but need to reset it. */
{
ntype = *typeptr;
- objfile = TYPE_OBJFILE (ntype);
- chain = TYPE_CHAIN (ntype);
- smash_type (ntype);
- TYPE_CHAIN (ntype) = chain;
- TYPE_OBJFILE (ntype) = objfile;
+ smash_type (ntype, length);
}
TYPE_TARGET_TYPE (ntype) = type;
TYPE_POINTER_TYPE (type) = ntype;
- /* FIXME! Assume the machine has only one representation for
- pointers! */
-
- TYPE_LENGTH (ntype) =
- gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT;
TYPE_CODE (ntype) = TYPE_CODE_PTR;
/* Mark pointers as unsigned. The target converts between pointers
@@ -277,17 +344,6 @@ make_pointer_type (struct type *type, st
gdbarch_address_to_pointer. */
TYPE_UNSIGNED (ntype) = 1;
- if (!TYPE_POINTER_TYPE (type)) /* Remember it, if don't have one. */
- TYPE_POINTER_TYPE (type) = ntype;
-
- /* Update the length of all the other variants of this type. */
- chain = TYPE_CHAIN (ntype);
- while (chain != ntype)
- {
- TYPE_LENGTH (chain) = TYPE_LENGTH (ntype);
- chain = TYPE_CHAIN (chain);
- }
-
return ntype;
}
@@ -295,9 +351,9 @@ make_pointer_type (struct type *type, st
May need to construct such a type if this is the first use. */
struct type *
-lookup_pointer_type (struct type *type)
+lookup_pointer_type (struct type *type, int length)
{
- return make_pointer_type (type, (struct type **) 0);
+ return make_pointer_type (type, (struct type **) 0, length);
}
/* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero,
@@ -306,63 +362,40 @@ lookup_pointer_type (struct type *type)
type we return. We allocate new memory if needed. */
struct type *
-make_reference_type (struct type *type, struct type **typeptr)
+make_reference_type (struct type *type, struct type **typeptr, int length)
{
struct type *ntype; /* New type */
- struct objfile *objfile;
- struct type *chain;
ntype = TYPE_REFERENCE_TYPE (type);
if (ntype)
{
- if (typeptr == 0)
- return ntype; /* Don't care about alloc,
- and have new type. */
- else if (*typeptr == 0)
- {
- *typeptr = ntype; /* Tracking alloc, and have new type. */
- return ntype;
- }
+ ntype = make_type_instance (ntype, length, 0,
+ typeptr ? *typeptr : NULL);
+ if (typeptr != NULL)
+ *typeptr = ntype;
+
+ return ntype;
}
if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
{
ntype = alloc_type (TYPE_OBJFILE (type));
+ TYPE_LENGTH (ntype) = length;
if (typeptr)
*typeptr = ntype;
}
else /* We have storage, but need to reset it. */
{
ntype = *typeptr;
- objfile = TYPE_OBJFILE (ntype);
- chain = TYPE_CHAIN (ntype);
- smash_type (ntype);
- TYPE_CHAIN (ntype) = chain;
- TYPE_OBJFILE (ntype) = objfile;
+ smash_type (ntype, length);
}
TYPE_TARGET_TYPE (ntype) = type;
TYPE_REFERENCE_TYPE (type) = ntype;
- /* FIXME! Assume the machine has only one representation for
- references, and that it matches the (only) representation for
- pointers! */
-
- TYPE_LENGTH (ntype) = gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT;
TYPE_CODE (ntype) = TYPE_CODE_REF;
- if (!TYPE_REFERENCE_TYPE (type)) /* Remember it, if don't have one. */
- TYPE_REFERENCE_TYPE (type) = ntype;
-
- /* Update the length of all the other variants of this type. */
- chain = TYPE_CHAIN (ntype);
- while (chain != ntype)
- {
- TYPE_LENGTH (chain) = TYPE_LENGTH (ntype);
- chain = TYPE_CHAIN (chain);
- }
-
return ntype;
}
@@ -370,9 +403,9 @@ make_reference_type (struct type *type,
details. */
struct type *
-lookup_reference_type (struct type *type)
+lookup_reference_type (struct type *type, int length)
{
- return make_reference_type (type, (struct type **) 0);
+ return make_reference_type (type, (struct type **) 0, length);
}
/* Lookup a function type that returns type TYPE. TYPEPTR, if
@@ -390,19 +423,18 @@ make_function_type (struct type *type, s
if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
{
ntype = alloc_type (objfile);
+ TYPE_LENGTH (ntype) = 1;
if (typeptr)
*typeptr = ntype;
}
else /* We have storage, but need to reset it. */
{
ntype = *typeptr;
- smash_type (ntype);
- TYPE_OBJFILE (ntype) = objfile;
+ smash_type (ntype, 1);
}
TYPE_TARGET_TYPE (ntype) = type;
- TYPE_LENGTH (ntype) = 1;
TYPE_CODE (ntype) = TYPE_CODE_FUNC;
return ntype;
@@ -472,60 +504,6 @@ address_class_int_to_name (int class_nr)
return NULL;
}
-/* Create a new type with instance flags NEW_FLAGS, based on TYPE.
-
- If STORAGE is non-NULL, create the new type instance there.
- STORAGE must be in the same obstack as TYPE. */
-
-static struct type *
-make_qualified_type (struct type *type, int new_flags,
- struct type *storage)
-{
- struct type *ntype;
-
- ntype = type;
- do
- {
- if (TYPE_INSTANCE_FLAGS (ntype) == new_flags)
- return ntype;
- ntype = TYPE_CHAIN (ntype);
- }
- while (ntype != type);
-
- /* Create a new type instance. */
- if (storage == NULL)
- ntype = alloc_type_instance (type);
- else
- {
- /* If STORAGE was provided, it had better be in the same objfile
- as TYPE. Otherwise, we can't link it into TYPE's cv chain:
- if one objfile is freed and the other kept, we'd have
- dangling pointers. */
- gdb_assert (TYPE_OBJFILE (type) == TYPE_OBJFILE (storage));
-
- ntype = storage;
- TYPE_MAIN_TYPE (ntype) = TYPE_MAIN_TYPE (type);
- TYPE_CHAIN (ntype) = ntype;
- }
-
- /* Pointers or references to the original type are not relevant to
- the new type. */
- TYPE_POINTER_TYPE (ntype) = (struct type *) 0;
- TYPE_REFERENCE_TYPE (ntype) = (struct type *) 0;
-
- /* Chain the new qualified type to the old type. */
- TYPE_CHAIN (ntype) = TYPE_CHAIN (type);
- TYPE_CHAIN (type) = ntype;
-
- /* Now set the instance flags and return the new type. */
- TYPE_INSTANCE_FLAGS (ntype) = new_flags;
-
- /* Set length of new type to that of the original type. */
- TYPE_LENGTH (ntype) = TYPE_LENGTH (type);
-
- return ntype;
-}
-
/* Make an address-class-delimited variant of a type -- a type that
is identical to the one supplied except that it has an address
class attribute attached to it (such as "code" or "data").
@@ -543,7 +521,7 @@ make_type_with_address_class (struct typ
& ~TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL)
| TYPE_INSTANCE_FLAG_ADDRESS_CLASS (class_nr));
- return make_qualified_type (type, new_flags, NULL);
+ return make_type_instance (type, TYPE_LENGTH (type), new_flags, NULL);
}
/* Make a "c-v" variant of a type -- a type that is identical to the
@@ -592,8 +570,8 @@ make_cv_type (int cnst, int voltl,
gdb_assert (TYPE_OBJFILE (*typeptr) == TYPE_OBJFILE (type));
}
- ntype = make_qualified_type (type, new_flags,
- typeptr ? *typeptr : NULL);
+ ntype = make_type_instance (type, TYPE_LENGTH (type), new_flags,
+ typeptr ? *typeptr : NULL);
if (typeptr != NULL)
*typeptr = ntype;
@@ -613,34 +591,15 @@ make_cv_type (int cnst, int voltl,
void
replace_type (struct type *ntype, struct type *type)
{
- struct type *chain;
-
/* These two types had better be in the same objfile. Otherwise,
the assignment of one type's main type structure to the other
will produce a type with references to objects (names; field
lists; etc.) allocated on an objfile other than its own. */
gdb_assert (TYPE_OBJFILE (ntype) == TYPE_OBJFILE (ntype));
+ smash_type (ntype, TYPE_LENGTH (type));
*TYPE_MAIN_TYPE (ntype) = *TYPE_MAIN_TYPE (type);
- /* The type length is not a part of the main type. Update it for
- each type on the variant chain. */
- chain = ntype;
- do
- {
- /* Assert that this element of the chain has no address-class bits
- set in its flags. Such type variants might have type lengths
- which are supposed to be different from the non-address-class
- variants. This assertion shouldn't ever be triggered because
- symbol readers which do construct address-class variants don't
- call replace_type(). */
- gdb_assert (TYPE_ADDRESS_CLASS (chain) == TYPE_ADDRESS_CLASS_GENERIC);
-
- TYPE_LENGTH (chain) = TYPE_LENGTH (type);
- chain = TYPE_CHAIN (chain);
- }
- while (ntype != chain);
-
/* Assert that the two types have equivalent instance qualifiers.
This should be true for at least all of our debug readers. */
gdb_assert (TYPE_INSTANCE_FLAGS (ntype) == TYPE_INSTANCE_FLAGS (type));
@@ -652,26 +611,26 @@ replace_type (struct type *ntype, struct
of the aggregate that the member belongs to. */
struct type *
-lookup_memberptr_type (struct type *type, struct type *domain)
+lookup_memberptr_type (struct type *type, struct type *domain, int length)
{
struct type *mtype;
mtype = alloc_type (TYPE_OBJFILE (type));
- smash_to_memberptr_type (mtype, domain, type);
+ smash_to_memberptr_type (mtype, domain, type, length);
return mtype;
}
/* Return a pointer-to-method type, for a method of type TO_TYPE. */
struct type *
-lookup_methodptr_type (struct type *to_type)
+lookup_methodptr_type (struct type *to_type, int length)
{
struct type *mtype;
mtype = alloc_type (TYPE_OBJFILE (to_type));
TYPE_TARGET_TYPE (mtype) = to_type;
TYPE_DOMAIN_TYPE (mtype) = TYPE_DOMAIN_TYPE (to_type);
- TYPE_LENGTH (mtype) = cplus_method_ptr_size (current_gdbarch);
+ TYPE_LENGTH (mtype) = length;
TYPE_CODE (mtype) = TYPE_CODE_METHODPTR;
return mtype;
}
@@ -949,7 +908,8 @@ make_vector_type (struct type *array_typ
if (TYPE_CODE (elt_type) == TYPE_CODE_INT)
{
flags = TYPE_INSTANCE_FLAGS (elt_type) | TYPE_FLAG_NOTTEXT;
- elt_type = make_qualified_type (elt_type, flags, NULL);
+ elt_type = make_type_instance (elt_type, TYPE_LENGTH (elt_type),
+ flags, NULL);
TYPE_TARGET_TYPE (inner_array) = elt_type;
}
@@ -974,53 +934,35 @@ init_vector_type (struct type *elt_type,
typed offset into a struct, e.g. "an int at offset 8". A MEMBER
TYPE doesn't include the offset (that's the value of the MEMBER
itself), but does include the structure type into which it points
- (for some reason).
-
- When "smashing" the type, we preserve the objfile that the old type
- pointed to, since we aren't changing where the type is actually
- allocated. */
+ (for some reason). */
void
smash_to_memberptr_type (struct type *type, struct type *domain,
- struct type *to_type)
+ struct type *to_type, int length)
{
- struct objfile *objfile;
+ smash_type (type, length);
- objfile = TYPE_OBJFILE (type);
-
- smash_type (type);
- TYPE_OBJFILE (type) = objfile;
TYPE_TARGET_TYPE (type) = to_type;
TYPE_DOMAIN_TYPE (type) = domain;
- TYPE_LENGTH (type) = cplus_member_ptr_size (current_gdbarch);
TYPE_CODE (type) = TYPE_CODE_MEMBERPTR;
}
/* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE.
- METHOD just means `function that gets an extra "this" argument'.
-
- When "smashing" the type, we preserve the objfile that the old type
- pointed to, since we aren't changing where the type is actually
- allocated. */
+ METHOD just means `function that gets an extra "this" argument'. */
void
smash_to_method_type (struct type *type, struct type *domain,
struct type *to_type, struct field *args,
int nargs, int varargs)
{
- struct objfile *objfile;
+ smash_type (type, 1);
- objfile = TYPE_OBJFILE (type);
-
- smash_type (type);
- TYPE_OBJFILE (type) = objfile;
TYPE_TARGET_TYPE (type) = to_type;
TYPE_DOMAIN_TYPE (type) = domain;
TYPE_FIELDS (type) = args;
TYPE_NFIELDS (type) = nargs;
if (varargs)
TYPE_VARARGS (type) = 1;
- TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */
TYPE_CODE (type) = TYPE_CODE_METHOD;
}
@@ -1582,6 +1524,9 @@ safe_parse_type (char *p, int length)
static void
check_stub_method (struct type *type, int method_id, int signature_id)
{
+ /* Use the objfile architecture to parse types, just like it would
+ have been used during symbol file reading. */
+ struct gdbarch *gdbarch = get_objfile_arch (TYPE_OBJFILE (type));
struct fn_field *f;
char *mangled_name = gdb_mangle_name (type, method_id, signature_id);
char *demangled_name = cplus_demangle (mangled_name,
@@ -1638,7 +1583,7 @@ check_stub_method (struct type *type, in
argcount = 0;
else
{
- argtypes[0].type = lookup_pointer_type (type);
+ argtypes[0].type = lookup_pointer_type (type, ptr_size (gdbarch));
argcount = 1;
}
@@ -3236,9 +3181,10 @@ gdbtypes_post_init (struct gdbarch *gdba
indeed in the unified virtual address space. */
builtin_type->builtin_data_ptr =
- make_pointer_type (builtin_type->builtin_void, NULL);
+ lookup_pointer_type (builtin_type->builtin_void, ptr_size (gdbarch));
builtin_type->builtin_func_ptr =
- lookup_pointer_type (lookup_function_type (builtin_type->builtin_void));
+ lookup_pointer_type (lookup_function_type (builtin_type->builtin_void),
+ ptr_size (gdbarch));
builtin_type->builtin_core_addr =
init_type (TYPE_CODE_INT,
gdbarch_addr_bit (gdbarch) / 8,
Index: gdb-head/gdb/defs.h
===================================================================
--- gdb-head.orig/gdb/defs.h
+++ gdb-head/gdb/defs.h
@@ -1046,6 +1046,9 @@ enum { MAX_REGISTER_SIZE = 16 };
#define HOST_CHAR_BIT TARGET_CHAR_BIT
#endif
+/* Helper macro to compute the default size in bytes of a target pointer. */
+#define ptr_size(gdbarch) (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT)
+
/* In findvar.c. */
extern LONGEST extract_signed_integer (const gdb_byte *, int);
Index: gdb-head/gdb/dwarf2read.c
===================================================================
--- gdb-head.orig/gdb/dwarf2read.c
+++ gdb-head/gdb/dwarf2read.c
@@ -43,6 +43,7 @@
#include "dwarf2expr.h"
#include "dwarf2loc.h"
#include "cp-support.h"
+#include "cp-abi.h"
#include "hashtab.h"
#include "command.h"
#include "gdbcmd.h"
@@ -4150,7 +4151,7 @@ dwarf2_attach_fn_fields_to_type (struct
/* Returns non-zero if NAME is the name of a vtable member in CU's
language, zero otherwise. */
static int
-is_vtable_name (const char *name, struct dwarf2_cu *cu)
+dwarf2_is_vtable_name (const char *name, struct dwarf2_cu *cu)
{
static const char vptr[] = "_vptr";
static const char vtable[] = "vtable";
@@ -4177,6 +4178,7 @@ static struct type *
quirk_gcc_member_function_pointer (struct die_info *die, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct type *type;
struct die_info *pfn_die, *delta_die;
struct attribute *pfn_name, *delta_name;
@@ -4226,7 +4228,7 @@ quirk_gcc_member_function_pointer (struc
smash_to_method_type (type, domain_type, TYPE_TARGET_TYPE (pfn_type),
TYPE_FIELDS (pfn_type), TYPE_NFIELDS (pfn_type),
TYPE_VARARGS (pfn_type));
- type = lookup_methodptr_type (type);
+ type = lookup_methodptr_type (type, cplus_method_ptr_size (gdbarch));
return set_die_type (die, type, cu);
}
@@ -4373,7 +4375,7 @@ read_structure_type (struct die_info *di
{
char *fieldname = TYPE_FIELD_NAME (t, i);
- if (is_vtable_name (fieldname, cu))
+ if (dwarf2_is_vtable_name (fieldname, cu))
{
TYPE_VPTR_FIELDNO (type) = i;
break;
@@ -4945,8 +4947,6 @@ read_tag_pointer_type (struct die_info *
struct attribute *attr_address_class;
int byte_size, addr_class;
- type = lookup_pointer_type (die_type (die, cu));
-
attr_byte_size = dwarf2_attr (die, DW_AT_byte_size, cu);
if (attr_byte_size)
byte_size = DW_UNSND (attr_byte_size);
@@ -4959,10 +4959,11 @@ read_tag_pointer_type (struct die_info *
else
addr_class = DW_ADDR_none;
- /* If the pointer size or address class is different than the
- default, create a type variant marked as such and set the
- length accordingly. */
- if (TYPE_LENGTH (type) != byte_size || addr_class != DW_ADDR_none)
+ type = lookup_pointer_type (die_type (die, cu), byte_size);
+
+ /* If the address class is different than the default,
+ create a type variant marked as such. */
+ if (addr_class != DW_ADDR_none)
{
if (gdbarch_type_address_class_p (gdbarch))
{
@@ -4970,16 +4971,11 @@ read_tag_pointer_type (struct die_info *
(gdbarch, byte_size, addr_class);
type = make_type_with_address_class (type, class_nr);
}
- else if (TYPE_LENGTH (type) != byte_size)
- {
- complaint (&symfile_complaints, _("invalid pointer size %d"), byte_size);
- }
else {
- /* Should we also complain about unhandled address classes? */
+ /* Should we complain about unhandled address classes? */
}
}
- TYPE_LENGTH (type) = byte_size;
return set_die_type (die, type, cu);
}
@@ -4990,6 +4986,7 @@ static struct type *
read_tag_ptr_to_member_type (struct die_info *die, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct type *type;
struct type *to_type;
struct type *domain;
@@ -4998,9 +4995,11 @@ read_tag_ptr_to_member_type (struct die_
domain = die_containing_type (die, cu);
if (TYPE_CODE (check_typedef (to_type)) == TYPE_CODE_METHOD)
- type = lookup_methodptr_type (to_type);
+ type = lookup_methodptr_type (to_type,
+ cplus_method_ptr_size (gdbarch));
else
- type = lookup_memberptr_type (to_type, domain);
+ type = lookup_memberptr_type (to_type, domain,
+ cplus_member_ptr_size (gdbarch));
return set_die_type (die, type, cu);
}
@@ -5014,17 +5013,19 @@ read_tag_reference_type (struct die_info
struct comp_unit_head *cu_header = &cu->header;
struct type *type;
struct attribute *attr;
+ int size;
- type = lookup_reference_type (die_type (die, cu));
attr = dwarf2_attr (die, DW_AT_byte_size, cu);
if (attr)
{
- TYPE_LENGTH (type) = DW_UNSND (attr);
+ size = DW_UNSND (attr);
}
else
{
- TYPE_LENGTH (type) = cu_header->addr_size;
+ size = cu_header->addr_size;
}
+
+ type = lookup_reference_type (die_type (die, cu), size);
return set_die_type (die, type, cu);
}
Index: gdb-head/gdb/gdbtypes.h
===================================================================
--- gdb-head.orig/gdb/gdbtypes.h
+++ gdb-head/gdb/gdbtypes.h
@@ -1137,9 +1137,9 @@ extern void append_flags_type_flag (stru
extern void make_vector_type (struct type *array_type);
extern struct type *init_vector_type (struct type *elt_type, int n);
-extern struct type *lookup_reference_type (struct type *);
+extern struct type *lookup_reference_type (struct type *, int);
-extern struct type *make_reference_type (struct type *, struct type **);
+extern struct type *make_reference_type (struct type *, struct type **, int);
extern struct type *make_cv_type (int, int, struct type *, struct type **);
@@ -1154,16 +1154,16 @@ extern const char *address_class_int_to_
extern struct type *make_type_with_address_class (struct type *type,
int class_nr);
-extern struct type *lookup_memberptr_type (struct type *, struct type *);
+extern struct type *lookup_memberptr_type (struct type *, struct type *, int);
-extern struct type *lookup_methodptr_type (struct type *);
+extern struct type *lookup_methodptr_type (struct type *, int);
extern void smash_to_method_type (struct type *type, struct type *domain,
struct type *to_type, struct field *args,
int nargs, int varargs);
extern void smash_to_memberptr_type (struct type *, struct type *,
- struct type *);
+ struct type *, int);
extern struct type *allocate_stub_method (struct type *);
@@ -1171,9 +1171,9 @@ extern char *type_name_no_tag (const str
extern struct type *lookup_struct_elt_type (struct type *, char *, int);
-extern struct type *make_pointer_type (struct type *, struct type **);
+extern struct type *make_pointer_type (struct type *, struct type **, int);
-extern struct type *lookup_pointer_type (struct type *);
+extern struct type *lookup_pointer_type (struct type *, int);
extern struct type *make_function_type (struct type *, struct type **,
struct objfile *);
Index: gdb-head/gdb/stabsread.c
===================================================================
--- gdb-head.orig/gdb/stabsread.c
+++ gdb-head/gdb/stabsread.c
@@ -962,7 +962,8 @@ define_symbol (CORE_ADDR valu, char *str
p++;
SYMBOL_TYPE (sym)
= lookup_pointer_type
- (lookup_function_type (read_type (&p, objfile)));
+ (lookup_function_type (read_type (&p, objfile)),
+ ptr_size (gdbarch));
}
else
SYMBOL_TYPE (sym) = read_type (&p, objfile);
@@ -1414,6 +1415,7 @@ error_type (char **pp, struct objfile *o
static struct type *
read_type (char **pp, struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct type *type = 0;
struct type *type1;
int typenums[2];
@@ -1672,12 +1674,14 @@ again:
case '*': /* Pointer to another type */
type1 = read_type (pp, objfile);
- type = make_pointer_type (type1, dbx_lookup_type (typenums));
+ type = make_pointer_type (type1, dbx_lookup_type (typenums),
+ ptr_size (gdbarch));
break;
case '&': /* Reference to another type */
type1 = read_type (pp, objfile);
- type = make_reference_type (type1, dbx_lookup_type (typenums));
+ type = make_reference_type (type1, dbx_lookup_type (typenums),
+ ptr_size (gdbarch));
break;
case 'f': /* Function returning another type */
@@ -1786,7 +1790,8 @@ again:
memtype = read_type (pp, objfile);
type = dbx_alloc_type (typenums, objfile);
- smash_to_memberptr_type (type, domain, memtype);
+ smash_to_memberptr_type (type, domain, memtype,
+ cplus_member_ptr_size (gdbarch));
}
else
/* type attribute */
Index: gdb-head/gdb/valops.c
===================================================================
--- gdb-head.orig/gdb/valops.c
+++ gdb-head/gdb/valops.c
@@ -150,9 +150,10 @@ find_function_in_inferior (struct gdbarc
{
struct type *type;
CORE_ADDR maddr;
- type = lookup_pointer_type (builtin_type (gdbarch)->builtin_char);
+ type = builtin_type (gdbarch)->builtin_char;
+ type = lookup_pointer_type (type, ptr_size (gdbarch));
type = lookup_function_type (type);
- type = lookup_pointer_type (type);
+ type = lookup_pointer_type (type, ptr_size (gdbarch));
maddr = SYMBOL_VALUE_ADDRESS (msymbol);
return value_from_pointer (type, gdbarch, maddr);
@@ -1027,7 +1028,8 @@ address_of_variable (struct symbol *var,
|| TYPE_CODE (type) == TYPE_CODE_FUNC)
{
CORE_ADDR addr = value_address (val);
- return value_from_pointer (lookup_pointer_type (type), gdbarch, addr);
+ struct type *p = lookup_pointer_type (type, ptr_size (gdbarch));
+ return value_from_pointer (p, gdbarch, addr);
}
/* Not a memory address; check what the problem was. */
@@ -1142,8 +1144,9 @@ value_coerce_array (struct value *arg1)
if (VALUE_LVAL (arg1) != lval_memory)
error (_("Attempt to take address of value not located in memory."));
- return value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
- value_arch (arg1), value_address (arg1));
+ type = lookup_pointer_type (TYPE_TARGET_TYPE (type),
+ ptr_size (value_arch (arg1)));
+ return value_from_pointer (type, value_arch (arg1), value_address (arg1));
}
/* Given a value which is a function, return a value which is a pointer
@@ -1153,12 +1156,13 @@ struct value *
value_coerce_function (struct value *arg1)
{
struct value *retval;
+ struct type *type;
if (VALUE_LVAL (arg1) != lval_memory)
error (_("Attempt to take address of value not located in memory."));
- retval = value_from_pointer (lookup_pointer_type (value_type (arg1)),
- value_arch (arg1), value_address (arg1));
+ type = lookup_pointer_type (value_type (arg1), ptr_size (value_arch (arg1)));
+ retval = value_from_pointer (type, value_arch (arg1), value_address (arg1));
return retval;
}
@@ -1177,8 +1181,9 @@ value_addr (struct value *arg1)
keep the same location information, which is efficient, and
allows &(&X) to get the location containing the reference. */
arg2 = value_copy (arg1);
- deprecated_set_value_type (arg2,
- lookup_pointer_type (TYPE_TARGET_TYPE (type)));
+ type = lookup_pointer_type (TYPE_TARGET_TYPE (type),
+ TYPE_LENGTH (value_type (arg2)));
+ deprecated_set_value_type (arg2, type);
return arg2;
}
if (TYPE_CODE (type) == TYPE_CODE_FUNC)
@@ -1192,14 +1197,16 @@ value_addr (struct value *arg1)
error (_("Attempt to take address of value not located in memory."));
/* Get target memory address */
- arg2 = value_from_pointer (lookup_pointer_type (value_type (arg1)),
- value_arch (arg1),
+ type = lookup_pointer_type (value_type (arg1), ptr_size (value_arch (arg1)));
+ arg2 = value_from_pointer (type, value_arch (arg1),
(value_address (arg1)
+ value_embedded_offset (arg1)));
/* This may be a pointer to a base subobject; so remember the
full derived object's type ... */
- arg2 = value_change_enclosing_type (arg2, lookup_pointer_type (value_enclosing_type (arg1)));
+ type = lookup_pointer_type (value_enclosing_type (arg1),
+ ptr_size (value_arch (arg1)));
+ arg2 = value_change_enclosing_type (arg2, type);
/* ... and also the relative position of the subobject in the full
object. */
set_value_pointed_to_offset (arg2, value_embedded_offset (arg1));
@@ -1219,7 +1226,8 @@ value_ref (struct value *arg1)
return arg1;
arg2 = value_addr (arg1);
- deprecated_set_value_type (arg2, lookup_reference_type (type));
+ type = lookup_reference_type (type, TYPE_LENGTH (value_type (arg2)));
+ deprecated_set_value_type (arg2, type);
return arg2;
}
@@ -2616,9 +2624,12 @@ value_struct_elt_for_reference (struct g
error (_("pointers to bitfield members not allowed"));
if (want_address)
- return value_from_longest
- (lookup_memberptr_type (TYPE_FIELD_TYPE (t, i), domain),
- gdbarch, offset + (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3));
+ {
+ ptr = lookup_memberptr_type (TYPE_FIELD_TYPE (t, i), domain,
+ cplus_member_ptr_size (gdbarch));
+ return value_from_longest (ptr, gdbarch, (LONGEST) offset
+ + (TYPE_FIELD_BITPOS (t, i) >> 3));
+ }
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
return allocate_value (TYPE_FIELD_TYPE (t, i), gdbarch);
else
@@ -2693,7 +2704,8 @@ value_struct_elt_for_reference (struct g
{
if (want_address)
{
- ptr = lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j));
+ ptr = lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j),
+ cplus_method_ptr_size (gdbarch));
result = allocate_value (ptr, gdbarch);
cplus_make_method_ptr (value_contents_writeable (result),
value_type (result),
@@ -2719,7 +2731,8 @@ value_struct_elt_for_reference (struct g
result = v;
else
{
- ptr = lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j));
+ ptr = lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j),
+ cplus_method_ptr_size (gdbarch));
result = allocate_value (ptr, gdbarch);
cplus_make_method_ptr (value_contents_writeable (result),
value_type (result),
Index: gdb-head/gdb/ada-exp.y
===================================================================
--- gdb-head.orig/gdb/ada-exp.y
+++ gdb-head/gdb/ada-exp.y
@@ -625,7 +625,8 @@ var_or_type: NAME %prec VAR
if ($$ == NULL)
write_exp_elt_opcode (UNOP_ADDR);
else
- $$ = lookup_pointer_type ($$);
+ $$ = lookup_pointer_type
+ ($$, ptr_size (parse_gdbarch));
}
| block NAME TICK_ACCESS
{
@@ -633,7 +634,8 @@ var_or_type: NAME %prec VAR
if ($$ == NULL)
write_exp_elt_opcode (UNOP_ADDR);
else
- $$ = lookup_pointer_type ($$);
+ $$ = lookup_pointer_type
+ ($$, ptr_size (parse_gdbarch));
}
;
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -1286,7 +1286,7 @@ thin_data_pntr (struct value *val)
{
struct type *type = value_type (val);
struct type *data_type = desc_data_target_type (thin_descriptor_type (type));
- data_type = lookup_pointer_type (data_type);
+ data_type = lookup_pointer_type (data_type, ptr_size (value_arch (val)));
if (TYPE_CODE (type) == TYPE_CODE_PTR)
return value_cast (data_type, value_copy (val));
@@ -1344,6 +1344,7 @@ desc_bounds (struct value *arr)
struct type *type = ada_check_typedef (value_type (arr));
if (is_thin_pntr (type))
{
+ struct type *ptr;
struct type *bounds_type =
desc_bounds_type (thin_descriptor_type (type));
LONGEST addr;
@@ -1359,10 +1360,9 @@ desc_bounds (struct value *arr)
else
addr = value_address (arr);
- return
- value_from_longest (lookup_pointer_type (bounds_type),
- value_arch (arr),
- addr - TYPE_LENGTH (bounds_type));
+ ptr = lookup_pointer_type (bounds_type, ptr_size (value_arch (arr)));
+ return value_from_longest (ptr, value_arch (arr),
+ addr - TYPE_LENGTH (bounds_type));
}
else if (is_thick_pntr (type))
@@ -1644,7 +1644,7 @@ ada_type_of_array (struct value *arr, in
elt_type = create_array_type (array_type, elt_type, range_type);
}
- return lookup_pointer_type (elt_type);
+ return lookup_pointer_type (elt_type, ptr_size (value_arch (arr)));
}
}
@@ -2296,11 +2296,14 @@ ada_value_ptr_subscript (struct value *a
{
LONGEST lwb, upb;
struct value *idx;
+ struct type *ptr;
if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
error (_("too many subscripts (%d expected)"), k);
- arr = value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
- value_copy (arr));
+
+ ptr = lookup_pointer_type (TYPE_TARGET_TYPE (type),
+ ptr_size (value_arch (arr)));
+ arr = value_cast (ptr, value_copy (arr));
get_discrete_bounds (TYPE_INDEX_TYPE (type), &lwb, &upb);
idx = value_pos_atr (builtin_type_int32, ind[k]);
if (lwb != 0)
@@ -5578,7 +5581,10 @@ ada_tag_name_2 (struct tag_args *args)
info_type = ada_find_any_type ("ada__tags__type_specific_data");
if (info_type == NULL)
return 0;
- info_type = lookup_pointer_type (lookup_pointer_type (info_type));
+ info_type = lookup_pointer_type (info_type,
+ ptr_size (value_arch (args->tag)));
+ info_type = lookup_pointer_type (info_type,
+ ptr_size (value_arch (args->tag)));
valp = value_cast (info_type, args->tag);
if (valp == NULL)
return 0;
@@ -9145,8 +9151,10 @@ ada_evaluate_subexp (struct type *expect
Otherwise, assume that the target type is an int. */
{
if (expect_type != NULL)
- return ada_value_ind (value_cast (lookup_pointer_type (expect_type),
- arg1));
+ return ada_value_ind
+ (value_cast (lookup_pointer_type
+ (expect_type, ptr_size (exp->gdbarch)),
+ arg1));
else
return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
exp->gdbarch, value_as_address (arg1));
@@ -11016,7 +11024,8 @@ ada_language_arch_info (struct gdbarch *
lai->primitive_type_vector [ada_primitive_type_system_address] =
lookup_pointer_type (init_type (TYPE_CODE_VOID, 1, 0, "void",
- (struct objfile *) NULL));
+ (struct objfile *) NULL),
+ ptr_size (gdbarch));
TYPE_NAME (lai->primitive_type_vector [ada_primitive_type_system_address])
= "system__address";
Index: gdb-head/gdb/ada-valprint.c
===================================================================
--- gdb-head.orig/gdb/ada-valprint.c
+++ gdb-head/gdb/ada-valprint.c
@@ -899,8 +899,8 @@ ada_val_print_1 (struct type *type, stru
{
struct value *deref_val =
ada_value_ind (value_from_longest
- (lookup_pointer_type (elttype), gdbarch,
- deref_val_int));
+ (lookup_pointer_type (elttype, ptr_size (gdbarch)),
+ gdbarch, deref_val_int));
val_print (value_type (deref_val), value_arch (deref_val),
value_contents (deref_val), 0,
value_address (deref_val), stream, recurse + 1,
Index: gdb-head/gdb/alpha-tdep.c
===================================================================
--- gdb-head.orig/gdb/alpha-tdep.c
+++ gdb-head/gdb/alpha-tdep.c
@@ -328,7 +328,8 @@ alpha_push_dummy_call (struct gdbarch *g
write_memory (sp, value_contents (arg), 16);
/* Construct the indirection. */
- arg_type = lookup_pointer_type (arg_type);
+ arg_type
+ = lookup_pointer_type (arg_type, ptr_size (value_arch (arg)));
arg = value_from_pointer (arg_type, value_arch (arg), sp);
}
break;
@@ -349,7 +350,8 @@ alpha_push_dummy_call (struct gdbarch *g
write_memory (sp, value_contents (arg), 32);
/* Construct the indirection. */
- arg_type = lookup_pointer_type (arg_type);
+ arg_type
+ = lookup_pointer_type (arg_type, ptr_size (value_arch (arg)));
arg = value_from_pointer (arg_type, value_arch (arg), sp);
}
break;
Index: gdb-head/gdb/ax-gdb.c
===================================================================
--- gdb-head.orig/gdb/ax-gdb.c
+++ gdb-head/gdb/ax-gdb.c
@@ -124,7 +124,8 @@ static void gen_logical_not (struct agen
struct type *result_type);
static void gen_complement (struct agent_expr *ax, struct axs_value *value);
static void gen_deref (struct agent_expr *, struct axs_value *);
-static void gen_address_of (struct agent_expr *, struct axs_value *);
+static void gen_address_of (struct expression *, struct agent_expr *,
+ struct axs_value *);
static int find_field (struct type *type, char *name);
static void gen_bitfield_ref (struct expression *exp, struct agent_expr *ax,
struct axs_value *value,
@@ -720,7 +721,7 @@ gen_usual_unary (struct expression *exp,
{
/* Functions get converted to a pointer to the function. */
case TYPE_CODE_FUNC:
- value->type = lookup_pointer_type (value->type);
+ value->type = lookup_pointer_type (value->type, ptr_size (exp->gdbarch));
value->kind = axs_rvalue; /* Should always be true, but just in case. */
break;
@@ -729,7 +730,7 @@ gen_usual_unary (struct expression *exp,
case TYPE_CODE_ARRAY:
{
struct type *elements = TYPE_TARGET_TYPE (value->type);
- value->type = lookup_pointer_type (elements);
+ value->type = lookup_pointer_type (elements, ptr_size (exp->gdbarch));
value->kind = axs_rvalue;
/* We don't need to generate any code; the address of the array
is also the address of its first element. */
@@ -1081,7 +1082,8 @@ gen_deref (struct agent_expr *ax, struct
/* Produce the address of the lvalue on the top of the stack. */
static void
-gen_address_of (struct agent_expr *ax, struct axs_value *value)
+gen_address_of (struct expression *exp, struct agent_expr *ax,
+ struct axs_value *value)
{
/* Special case for taking the address of a function. The ANSI
standard describes this as a special case, too, so this
@@ -1089,7 +1091,7 @@ gen_address_of (struct agent_expr *ax, s
if (TYPE_CODE (value->type) == TYPE_CODE_FUNC)
/* The value's already an rvalue on the stack, so we just need to
change the type. */
- value->type = lookup_pointer_type (value->type);
+ value->type = lookup_pointer_type (value->type, ptr_size (exp->gdbarch));
else
switch (value->kind)
{
@@ -1101,7 +1103,8 @@ gen_address_of (struct agent_expr *ax, s
case axs_lvalue_memory:
value->kind = axs_rvalue;
- value->type = lookup_pointer_type (value->type);
+ value->type
+ = lookup_pointer_type (value->type, ptr_size (exp->gdbarch));
break;
}
}
@@ -1683,7 +1686,7 @@ gen_expr (struct expression *exp, union
case UNOP_ADDR:
(*pc)++;
gen_expr (exp, pc, ax, value);
- gen_address_of (ax, value);
+ gen_address_of (exp, ax, value);
break;
case UNOP_SIZEOF:
Index: gdb-head/gdb/c-valprint.c
===================================================================
--- gdb-head.orig/gdb/c-valprint.c
+++ gdb-head/gdb/c-valprint.c
@@ -622,10 +622,10 @@ c_value_print (struct value *val, struct
/* Copy value, change to pointer, so we don't get an
* error about a non-pointer type in value_rtti_target_type
*/
- struct value *temparg;
- temparg=value_copy(val);
- deprecated_set_value_type (temparg, lookup_pointer_type (TYPE_TARGET_TYPE(type)));
- val=temparg;
+ struct type *ptr = lookup_pointer_type (TYPE_TARGET_TYPE (type),
+ TYPE_LENGTH (type));
+ val = value_copy (val);
+ deprecated_set_value_type (val, ptr);
}
/* Pointer to class, check real type of object */
fprintf_filtered (stream, "(");
@@ -636,12 +636,12 @@ c_value_print (struct value *val, struct
if (TYPE_CODE (type) == TYPE_CODE_PTR)
{
/* create a pointer type pointing to the real type */
- type = lookup_pointer_type (real_type);
+ type = lookup_pointer_type (real_type, TYPE_LENGTH (type));
}
else
{
/* create a reference type referencing the real type */
- type = lookup_reference_type (real_type);
+ type = lookup_reference_type (real_type, TYPE_LENGTH (type));
}
/* JYG: Need to adjust pointer value. */
/* NOTE: cagney/2005-01-02: THIS IS BOGUS. */
Index: gdb-head/gdb/coffread.c
===================================================================
--- gdb-head.orig/gdb/coffread.c
+++ gdb-head/gdb/coffread.c
@@ -1677,6 +1677,7 @@ static struct type *
decode_type (struct coff_symbol *cs, unsigned int c_type,
union internal_auxent *aux, struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct type *type = 0;
unsigned int new_c_type;
@@ -1686,7 +1687,7 @@ decode_type (struct coff_symbol *cs, uns
if (ISPTR (c_type))
{
type = decode_type (cs, new_c_type, aux, objfile);
- type = lookup_pointer_type (type);
+ type = lookup_pointer_type (type, ptr_size (gdbarch));
}
else if (ISFCN (c_type))
{
Index: gdb-head/gdb/eval.c
===================================================================
--- gdb-head.orig/gdb/eval.c
+++ gdb-head/gdb/eval.c
@@ -1079,9 +1079,9 @@ evaluate_subexp_standard (struct type *e
{
struct type *type = selector_type;
type = lookup_function_type (type);
- type = lookup_pointer_type (type);
+ type = lookup_pointer_type (type, ptr_size (exp->gdbarch));
type = lookup_function_type (type);
- type = lookup_pointer_type (type);
+ type = lookup_pointer_type (type, ptr_size (exp->gdbarch));
msg_send
= find_function_in_inferior (exp->gdbarch, "objc_msg_lookup");
@@ -1288,8 +1288,10 @@ evaluate_subexp_standard (struct type *e
if (gnu_runtime && (method != NULL))
{
/* Function objc_msg_lookup returns a pointer. */
- deprecated_set_value_type (argvec[0],
- lookup_function_type (lookup_pointer_type (value_type (argvec[0]))));
+ struct type *fn_type = value_type (argvec[0]);
+ fn_type = lookup_pointer_type (fn_type, ptr_size (exp->gdbarch));
+ fn_type = lookup_function_type (fn_type);
+ deprecated_set_value_type (argvec[0], fn_type);
argvec[0] = call_function_by_hand (argvec[0], nargs + 2, argvec + 1);
}
@@ -1449,6 +1451,7 @@ evaluate_subexp_standard (struct type *e
/* Non-C++ case -- or no overload resolution */
{
struct value *temp = arg2;
+ struct type *ptr;
argvec[0] = value_struct_elt (&temp, argvec + 1, tstr,
&static_memfuncp,
op == STRUCTOP_STRUCT
@@ -1456,8 +1459,9 @@ evaluate_subexp_standard (struct type *e
/* value_struct_elt updates temp with the correct value
of the ``this'' pointer if necessary, so modify argvec[1] to
reflect any ``this'' changes. */
- arg2 = value_from_longest (lookup_pointer_type(value_type (temp)),
- value_arch (temp),
+ ptr = lookup_pointer_type (value_type (temp),
+ ptr_size (value_arch (temp)));
+ arg2 = value_from_longest (ptr, value_arch (temp),
value_address (temp)
+ value_embedded_offset (temp));
argvec[1] = arg2; /* the ``this'' pointer */
@@ -1664,9 +1668,11 @@ evaluate_subexp_standard (struct type *e
if (real_type)
{
if (TYPE_CODE (type) == TYPE_CODE_PTR)
- real_type = lookup_pointer_type (real_type);
+ real_type = lookup_pointer_type (real_type,
+ TYPE_LENGTH (type));
else
- real_type = lookup_reference_type (real_type);
+ real_type = lookup_reference_type (real_type,
+ TYPE_LENGTH (type));
arg1 = value_cast (real_type, arg1);
}
@@ -1712,16 +1718,21 @@ evaluate_subexp_standard (struct type *e
}
case TYPE_CODE_MEMBERPTR:
- /* Now, convert these values to an address. */
- arg1 = value_cast (lookup_pointer_type (TYPE_DOMAIN_TYPE (type)),
- arg1);
-
- mem_offset = value_as_long (arg2);
-
- arg3 = value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
- value_arch (arg1),
- value_as_long (arg1) + mem_offset);
- return value_ind (arg3);
+ {
+ /* Now, convert these values to an address. */
+ struct type *ptr;
+ ptr = lookup_pointer_type (TYPE_DOMAIN_TYPE (type),
+ ptr_size (value_arch (arg1)));
+ arg1 = value_cast (ptr, arg1);
+
+ mem_offset = value_as_long (arg2);
+
+ ptr = lookup_pointer_type (TYPE_TARGET_TYPE (type),
+ ptr_size (value_arch (arg1)));
+ arg3 = value_from_pointer (ptr, value_arch (arg1),
+ value_as_long (arg1) + mem_offset);
+ return value_ind (arg3);
+ }
default:
error (_("non-pointer-to-member value used in pointer-to-member construct"));
@@ -2584,7 +2595,8 @@ evaluate_subexp_for_address (struct expr
case UNOP_MEMVAL:
(*pos) += 3;
- return value_cast (lookup_pointer_type (exp->elts[pc + 1].type),
+ return value_cast (lookup_pointer_type (exp->elts[pc + 1].type,
+ ptr_size (exp->gdbarch)),
evaluate_subexp (NULL_TYPE, exp, pos, noside));
case OP_VAR_VALUE:
@@ -2598,8 +2610,8 @@ evaluate_subexp_for_address (struct expr
(*pos) += 4;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
- struct type *type =
- lookup_pointer_type (SYMBOL_TYPE (var));
+ struct type *type = lookup_pointer_type (SYMBOL_TYPE (var),
+ ptr_size (exp->gdbarch));
enum address_class sym_class = SYMBOL_CLASS (var);
if (sym_class == LOC_CONST
@@ -2633,10 +2645,12 @@ evaluate_subexp_for_address (struct expr
struct type *type = check_typedef (value_type (x));
if (VALUE_LVAL (x) == lval_memory || value_must_coerce_to_target (x))
- return value_zero (lookup_pointer_type (value_type (x)),
+ return value_zero (lookup_pointer_type (value_type (x),
+ ptr_size (exp->gdbarch)),
exp->gdbarch, not_lval);
else if (TYPE_CODE (type) == TYPE_CODE_REF)
- return value_zero (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
+ return value_zero (lookup_pointer_type (TYPE_TARGET_TYPE (type),
+ ptr_size (exp->gdbarch)),
exp->gdbarch, not_lval);
else
error (_("Attempt to take address of value not located in memory."));
@@ -2682,7 +2696,8 @@ evaluate_subexp_with_coercion (struct ex
(*pos) += 4;
val = address_of_variable (var, exp->gdbarch,
exp->elts[pc + 1].block);
- return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
+ return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type),
+ ptr_size (exp->gdbarch)),
val);
}
/* FALLTHROUGH */
Index: gdb-head/gdb/f-exp.y
===================================================================
--- gdb-head.orig/gdb/f-exp.y
+++ gdb-head/gdb/f-exp.y
@@ -544,10 +544,12 @@ ptype : typebase
done = 1;
break;
case tp_pointer:
- follow_type = lookup_pointer_type (follow_type);
+ follow_type = lookup_pointer_type
+ (follow_type, ptr_size (parse_gdbarch));
break;
case tp_reference:
- follow_type = lookup_reference_type (follow_type);
+ follow_type = lookup_reference_type
+ (follow_type, ptr_size (parse_gdbarch));
break;
case tp_array:
array_size = pop_type_int ();
@@ -562,7 +564,8 @@ ptype : typebase
follow_type, range_type);
}
else
- follow_type = lookup_pointer_type (follow_type);
+ follow_type = lookup_pointer_type
+ (follow_type, ptr_size (parse_gdbarch));
break;
case tp_function:
follow_type = lookup_function_type (follow_type);
Index: gdb-head/gdb/findvar.c
===================================================================
--- gdb-head.orig/gdb/findvar.c
+++ gdb-head/gdb/findvar.c
@@ -467,7 +467,8 @@ read_var_value (struct symbol *var, stru
if (!argref)
return 0;
argref += SYMBOL_VALUE (var);
- ref = value_at (lookup_pointer_type (type), gdbarch, argref);
+ ref = value_at (lookup_pointer_type (type, ptr_size (gdbarch)),
+ gdbarch, argref);
addr = value_as_address (ref);
break;
}
@@ -498,8 +499,9 @@ read_var_value (struct symbol *var, stru
if (SYMBOL_CLASS (var) == LOC_REGPARM_ADDR)
{
- regval = value_from_register (lookup_pointer_type (type),
- gdbarch, regno, frame);
+ struct type *ptr_type;
+ ptr_type = lookup_pointer_type (type, ptr_size (gdbarch));
+ regval = value_from_register (ptr_type, gdbarch, regno, frame);
if (regval == NULL)
error (_("Value of register variable not available."));
Index: gdb-head/gdb/gnu-v2-abi.c
===================================================================
--- gdb-head.orig/gdb/gnu-v2-abi.c
+++ gdb-head/gdb/gnu-v2-abi.c
@@ -110,7 +110,7 @@ gnuv2_virtual_fn_field (struct value **a
This won't work right for multiple inheritance, but at least we
should do as well as GDB 3.x did. */
fcontext = TYPE_VPTR_BASETYPE (type);
- context = lookup_pointer_type (fcontext);
+ context = lookup_pointer_type (fcontext, ptr_size (gdbarch));
/* Now context is a pointer to the basetype containing the vtbl. */
if (TYPE_TARGET_TYPE (context) != type1)
{
@@ -175,7 +175,8 @@ gnuv2_virtual_fn_field (struct value **a
else
error (_("I'm confused: virtual function table has bad type"));
/* Reinstantiate the function pointer with the correct type. */
- deprecated_set_value_type (vfn, lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j)));
+ deprecated_set_value_type (vfn, lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j),
+ ptr_size (gdbarch)));
*arg1p = arg1;
return vfn;
Index: gdb-head/gdb/gnu-v3-abi.c
===================================================================
--- gdb-head.orig/gdb/gnu-v3-abi.c
+++ gdb-head/gdb/gnu-v3-abi.c
@@ -309,7 +309,7 @@ gnuv3_get_vtable (struct gdbarch *gdbarc
be large. */
/* Find the type "pointer to virtual table". */
- vtable_pointer_type = lookup_pointer_type (vtable_type);
+ vtable_pointer_type = lookup_pointer_type (vtable_type, ptr_size (gdbarch));
/* Load it from the start of the class. */
vtable_pointer_address = value_as_address (value_addr (container));
@@ -347,7 +347,7 @@ gnuv3_get_virtual_fn (struct gdbarch *gd
vfn = value_addr (vfn);
/* Cast the function pointer to the appropriate type. */
- vfn = value_cast (lookup_pointer_type (fntype), vfn);
+ vfn = value_cast (lookup_pointer_type (fntype, ptr_size (gdbarch)), vfn);
return vfn;
}
@@ -666,7 +666,7 @@ gnuv3_method_ptr_to_value (struct value
int vbit;
domain_type = TYPE_DOMAIN_TYPE (check_typedef (value_type (method_ptr)));
- final_type = lookup_pointer_type (domain_type);
+ final_type = lookup_pointer_type (domain_type, ptr_size (gdbarch));
method_type = TYPE_TARGET_TYPE (check_typedef (value_type (method_ptr)));
@@ -706,7 +706,8 @@ gnuv3_method_ptr_to_value (struct value
method_type, voffset);
}
else
- return value_from_pointer (lookup_pointer_type (method_type),
+ return value_from_pointer (lookup_pointer_type (method_type,
+ ptr_size (gdbarch)),
gdbarch, ptr_value);
}
Index: gdb-head/gdb/infcall.c
===================================================================
--- gdb-head.orig/gdb/infcall.c
+++ gdb-head/gdb/infcall.c
@@ -169,7 +169,7 @@ value_arg_coerce (struct gdbarch *gdbarc
}
break;
case TYPE_CODE_FUNC:
- type = lookup_pointer_type (type);
+ type = lookup_pointer_type (type, ptr_size (gdbarch));
break;
case TYPE_CODE_ARRAY:
/* Arrays are coerced to pointers to their first element, unless
@@ -177,7 +177,8 @@ value_arg_coerce (struct gdbarch *gdbarc
because they are passed by value. */
if (current_language->c_style_arrays)
if (!TYPE_VECTOR (type))
- type = lookup_pointer_type (TYPE_TARGET_TYPE (type));
+ type = lookup_pointer_type (TYPE_TARGET_TYPE (type),
+ ptr_size (gdbarch));
break;
case TYPE_CODE_UNDEF:
case TYPE_CODE_PTR:
@@ -671,11 +672,12 @@ call_function_by_hand (struct value *fun
if (lang_struct_return)
{
struct value **new_args;
+ struct type *ptr;
/* Add the new argument to the front of the argument list. */
new_args = xmalloc (sizeof (struct value *) * (nargs + 1));
- new_args[0] = value_from_pointer (lookup_pointer_type (values_type),
- gdbarch, struct_addr);
+ ptr = lookup_pointer_type (values_type, ptr_size (gdbarch));
+ new_args[0] = value_from_pointer (ptr, gdbarch, struct_addr);
memcpy (&new_args[1], &args[0], sizeof (struct value *) * nargs);
args = new_args;
nargs++;
Index: gdb-head/gdb/jv-exp.y
===================================================================
--- gdb-head.orig/gdb/jv-exp.y
+++ gdb-head/gdb/jv-exp.y
@@ -560,7 +560,7 @@ CastExpression:
expout->elts[base + i] = expout->elts[base + i + 3];
expout_ptr -= 3;
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
- type = lookup_pointer_type (type);
+ type = lookup_pointer_type (type, ptr_size (parse_gdbarch));
write_exp_elt_opcode (UNOP_CAST);
write_exp_elt_type (type);
write_exp_elt_opcode (UNOP_CAST);
Index: gdb-head/gdb/jv-lang.c
===================================================================
--- gdb-head.orig/gdb/jv-lang.c
+++ gdb-head/gdb/jv-lang.c
@@ -308,6 +308,7 @@ type_from_class (struct value *clas)
if (name[0] == '[')
{
+ struct type *ptr;
char *signature = name;
int namelen = java_demangled_signature_length (signature);
if (namelen > strlen (name))
@@ -318,7 +319,9 @@ type_from_class (struct value *clas)
temp = clas;
/* Set array element type. */
temp = value_struct_elt (&temp, NULL, "methods", NULL, "structure");
- deprecated_set_value_type (temp, lookup_pointer_type (value_type (clas)));
+ ptr = lookup_pointer_type (value_type (clas),
+ ptr_size (value_arch (clas)));
+ deprecated_set_value_type (temp, ptr);
TYPE_TARGET_TYPE (type) = type_from_class (temp);
}
@@ -481,7 +484,7 @@ java_link_class_type (struct type *type,
temp = value_struct_elt (&temp, NULL, "type", NULL, "structure");
ftype = type_from_class (temp);
if (TYPE_CODE (ftype) == TYPE_CODE_STRUCT)
- ftype = lookup_pointer_type (ftype);
+ ftype = lookup_pointer_type (ftype, ptr_size (value_arch (clas)));
TYPE_FIELD_TYPE (type, i) = ftype;
}
}
@@ -855,7 +858,8 @@ evaluate_subexp_java (struct type *expec
struct type *type;
type = type_from_class (java_class_from_object (arg1));
- arg1 = value_cast (lookup_pointer_type (type), arg1);
+ type = lookup_pointer_type (type, ptr_size (value_arch (arg1)));
+ arg1 = value_cast (type, arg1);
}
if (noside == EVAL_SKIP)
goto nosideret;
@@ -895,7 +899,8 @@ evaluate_subexp_java (struct type *expec
deprecated_set_value_type (temp, value_type (clas));
el_type = type_from_class (temp);
if (TYPE_CODE (el_type) == TYPE_CODE_STRUCT)
- el_type = lookup_pointer_type (el_type);
+ el_type
+ = lookup_pointer_type (el_type, ptr_size (value_arch (clas)));
if (noside == EVAL_AVOID_SIDE_EFFECTS)
return value_zero (el_type, value_arch (arg1), VALUE_LVAL (arg1));
Index: gdb-head/gdb/jv-valprint.c
===================================================================
--- gdb-head.orig/gdb/jv-valprint.c
+++ gdb-head/gdb/jv-valprint.c
@@ -59,7 +59,7 @@ java_value_print (struct value *val, str
if (obj_addr != 0)
{
type = type_from_class (java_class_from_object (val));
- type = lookup_pointer_type (type);
+ type = lookup_pointer_type (type, ptr_size (gdbarch));
val = value_at (type, gdbarch, address);
}
Index: gdb-head/gdb/mdebugread.c
===================================================================
--- gdb-head.orig/gdb/mdebugread.c
+++ gdb-head/gdb/mdebugread.c
@@ -745,7 +745,7 @@ parse_symbol (SYMR *sh, union aux_ext *a
patch up the type and make it void*
instead. (davidm@azstarnet.com)
*/
- t = make_pointer_type (t, NULL);
+ t = lookup_pointer_type (t, ptr_size (gdbarch));
}
}
b = top_stack->cur_block;
@@ -1801,6 +1801,7 @@ static int
upgrade_type (int fd, struct type **tpp, int tq, union aux_ext *ax, int bigend,
char *sym_name)
{
+ struct gdbarch *gdbarch = get_objfile_arch (current_objfile);
int off;
struct type *t;
@@ -1815,7 +1816,7 @@ upgrade_type (int fd, struct type **tpp,
switch (tq)
{
case tqPtr:
- t = lookup_pointer_type (*tpp);
+ t = lookup_pointer_type (*tpp, ptr_size (gdbarch));
*tpp = t;
return 0;
Index: gdb-head/gdb/objc-lang.c
===================================================================
--- gdb-head.orig/gdb/objc-lang.c
+++ gdb-head/gdb/objc-lang.c
@@ -210,7 +210,7 @@ value_nsstring (struct gdbarch *gdbarch,
if (sym == NULL)
type = builtin_type (gdbarch)->builtin_data_ptr;
else
- type = lookup_pointer_type(SYMBOL_TYPE (sym));
+ type = lookup_pointer_type (SYMBOL_TYPE (sym), ptr_size (gdbarch));
deprecated_set_value_type (nsstringValue, type);
return nsstringValue;
Index: gdb-head/gdb/p-exp.y
===================================================================
--- gdb-head.orig/gdb/p-exp.y
+++ gdb-head/gdb/p-exp.y
@@ -747,7 +747,8 @@ type : ptype
typebase /* Implements (approximately): (type-qualifier)* type-specifier */
: '^' typebase
- { $$ = lookup_pointer_type ($2); }
+ { $$ = lookup_pointer_type
+ ($2, ptr_size (parse_gdbarch)); }
| TYPENAME
{ $$ = $1.type; }
| STRUCT name
Index: gdb-head/gdb/parse.c
===================================================================
--- gdb-head.orig/gdb/parse.c
+++ gdb-head/gdb/parse.c
@@ -1289,7 +1289,8 @@ follow_types (struct type *follow_type)
make_addr_class = pop_type_int ();
break;
case tp_pointer:
- follow_type = lookup_pointer_type (follow_type);
+ follow_type = lookup_pointer_type (follow_type,
+ ptr_size (parse_gdbarch));
if (make_const)
follow_type = make_cv_type (make_const,
TYPE_VOLATILE (follow_type),
@@ -1305,7 +1306,8 @@ follow_types (struct type *follow_type)
make_addr_class = 0;
break;
case tp_reference:
- follow_type = lookup_reference_type (follow_type);
+ follow_type = lookup_reference_type (follow_type,
+ ptr_size (parse_gdbarch));
if (make_const)
follow_type = make_cv_type (make_const,
TYPE_VOLATILE (follow_type),
Index: gdb-head/gdb/printcmd.c
===================================================================
--- gdb-head.orig/gdb/printcmd.c
+++ gdb-head/gdb/printcmd.c
@@ -1381,7 +1381,8 @@ x_command (char *exp, int from_tty)
/* Make last address examined available to the user as $_. Use
the correct pointer type. */
struct type *pointer_type
- = lookup_pointer_type (value_type (last_examine_value));
+ = lookup_pointer_type (value_type (last_examine_value),
+ ptr_size (last_examine_arch));
set_internalvar (lookup_internalvar ("_"),
value_from_pointer (pointer_type,
last_examine_arch,
Index: gdb-head/gdb/sparc-tdep.c
===================================================================
--- gdb-head.orig/gdb/sparc-tdep.c
+++ gdb-head/gdb/sparc-tdep.c
@@ -419,6 +419,8 @@ sparc32_store_arguments (struct regcache
if (sparc_structure_or_union_p (type)
|| (sparc_floating_p (type) && len == 16))
{
+ struct type *p;
+
/* Structure, Union and Quad-Precision Arguments. */
sp -= len;
@@ -427,8 +429,8 @@ sparc32_store_arguments (struct regcache
sp &= ~0x7;
write_memory (sp, value_contents (args[i]), len);
- args[i] = value_from_pointer (lookup_pointer_type (type),
- value_arch (args[i]), sp);
+ p = lookup_pointer_type (type, ptr_size (value_arch (args[i])));
+ args[i] = value_from_pointer (p, value_arch (args[i]), sp);
num_elements++;
}
else if (sparc_floating_p (type))
Index: gdb-head/gdb/sparc64-tdep.c
===================================================================
--- gdb-head.orig/gdb/sparc64-tdep.c
+++ gdb-head/gdb/sparc64-tdep.c
@@ -717,6 +717,8 @@ sparc64_store_arguments (struct regcache
}
else
{
+ struct type *p;
+
/* The psABI says that "Structures or unions larger than
sixteen bytes are copied by the caller and passed
indirectly; the caller will pass the address of a
@@ -733,8 +735,8 @@ sparc64_store_arguments (struct regcache
sp &= ~0xf;
write_memory (sp, value_contents (args[i]), len);
- args[i] = value_from_pointer (lookup_pointer_type (type),
- value_arch (args[i]), sp);
+ p = lookup_pointer_type (type, ptr_size (value_arch (args[i])));
+ args[i] = value_from_pointer (p, value_arch (args[i]), sp);
num_elements++;
}
}
Index: gdb-head/gdb/typeprint.c
===================================================================
--- gdb-head.orig/gdb/typeprint.c
+++ gdb-head/gdb/typeprint.c
@@ -145,9 +145,11 @@ whatis_exp (char *exp, int show)
if (real_type)
{
if (TYPE_CODE (type) == TYPE_CODE_PTR)
- real_type = lookup_pointer_type (real_type);
+ real_type = lookup_pointer_type (real_type,
+ TYPE_LENGTH (type));
else
- real_type = lookup_reference_type (real_type);
+ real_type = lookup_reference_type (real_type,
+ TYPE_LENGTH (type));
}
}
else if (TYPE_CODE (type) == TYPE_CODE_CLASS)
Index: gdb-head/gdb/value.c
===================================================================
--- gdb-head.orig/gdb/value.c
+++ gdb-head/gdb/value.c
@@ -1880,8 +1880,9 @@ value_fn_field (struct value **arg1p, st
if (arg1p)
{
if (type != value_type (*arg1p))
- *arg1p = value_ind (value_cast (lookup_pointer_type (type),
- value_addr (*arg1p)));
+ *arg1p = value_ind (value_cast
+ (lookup_pointer_type (type, ptr_size (gdbarch)),
+ value_addr (*arg1p)));
/* Move the `this' pointer according to the offset.
VALUE_OFFSET (*arg1p) += offset;
Index: gdb-head/gdb/linux-tdep.c
===================================================================
--- gdb-head.orig/gdb/linux-tdep.c
+++ gdb-head/gdb/linux-tdep.c
@@ -42,7 +42,8 @@ linux_get_siginfo_type (struct gdbarch *
long_type = init_type (TYPE_CODE_INT,
gdbarch_long_bit (gdbarch) / HOST_CHAR_BIT,
0, "long", NULL);
- void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
+ void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void,
+ ptr_size (gdbarch));
/* sival_t */
sigval_type = init_composite_type (NULL, TYPE_CODE_UNION);
Index: gdb-head/gdb/python/python-type.c
===================================================================
--- gdb-head.orig/gdb/python/python-type.c
+++ gdb-head/gdb/python/python-type.c
@@ -258,7 +258,7 @@ typy_pointer (PyObject *self, PyObject *
TRY_CATCH (except, RETURN_MASK_ALL)
{
- type = lookup_pointer_type (type);
+ type = lookup_pointer_type (type, ptr_size (python_gdbarch));
}
GDB_PY_HANDLE_EXCEPTION (except);
@@ -274,7 +274,7 @@ typy_reference (PyObject *self, PyObject
TRY_CATCH (except, RETURN_MASK_ALL)
{
- type = lookup_reference_type (type);
+ type = lookup_reference_type (type, ptr_size (python_gdbarch));
}
GDB_PY_HANDLE_EXCEPTION (except);
@@ -411,9 +411,9 @@ typy_lookup_type (struct demangle_compon
switch (demangled_type)
{
case DEMANGLE_COMPONENT_REFERENCE:
- return lookup_reference_type (type);
+ return lookup_reference_type (type, ptr_size (python_gdbarch));
case DEMANGLE_COMPONENT_POINTER:
- return lookup_pointer_type (type);
+ return lookup_pointer_type (type, ptr_size (python_gdbarch));
case DEMANGLE_COMPONENT_CONST:
return make_cv_type (1, 0, type, NULL);
case DEMANGLE_COMPONENT_VOLATILE:
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com