mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-18 12:24:38 +08:00
Have ptype handle types declared pragma Unchecked_Variants.
When a type is marked with pragma Unchecked_Variants, ptype did not print variants having a single component, since the compiler produces incorrect debugging output for such cases. With this patch, we special-case these components so that they print. Changelog: * gdb/ada-typeprint.c (print_selected_record_field_types): New function, incorporating and generalizing print_record_field_types. (print_record_field_types): Change return value and update comment. Re-implement using print_selected_record_field_types. (print_choices): Print "=>" here. Handle case of unencoded variant branch. (print_variant_clauses): Reformat comment. Special-case unencoded variant branch.
This commit is contained in:
parent
7358912389
commit
83e3a93c83
@ -1,4 +1,15 @@
|
||||
2010-10-03 Paul Hilfinger <hilfingr@syracuse.mckusick.com>
|
||||
2010-10-03 Paul Hilfinger <hilfinger@adacore.com>
|
||||
|
||||
* gdb/ada-typeprint.c (print_selected_record_field_types): New function,
|
||||
incorporating and generalizing print_record_field_types.
|
||||
(print_record_field_types): Change return value and update comment.
|
||||
Re-implement using print_selected_record_field_types.
|
||||
(print_choices): Print "=>" here.
|
||||
Handle case of unencoded variant branch.
|
||||
(print_variant_clauses): Reformat comment.
|
||||
Special-case unencoded variant branch.
|
||||
|
||||
2010-10-03 Paul Hilfinger <hilfinger@adacore.com>
|
||||
|
||||
* ada-lang.c (wild_match): Reimplement.
|
||||
Change API to eliminate unused length argument, reverse arguments and
|
||||
|
@ -38,13 +38,17 @@
|
||||
#include "gdb_string.h"
|
||||
#include <errno.h>
|
||||
|
||||
static int print_selected_record_field_types (struct type *, struct type *,
|
||||
int, int,
|
||||
struct ui_file *, int, int);
|
||||
|
||||
static int print_record_field_types (struct type *, struct type *,
|
||||
struct ui_file *, int, int);
|
||||
|
||||
static void print_array_type (struct type *, struct ui_file *, int, int);
|
||||
|
||||
static void print_choices (struct type *, int, struct ui_file *,
|
||||
struct type *);
|
||||
static int print_choices (struct type *, int, struct ui_file *,
|
||||
struct type *);
|
||||
|
||||
static void print_range (struct type *, struct ui_file *);
|
||||
|
||||
@ -397,9 +401,14 @@ print_array_type (struct type *type, struct ui_file *stream, int show,
|
||||
}
|
||||
|
||||
/* Print the choices encoded by field FIELD_NUM of variant-part TYPE on
|
||||
STREAM, assuming that VAL_TYPE (if non-NULL) is the type of the values. */
|
||||
STREAM, assuming that VAL_TYPE (if non-NULL) is the type of the
|
||||
values. Returns non-zero if the field is an encoding of
|
||||
discriminant values, as in a standard variant record, and 0 if the
|
||||
field is not so encoded (as happens with single-component variants
|
||||
in types annotated with pragma Unchecked_Variant.)
|
||||
*/
|
||||
|
||||
static void
|
||||
static int
|
||||
print_choices (struct type *type, int field_num, struct ui_file *stream,
|
||||
struct type *val_type)
|
||||
{
|
||||
@ -423,7 +432,11 @@ print_choices (struct type *type, int field_num, struct ui_file *stream,
|
||||
switch (name[p])
|
||||
{
|
||||
default:
|
||||
return;
|
||||
goto Huh;
|
||||
case '_':
|
||||
case '\0':
|
||||
fprintf_filtered (stream, " =>");
|
||||
return 1;
|
||||
case 'S':
|
||||
case 'R':
|
||||
case 'O':
|
||||
@ -464,18 +477,17 @@ print_choices (struct type *type, int field_num, struct ui_file *stream,
|
||||
}
|
||||
|
||||
Huh:
|
||||
fprintf_filtered (stream, "??");
|
||||
|
||||
fprintf_filtered (stream, "?? =>");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Assuming that field FIELD_NUM of TYPE is a VARIANTS field whose
|
||||
discriminant is contained in OUTER_TYPE, print its variants on STREAM.
|
||||
LEVEL is the recursion
|
||||
(indentation) level, in case any of the fields themselves have
|
||||
nested structure, and SHOW is the number of levels of internal structure
|
||||
to show (see ada_print_type). For this purpose, fields nested in a
|
||||
variant part are taken to be at the same level as the fields
|
||||
immediately outside the variant part. */
|
||||
/* Assuming that field FIELD_NUM of TYPE represents variants whose
|
||||
discriminant is contained in OUTER_TYPE, print its components on STREAM.
|
||||
LEVEL is the recursion (indentation) level, in case any of the fields
|
||||
themselves have nested structure, and SHOW is the number of levels of
|
||||
internal structure to show (see ada_print_type). For this purpose,
|
||||
fields nested in a variant part are taken to be at the same level as
|
||||
the fields immediately outside the variant part. */
|
||||
|
||||
static void
|
||||
print_variant_clauses (struct type *type, int field_num,
|
||||
@ -503,11 +515,16 @@ print_variant_clauses (struct type *type, int field_num,
|
||||
for (i = 0; i < TYPE_NFIELDS (var_type); i += 1)
|
||||
{
|
||||
fprintf_filtered (stream, "\n%*swhen ", level + 4, "");
|
||||
print_choices (var_type, i, stream, discr_type);
|
||||
fprintf_filtered (stream, " =>");
|
||||
if (print_record_field_types (TYPE_FIELD_TYPE (var_type, i),
|
||||
outer_type, stream, show, level + 4) <= 0)
|
||||
fprintf_filtered (stream, " null;");
|
||||
if (print_choices (var_type, i, stream, discr_type))
|
||||
{
|
||||
if (print_record_field_types (TYPE_FIELD_TYPE (var_type, i),
|
||||
outer_type, stream, show, level + 4)
|
||||
<= 0)
|
||||
fprintf_filtered (stream, " null;");
|
||||
}
|
||||
else
|
||||
print_selected_record_field_types (var_type, outer_type, i, i,
|
||||
stream, show, level + 4);
|
||||
}
|
||||
}
|
||||
|
||||
@ -531,28 +548,28 @@ print_variant_part (struct type *type, int field_num, struct type *outer_type,
|
||||
fprintf_filtered (stream, "\n%*send case;", level + 4, "");
|
||||
}
|
||||
|
||||
/* Print a description on STREAM of the fields in record type TYPE, whose
|
||||
discriminants are in OUTER_TYPE. LEVEL is the recursion (indentation)
|
||||
level, in case any of the fields themselves have nested structure,
|
||||
and SHOW is the number of levels of internal structure to show
|
||||
(see ada_print_type). Does not print parent type information of TYPE.
|
||||
Returns 0 if no fields printed, -1 for an incomplete type, else > 0.
|
||||
Prints each field beginning on a new line, but does not put a new line at
|
||||
end. */
|
||||
/* Print a description on STREAM of the fields FLD0 through FLD1 in
|
||||
record or union type TYPE, whose discriminants are in OUTER_TYPE.
|
||||
LEVEL is the recursion (indentation) level, in case any of the
|
||||
fields themselves have nested structure, and SHOW is the number of
|
||||
levels of internal structure to show (see ada_print_type). Does
|
||||
not print parent type information of TYPE. Returns 0 if no fields
|
||||
printed, -1 for an incomplete type, else > 0. Prints each field
|
||||
beginning on a new line, but does not put a new line at end. */
|
||||
|
||||
static int
|
||||
print_record_field_types (struct type *type, struct type *outer_type,
|
||||
struct ui_file *stream, int show, int level)
|
||||
print_selected_record_field_types (struct type *type, struct type *outer_type,
|
||||
int fld0, int fld1,
|
||||
struct ui_file *stream, int show, int level)
|
||||
{
|
||||
int len, i, flds;
|
||||
int i, flds;
|
||||
|
||||
flds = 0;
|
||||
len = TYPE_NFIELDS (type);
|
||||
|
||||
if (len == 0 && TYPE_STUB (type))
|
||||
if (fld0 > fld1 && TYPE_STUB (type))
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < len; i += 1)
|
||||
for (i = fld0; i <= fld1; i += 1)
|
||||
{
|
||||
QUIT;
|
||||
|
||||
@ -580,6 +597,19 @@ print_record_field_types (struct type *type, struct type *outer_type,
|
||||
return flds;
|
||||
}
|
||||
|
||||
/* Print a description on STREAM of all fields of record or union type
|
||||
TYPE, as for print_selected_record_field_types, above. */
|
||||
|
||||
static int
|
||||
print_record_field_types (struct type *type, struct type *outer_type,
|
||||
struct ui_file *stream, int show, int level)
|
||||
{
|
||||
return print_selected_record_field_types (type, outer_type,
|
||||
0, TYPE_NFIELDS (type) - 1,
|
||||
stream, show, level);
|
||||
}
|
||||
|
||||
|
||||
/* Print record type TYPE on STREAM. LEVEL is the recursion (indentation)
|
||||
level, in case the element type itself has nested structure, and SHOW is
|
||||
the number of levels of internal structure to show (see ada_print_type). */
|
||||
|
Loading…
Reference in New Issue
Block a user