aboutsummaryrefslogtreecommitdiff
path: root/gdb/cp-valprint.c
diff options
context:
space:
mode:
authorDoug Evans <xdje42@gmail.com>2015-01-31 21:21:01 -0800
committerDoug Evans <xdje42@gmail.com>2015-01-31 21:21:01 -0800
commit09e2d7c72040dd2d1833c140b5f04a85bc3f6a0f (patch)
treeaf43cb916c40daf7667f517c615abe47251046ec /gdb/cp-valprint.c
parent4bfb94b8648cebad2683d24ebe033ef539df1dbb (diff)
downloadgdb-09e2d7c72040dd2d1833c140b5f04a85bc3f6a0f.zip
gdb-09e2d7c72040dd2d1833c140b5f04a85bc3f6a0f.tar.gz
gdb-09e2d7c72040dd2d1833c140b5f04a85bc3f6a0f.tar.bz2
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) <need_gnat_info>: 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) <type_specific>: New member self_type. (struct cplus_struct_type) <fn_field.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.
Diffstat (limited to 'gdb/cp-valprint.c')
-rw-r--r--gdb/cp-valprint.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 9eea7ce..624976b 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);