aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorWilfried Moser <moser@cygnus>1996-01-29 08:17:22 +0000
committerWilfried Moser <moser@cygnus>1996-01-29 08:17:22 +0000
commitd221b17e83dc8562129b8e9284021baa89e3c877 (patch)
treeebac50e4ff99151cfef40b713f18ccc080123db1 /gdb
parentd59558827ed8da7fd4cf379a5bb25f3a2fca3091 (diff)
downloadgdb-d221b17e83dc8562129b8e9284021baa89e3c877.zip
gdb-d221b17e83dc8562129b8e9284021baa89e3c877.tar.gz
gdb-d221b17e83dc8562129b8e9284021baa89e3c877.tar.bz2
* ch-valprint.c (calculate_array_length): New function to determine
the length of an array type (see comment). (chill_val_print (case TYPE_CODE_ARRAY)): If the length of an array type is zero, call calculate_array_length. * gdbtypes.c (get_discrete_bounds (case TYPE_CODE_ENUM)): They values may not be sorted. Scan all entries and set the real lower and
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/ch-valprint.c47
-rw-r--r--gdb/gdbtypes.c14
3 files changed, 70 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bd233a1..363ee78 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+Mon Jan 29 00:10:35 1996 Wilfried Moser (Alcatel) <moser@rtl.cygnus.com>
+
+ * ch-valprint.c (calculate_array_length): New function to determine
+ the length of an array type (see comment).
+ (chill_val_print (case TYPE_CODE_ARRAY)): If the length of an
+ array type is zero, call calculate_array_length.
+
+ * gdbtypes.c (get_discrete_bounds (case TYPE_CODE_ENUM)): They values
+ may not be sorted. Scan all entries and set the real lower and
+ upper bound.
+
Sun Jan 28 15:50:42 1996 Fred Fish <fnf@cygnus.com>
* config/xm-linux.h: Move include of solib.h and #define of
diff --git a/gdb/ch-valprint.c b/gdb/ch-valprint.c
index 9b20137..de66d46 100644
--- a/gdb/ch-valprint.c
+++ b/gdb/ch-valprint.c
@@ -176,6 +176,49 @@ chill_val_print_array_elements (type, valaddr, address, stream,
}
}
+/* In certain cases it could happen, that an array type doesn't
+ have a length (this have to do with seizing). The reason is
+ shown in the following stabs:
+
+ .stabs "m_x:Tt81=s36i:1,0,32;ar:82=ar80;0;1;83=xsm_struct:,32,256;;",128,0,25,0
+
+ .stabs "m_struct:Tt83=s16f1:9,0,16;f2:85=*84,32,32;f3:84,64,64;;",128,0,10,0
+
+ When processing t81, the array ar80 doesn't have a length, cause
+ struct m_struct is specified extern at thse moment. Afterwards m_struct
+ gets specified and updated, but not the surrounding type.
+
+ So we walk through array's till we find a type with a length and
+ calculate the array length.
+
+ FIXME: Where may this happen too ?
+ */
+
+static void
+calculate_array_length (type)
+ struct type *type;
+{
+ struct type *target_type;
+ struct type *range_type;
+ LONGEST lower_bound, upper_bound;
+
+ if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
+ /* not an array, stop processing */
+ return;
+
+ target_type = TYPE_TARGET_TYPE (type);
+ range_type = TYPE_FIELD_TYPE (type, 0);
+ lower_bound = TYPE_FIELD_BITPOS (range_type, 0);
+ upper_bound = TYPE_FIELD_BITPOS (range_type, 1);
+
+ if (TYPE_LENGTH (target_type) == 0 &&
+ TYPE_CODE (target_type) == TYPE_CODE_ARRAY)
+ /* we've got another array */
+ calculate_array_length (target_type);
+
+ TYPE_LENGTH (type) = (upper_bound - lower_bound + 1) * TYPE_LENGTH (target_type);
+}
+
/* Print data of type TYPE located at VALADDR (within GDB), which came from
the inferior at address ADDRESS, onto stdio stream STREAM according to
FORMAT (a letter or 0 for natural format). The data at VALADDR is in
@@ -211,6 +254,10 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
+ if (TYPE_LENGTH (type) == 0)
+ /* see comment function calculate_array_length */
+ calculate_array_length (type);
+
if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
{
if (prettyprint_arrays)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index a21f959..13a111f 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -356,8 +356,18 @@ get_discrete_bounds (type, lowp, highp)
case TYPE_CODE_ENUM:
if (TYPE_NFIELDS (type) > 0)
{
- *lowp = TYPE_FIELD_BITPOS (type, 0);
- *highp = TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1);
+ /* The enums may not be sorted by value, so search all
+ entries */
+ int i;
+
+ *lowp = *highp = TYPE_FIELD_BITPOS (type, 0);
+ for (i = 0; i < TYPE_NFIELDS (type); i++)
+ {
+ if (TYPE_FIELD_BITPOS (type, i) < *lowp)
+ *lowp = TYPE_FIELD_BITPOS (type, i);
+ if (TYPE_FIELD_BITPOS (type, i) > *highp)
+ *highp = TYPE_FIELD_BITPOS (type, i);
+ }
}
else
{