From: Doug Evans Date: Sun, 1 Feb 2015 05:21:01 +0000 (-0800) Subject: Move TYPE_SELF_TYPE into new field type_specific. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=09e2d7c72040dd2d1833c140b5f04a85bc3f6a0f;p=binutils-gdb.git Move TYPE_SELF_TYPE into new field type_specific. This patch moves TYPE_SELF_TYPE into new field type_specific.self_type for MEMBERPTR,METHODPTR types, and into type_specific.func_stuff for METHODs, and then updates everything to use that. TYPE_CODE_METHOD could share some things with TYPE_CODE_FUNC (e.g. TYPE_NO_RETURN) and it seemed simplest to keep them together. Moving TYPE_SELF_TYPE into type_specific.func_stuff for TYPE_CODE_METHOD is also nice because when we allocate space for function types we assume they're TYPE_CODE_FUNCs. If TYPE_CODE_METHODs don't need or use that space then that space would be wasted, and cleaning that up would involve more invasive changes. In order to catch errant uses I've added accessor functions that do some checking. One can no longer assign to TYPE_SELF_TYPE like this: TYPE_SELF_TYPE (foo) = bar; One instead has to do: set_type_self_type (foo, bar); But I've left reading of the type to the macro: bar = TYPE_SELF_TYPE (foo); In order to discourage bypassing the TYPE_SELF_TYPE macro I've named the underlying function that implements it internal_type_self_type. While testing this I found the stabs reader leaving methods as TYPE_CODE_FUNCs, hitting my newly added asserts. Since the dwarf reader smashes functions to methods (via smash_to_method) I've done a similar thing for stabs. gdb/ChangeLog: * cp-valprint.c (cp_find_class_member): Rename parameter domain_p to self_p. (cp_print_class_member): Rename local domain to self_type. * dwarf2read.c (quirk_gcc_member_function_pointer): Rename local domain_type to self_type. (set_die_type) : Handle TYPE_CODE_METHODPTR, TYPE_CODE_MEMBERPTR, TYPE_CODE_METHOD. * gdb-gdb.py (StructMainTypePrettyPrinter): Handle TYPE_SPECIFIC_SELF_TYPE. * gdbtypes.c (internal_type_self_type): New function. (set_type_self_type): New function. (smash_to_memberptr_type): Rename parameter domain to self_type. Update setting of TYPE_SELF_TYPE. (smash_to_methodptr_type): Update setting of TYPE_SELF_TYPE. (smash_to_method_type): Rename parameter domain to self_type. Update setting of TYPE_SELF_TYPE. (check_stub_method): Call smash_to_method_type. (recursive_dump_type): Handle TYPE_SPECIFIC_SELF_TYPE. (copy_type_recursive): Ditto. * gdbtypes.h (enum type_specific_kind): New value TYPE_SPECIFIC_SELF_TYPE. (struct main_type) : New member self_type. (struct cplus_struct_type) : Update comment. (TYPE_SELF_TYPE): Rewrite. (internal_type_self_type, set_type_self_type): Declare. * gnu-v3-abi.c (gnuv3_print_method_ptr): Rename local domain to self_type. (gnuv3_method_ptr_to_value): Rename local domain_type to self_type. * m2-typeprint.c (m2_range): Replace TYPE_SELF_TYPE with TYPE_TARGET_TYPE. * stabsread.c (read_member_functions): Mark methods with TYPE_CODE_METHOD, not TYPE_CODE_FUNC. Update setting of TYPE_SELF_TYPE. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6a790d38a58..f2d739e0719 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,39 @@ +2015-01-31 Doug Evans + + * cp-valprint.c (cp_find_class_member): Rename parameter domain_p + to self_p. + (cp_print_class_member): Rename local domain to self_type. + * dwarf2read.c (quirk_gcc_member_function_pointer): Rename local + domain_type to self_type. + (set_die_type) : Handle + TYPE_CODE_METHODPTR, TYPE_CODE_MEMBERPTR, TYPE_CODE_METHOD. + * gdb-gdb.py (StructMainTypePrettyPrinter): Handle + TYPE_SPECIFIC_SELF_TYPE. + * gdbtypes.c (internal_type_self_type): New function. + (set_type_self_type): New function. + (smash_to_memberptr_type): Rename parameter domain to self_type. + Update setting of TYPE_SELF_TYPE. + (smash_to_methodptr_type): Update setting of TYPE_SELF_TYPE. + (smash_to_method_type): Rename parameter domain to self_type. + Update setting of TYPE_SELF_TYPE. + (check_stub_method): Call smash_to_method_type. + (recursive_dump_type): Handle TYPE_SPECIFIC_SELF_TYPE. + (copy_type_recursive): Ditto. + * gdbtypes.h (enum type_specific_kind): New value + TYPE_SPECIFIC_SELF_TYPE. + (struct main_type) : New member self_type. + (struct cplus_struct_type) : Update comment. + (TYPE_SELF_TYPE): Rewrite. + (internal_type_self_type, set_type_self_type): Declare. + * gnu-v3-abi.c (gnuv3_print_method_ptr): Rename local domain to + self_type. + (gnuv3_method_ptr_to_value): Rename local domain_type to self_type. + * m2-typeprint.c (m2_range): Replace TYPE_SELF_TYPE with + TYPE_TARGET_TYPE. + * stabsread.c (read_member_functions): Mark methods with + TYPE_CODE_METHOD, not TYPE_CODE_FUNC. Update setting of + TYPE_SELF_TYPE. + 2015-01-31 Doug Evans * gdbtypes.h (TYPE_SELF_TYPE): Renamed from TYPE_DOMAIN_TYPE. diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 9eea7cec8ae..624976b0c05 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -709,27 +709,26 @@ cp_print_static_field (struct type *type, &opts, current_language); } - -/* Find the field in *DOMAIN, or its non-virtual base classes, with - bit offset OFFSET. Set *DOMAIN to the containing type and *FIELDNO +/* Find the field in *SELF, or its non-virtual base classes, with + bit offset OFFSET. Set *SELF to the containing type and *FIELDNO to the containing field number. If OFFSET is not exactly at the - start of some field, set *DOMAIN to NULL. */ + start of some field, set *SELF to NULL. */ static void -cp_find_class_member (struct type **domain_p, int *fieldno, +cp_find_class_member (struct type **self_p, int *fieldno, LONGEST offset) { - struct type *domain; + struct type *self; unsigned int i; unsigned len; - *domain_p = check_typedef (*domain_p); - domain = *domain_p; - len = TYPE_NFIELDS (domain); + *self_p = check_typedef (*self_p); + self = *self_p; + len = TYPE_NFIELDS (self); - for (i = TYPE_N_BASECLASSES (domain); i < len; i++) + for (i = TYPE_N_BASECLASSES (self); i < len; i++) { - LONGEST bitpos = TYPE_FIELD_BITPOS (domain, i); + LONGEST bitpos = TYPE_FIELD_BITPOS (self, i); QUIT; if (offset == bitpos) @@ -739,20 +738,20 @@ cp_find_class_member (struct type **domain_p, int *fieldno, } } - for (i = 0; i < TYPE_N_BASECLASSES (domain); i++) + for (i = 0; i < TYPE_N_BASECLASSES (self); i++) { - LONGEST bitpos = TYPE_FIELD_BITPOS (domain, i); - LONGEST bitsize = 8 * TYPE_LENGTH (TYPE_FIELD_TYPE (domain, i)); + LONGEST bitpos = TYPE_FIELD_BITPOS (self, i); + LONGEST bitsize = 8 * TYPE_LENGTH (TYPE_FIELD_TYPE (self, i)); if (offset >= bitpos && offset < bitpos + bitsize) { - *domain_p = TYPE_FIELD_TYPE (domain, i); - cp_find_class_member (domain_p, fieldno, offset - bitpos); + *self_p = TYPE_FIELD_TYPE (self, i); + cp_find_class_member (self_p, fieldno, offset - bitpos); return; } } - *domain_p = NULL; + *self_p = NULL; } void @@ -761,10 +760,10 @@ cp_print_class_member (const gdb_byte *valaddr, struct type *type, { enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type)); - /* VAL is a byte offset into the structure type DOMAIN. + /* VAL is a byte offset into the structure type SELF_TYPE. Find the name of the field for that offset and print it. */ - struct type *domain = TYPE_SELF_TYPE (type); + struct type *self_type = TYPE_SELF_TYPE (type); LONGEST val; int fieldno; @@ -788,20 +787,20 @@ cp_print_class_member (const gdb_byte *valaddr, struct type *type, return; } - cp_find_class_member (&domain, &fieldno, val << 3); + cp_find_class_member (&self_type, &fieldno, val << 3); - if (domain != NULL) + if (self_type != NULL) { const char *name; fputs_filtered (prefix, stream); - name = type_name_no_tag (domain); + name = type_name_no_tag (self_type); if (name) fputs_filtered (name, stream); else - c_type_print_base (domain, stream, 0, 0, &type_print_raw_options); + c_type_print_base (self_type, stream, 0, 0, &type_print_raw_options); fprintf_filtered (stream, "::"); - fputs_filtered (TYPE_FIELD_NAME (domain, fieldno), stream); + fputs_filtered (TYPE_FIELD_NAME (self_type, fieldno), stream); } else fprintf_filtered (stream, "%ld", (long) val); diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 56e82f53a75..36248f547a4 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -12997,7 +12997,7 @@ is_vtable_name (const char *name, struct dwarf2_cu *cu) static void quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile) { - struct type *pfn_type, *domain_type, *new_type; + struct type *pfn_type, *self_type, *new_type; /* Check for a structure with no name and two children. */ if (TYPE_CODE (type) != TYPE_CODE_STRUCT || TYPE_NFIELDS (type) != 2) @@ -13024,9 +13024,9 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile) || TYPE_CODE (TYPE_FIELD_TYPE (pfn_type, 0)) != TYPE_CODE_PTR) return; - domain_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (pfn_type, 0)); + self_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (pfn_type, 0)); new_type = alloc_type (objfile); - smash_to_method_type (new_type, domain_type, TYPE_TARGET_TYPE (pfn_type), + smash_to_method_type (new_type, self_type, TYPE_TARGET_TYPE (pfn_type), TYPE_FIELDS (pfn_type), TYPE_NFIELDS (pfn_type), TYPE_VARARGS (pfn_type)); smash_to_methodptr_type (type, new_type); @@ -22032,6 +22032,9 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) if (need_gnat_info (cu) && TYPE_CODE (type) != TYPE_CODE_FUNC && TYPE_CODE (type) != TYPE_CODE_FLT + && TYPE_CODE (type) != TYPE_CODE_METHODPTR + && TYPE_CODE (type) != TYPE_CODE_MEMBERPTR + && TYPE_CODE (type) != TYPE_CODE_METHOD && !HAVE_GNAT_AUX_INFO (type)) INIT_GNAT_SPECIFIC (type); diff --git a/gdb/gdb-gdb.py b/gdb/gdb-gdb.py index 9b8ac620e56..5cc045b703f 100644 --- a/gdb/gdb-gdb.py +++ b/gdb/gdb-gdb.py @@ -209,6 +209,8 @@ class StructMainTypePrettyPrinter: img = ("calling_convention = %d" % type_specific['func_stuff']['calling_convention']) # tail_call_list is not printed. + elif type_specific_kind == "TYPE_SPECIFIC_SELF_TYPE": + img = "self_type = %s" % type_specific['self_type'] else: img = ("type_specific = ??? (unknown type_secific_kind: %s)" % type_specific_kind) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index ad516c25070..0e72e1ba3e8 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1188,7 +1188,58 @@ init_vector_type (struct type *elt_type, int n) return array_type; } -/* Smash TYPE to be a type of pointers to members of DOMAIN with type +/* Internal routine called by TYPE_SELF_TYPE to return the type that TYPE + belongs to. In c++ this is the class of "this", but TYPE_THIS_TYPE is too + confusing. "self" is a common enough replacement for "this". + TYPE must be one of TYPE_CODE_METHODPTR, TYPE_CODE_MEMBERPTR, or + TYPE_CODE_METHOD. */ + +struct type * +internal_type_self_type (struct type *type) +{ + switch (TYPE_CODE (type)) + { + case TYPE_CODE_METHODPTR: + case TYPE_CODE_MEMBERPTR: + gdb_assert (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_SELF_TYPE); + return TYPE_MAIN_TYPE (type)->type_specific.self_type; + case TYPE_CODE_METHOD: + gdb_assert (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_FUNC); + return TYPE_MAIN_TYPE (type)->type_specific.func_stuff->self_type; + default: + gdb_assert_not_reached ("bad type"); + } +} + +/* Set the type of the class that TYPE belongs to. + In c++ this is the class of "this". + TYPE must be one of TYPE_CODE_METHODPTR, TYPE_CODE_MEMBERPTR, or + TYPE_CODE_METHOD. */ + +void +set_type_self_type (struct type *type, struct type *self_type) +{ + switch (TYPE_CODE (type)) + { + case TYPE_CODE_METHODPTR: + case TYPE_CODE_MEMBERPTR: + if (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE) + TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_SELF_TYPE; + gdb_assert (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_SELF_TYPE); + TYPE_MAIN_TYPE (type)->type_specific.self_type = self_type; + break; + case TYPE_CODE_METHOD: + if (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE) + INIT_FUNC_SPECIFIC (type); + gdb_assert (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_FUNC); + TYPE_MAIN_TYPE (type)->type_specific.func_stuff->self_type = self_type; + break; + default: + gdb_assert_not_reached ("bad type"); + } +} + +/* Smash TYPE to be a type of pointers to members of SELF_TYPE with type TO_TYPE. A member pointer is a wierd thing -- it amounts to a 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 @@ -1200,17 +1251,17 @@ init_vector_type (struct type *elt_type, int n) allocated. */ void -smash_to_memberptr_type (struct type *type, struct type *domain, +smash_to_memberptr_type (struct type *type, struct type *self_type, struct type *to_type) { smash_type (type); + TYPE_CODE (type) = TYPE_CODE_MEMBERPTR; TYPE_TARGET_TYPE (type) = to_type; - TYPE_SELF_TYPE (type) = domain; + set_type_self_type (type, self_type); /* Assume that a data member pointer is the same size as a normal pointer. */ TYPE_LENGTH (type) = gdbarch_ptr_bit (get_type_arch (to_type)) / TARGET_CHAR_BIT; - TYPE_CODE (type) = TYPE_CODE_MEMBERPTR; } /* Smash TYPE to be a type of pointer to methods type TO_TYPE. @@ -1223,13 +1274,13 @@ void smash_to_methodptr_type (struct type *type, struct type *to_type) { smash_type (type); + TYPE_CODE (type) = TYPE_CODE_METHODPTR; TYPE_TARGET_TYPE (type) = to_type; - TYPE_SELF_TYPE (type) = TYPE_SELF_TYPE (to_type); + set_type_self_type (type, TYPE_SELF_TYPE (to_type)); TYPE_LENGTH (type) = cplus_method_ptr_size (to_type); - TYPE_CODE (type) = TYPE_CODE_METHODPTR; } -/* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE. +/* Smash TYPE to be a type of method of SELF_TYPE 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 @@ -1237,19 +1288,19 @@ smash_to_methodptr_type (struct type *type, struct type *to_type) allocated. */ void -smash_to_method_type (struct type *type, struct type *domain, +smash_to_method_type (struct type *type, struct type *self_type, struct type *to_type, struct field *args, int nargs, int varargs) { smash_type (type); + TYPE_CODE (type) = TYPE_CODE_METHOD; TYPE_TARGET_TYPE (type) = to_type; - TYPE_SELF_TYPE (type) = domain; + set_type_self_type (type, self_type); 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; } /* Return a typename for a struct/union/enum type without "struct ", @@ -2311,13 +2362,12 @@ check_stub_method (struct type *type, int method_id, int signature_id) /* Now update the old "stub" type into a real type. */ mtype = TYPE_FN_FIELD_TYPE (f, signature_id); - TYPE_SELF_TYPE (mtype) = type; - TYPE_FIELDS (mtype) = argtypes; - TYPE_NFIELDS (mtype) = argcount; + /* MTYPE may currently be a function (TYPE_CODE_FUNC). + We want a method (TYPE_CODE_METHOD). */ + smash_to_method_type (mtype, type, TYPE_TARGET_TYPE (mtype), + argtypes, argcount, p[-2] == '.'); TYPE_STUB (mtype) = 0; TYPE_FN_FIELD_STUB (f, signature_id) = 0; - if (p[-2] == '.') - TYPE_VARARGS (mtype) = 1; xfree (demangled_name); } @@ -4051,6 +4101,12 @@ recursive_dump_type (struct type *type, int spaces) TYPE_CALLING_CONVENTION (type)); /* tail_call_list is not printed. */ break; + + case TYPE_SPECIFIC_SELF_TYPE: + printfi_filtered (spaces, "self_type "); + gdb_print_host_address (TYPE_SELF_TYPE (type), gdb_stdout); + puts_filtered ("\n"); + break; } if (spaces == 0) @@ -4243,6 +4299,11 @@ copy_type_recursive (struct objfile *objfile, case TYPE_SPECIFIC_GNAT_STUFF: INIT_GNAT_SPECIFIC (new_type); break; + case TYPE_SPECIFIC_SELF_TYPE: + set_type_self_type (new_type, + copy_type_recursive (objfile, TYPE_SELF_TYPE (type), + copied_types)); + break; default: gdb_assert_not_reached ("bad type_specific_kind"); } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 7f90ec6cd81..50ffef314d4 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -439,7 +439,7 @@ enum field_loc_kind /* * A discriminant to determine which field in the main_type.type_specific union is being used, if any. - For types such as TYPE_CODE_FLT or TYPE_CODE_FUNC, the use of this + For types such as TYPE_CODE_FLT, the use of this discriminant is really redundant, as we know from the type code which field is going to be used. As such, it would be possible to reduce the size of this enum in order to save a bit or two for @@ -453,7 +453,9 @@ enum type_specific_kind TYPE_SPECIFIC_CPLUS_STUFF, TYPE_SPECIFIC_GNAT_STUFF, TYPE_SPECIFIC_FLOATFORMAT, - TYPE_SPECIFIC_FUNC + /* Note: This is used by TYPE_CODE_FUNC and TYPE_CODE_METHOD. */ + TYPE_SPECIFIC_FUNC, + TYPE_SPECIFIC_SELF_TYPE }; /* * Main structure representing a type in GDB. @@ -678,13 +680,6 @@ struct main_type VPTR_BASETYPE is the base class which defined the virtual function table pointer. - For types that are pointer to member types (TYPE_CODE_METHODPTR, - TYPE_CODE_MEMBERPTR), VPTR_BASETYPE is the type that this pointer - is a member of. - - For method types (TYPE_CODE_METHOD), VPTR_BASETYPE is the aggregate - type that contains the method. - Unused otherwise. */ struct type *vptr_basetype; @@ -712,9 +707,15 @@ struct main_type const struct floatformat **floatformat; - /* * For TYPE_CODE_FUNC types, */ + /* * For TYPE_CODE_FUNC and TYPE_CODE_METHOD types. */ struct func_type *func_stuff; + + /* * For types that are pointer to member types (TYPE_CODE_METHODPTR, + TYPE_CODE_MEMBERPTR), SELF_TYPE is the type that this pointer + is a member of. */ + + struct type *self_type; } type_specific; /* * Contains a location description value for the current type. Evaluating @@ -904,7 +905,7 @@ struct cplus_struct_type (This comment used to say "The return value of the method", but that's wrong. The function type is - expected here, i.e. something with TYPE_CODE_FUNC, and + expected here, i.e. something with TYPE_CODE_METHOD, and *not* the return-value type). */ struct type *type; @@ -1014,7 +1015,7 @@ struct gnat_aux_type struct type* descriptive_type; }; -/* * For TYPE_CODE_FUNC types. */ +/* * For TYPE_CODE_FUNC and TYPE_CODE_METHOD types. */ struct func_type { @@ -1039,6 +1040,11 @@ struct func_type DW_TAG_GNU_call_site's exist in such function. */ struct call_site *tail_call_list; + + /* * For method types (TYPE_CODE_METHOD), the aggregate type that + contains the method. */ + + struct type *self_type; }; /* struct call_site_parameter can be referenced in callees by several ways. */ @@ -1232,8 +1238,12 @@ extern void allocate_gnat_aux_type (struct type *); /* C++ */ +#define TYPE_SELF_TYPE(thistype) internal_type_self_type (thistype) +/* Do not call this, use TYPE_SELF_TYPE. */ +extern struct type *internal_type_self_type (struct type *); +extern void set_type_self_type (struct type *, struct type *); + #define TYPE_VPTR_BASETYPE(thistype) TYPE_MAIN_TYPE(thistype)->vptr_basetype -#define TYPE_SELF_TYPE(thistype) TYPE_MAIN_TYPE(thistype)->vptr_basetype #define TYPE_VPTR_FIELDNO(thistype) TYPE_MAIN_TYPE(thistype)->vptr_fieldno #define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields #define TYPE_SPECIFIC_FIELD(thistype) \ @@ -1655,7 +1665,7 @@ extern struct type *lookup_memberptr_type (struct type *, struct type *); extern struct type *lookup_methodptr_type (struct type *); -extern void smash_to_method_type (struct type *type, struct type *domain, +extern void smash_to_method_type (struct type *type, struct type *self_type, struct type *to_type, struct field *args, int nargs, int varargs); diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index eddda4f4947..cdcb35463b1 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -584,8 +584,8 @@ gnuv3_print_method_ptr (const gdb_byte *contents, struct type *type, struct ui_file *stream) { - struct type *domain = TYPE_SELF_TYPE (type); - struct gdbarch *gdbarch = get_type_arch (domain); + struct type *self_type = TYPE_SELF_TYPE (type); + struct gdbarch *gdbarch = get_type_arch (self_type); CORE_ADDR ptr_value; LONGEST adjustment; int vbit; @@ -611,7 +611,7 @@ gnuv3_print_method_ptr (const gdb_byte *contents, to an index, as used in TYPE_FN_FIELD_VOFFSET. */ voffset = ptr_value / TYPE_LENGTH (vtable_ptrdiff_type (gdbarch)); - physname = gnuv3_find_method_in (domain, voffset, adjustment); + physname = gnuv3_find_method_in (self_type, voffset, adjustment); /* If we found a method, print that. We don't bother to disambiguate possible paths to the method based on the adjustment. */ @@ -709,17 +709,17 @@ gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr) struct gdbarch *gdbarch; const gdb_byte *contents = value_contents (method_ptr); CORE_ADDR ptr_value; - struct type *domain_type, *final_type, *method_type; + struct type *self_type, *final_type, *method_type; LONGEST adjustment; int vbit; - domain_type = TYPE_SELF_TYPE (check_typedef (value_type (method_ptr))); - final_type = lookup_pointer_type (domain_type); + self_type = TYPE_SELF_TYPE (check_typedef (value_type (method_ptr))); + final_type = lookup_pointer_type (self_type); method_type = TYPE_TARGET_TYPE (check_typedef (value_type (method_ptr))); /* Extract the pointer to member. */ - gdbarch = get_type_arch (domain_type); + gdbarch = get_type_arch (self_type); vbit = gnuv3_decode_method_ptr (gdbarch, contents, &ptr_value, &adjustment); /* First convert THIS to match the containing type of the pointer to diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c index 4e829381041..21bca390721 100644 --- a/gdb/m2-typeprint.c +++ b/gdb/m2-typeprint.c @@ -188,8 +188,12 @@ m2_range (struct type *type, struct ui_file *stream, int show, int level, const struct type_print_options *flags) { if (TYPE_HIGH_BOUND (type) == TYPE_LOW_BOUND (type)) - m2_print_type (TYPE_SELF_TYPE (type), "", stream, show, level, - flags); + { + /* FIXME: TYPE_TARGET_TYPE used to be TYPE_DOMAIN_TYPE but that was + wrong. Not sure if TYPE_TARGET_TYPE is correct though. */ + m2_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level, + flags); + } else { struct type *target = TYPE_TARGET_TYPE (type); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 1f46f757c8b..423c44211de 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -2376,14 +2376,21 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type, p++; } - /* If this is just a stub, then we don't have the real name here. */ + /* These are methods, not functions. */ + if (TYPE_CODE (new_sublist->fn_field.type) == TYPE_CODE_FUNC) + TYPE_CODE (new_sublist->fn_field.type) = TYPE_CODE_METHOD; + else + gdb_assert (TYPE_CODE (new_sublist->fn_field.type) + == TYPE_CODE_METHOD); + /* If this is just a stub, then we don't have the real name here. */ if (TYPE_STUB (new_sublist->fn_field.type)) { if (!TYPE_SELF_TYPE (new_sublist->fn_field.type)) - TYPE_SELF_TYPE (new_sublist->fn_field.type) = type; + set_type_self_type (new_sublist->fn_field.type, type); new_sublist->fn_field.is_stub = 1; } + new_sublist->fn_field.physname = savestring (*pp, p - *pp); *pp = p + 1;