public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-jankratochvil-vla: Drop new separate create_range_type_nfields() and unify the code on
@ 2008-12-26 22:24 jkratoch
0 siblings, 0 replies; only message in thread
From: jkratoch @ 2008-12-26 22:24 UTC (permalink / raw)
To: archer-commits
The branch, archer-jankratochvil-vla has been updated
via 9455db1d51d5627bac7085f161100dec3600e676 (commit)
from 16a63ebc3925d782f3df69b4159b8ef29c7ecc0d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit 9455db1d51d5627bac7085f161100dec3600e676
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Fri Dec 26 23:20:36 2008 +0100
Drop new separate create_range_type_nfields() and unify the code on
create_range_type().
Always use 3-fields TYPE_CODE_RANGE (no longer option 2 vs. 3 fields).
Fix TYPE_HIGH_BOUND for TYPE_CODE_RANGE using arbitrary TYPE_NFIELDS.
-----------------------------------------------------------------------
Summary of changes:
gdb/ada-lang.c | 49 ++++++++++++++++++++-----------------------------
gdb/ada-typeprint.c | 5 +++--
gdb/dwarf2read.c | 28 +++++++++++++---------------
gdb/gdbtypes.c | 42 +++++++++++-------------------------------
gdb/gdbtypes.h | 12 ++----------
5 files changed, 49 insertions(+), 87 deletions(-)
First 500 lines of diff:
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 3070696..8e87d72 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2492,8 +2492,9 @@ static LONGEST
ada_array_bound_from_type (struct type * arr_type, int n, int which,
struct type ** typep)
{
- struct type *type;
- struct type *index_type_desc;
+ struct type *type, *index_type_desc, *index_type;
+
+ gdb_assert (which == 0 || which == 1);
if (ada_is_packed_array_type (arr_type))
arr_type = decode_packed_array_type (arr_type);
@@ -2511,10 +2512,11 @@ ada_array_bound_from_type (struct type * arr_type, int n, int which,
type = arr_type;
index_type_desc = ada_find_parallel_type (type, "___XA");
- if (index_type_desc == NULL)
+ if (index_type_desc != NULL)
+ index_type = to_fixed_range_type (TYPE_FIELD_NAME (index_type_desc, n - 1),
+ NULL, TYPE_OBJFILE (arr_type));
+ else
{
- struct type *index_type;
-
while (n > 1)
{
type = TYPE_TARGET_TYPE (type);
@@ -2522,33 +2524,22 @@ ada_array_bound_from_type (struct type * arr_type, int n, int which,
}
index_type = TYPE_INDEX_TYPE (type);
- if (typep != NULL)
- *typep = index_type;
-
- /* The index type is either a range type or an enumerated type.
- For the range type, we have some macros that allow us to
- extract the value of the low and high bounds. But they
- do now work for enumerated types. The expressions used
- below work for both range and enum types. */
- return
- (LONGEST) (which == 0
- ? TYPE_FIELD_BITPOS (index_type, 0)
- : TYPE_FIELD_BITPOS (index_type,
- TYPE_NFIELDS (index_type) - 1));
}
- else
- {
- struct type *index_type =
- to_fixed_range_type (TYPE_FIELD_NAME (index_type_desc, n - 1),
- NULL, TYPE_OBJFILE (arr_type));
- if (typep != NULL)
- *typep = index_type;
+ if (typep != NULL)
+ *typep = index_type;
- return
- (LONGEST) (which == 0
- ? TYPE_LOW_BOUND (index_type)
- : TYPE_HIGH_BOUND (index_type));
+ switch (TYPE_CODE (index_type))
+ {
+ case TYPE_CODE_RANGE:
+ return which == 0 ? TYPE_LOW_BOUND (index_type)
+ : TYPE_HIGH_BOUND (index_type);
+ case TYPE_CODE_ENUM:
+ return which == 0 ? TYPE_FIELD_BITPOS (index_type, 0)
+ : TYPE_FIELD_BITPOS (index_type,
+ TYPE_NFIELDS (index_type) - 1);
+ default:
+ internal_error (__FILE__, __LINE__, _("invalid type code of index type"));
}
}
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index cb4fecd..ad4a73c 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -170,8 +170,9 @@ print_range (struct type *type, struct ui_file *stream)
/* We extract the range type bounds respectively from the first element
and the last element of the type->fields array */
const LONGEST lower_bound = (LONGEST) TYPE_LOW_BOUND (type);
- const LONGEST upper_bound =
- (LONGEST) TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1);
+ const LONGEST upper_bound = (TYPE_CODE (type) == TYPE_CODE_RANGE
+ ? (LONGEST) TYPE_HIGH_BOUND (type)
+ : (LONGEST) TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1));
ada_print_scalar (target_type, lower_bound, stream);
fprintf_filtered (stream, " .. ");
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index d088aa0..450aed3 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4924,8 +4924,8 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
index_type = builtin_type_int32;
/* RANGE_TYPE is allocated from OBJFILE, not OBJFILE_INTERNAL. */
range_type = alloc_type (objfile, index_type);
- range_type = create_range_type_nfields (range_type, index_type, 2);
- TYPE_UNSIGNED (range_type) = 1;
+ /* LOW_BOUND and HIGH_BOUND are set for real below. */
+ range_type = create_range_type (range_type, index_type, 0, -1);
/* C/C++ should probably have the low bound 0 but C/C++ does not use
DW_TAG_string_type. */
@@ -5205,9 +5205,9 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
struct gdbarch *gdbarch = get_objfile_arch (cu->objfile);
struct type *base_type;
struct type *range_type;
- struct attribute *attr, *byte_stride_attr;
+ struct attribute *attr;
int low, high, byte_stride_int;
- enum dwarf2_get_attr_constant_value high_type, byte_stride_type;
+ enum dwarf2_get_attr_constant_value high_type;
char *name;
base_type = die_type (die, cu);
@@ -5220,13 +5220,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
0, NULL, cu->objfile);
}
- /* DW_AT_bit_stride is currently unsupported as we count in bytes. */
- byte_stride_attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
- byte_stride_type = dwarf2_get_attr_constant_value (byte_stride_attr,
- &byte_stride_int);
-
- range_type = create_range_type_nfields
- (NULL, base_type, byte_stride_type == dwarf2_attr_unknown ? 2 : 3);
+ /* LOW_BOUND and HIGH_BOUND are set for real below. */
+ range_type = create_range_type (NULL, base_type, 0, -1);
attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
switch (dwarf2_get_attr_constant_value (attr, &low))
@@ -5290,19 +5285,22 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
break;
}
- switch (byte_stride_type)
+ /* DW_AT_bit_stride is currently unsupported as we count in bytes. */
+ attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
+ switch (dwarf2_get_attr_constant_value (attr, &byte_stride_int))
{
case dwarf2_attr_unknown:
break;
case dwarf2_attr_const:
if (byte_stride_int == 0)
- warning (_("Found DW_AT_byte_stride with unsupported value 0"));
- SET_TYPE_BYTE_STRIDE (range_type, byte_stride_int);
+ complaint (&symfile_complaints,
+ _("Found DW_AT_byte_stride with unsupported value 0"));
+ TYPE_BYTE_STRIDE (range_type) = byte_stride_int;
break;
case dwarf2_attr_block:
TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 2);
TYPE_FIELD_DWARF_BLOCK (range_type, 2) = dwarf2_attr_to_locexpr_baton
- (byte_stride_attr, cu);
+ (attr, cu);
TYPE_DYNAMIC (range_type) = 1;
break;
}
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 6799db3..fd99511 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -729,21 +729,16 @@ allocate_stub_method (struct type *type)
RESULT_TYPE, or creating a new type, inheriting the objfile from
INDEX_TYPE.
- Indices will be of type INDEX_TYPE. NFIELDS should be 2 for standard
- arrays, 3 for custom TYPE_BYTE_STRIDE. Use CREATE_RANGE_TYPE for common
- constant TYPE_LOW_BOUND/TYPE_HIGH_BOUND ranges instead.
-
- You must to decide TYPE_UNSIGNED yourself as being done in CREATE_RANGE_TYPE.
+ Indices will be of type INDEX_TYPE, and will range from LOW_BOUND
+ to HIGH_BOUND, inclusive.
FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
sure it is TYPE_CODE_UNDEF before we bash it into a range type? */
struct type *
-create_range_type_nfields (struct type *result_type, struct type *index_type,
- int nfields)
+create_range_type (struct type *result_type, struct type *index_type,
+ int low_bound, int high_bound)
{
- int fieldno;
-
if (result_type == NULL)
{
result_type = alloc_type (TYPE_OBJFILE (index_type), index_type);
@@ -754,33 +749,18 @@ create_range_type_nfields (struct type *result_type, struct type *index_type,
TYPE_TARGET_STUB (result_type) = 1;
else
TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type));
- TYPE_NFIELDS (result_type) = nfields;
+ TYPE_NFIELDS (result_type) = 3;
TYPE_FIELDS (result_type) = (struct field *)
- TYPE_ALLOC (result_type,
- TYPE_NFIELDS (result_type) * sizeof (struct field));
- memset (TYPE_FIELDS (result_type), 0,
- TYPE_NFIELDS (result_type) * sizeof (struct field));
-
- return (result_type);
-}
-
-/* Simplified CREATE_RANGE_TYPE_NFIELDS for constant ranges from LOW_BOUND to
- HIGH_BOUND, inclusive. TYPE_BYTE_STRIDE is always set to zero (default
- native target type length). */
-
-struct type *
-create_range_type (struct type *result_type, struct type *index_type,
- int low_bound, int high_bound)
-{
- result_type = create_range_type_nfields (result_type, index_type, 2);
-
- TYPE_LOW_BOUND (result_type) = low_bound;
- TYPE_HIGH_BOUND (result_type) = high_bound;
+ TYPE_ALLOC (result_type, 3 * sizeof (struct field));
+ memset (TYPE_FIELDS (result_type), 0, 3 * sizeof (struct field));
+ TYPE_FIELD_BITPOS (result_type, 0) = low_bound;
+ TYPE_FIELD_BITPOS (result_type, 1) = high_bound;
+ TYPE_BYTE_STRIDE (result_type) = 0;
if (low_bound >= 0)
TYPE_UNSIGNED (result_type) = 1;
- return result_type;
+ return (result_type);
}
/* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 833a515..252febe 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -828,13 +828,9 @@ extern void allocate_cplus_struct_type (struct type *);
#define TYPE_ASSOCIATED(thistype) TYPE_MAIN_TYPE (thistype)->associated
#define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
-/* `TYPE_NFIELDS (range_type) >= 3' check is required before accessing it: */
-#define SET_TYPE_BYTE_STRIDE(range_type, n) \
- (TYPE_FIELD_BITPOS (range_type, 2) = (n))
#define TYPE_LOW_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 0)
#define TYPE_HIGH_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 1)
-#define TYPE_BYTE_STRIDE(range_type) \
- (TYPE_NFIELDS (range_type) < 3 ? 0 : TYPE_FIELD_BITPOS (range_type, 2))
+#define TYPE_BYTE_STRIDE(range_type) TYPE_FIELD_BITPOS (range_type, 2)
/* Whether we should use TYPE_FIELD_DWARF_BLOCK (and not TYPE_FIELD_BITPOS). */
#define TYPE_RANGE_BOUND_IS_DWARF_BLOCK(range_type, fieldno) \
@@ -865,7 +861,7 @@ extern void allocate_cplus_struct_type (struct type *);
/* TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) with a fallback to the
element size if no specific stride value is known. */
#define TYPE_ARRAY_BYTE_STRIDE_VALUE(arraytype) \
- (TYPE_NFIELDS (TYPE_INDEX_TYPE (arraytype)) < 2 \
+ (TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) == 0 \
? TYPE_LENGTH (TYPE_TARGET_TYPE (arraytype)) \
: TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)))
@@ -1216,10 +1212,6 @@ extern struct type *make_function_type (struct type *, struct type **);
extern struct type *lookup_function_type (struct type *);
-extern struct type *create_range_type_nfields (struct type *result_type,
- struct type *index_type,
- int nfields);
-
extern struct type *create_range_type (struct type *, struct type *, int,
int);
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-12-26 22:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-26 22:24 [SCM] archer-jankratochvil-vla: Drop new separate create_range_type_nfields() and unify the code on jkratoch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).