/* Support for printing Ada types for GDB, the GNU debugger.
- Copyright (C) 1986, 1988, 1989, 1991, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1986, 1988-1989, 1991, 1997-2004, 2007-2012 Free
+ Software Foundation, Inc.
This file is part of GDB.
return NULL;
else
{
- char *raw_name = ada_type_name (type);
+ const char *raw_name = ada_type_name (type);
char *s, *q;
if (name_buffer == NULL || name_buffer_len <= strlen (raw_name))
static void
print_range_type (struct type *raw_type, struct ui_file *stream)
{
- char *name;
+ const char *name;
struct type *base_type;
- char *subtype_info;
+ const char *subtype_info;
gdb_assert (raw_type != NULL);
name = TYPE_NAME (raw_type);
print_enum_type (struct type *type, struct ui_file *stream)
{
int len = TYPE_NFIELDS (type);
- int i, lastval;
+ int i;
+ LONGEST lastval;
fprintf_filtered (stream, "(");
wrap_here (" ");
fprintf_filtered (stream, ", ");
wrap_here (" ");
fputs_filtered (ada_enum_name (TYPE_FIELD_NAME (type, i)), stream);
- if (lastval != TYPE_FIELD_BITPOS (type, i))
+ if (lastval != TYPE_FIELD_ENUMVAL (type, i))
{
- fprintf_filtered (stream, " => %d", TYPE_FIELD_BITPOS (type, i));
- lastval = TYPE_FIELD_BITPOS (type, i);
+ fprintf_filtered (stream, " => %s",
+ plongest (TYPE_FIELD_ENUMVAL (type, i)));
+ lastval = TYPE_FIELD_ENUMVAL (type, i);
}
lastval += 1;
}
parent_type = ada_parent_type (type);
if (ada_type_name (parent_type) != NULL)
- fprintf_filtered (stream, "new %s with record",
- decoded_type_name (parent_type));
+ {
+ const char *parent_name = decoded_type_name (parent_type);
+
+ /* If we fail to decode the parent type name, then use the parent
+ type name as is. Not pretty, but should never happen except
+ when the debugging info is incomplete or incorrect. This
+ prevents a crash trying to print a NULL pointer. */
+ if (parent_name == NULL)
+ parent_name = ada_type_name (parent_type);
+ fprintf_filtered (stream, "new %s with record", parent_name);
+ }
else if (parent_type == NULL && ada_is_tagged_type (type, 0))
fprintf_filtered (stream, "tagged record");
else
fprintf_filtered (stream, "%.*s: ",
ada_name_prefix_len (varstring), varstring);
- if (type_name != NULL && show <= 0)
+ if (type_name != NULL && show <= 0 && !ada_is_aligner_type (type))
{
fprintf_filtered (stream, "%.*s",
ada_name_prefix_len (type_name), type_name);
if (ada_is_aligner_type (type))
ada_print_type (ada_aligned_type (type), "", stream, show, level);
- else if (ada_is_constrained_packed_array_type (type))
- {
- if (TYPE_CODE (type) == TYPE_CODE_PTR)
- {
- fprintf_filtered (stream, "access ");
- print_array_type (TYPE_TARGET_TYPE (type), stream, show, level);
- }
- else
- {
- print_array_type (type, stream, show, level);
- }
- }
+ else if (ada_is_constrained_packed_array_type (type)
+ && TYPE_CODE (type) != TYPE_CODE_PTR)
+ print_array_type (type, stream, show, level);
else
switch (TYPE_CODE (type))
{
print_fixed_point_type (type, stream);
else
{
- char *name = ada_type_name (type);
+ const char *name = ada_type_name (type);
if (!ada_is_range_type_name (name))
fprintf_filtered (stream, _("<%d-byte integer>"),