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"
#include "c-lang.h" /* For c_val_print */
#include "typeprint.h"
#include "ch-lang.h"
+#include "annotate.h"
static void
chill_print_value_fields PARAMS ((struct type *, char *, GDB_FILE *, int, int,
enum val_prettyprint, struct type **));
+\f
+/* Print integral scalar data VAL, of type TYPE, onto stdio stream STREAM.
+ Used to print data from type structures in a specified type. For example,
+ array bounds may be characters or booleans in some languages, and this
+ allows the ranges to be printed in their "natural" form rather than as
+ decimal integer values. */
+
+void
+chill_print_type_scalar (type, val, stream)
+ struct type *type;
+ LONGEST val;
+ GDB_FILE *stream;
+{
+ switch (TYPE_CODE (type))
+ {
+ case TYPE_CODE_RANGE:
+ if (TYPE_TARGET_TYPE (type))
+ {
+ 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);
+}
\f
/* Print the elements of an array.
Similar to val_print_array_elements, but prints
/* 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;
}
fputs_filtered ("(", stream);
- print_type_scalar (index_type, low_bound + i, stream);
+ chill_print_type_scalar (index_type, low_bound + i, stream);
if (reps > 1)
{
fputs_filtered (":", stream);
- print_type_scalar (index_type, low_bound + i + reps - 1, stream);
+ chill_print_type_scalar (index_type, low_bound + i + reps - 1,
+ stream);
fputs_filtered ("): ", stream);
val_print (elttype, valaddr + i * eltlen, 0, stream, format,
deref_ref, recurse + 1, pretty);
struct type *elttype;
CORE_ADDR addr;
+ CHECK_TYPEDEF (type);
+
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
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)
+ {
+ fputs_filtered ("NULL", stream);
+ return 0;
+ }
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{
break;
case TYPE_CODE_STRING:
- if (format && format != 's')
- {
- print_scalar_formatted (valaddr, type, format, 0, stream);
- break;
- }
i = TYPE_LENGTH (type);
LA_PRINT_STRING (stream, valaddr, i, 0);
/* Return number of characters printed, plus one for the terminating
case TYPE_CODE_BITSTRING:
case TYPE_CODE_SET:
+ elttype = TYPE_INDEX_TYPE (type);
+ CHECK_TYPEDEF (elttype);
+ if (TYPE_FLAGS (elttype) & TYPE_FLAG_STUB)
+ {
+ fprintf_filtered (stream, "<incomplete type>");
+ gdb_flush (stream);
+ break;
+ }
{
- struct type *range = TYPE_FIELD_TYPE (type, 0);
- int low_bound = TYPE_LOW_BOUND (range);
- int high_bound = TYPE_HIGH_BOUND (range);
+ struct type *range = elttype;
+ 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)
{
if (need_comma)
fputs_filtered (", ", stream);
- print_type_scalar (TYPE_TARGET_TYPE (range), i, stream);
+ chill_print_type_scalar (range, i, stream);
need_comma = 1;
/* Look for a continuous range of true elements. */
while (i+1 <= high_bound
&& value_bit_index (type, valaddr, ++i))
j = i;
- print_type_scalar (TYPE_TARGET_TYPE (range), j, stream);
+ chill_print_type_scalar (range, j, stream);
}
}
}
+ done:
if (is_bitstring)
fputs_filtered ("'", stream);
else
break;
case TYPE_CODE_STRUCT:
- if (chill_is_varying_struct (type))
+ 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);
}
fprintf_filtered (stream, "]");
}
+\f
+int
+chill_value_print (val, stream, format, pretty)
+ value_ptr val;
+ GDB_FILE *stream;
+ int format;
+ enum val_prettyprint pretty;
+{
+ struct type *type = VALUE_TYPE (val);
+ struct type *real_type = check_typedef (type);
+
+ /* If it is a pointer, indicate what it points to.
+
+ Print type also if it is a reference. */
+
+ 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)
+ {
+ 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);
+ fprintf_filtered (stream, ")");
+ return i;
+ }
+ }
+ return (val_print (type, VALUE_CONTENTS (val),
+ VALUE_ADDRESS (val), stream, format, 1, 0, pretty));
+}
+
+