You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "obstack.h"
chill_print_type_scalar (TYPE_TARGET_TYPE (type), val, stream);
return;
}
+ break;
+ case TYPE_CODE_UNDEF:
+ case TYPE_CODE_PTR:
+ case TYPE_CODE_ARRAY:
+ case TYPE_CODE_STRUCT:
+ case TYPE_CODE_UNION:
+ case TYPE_CODE_ENUM:
+ case TYPE_CODE_FUNC:
+ case TYPE_CODE_INT:
+ case TYPE_CODE_FLT:
+ case TYPE_CODE_VOID:
+ case TYPE_CODE_SET:
+ case TYPE_CODE_STRING:
+ case TYPE_CODE_BITSTRING:
+ case TYPE_CODE_ERROR:
+ case TYPE_CODE_MEMBER:
+ case TYPE_CODE_METHOD:
+ case TYPE_CODE_REF:
+ case TYPE_CODE_CHAR:
+ case TYPE_CODE_BOOL:
+ case TYPE_CODE_COMPLEX:
+ case TYPE_CODE_TYPEDEF:
+ default:
+ break;
}
print_type_scalar (type, val, stream);
}
/* Number of repetitions we have detected so far. */
unsigned int reps;
LONGEST low_bound = TYPE_FIELD_BITPOS (range_type, 0);
- LONGEST high_bound = TYPE_FIELD_BITPOS (range_type, 1);
- elttype = TYPE_TARGET_TYPE (type);
+ elttype = check_typedef (TYPE_TARGET_TYPE (type));
eltlen = TYPE_LENGTH (elttype);
len = TYPE_LENGTH (type) / eltlen;
}
}
+/* 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
struct type *elttype;
CORE_ADDR addr;
+ CHECK_TYPEDEF (type);
+
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)
break;
}
addr = unpack_pointer (type, valaddr);
- elttype = TYPE_TARGET_TYPE (type);
+ elttype = check_typedef (TYPE_TARGET_TYPE (type));
/* We assume a NULL pointer is all zeros ... */
if (addr == 0)
case TYPE_CODE_BITSTRING:
case TYPE_CODE_SET:
elttype = TYPE_INDEX_TYPE (type);
- check_stub_type (elttype);
+ CHECK_TYPEDEF (elttype);
if (TYPE_FLAGS (elttype) & TYPE_FLAG_STUB)
{
fprintf_filtered (stream, "<incomplete type>");
}
{
struct type *range = elttype;
- int low_bound = TYPE_LOW_BOUND (range);
- int high_bound = TYPE_HIGH_BOUND (range);
+ LONGEST low_bound, high_bound;
int i;
int is_bitstring = TYPE_CODE (type) == TYPE_CODE_BITSTRING;
int need_comma = 0;
fputs_filtered ("B'", stream);
else
fputs_filtered ("[", stream);
+
+ i = get_discrete_bounds (range, &low_bound, &high_bound);
+ maybe_bad_bstring:
+ if (i < 0)
+ {
+ fputs_filtered ("<error value>", stream);
+ goto done;
+ }
+
for (i = low_bound; i <= high_bound; i++)
{
int element = value_bit_index (type, valaddr, i);
+ if (element < 0)
+ {
+ i = element;
+ goto maybe_bad_bstring;
+ }
if (is_bitstring)
fprintf_filtered (stream, "%d", element);
else if (element)
}
}
}
+ done:
if (is_bitstring)
fputs_filtered ("'", stream);
else
case TYPE_CODE_STRUCT:
if (chill_varying_type (type))
{
- struct type *inner = TYPE_FIELD_TYPE (type, 1);
+ struct type *inner = check_typedef (TYPE_FIELD_TYPE (type, 1));
long length = unpack_long (TYPE_FIELD_TYPE (type, 0), valaddr);
char *data_addr = valaddr + TYPE_FIELD_BITPOS (type, 1) / 8;
if (length > TYPE_LENGTH (type))
{
fprintf_filtered (stream,
- "<dynamic length %d > static length %d>",
+ "<dynamic length %ld > static length %d>",
length, TYPE_LENGTH (type));
}
LA_PRINT_STRING (stream, data_addr, length, 0);
int i, len;
int fields_seen = 0;
- check_stub_type (type);
+ CHECK_TYPEDEF (type);
fprintf_filtered (stream, "[");
len = TYPE_NFIELDS (type);
int format;
enum val_prettyprint pretty;
{
- /* A "repeated" value really contains several values in a row.
- They are made by the @ operator.
- Print such values as if they were arrays. */
-
- if (VALUE_REPEATED (val))
- {
- register unsigned int n = VALUE_REPETITIONS (val);
- register unsigned int typelen = TYPE_LENGTH (VALUE_TYPE (val));
- fprintf_filtered (stream, "[");
- /* Print arrays of characters using string syntax. */
- if (typelen == 1 && TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT
- && format == 0)
- LA_PRINT_STRING (stream, VALUE_CONTENTS (val), n, 0);
- else
- {
- value_print_array_elements (val, stream, format, pretty);
- }
- fprintf_filtered (stream, "]");
- return (n * typelen);
- }
- else
- {
- struct type *type = VALUE_TYPE (val);
+ struct type *type = VALUE_TYPE (val);
+ struct type *real_type = check_typedef (type);
- /* If it is a pointer, indicate what it points to.
+ /* If it is a pointer, indicate what it points to.
- Print type also if it is a reference.
+ Print type also if it is a reference. */
- C++: if it is a member pointer, we will take care
- of that when we print it. */
- if (TYPE_CODE (type) == TYPE_CODE_PTR ||
- TYPE_CODE (type) == TYPE_CODE_REF)
+ if (TYPE_CODE (real_type) == TYPE_CODE_PTR ||
+ TYPE_CODE (real_type) == TYPE_CODE_REF)
+ {
+ char *valaddr = VALUE_CONTENTS (val);
+ CORE_ADDR addr = unpack_pointer (type, valaddr);
+ if (TYPE_CODE (type) != TYPE_CODE_PTR || addr != 0)
{
- char *valaddr = VALUE_CONTENTS (val);
- CORE_ADDR addr = unpack_pointer (type, valaddr);
- if (TYPE_CODE (type) != TYPE_CODE_PTR || addr != 0)
+ int i;
+ char *name = TYPE_NAME (type);
+ if (name)
+ fputs_filtered (name, stream);
+ else if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID)
+ fputs_filtered ("PTR", stream);
+ else
{
- int i;
- char *name = TYPE_NAME (type);
- if (name)
- fputs_filtered (name, stream);
- else if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID)
- fputs_filtered ("PTR", stream);
- else
- {
- fprintf_filtered (stream, "(");
- type_print (type, "", stream, -1);
- fprintf_filtered (stream, ")");
- }
fprintf_filtered (stream, "(");
- i = val_print (type, valaddr, VALUE_ADDRESS (val),
- stream, format, 1, 0, pretty);
+ type_print (type, "", stream, -1);
fprintf_filtered (stream, ")");
- return i;
}
+ fprintf_filtered (stream, "(");
+ i = val_print (type, valaddr, VALUE_ADDRESS (val),
+ stream, format, 1, 0, pretty);
+ fprintf_filtered (stream, ")");
+ return i;
}
- return (val_print (type, VALUE_CONTENTS (val),
- VALUE_ADDRESS (val), stream, format, 1, 0, pretty));
}
+ return (val_print (type, VALUE_CONTENTS (val),
+ VALUE_ADDRESS (val), stream, format, 1, 0, pretty));
}