X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fada-varobj.c;h=f67fe5002a32d4cfbae0e0c7bf68538b6d486e3f;hb=a350efd4fb368a35ada608f6bc26ccd3bed0ae6b;hp=3f375c8f04ae66caccae0d0f92cc8062a7a61bb4;hpb=d55e5aa6b29906346c51ad00e6a9b112590aa294;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c index 3f375c8f04..f67fe5002a 100644 --- a/gdb/ada-varobj.c +++ b/gdb/ada-varobj.c @@ -1,6 +1,6 @@ /* varobj support for Ada. - Copyright (C) 2012-2019 Free Software Foundation, Inc. + Copyright (C) 2012-2020 Free Software Foundation, Inc. This file is part of GDB. @@ -18,12 +18,10 @@ along with this program. If not, see . */ #include "defs.h" - -/* Local non-gdb includes. */ #include "ada-lang.h" +#include "varobj.h" #include "language.h" #include "valprint.h" -#include "varobj.h" /* Implementation principle used in this unit: @@ -107,7 +105,7 @@ ada_varobj_struct_elt (struct value *parent_value, type = value_type (value); } else - type = TYPE_FIELD_TYPE (parent_type, fieldno); + type = parent_type->field (fieldno).type (); if (child_value) *child_value = value; @@ -134,11 +132,11 @@ ada_varobj_ind (struct value *parent_value, ada_get_decoded_value would have transformed our parent_type into a simple array pointer type. */ gdb_assert (parent_value == NULL); - gdb_assert (TYPE_CODE (parent_type) == TYPE_CODE_TYPEDEF); + gdb_assert (parent_type->code () == TYPE_CODE_TYPEDEF); /* Decode parent_type by the equivalent pointer to (decoded) array. */ - while (TYPE_CODE (parent_type) == TYPE_CODE_TYPEDEF) + while (parent_type->code () == TYPE_CODE_TYPEDEF) parent_type = TYPE_TARGET_TYPE (parent_type); parent_type = ada_coerce_to_simple_array_type (parent_type); parent_type = lookup_pointer_type (parent_type); @@ -180,7 +178,7 @@ ada_varobj_simple_array_elt (struct value *parent_value, if (parent_value) { struct value *index_value = - value_from_longest (TYPE_INDEX_TYPE (parent_type), elt_index); + value_from_longest (parent_type->index_type (), elt_index); value = ada_value_subscript (parent_value, 1, &index_value); type = value_type (value); @@ -208,9 +206,9 @@ ada_varobj_adjust_for_child_access (struct value **value, one child (the struct), their children are the components of the struct/union type. We handle this situation by dereferencing the (value, type) couple. */ - if (TYPE_CODE (*type) == TYPE_CODE_PTR - && (TYPE_CODE (TYPE_TARGET_TYPE (*type)) == TYPE_CODE_STRUCT - || TYPE_CODE (TYPE_TARGET_TYPE (*type)) == TYPE_CODE_UNION) + if ((*type)->code () == TYPE_CODE_PTR + && (TYPE_TARGET_TYPE (*type)->code () == TYPE_CODE_STRUCT + || TYPE_TARGET_TYPE (*type)->code () == TYPE_CODE_UNION) && !ada_is_array_descriptor_type (TYPE_TARGET_TYPE (*type)) && !ada_is_constrained_packed_array_type (TYPE_TARGET_TYPE (*type))) ada_varobj_ind (*value, *type, value, type); @@ -236,7 +234,7 @@ ada_varobj_get_array_number_of_children (struct value *parent_value, LONGEST lo, hi; if (parent_value == NULL - && is_dynamic_type (TYPE_INDEX_TYPE (parent_type))) + && is_dynamic_type (parent_type->index_type ())) { /* This happens when listing the children of an object which does not exist in memory (Eg: when requesting @@ -272,10 +270,10 @@ ada_varobj_get_struct_number_of_children (struct value *parent_value, int n_children = 0; int i; - gdb_assert (TYPE_CODE (parent_type) == TYPE_CODE_STRUCT - || TYPE_CODE (parent_type) == TYPE_CODE_UNION); + gdb_assert (parent_type->code () == TYPE_CODE_STRUCT + || parent_type->code () == TYPE_CODE_UNION); - for (i = 0; i < TYPE_NFIELDS (parent_type); i++) + for (i = 0; i < parent_type->num_fields (); i++) { if (ada_is_ignored_field (parent_type, i)) continue; @@ -331,8 +329,8 @@ ada_varobj_get_ptr_number_of_children (struct value *parent_value, /* Pointer to functions and to void do not have a child, since you cannot print what they point to. */ - if (TYPE_CODE (child_type) == TYPE_CODE_FUNC - || TYPE_CODE (child_type) == TYPE_CODE_VOID) + if (child_type->code () == TYPE_CODE_FUNC + || child_type->code () == TYPE_CODE_VOID) return 0; /* All other types have 1 child. */ @@ -355,16 +353,16 @@ ada_varobj_get_number_of_children (struct value *parent_value, if (ada_is_access_to_unconstrained_array (parent_type)) return 1; - if (TYPE_CODE (parent_type) == TYPE_CODE_ARRAY) + if (parent_type->code () == TYPE_CODE_ARRAY) return ada_varobj_get_array_number_of_children (parent_value, parent_type); - if (TYPE_CODE (parent_type) == TYPE_CODE_STRUCT - || TYPE_CODE (parent_type) == TYPE_CODE_UNION) + if (parent_type->code () == TYPE_CODE_STRUCT + || parent_type->code () == TYPE_CODE_UNION) return ada_varobj_get_struct_number_of_children (parent_value, parent_type); - if (TYPE_CODE (parent_type) == TYPE_CODE_PTR) + if (parent_type->code () == TYPE_CODE_PTR) return ada_varobj_get_ptr_number_of_children (parent_value, parent_type); @@ -420,10 +418,10 @@ ada_varobj_describe_struct_child (struct value *parent_value, int fieldno; int childno = 0; - gdb_assert (TYPE_CODE (parent_type) == TYPE_CODE_STRUCT - || TYPE_CODE (parent_type) == TYPE_CODE_UNION); + gdb_assert (parent_type->code () == TYPE_CODE_STRUCT + || parent_type->code () == TYPE_CODE_UNION); - for (fieldno = 0; fieldno < TYPE_NFIELDS (parent_type); fieldno++) + for (fieldno = 0; fieldno < parent_type->num_fields (); fieldno++) { if (ada_is_ignored_field (parent_type, fieldno)) continue; @@ -589,9 +587,9 @@ ada_varobj_describe_simple_array_child (struct value *parent_value, struct type *index_type; int real_index; - gdb_assert (TYPE_CODE (parent_type) == TYPE_CODE_ARRAY); + gdb_assert (parent_type->code () == TYPE_CODE_ARRAY); - index_type = TYPE_INDEX_TYPE (parent_type); + index_type = parent_type->index_type (); real_index = child_index + ada_discrete_type_low_bound (index_type); if (child_name) @@ -626,17 +624,21 @@ ada_varobj_describe_simple_array_child (struct value *parent_value, of the array index type when such type qualification is needed. */ const char *index_type_name = NULL; + std::string decoded; /* If the index type is a range type, find the base type. */ - while (TYPE_CODE (index_type) == TYPE_CODE_RANGE) + while (index_type->code () == TYPE_CODE_RANGE) index_type = TYPE_TARGET_TYPE (index_type); - if (TYPE_CODE (index_type) == TYPE_CODE_ENUM - || TYPE_CODE (index_type) == TYPE_CODE_BOOL) + if (index_type->code () == TYPE_CODE_ENUM + || index_type->code () == TYPE_CODE_BOOL) { index_type_name = ada_type_name (index_type); if (index_type_name) - index_type_name = ada_decode (index_type_name); + { + decoded = ada_decode (index_type_name); + index_type_name = decoded.c_str (); + } } if (index_type_name != NULL) @@ -691,7 +693,7 @@ ada_varobj_describe_child (struct value *parent_value, return; } - if (TYPE_CODE (parent_type) == TYPE_CODE_ARRAY) + if (parent_type->code () == TYPE_CODE_ARRAY) { ada_varobj_describe_simple_array_child (parent_value, parent_type, parent_name, parent_path_expr, @@ -700,8 +702,8 @@ ada_varobj_describe_child (struct value *parent_value, return; } - if (TYPE_CODE (parent_type) == TYPE_CODE_STRUCT - || TYPE_CODE (parent_type) == TYPE_CODE_UNION) + if (parent_type->code () == TYPE_CODE_STRUCT + || parent_type->code () == TYPE_CODE_UNION) { ada_varobj_describe_struct_child (parent_value, parent_type, parent_name, parent_path_expr, @@ -711,7 +713,7 @@ ada_varobj_describe_child (struct value *parent_value, return; } - if (TYPE_CODE (parent_type) == TYPE_CODE_PTR) + if (parent_type->code () == TYPE_CODE_PTR) { ada_varobj_describe_ptr_child (parent_value, parent_type, parent_name, parent_path_expr, @@ -854,7 +856,7 @@ ada_varobj_get_value_of_variable (struct value *value, { ada_varobj_decode_var (&value, &type); - switch (TYPE_CODE (type)) + switch (type->code ()) { case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: @@ -937,7 +939,7 @@ ada_value_is_changeable_p (const struct varobj *var) struct type *type = (var->value != nullptr ? value_type (var->value.get ()) : var->type); - if (TYPE_CODE (type) == TYPE_CODE_REF) + if (type->code () == TYPE_CODE_REF) type = TYPE_TARGET_TYPE (type); if (ada_is_access_to_unconstrained_array (type))