summaryrefslogtreecommitdiff
path: root/gdb/gdbtypes.h
diff options
context:
space:
mode:
authorDoug Evans <xdje42@gmail.com>2015-01-31 21:40:57 -0800
committerDoug Evans <xdje42@gmail.com>2015-01-31 21:40:57 -0800
commitae6ae97502b183d0cdb9c298a60fa05240f230bf (patch)
tree21c2fcba0eba7afd4d1ac80e98ec2dd21698fcd1 /gdb/gdbtypes.h
parent09e2d7c72040dd2d1833c140b5f04a85bc3f6a0f (diff)
Move vptr_{fieldno,basetype} out of main_type, and update everything accordingly.
Every type has to pay the price in memory usage for their presence. The proper place for them is in the type_specific field which exists for this purpose. gdb/ChangeLog: * dwarf2read.c (process_structure_scope): Update setting of TYPE_VPTR_BASETYPE, TYPE_VPTR_FIELDNO. * gdbtypes.c (internal_type_vptr_fieldno): New function. (set_type_vptr_fieldno): New function. (internal_type_vptr_basetype): New function. (set_type_vptr_basetype): New function. (get_vptr_fieldno): Update setting of TYPE_VPTR_FIELDNO, TYPE_VPTR_BASETYPE. (allocate_cplus_struct_type): Initialize vptr_fieldno. (recursive_dump_type): Printing of vptr_fieldno, vptr_basetype ... (print_cplus_stuff): ... moved here. (copy_type_recursive): Don't copy TYPE_VPTR_BASETYPE. * gdbtypes.h (struct main_type): Members vptr_fieldno, vptr_basetype moved to ... (struct cplus_struct_type): ... here. All uses updated. (TYPE_VPTR_FIELDNO, TYPE_VPTR_BASETYPE): Rewrite. (internal_type_vptr_fieldno, set_type_vptr_fieldno): Declare. (internal_type_vptr_basetype, set_type_vptr_basetype): Declare. * stabsread.c (read_tilde_fields): Update setting of TYPE_VPTR_FIELDNO, TYPE_VPTR_BASETYPE. gdb/testsuite/ChangeLog: * gdb.base/maint.exp <maint print type argc>: Update expected output.
Diffstat (limited to 'gdb/gdbtypes.h')
-rw-r--r--gdb/gdbtypes.h50
1 files changed, 27 insertions, 23 deletions
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 50ffef314d..7ca44f0179 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -507,19 +507,6 @@ struct main_type
short nfields;
- /* * Field number of the virtual function table pointer in
- VPTR_BASETYPE. If -1, we were unable to find the virtual
- function table pointer in initial symbol reading, and
- get_vptr_fieldno should be called to find it if possible.
- get_vptr_fieldno will update this field if possible. Otherwise
- the value is left at -1.
-
- Unused if this type does not have virtual functions.
-
- This field appears at this location because it packs nicely here. */
-
- short vptr_fieldno;
-
/* * Name of this type, or NULL if none.
This is used for printing only, except by poorly designed C++
@@ -676,14 +663,6 @@ struct main_type
} flds_bnds;
- /* * For types with virtual functions (TYPE_CODE_STRUCT),
- VPTR_BASETYPE is the base class which defined the virtual
- function table pointer.
-
- Unused otherwise. */
-
- struct type *vptr_basetype;
-
/* * Slot to point to additional language-specific fields of this
type. */
@@ -806,6 +785,22 @@ struct cplus_struct_type
short n_baseclasses;
+ /* * Field number of the virtual function table pointer in VPTR_BASETYPE.
+ All access to this field must be through TYPE_VPTR_FIELDNO as one
+ thing it does is check whether the field has been initialized.
+ Initially TYPE_RAW_CPLUS_SPECIFIC has the value of cplus_struct_default,
+ which for portability reasons doesn't initialize this field.
+ TYPE_VPTR_FIELDNO returns -1 for this case.
+
+ If -1, we were unable to find the virtual function table pointer in
+ initial symbol reading, and get_vptr_fieldno should be called to find
+ it if possible. get_vptr_fieldno will update this field if possible.
+ Otherwise the value is left at -1.
+
+ Unused if this type does not have virtual functions. */
+
+ short vptr_fieldno;
+
/* * Number of methods with unique names. All overloaded methods
with the same name count only once. */
@@ -827,6 +822,10 @@ struct cplus_struct_type
unsigned int is_java : 1;
+ /* * The base class which defined the virtual function table pointer. */
+
+ struct type *vptr_basetype;
+
/* * For derived classes, the number of base classes is given by
n_baseclasses and virtual_field_bits is a bit vector containing
one bit per base class. If the base class is virtual, the
@@ -1243,8 +1242,13 @@ extern void allocate_gnat_aux_type (struct 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_VPTR_FIELDNO(thistype) TYPE_MAIN_TYPE(thistype)->vptr_fieldno
+extern int internal_type_vptr_fieldno (struct type *);
+extern void set_type_vptr_fieldno (struct type *, int);
+extern struct type *internal_type_vptr_basetype (struct type *);
+extern void set_type_vptr_basetype (struct type *, struct type *);
+#define TYPE_VPTR_FIELDNO(thistype) internal_type_vptr_fieldno (thistype)
+#define TYPE_VPTR_BASETYPE(thistype) internal_type_vptr_basetype (thistype)
+
#define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields
#define TYPE_SPECIFIC_FIELD(thistype) \
TYPE_MAIN_TYPE(thistype)->type_specific_field