This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 16/18] fix up gdbtypes.h
- From: Ondrej Oprala <ooprala at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tromey at redhat dot com>
- Date: Wed, 9 Oct 2013 19:17:31 +0200
- Subject: [PATCH 16/18] fix up gdbtypes.h
- Authentication-results: sourceware.org; auth=none
- References: <1381339053-14519-1-git-send-email-ooprala at redhat dot com>
From: Tom Tromey <tromey@redhat.com>
* gdbtypes.h : Unbundle structures nested in union flds_bnds.
---
gdb/ChangeLog | 4 +
gdb/gdbtypes.h | 436 +++++++++++++++++++++++++++++----------------------------
2 files changed, 226 insertions(+), 214 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7cbf071..7552cc7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -17,6 +17,10 @@
2013-10-09 Tom Tromey <tromey@redhat.com>
+ * gdbtypes.h : Unbundle structures nested in union flds_bnds.
+
+2013-10-09 Tom Tromey <tromey@redhat.com>
+
* common/vec.c (vec_p_preserve) : Add typedefs to struct vec_prefix *.
* common/vec.h (VEC_OP) : Add typedefs to VEC(T).
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 5e8d1e7..25091e4 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -396,6 +396,91 @@ enum type_specific_kind
TYPE_SPECIFIC_FUNC
};
+union type_owner
+{
+ struct objfile *objfile;
+ struct gdbarch *gdbarch;
+};
+
+union field_location
+{
+ /* Position of this field, counting in bits from start of
+ containing structure. For gdbarch_bits_big_endian=1
+ targets, it is the bit offset to the MSB. For
+ gdbarch_bits_big_endian=0 targets, it is the bit offset to
+ the LSB. */
+
+ int bitpos;
+
+ /* Enum value. */
+ LONGEST enumval;
+
+ /* For a static field, if TYPE_FIELD_STATIC_HAS_ADDR then physaddr
+ is the location (in the target) of the static field.
+ Otherwise, physname is the mangled label of the static field. */
+
+ CORE_ADDR physaddr;
+ const char *physname;
+
+ /* The field location can be computed by evaluating the following DWARF
+ block. Its DATA is allocated on objfile_obstack - no CU load is
+ needed to access it. */
+
+ struct dwarf2_locexpr_baton *dwarf_block;
+};
+
+struct field
+{
+ union field_location loc;
+
+ /* For a function or member type, this is 1 if the argument is marked
+ artificial. Artificial arguments should not be shown to the
+ user. For TYPE_CODE_RANGE it is set if the specific bound is not
+ defined. */
+ unsigned int artificial : 1;
+
+ /* Discriminant for union field_location. */
+ ENUM_BITFIELD(field_loc_kind) loc_kind : 3;
+
+ /* Size of this field, in bits, or zero if not packed.
+ If non-zero in an array type, indicates the element size in
+ bits (used only in Ada at the moment).
+ For an unpacked field, the field's type's length
+ says how many bytes the field occupies. */
+
+ unsigned int bitsize : 28;
+
+ /* In a struct or union type, type of this field.
+ In a function or member type, type of this argument.
+ In an array type, the domain-type of the array. */
+
+ struct type *type;
+
+ /* Name of field, value or argument.
+ NULL for range bounds, array domains, and member function
+ arguments. */
+
+ const char *name;
+};
+
+struct range_bounds
+{
+ /* Low bound of range. */
+
+ LONGEST low;
+
+ /* High bound of range. */
+
+ LONGEST high;
+
+ /* Flags indicating whether the values of low and high are
+ valid. When true, the respective range value is
+ undefined. Currently used only for FORTRAN arrays. */
+
+ char low_undefined;
+ char high_undefined;
+};
+
/* This structure is space-critical.
Its layout has been tweaked to reduce the space used. */
@@ -487,11 +572,7 @@ struct main_type
major overhaul of the internal type system, it can't be avoided
for now. */
- union type_owner
- {
- struct objfile *objfile;
- struct gdbarch *gdbarch;
- } owner;
+ union type_owner owner;
/* For a pointer type, describes the type of object pointed to.
For an array type, describes the type of the elements.
@@ -523,86 +604,11 @@ struct main_type
union
{
- struct field
- {
- union field_location
- {
- /* Position of this field, counting in bits from start of
- containing structure. For gdbarch_bits_big_endian=1
- targets, it is the bit offset to the MSB. For
- gdbarch_bits_big_endian=0 targets, it is the bit offset to
- the LSB. */
-
- int bitpos;
-
- /* Enum value. */
- LONGEST enumval;
-
- /* For a static field, if TYPE_FIELD_STATIC_HAS_ADDR then physaddr
- is the location (in the target) of the static field.
- Otherwise, physname is the mangled label of the static field. */
-
- CORE_ADDR physaddr;
- const char *physname;
-
- /* The field location can be computed by evaluating the following DWARF
- block. Its DATA is allocated on objfile_obstack - no CU load is
- needed to access it. */
-
- struct dwarf2_locexpr_baton *dwarf_block;
- }
- loc;
-
- /* For a function or member type, this is 1 if the argument is marked
- artificial. Artificial arguments should not be shown to the
- user. For TYPE_CODE_RANGE it is set if the specific bound is not
- defined. */
- unsigned int artificial : 1;
-
- /* Discriminant for union field_location. */
- ENUM_BITFIELD(field_loc_kind) loc_kind : 3;
-
- /* Size of this field, in bits, or zero if not packed.
- If non-zero in an array type, indicates the element size in
- bits (used only in Ada at the moment).
- For an unpacked field, the field's type's length
- says how many bytes the field occupies. */
-
- unsigned int bitsize : 28;
-
- /* In a struct or union type, type of this field.
- In a function or member type, type of this argument.
- In an array type, the domain-type of the array. */
-
- struct type *type;
-
- /* Name of field, value or argument.
- NULL for range bounds, array domains, and member function
- arguments. */
-
- const char *name;
- } *fields;
+ struct field *fields;
/* Union member used for range types. */
- struct range_bounds
- {
- /* Low bound of range. */
-
- LONGEST low;
-
- /* High bound of range. */
-
- LONGEST high;
-
- /* Flags indicating whether the values of low and high are
- valid. When true, the respective range value is
- undefined. Currently used only for FORTRAN arrays. */
-
- char low_undefined;
- char high_undefined;
-
- } *bounds;
+ struct range_bounds *bounds;
} flds_bnds;
@@ -711,6 +717,103 @@ struct type
#define NULL_TYPE ((struct type *) 0)
+struct fn_field
+{
+ /* If is_stub is clear, this is the mangled name which we can
+ look up to find the address of the method (FIXME: it would
+ be cleaner to have a pointer to the struct symbol here
+ instead). */
+
+ /* If is_stub is set, this is the portion of the mangled
+ name which specifies the arguments. For example, "ii",
+ if there are two int arguments, or "" if there are no
+ arguments. See gdb_mangle_name for the conversion from this
+ format to the one used if is_stub is clear. */
+
+ const char *physname;
+
+ /* The function type for the method.
+ (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 *not* the return-value type). */
+
+ struct type *type;
+
+ /* For virtual functions.
+ First baseclass that defines this virtual function. */
+
+ struct type *fcontext;
+
+ /* Attributes. */
+
+ unsigned int is_const:1;
+ unsigned int is_volatile:1;
+ unsigned int is_private:1;
+ unsigned int is_protected:1;
+ unsigned int is_public:1;
+ unsigned int is_abstract:1;
+ unsigned int is_static:1;
+ unsigned int is_final:1;
+ unsigned int is_synchronized:1;
+ unsigned int is_native:1;
+ unsigned int is_artificial:1;
+
+ /* A stub method only has some fields valid (but they are enough
+ to reconstruct the rest of the fields). */
+ unsigned int is_stub:1;
+
+ /* True if this function is a constructor, false
+ otherwise. */
+ unsigned int is_constructor : 1;
+
+ /* Unused. */
+ unsigned int dummy:3;
+
+ /* Index into that baseclass's virtual function table,
+ minus 2; else if static: VOFFSET_STATIC; else: 0. */
+
+ unsigned int voffset:16;
+
+#define VOFFSET_STATIC 1
+
+};
+
+/* For classes, structures, and unions, a description of each field,
+ which consists of an overloaded name, followed by the types of
+ arguments that the method expects, and then the name after it
+ has been renamed to make it distinct.
+
+ fn_fieldlists points to an array of nfn_fields of these. */
+
+struct fn_fieldlist
+{
+ /* The overloaded name.
+ This is generally allocated in the objfile's obstack.
+ However stabsread.c sometimes uses malloc. */
+
+ const char *name;
+
+ /* The number of methods with this name. */
+
+ int length;
+
+ /* The list of methods. */
+
+ struct fn_field *fn_fields;
+};
+
+/* typedefs defined inside this class. TYPEDEF_FIELD points to an array of
+ TYPEDEF_FIELD_COUNT elements. */
+struct typedef_field
+{
+ /* Unqualified name to be prefixed by owning class qualified name. */
+ const char *name;
+
+ /* Type this typedef named NAME represents. */
+ struct type *type;
+};
+
/* C++ language-specific information for TYPE_CODE_STRUCT and TYPE_CODE_UNION
nodes. */
@@ -775,106 +878,9 @@ struct cplus_struct_type
B_TYPE *ignore_field_bits;
- /* For classes, structures, and unions, a description of each field,
- which consists of an overloaded name, followed by the types of
- arguments that the method expects, and then the name after it
- has been renamed to make it distinct.
-
- fn_fieldlists points to an array of nfn_fields of these. */
-
- struct fn_fieldlist
- {
-
- /* The overloaded name.
- This is generally allocated in the objfile's obstack.
- However stabsread.c sometimes uses malloc. */
-
- const char *name;
-
- /* The number of methods with this name. */
-
- int length;
-
- /* The list of methods. */
-
- struct fn_field
- {
+ struct fn_fieldlist *fn_fieldlists;
- /* If is_stub is clear, this is the mangled name which we can
- look up to find the address of the method (FIXME: it would
- be cleaner to have a pointer to the struct symbol here
- instead). */
-
- /* If is_stub is set, this is the portion of the mangled
- name which specifies the arguments. For example, "ii",
- if there are two int arguments, or "" if there are no
- arguments. See gdb_mangle_name for the conversion from this
- format to the one used if is_stub is clear. */
-
- const char *physname;
-
- /* The function type for the method.
- (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 *not* the return-value type). */
-
- struct type *type;
-
- /* For virtual functions.
- First baseclass that defines this virtual function. */
-
- struct type *fcontext;
-
- /* Attributes. */
-
- unsigned int is_const:1;
- unsigned int is_volatile:1;
- unsigned int is_private:1;
- unsigned int is_protected:1;
- unsigned int is_public:1;
- unsigned int is_abstract:1;
- unsigned int is_static:1;
- unsigned int is_final:1;
- unsigned int is_synchronized:1;
- unsigned int is_native:1;
- unsigned int is_artificial:1;
-
- /* A stub method only has some fields valid (but they are enough
- to reconstruct the rest of the fields). */
- unsigned int is_stub:1;
-
- /* True if this function is a constructor, false
- otherwise. */
- unsigned int is_constructor : 1;
-
- /* Unused. */
- unsigned int dummy:3;
-
- /* Index into that baseclass's virtual function table,
- minus 2; else if static: VOFFSET_STATIC; else: 0. */
-
- unsigned int voffset:16;
-
-#define VOFFSET_STATIC 1
-
- }
- *fn_fields;
-
- }
- *fn_fieldlists;
-
- /* typedefs defined inside this class. TYPEDEF_FIELD points to an array of
- TYPEDEF_FIELD_COUNT elements. */
- struct typedef_field
- {
- /* Unqualified name to be prefixed by owning class qualified name. */
- const char *name;
-
- /* Type this typedef named NAME represents. */
- struct type *type;
- }
- *typedef_field;
+ struct typedef_field *typedef_field;
unsigned typedef_field_count;
/* The template arguments. This is an array with
@@ -943,6 +949,40 @@ enum call_site_parameter_kind
CALL_SITE_PARAMETER_PARAM_OFFSET
};
+union call_site_parameter_u
+{
+ /* DW_TAG_formal_parameter's DW_AT_location's DW_OP_regX as DWARF
+ register number, for register passed parameters. */
+ int dwarf_reg;
+
+ /* Offset from the callee's frame base, for stack passed parameters.
+ This equals offset from the caller's stack pointer. */
+ CORE_ADDR fb_offset;
+
+ /* Offset relative to the start of this PER_CU to
+ DW_TAG_formal_parameter which is referenced by both caller and
+ the callee. */
+ cu_offset param_offset;
+};
+
+/* Describe DW_TAG_GNU_call_site's DW_TAG_formal_parameter. */
+struct call_site_parameter
+{
+ ENUM_BITFIELD (call_site_parameter_kind) kind : 2;
+
+ union call_site_parameter_u u;
+
+ /* DW_TAG_formal_parameter's DW_AT_GNU_call_site_value. It is never
+ NULL. */
+ const gdb_byte *value;
+ size_t value_size;
+
+ /* DW_TAG_formal_parameter's DW_AT_GNU_call_site_data_value. It may be
+ NULL if not provided by DWARF. */
+ const gdb_byte *data_value;
+ size_t data_value_size;
+};
+
/* A place where a function gets called from, represented by
DW_TAG_GNU_call_site. It can be looked up from symtab->call_site_htab. */
@@ -973,39 +1013,7 @@ struct call_site
blocks execution in the parameter array below. */
struct dwarf2_per_cu_data *per_cu;
- /* Describe DW_TAG_GNU_call_site's DW_TAG_formal_parameter. */
- struct call_site_parameter
- {
- ENUM_BITFIELD (call_site_parameter_kind) kind : 2;
-
- union call_site_parameter_u
- {
- /* DW_TAG_formal_parameter's DW_AT_location's DW_OP_regX as DWARF
- register number, for register passed parameters. */
- int dwarf_reg;
-
- /* Offset from the callee's frame base, for stack passed parameters.
- This equals offset from the caller's stack pointer. */
- CORE_ADDR fb_offset;
-
- /* Offset relative to the start of this PER_CU to
- DW_TAG_formal_parameter which is referenced by both caller and
- the callee. */
- cu_offset param_offset;
- }
- u;
-
- /* DW_TAG_formal_parameter's DW_AT_GNU_call_site_value. It is never
- NULL. */
- const gdb_byte *value;
- size_t value_size;
-
- /* DW_TAG_formal_parameter's DW_AT_GNU_call_site_data_value. It may be
- NULL if not provided by DWARF. */
- const gdb_byte *data_value;
- size_t data_value_size;
- }
- parameter[1];
+ struct call_site_parameter parameter[1];
};
/* The default value of TYPE_CPLUS_SPECIFIC(T) points to the
--
1.8.3.1