/* Support for printing Ada types for GDB, the GNU debugger.
- Copyright 1986, 1988, 1989, 1991, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1986, 1988, 1989, 1991, 1997, 1998, 1999, 2000, 2001, 2002,
+ 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
-This file is part of GDB.
+ This file is part of GDB.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-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. */
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "gdb_obstack.h"
print_dynamic_range_bound (struct type *, const char *, int,
const char *, struct ui_file *);
-static void print_range_type_named (char *, struct ui_file *);
+static void print_range_type_named (char *, struct type *, struct ui_file *);
\f
}
}
-
-/* Print a description of a type in the format of a
- typedef for the current language.
- NEW is the new name for a type TYPE. */
-
-void
-ada_typedef_print (struct type *type, struct symbol *new,
- struct ui_file *stream)
-{
- fprintf_filtered (stream, "type %.*s is ",
- ada_name_prefix_len (SYMBOL_PRINT_NAME (new)),
- SYMBOL_PRINT_NAME (new));
- type_print (type, "", stream, 1);
-}
-
/* Print range type TYPE on STREAM. */
static void
case TYPE_CODE_ENUM:
break;
default:
- target_type = builtin_type_int;
+ target_type = NULL;
break;
}
than 2, just print the type name instead of the range itself.
This check handles cases such as characters, for example.
- Note that if the name is not defined, then we don't print anything.
+ If the name is not defined, then we don't print anything.
*/
fprintf_filtered (stream, "%.*s",
ada_name_prefix_len (TYPE_NAME (type)),
/* 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, " .. ");
be printed as a signed or an unsigned value. This causes
the upper bound of the 0 .. -1 range types to be printed as
a very large unsigned number instead of -1.
- To workaround this stabs deficiency, we replace the TYPE by
- builtin_type_long when we detect that the bound is negative,
+ To workaround this stabs deficiency, we replace the TYPE by NULL
+ to indicate default output when we detect that the bound is negative,
and the type is a TYPE_CODE_INT. The bound is negative when
'm' is the last character of the number scanned in BOUNDS. */
if (bounds[*n - 1] == 'm' && TYPE_CODE (type) == TYPE_CODE_INT)
- type = builtin_type_long;
+ type = NULL;
ada_print_scalar (type, B, stream);
if (bounds[*n] == '_')
*n += 2;
fprintf_filtered (stream, "?");
}
-/* Print the range type named NAME. */
+/* Print the range type named NAME. If symbol lookup fails, fall back
+ to ORIG_TYPE as base type. */
static void
-print_range_type_named (char *name, struct ui_file *stream)
+print_range_type_named (char *name, struct type *orig_type,
+ struct ui_file *stream)
{
struct type *raw_type = ada_find_any_type (name);
struct type *base_type;
char *subtype_info;
if (raw_type == NULL)
- base_type = builtin_type_int;
- else if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
+ raw_type = orig_type;
+
+ if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
base_type = TYPE_TARGET_TYPE (raw_type);
else
base_type = raw_type;
subtype_info = strstr (name, "___XD");
- if (subtype_info == NULL && raw_type == NULL)
- fprintf_filtered (stream, "? .. ?");
- else if (subtype_info == NULL)
+ if (subtype_info == NULL)
print_range (raw_type, stream);
else
{
int bitsize;
int n_indices;
+ if (ada_is_packed_array_type (type))
+ type = ada_coerce_to_simple_array_type (type);
+
bitsize = 0;
fprintf_filtered (stream, "array (");
+ if (type == NULL)
+ {
+ fprintf_filtered (stream, _("<undecipherable array type>"));
+ return;
+ }
+
n_indices = -1;
if (show < 0)
fprintf_filtered (stream, "...");
else
{
- if (ada_is_packed_array_type (type))
- type = ada_coerce_to_simple_array_type (type);
- if (type == NULL)
- {
- fprintf_filtered (stream, "<undecipherable array type>");
- return;
- }
if (ada_is_simple_array_type (type))
{
struct type *range_desc_type =
if (k > 0)
fprintf_filtered (stream, ", ");
print_range_type_named (TYPE_FIELD_NAME
- (range_desc_type, k), stream);
+ (range_desc_type, k),
+ TYPE_INDEX_TYPE (arr_type), stream);
if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0)
bitsize = TYPE_FIELD_BITSIZE (arr_type, 0);
}
}
/* Print the choices encoded by field FIELD_NUM of variant-part TYPE on
- STREAM, assuming the VAL_TYPE is the type of the values. */
+ STREAM, assuming that VAL_TYPE (if non-NULL) is the type of the values. */
static void
print_choices (struct type *type, int field_num, struct ui_file *stream,
flds = 0;
len = TYPE_NFIELDS (type);
- if (len == 0 && (TYPE_FLAGS (type) & TYPE_FLAG_STUB) != 0)
+ if (len == 0 && TYPE_STUB (type))
return -1;
for (i = 0; i < len; i += 1)
parent_type = ada_parent_type (type);
if (ada_type_name (parent_type) != NULL)
- fprintf_filtered (stream, "new %s with ",
+ fprintf_filtered (stream, "new %s with record",
decoded_type_name (parent_type));
else if (parent_type == NULL && ada_is_tagged_type (type, 0))
- fprintf_filtered (stream, "tagged ");
-
- fprintf_filtered (stream, "record");
+ fprintf_filtered (stream, "tagged record");
+ else
+ fprintf_filtered (stream, "record");
if (show < 0)
fprintf_filtered (stream, " ... end record");
if (flds > 0)
fprintf_filtered (stream, "\n%*send record", level, "");
else if (flds < 0)
- fprintf_filtered (stream, " <incomplete type> end record");
+ fprintf_filtered (stream, _(" <incomplete type> end record"));
else
fprintf_filtered (stream, " null; end record");
}
print_unchecked_union_type (struct type *type, struct ui_file *stream,
int show, int level)
{
- fprintf_filtered (stream, "record (?) is");
-
if (show < 0)
- fprintf_filtered (stream, " ... end record");
+ fprintf_filtered (stream, "record (?) is ... end record");
else if (TYPE_NFIELDS (type) == 0)
- fprintf_filtered (stream, " null; end record");
+ fprintf_filtered (stream, "record (?) is null; end record");
else
{
int i;
- fprintf_filtered (stream, "\n%*scase ? is", level + 4, "");
+ fprintf_filtered (stream, "record (?) is\n%*scase ? is", level + 4, "");
for (i = 0; i < TYPE_NFIELDS (type); i += 1)
{
ada_print_type (struct type *type0, char *varstring, struct ui_file *stream,
int show, int level)
{
- struct type *type = ada_completed_type (ada_get_base_type (type0));
- char *type_name = decoded_type_name (type);
+ struct type *type = ada_check_typedef (ada_get_base_type (type0));
+ char *type_name = decoded_type_name (type0);
int is_var_decl = (varstring != NULL && varstring[0] != '\0');
if (type == NULL)
}
if (show > 0)
- CHECK_TYPEDEF (type);
+ type = ada_check_typedef (type);
if (is_var_decl && TYPE_CODE (type) != TYPE_CODE_FUNC)
fprintf_filtered (stream, "%.*s: ",
if (ada_is_aligner_type (type))
ada_print_type (ada_aligned_type (type), "", stream, show, level);
else if (ada_is_packed_array_type (type))
- print_array_type (type, stream, show, level);
+ {
+ 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
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
print_array_type (type, stream, show, level);
break;
+ case TYPE_CODE_BOOL:
+ fprintf_filtered (stream, "(false, true)");
+ break;
case TYPE_CODE_INT:
if (ada_is_fixed_point_type (type))
print_fixed_point_type (type, stream);
{
char *name = ada_type_name (type);
if (!ada_is_range_type_name (name))
- fprintf_filtered (stream, "<%d-byte integer>",
+ fprintf_filtered (stream, _("<%d-byte integer>"),
TYPE_LENGTH (type));
else
{
fprintf_filtered (stream, "range ");
- print_range_type_named (name, stream);
+ print_range_type_named (name, type, stream);
}
}
break;
else if (ada_is_vax_floating_type (type))
print_vax_floating_point_type (type, stream);
else if (ada_is_modular_type (type))
- fprintf_filtered (stream, "mod %ld", (long) ada_modulus (type));
+ fprintf_filtered (stream, "mod %s",
+ int_string (ada_modulus (type), 10, 0, 0, 1));
else
{
fprintf_filtered (stream, "range ");
}
break;
case TYPE_CODE_FLT:
- fprintf_filtered (stream, "<%d-byte float>", TYPE_LENGTH (type));
+ fprintf_filtered (stream, _("<%d-byte float>"), TYPE_LENGTH (type));
break;
case TYPE_CODE_ENUM:
if (show < 0)
print_array_type (type, stream, show, level);
else if (ada_is_bogus_array_descriptor (type))
fprintf_filtered (stream,
- "array (?) of ? (<mal-formed descriptor>)");
+ _("array (?) of ? (<mal-formed descriptor>)"));
else
print_record_type (type, stream, show, level);
break;