forked from Imagelibrary/binutils-gdb
Give a language to a type
This changes main_type to hold a language, and updates the debug readers to set this field. This is done by adding the language to the type-allocator object. Note that the non-DWARF readers are changed on a "best effort" basis. This patch also reimplements type::is_array_like to use the type's language, and it adds a new type::is_string_like as well. This in turn lets us change the Python implementation of these methods to simply defer to the type.
This commit is contained in:
@@ -354,7 +354,7 @@ coff_alloc_type (int index)
|
|||||||
We will fill it in later if we find out how. */
|
We will fill it in later if we find out how. */
|
||||||
if (type == NULL)
|
if (type == NULL)
|
||||||
{
|
{
|
||||||
type = type_allocator (coffread_objfile).new_type ();
|
type = type_allocator (coffread_objfile, language_c).new_type ();
|
||||||
*type_addr = type;
|
*type_addr = type;
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
@@ -1763,7 +1763,7 @@ decode_type (struct coff_symbol *cs, unsigned int c_type,
|
|||||||
|
|
||||||
base_type = decode_type (cs, new_c_type, aux, objfile);
|
base_type = decode_type (cs, new_c_type, aux, objfile);
|
||||||
index_type = builtin_type (objfile)->builtin_int;
|
index_type = builtin_type (objfile)->builtin_int;
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, language_c);
|
||||||
range_type
|
range_type
|
||||||
= create_static_range_type (alloc, index_type, 0, n - 1);
|
= create_static_range_type (alloc, index_type, 0, n - 1);
|
||||||
type = create_array_type (alloc, base_type, range_type);
|
type = create_array_type (alloc, base_type, range_type);
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ ctf_init_float_type (struct objfile *objfile,
|
|||||||
const struct floatformat **format;
|
const struct floatformat **format;
|
||||||
struct type *type;
|
struct type *type;
|
||||||
|
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, language_c);
|
||||||
format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits);
|
format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits);
|
||||||
if (format != nullptr)
|
if (format != nullptr)
|
||||||
type = init_float_type (alloc, bits, name, format);
|
type = init_float_type (alloc, bits, name, format);
|
||||||
@@ -553,7 +553,7 @@ read_base_type (struct ctf_context *ccp, ctf_id_t tid)
|
|||||||
ctf_errmsg (ctf_errno (fp)));
|
ctf_errmsg (ctf_errno (fp)));
|
||||||
}
|
}
|
||||||
|
|
||||||
type_allocator alloc (of);
|
type_allocator alloc (of, language_c);
|
||||||
kind = ctf_type_kind (fp, tid);
|
kind = ctf_type_kind (fp, tid);
|
||||||
if (kind == CTF_K_INTEGER)
|
if (kind == CTF_K_INTEGER)
|
||||||
{
|
{
|
||||||
@@ -629,7 +629,7 @@ read_structure_type (struct ctf_context *ccp, ctf_id_t tid)
|
|||||||
struct type *type;
|
struct type *type;
|
||||||
uint32_t kind;
|
uint32_t kind;
|
||||||
|
|
||||||
type = type_allocator (of).new_type ();
|
type = type_allocator (of, language_c).new_type ();
|
||||||
|
|
||||||
const char *name = ctf_type_name_raw (fp, tid);
|
const char *name = ctf_type_name_raw (fp, tid);
|
||||||
if (name != nullptr && strlen (name) != 0)
|
if (name != nullptr && strlen (name) != 0)
|
||||||
@@ -688,7 +688,7 @@ read_func_kind_type (struct ctf_context *ccp, ctf_id_t tid)
|
|||||||
ctf_funcinfo_t cfi;
|
ctf_funcinfo_t cfi;
|
||||||
uint32_t argc;
|
uint32_t argc;
|
||||||
|
|
||||||
type = type_allocator (of).new_type ();
|
type = type_allocator (of, language_c).new_type ();
|
||||||
|
|
||||||
type->set_code (TYPE_CODE_FUNC);
|
type->set_code (TYPE_CODE_FUNC);
|
||||||
if (ctf_func_type_info (fp, tid, &cfi) < 0)
|
if (ctf_func_type_info (fp, tid, &cfi) < 0)
|
||||||
@@ -739,7 +739,7 @@ read_enum_type (struct ctf_context *ccp, ctf_id_t tid)
|
|||||||
ctf_dict_t *fp = ccp->fp;
|
ctf_dict_t *fp = ccp->fp;
|
||||||
struct type *type;
|
struct type *type;
|
||||||
|
|
||||||
type = type_allocator (of).new_type ();
|
type = type_allocator (of, language_c).new_type ();
|
||||||
|
|
||||||
const char *name = ctf_type_name_raw (fp, tid);
|
const char *name = ctf_type_name_raw (fp, tid);
|
||||||
if (name != nullptr && strlen (name) != 0)
|
if (name != nullptr && strlen (name) != 0)
|
||||||
@@ -828,7 +828,7 @@ read_array_type (struct ctf_context *ccp, ctf_id_t tid)
|
|||||||
if (idx_type == nullptr)
|
if (idx_type == nullptr)
|
||||||
idx_type = builtin_type (objfile)->builtin_int;
|
idx_type = builtin_type (objfile)->builtin_int;
|
||||||
|
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, language_c);
|
||||||
range_type = create_static_range_type (alloc, idx_type, 0, ar.ctr_nelems - 1);
|
range_type = create_static_range_type (alloc, idx_type, 0, ar.ctr_nelems - 1);
|
||||||
type = create_array_type (alloc, element_type, range_type);
|
type = create_array_type (alloc, element_type, range_type);
|
||||||
if (ar.ctr_nelems <= 1) /* Check if undefined upper bound. */
|
if (ar.ctr_nelems <= 1) /* Check if undefined upper bound. */
|
||||||
@@ -928,7 +928,8 @@ read_typedef_type (struct ctf_context *ccp, ctf_id_t tid,
|
|||||||
struct type *this_type, *target_type;
|
struct type *this_type, *target_type;
|
||||||
|
|
||||||
char *aname = obstack_strdup (&objfile->objfile_obstack, name);
|
char *aname = obstack_strdup (&objfile->objfile_obstack, name);
|
||||||
this_type = type_allocator (objfile).new_type (TYPE_CODE_TYPEDEF, 0, aname);
|
this_type = type_allocator (objfile, language_c).new_type (TYPE_CODE_TYPEDEF,
|
||||||
|
0, aname);
|
||||||
set_tid_type (objfile, tid, this_type);
|
set_tid_type (objfile, tid, this_type);
|
||||||
target_type = fetch_tid_type (ccp, btid);
|
target_type = fetch_tid_type (ccp, btid);
|
||||||
if (target_type != this_type)
|
if (target_type != this_type)
|
||||||
@@ -976,7 +977,7 @@ read_forward_type (struct ctf_context *ccp, ctf_id_t tid)
|
|||||||
struct type *type;
|
struct type *type;
|
||||||
uint32_t kind;
|
uint32_t kind;
|
||||||
|
|
||||||
type = type_allocator (of).new_type ();
|
type = type_allocator (of, language_c).new_type ();
|
||||||
|
|
||||||
const char *name = ctf_type_name_raw (fp, tid);
|
const char *name = ctf_type_name_raw (fp, tid);
|
||||||
if (name != nullptr && strlen (name) != 0)
|
if (name != nullptr && strlen (name) != 0)
|
||||||
|
|||||||
@@ -5890,7 +5890,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
|
|||||||
struct objfile *objfile = cu->per_objfile->objfile;
|
struct objfile *objfile = cu->per_objfile->objfile;
|
||||||
const char *saved_package_name = objfile->intern (package_name.get ());
|
const char *saved_package_name = objfile->intern (package_name.get ());
|
||||||
struct type *type
|
struct type *type
|
||||||
= type_allocator (objfile).new_type (TYPE_CODE_MODULE, 0,
|
= type_allocator (objfile, cu->lang ()).new_type (TYPE_CODE_MODULE, 0,
|
||||||
saved_package_name);
|
saved_package_name);
|
||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
|
|
||||||
@@ -6077,7 +6077,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
|
|||||||
= rust_fully_qualify (&objfile->objfile_obstack, type->name (),
|
= rust_fully_qualify (&objfile->objfile_obstack, type->name (),
|
||||||
name);
|
name);
|
||||||
struct type *dataless_type
|
struct type *dataless_type
|
||||||
= type_allocator (objfile).new_type (TYPE_CODE_VOID, 0,
|
= type_allocator (type).new_type (TYPE_CODE_VOID, 0,
|
||||||
dataless_name);
|
dataless_name);
|
||||||
type->field (2).set_type (dataless_type);
|
type->field (2).set_type (dataless_type);
|
||||||
/* NAME points into the original discriminant name, which
|
/* NAME points into the original discriminant name, which
|
||||||
@@ -12215,7 +12215,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
|
|||||||
fnp->physname = physname ? physname : "";
|
fnp->physname = physname ? physname : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
fnp->type = type_allocator (objfile).new_type ();
|
fnp->type = type_allocator (objfile, cu->lang ()).new_type ();
|
||||||
this_type = read_type_die (die, cu);
|
this_type = read_type_die (die, cu);
|
||||||
if (this_type && this_type->code () == TYPE_CODE_FUNC)
|
if (this_type && this_type->code () == TYPE_CODE_FUNC)
|
||||||
{
|
{
|
||||||
@@ -12446,7 +12446,7 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
self_type = pfn_type->field (0).type ()->target_type ();
|
self_type = pfn_type->field (0).type ()->target_type ();
|
||||||
new_type = type_allocator (objfile).new_type ();
|
new_type = type_allocator (type).new_type ();
|
||||||
smash_to_method_type (new_type, self_type, pfn_type->target_type (),
|
smash_to_method_type (new_type, self_type, pfn_type->target_type (),
|
||||||
pfn_type->fields (), pfn_type->num_fields (),
|
pfn_type->fields (), pfn_type->num_fields (),
|
||||||
pfn_type->has_varargs ());
|
pfn_type->has_varargs ());
|
||||||
@@ -12680,14 +12680,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
|
|||||||
return set_die_type (die, type, cu);
|
return set_die_type (die, type, cu);
|
||||||
}
|
}
|
||||||
|
|
||||||
type = type_allocator (objfile).new_type ();
|
type = type_allocator (objfile, cu->lang ()).new_type ();
|
||||||
if (cu->lang () == language_rust)
|
|
||||||
{
|
|
||||||
/* This is currently only needed for types that might be
|
|
||||||
slices. */
|
|
||||||
INIT_RUST_SPECIFIC (type);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
INIT_CPLUS_SPECIFIC (type);
|
INIT_CPLUS_SPECIFIC (type);
|
||||||
|
|
||||||
name = dwarf2_name (die, cu);
|
name = dwarf2_name (die, cu);
|
||||||
@@ -13291,7 +13284,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu)
|
|||||||
return set_die_type (die, type, cu);
|
return set_die_type (die, type, cu);
|
||||||
}
|
}
|
||||||
|
|
||||||
type = type_allocator (objfile).new_type ();
|
type = type_allocator (objfile, cu->lang ()).new_type ();
|
||||||
|
|
||||||
type->set_code (TYPE_CODE_ENUM);
|
type->set_code (TYPE_CODE_ENUM);
|
||||||
name = dwarf2_full_name (NULL, die, cu);
|
name = dwarf2_full_name (NULL, die, cu);
|
||||||
@@ -13621,7 +13614,7 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu,
|
|||||||
range_fields[i + 1].set_name (objfile->intern (name));
|
range_fields[i + 1].set_name (objfile->intern (name));
|
||||||
}
|
}
|
||||||
|
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, cu->lang ());
|
||||||
struct type *bounds = alloc.new_type ();
|
struct type *bounds = alloc.new_type ();
|
||||||
bounds->set_code (TYPE_CODE_STRUCT);
|
bounds->set_code (TYPE_CODE_STRUCT);
|
||||||
|
|
||||||
@@ -13645,7 +13638,7 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu,
|
|||||||
iter = iter->target_type ();
|
iter = iter->target_type ();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct type *result = type_allocator (objfile).new_type ();
|
struct type *result = type_allocator (objfile, cu->lang ()).new_type ();
|
||||||
result->set_code (TYPE_CODE_STRUCT);
|
result->set_code (TYPE_CODE_STRUCT);
|
||||||
|
|
||||||
result->alloc_fields (2);
|
result->alloc_fields (2);
|
||||||
@@ -13722,7 +13715,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
|
|||||||
if (die->child == NULL)
|
if (die->child == NULL)
|
||||||
{
|
{
|
||||||
index_type = builtin_type (objfile)->builtin_int;
|
index_type = builtin_type (objfile)->builtin_int;
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, cu->lang ());
|
||||||
range_type = create_static_range_type (alloc, index_type, 0, -1);
|
range_type = create_static_range_type (alloc, index_type, 0, -1);
|
||||||
type = create_array_type_with_stride (alloc, element_type, range_type,
|
type = create_array_type_with_stride (alloc, element_type, range_type,
|
||||||
byte_stride_prop, bit_stride);
|
byte_stride_prop, bit_stride);
|
||||||
@@ -13761,7 +13754,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
|
|||||||
|
|
||||||
type = element_type;
|
type = element_type;
|
||||||
|
|
||||||
type_allocator alloc (cu->per_objfile->objfile);
|
type_allocator alloc (cu->per_objfile->objfile, cu->lang ());
|
||||||
if (read_array_order (die, cu) == DW_ORD_col_major)
|
if (read_array_order (die, cu) == DW_ORD_col_major)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -13891,7 +13884,7 @@ read_set_type (struct die_info *die, struct dwarf2_cu *cu)
|
|||||||
if (set_type)
|
if (set_type)
|
||||||
return set_type;
|
return set_type;
|
||||||
|
|
||||||
type_allocator alloc (cu->per_objfile->objfile);
|
type_allocator alloc (cu->per_objfile->objfile, cu->lang ());
|
||||||
set_type = create_set_type (alloc, domain_type);
|
set_type = create_set_type (alloc, domain_type);
|
||||||
|
|
||||||
attr = dwarf2_attr (die, DW_AT_byte_size, cu);
|
attr = dwarf2_attr (die, DW_AT_byte_size, cu);
|
||||||
@@ -14111,7 +14104,8 @@ read_namespace_type (struct die_info *die, struct dwarf2_cu *cu)
|
|||||||
previous_prefix, name, 0, cu);
|
previous_prefix, name, 0, cu);
|
||||||
|
|
||||||
/* Create the type. */
|
/* Create the type. */
|
||||||
type = type_allocator (objfile).new_type (TYPE_CODE_NAMESPACE, 0, name);
|
type = type_allocator (objfile, cu->lang ()).new_type (TYPE_CODE_NAMESPACE,
|
||||||
|
0, name);
|
||||||
|
|
||||||
return set_die_type (die, type, cu);
|
return set_die_type (die, type, cu);
|
||||||
}
|
}
|
||||||
@@ -14173,7 +14167,8 @@ read_module_type (struct die_info *die, struct dwarf2_cu *cu)
|
|||||||
struct type *type;
|
struct type *type;
|
||||||
|
|
||||||
module_name = dwarf2_name (die, cu);
|
module_name = dwarf2_name (die, cu);
|
||||||
type = type_allocator (objfile).new_type (TYPE_CODE_MODULE, 0, module_name);
|
type = type_allocator (objfile, cu->lang ()).new_type (TYPE_CODE_MODULE,
|
||||||
|
0, module_name);
|
||||||
|
|
||||||
return set_die_type (die, type, cu);
|
return set_die_type (die, type, cu);
|
||||||
}
|
}
|
||||||
@@ -14328,7 +14323,7 @@ read_tag_ptr_to_member_type (struct die_info *die, struct dwarf2_cu *cu)
|
|||||||
else if (check_typedef (to_type)->code () == TYPE_CODE_FUNC)
|
else if (check_typedef (to_type)->code () == TYPE_CODE_FUNC)
|
||||||
{
|
{
|
||||||
struct type *new_type
|
struct type *new_type
|
||||||
= type_allocator (cu->per_objfile->objfile).new_type ();
|
= type_allocator (cu->per_objfile->objfile, cu->lang ()).new_type ();
|
||||||
|
|
||||||
smash_to_method_type (new_type, domain, to_type->target_type (),
|
smash_to_method_type (new_type, domain, to_type->target_type (),
|
||||||
to_type->fields (), to_type->num_fields (),
|
to_type->fields (), to_type->num_fields (),
|
||||||
@@ -14566,7 +14561,7 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
index_type = builtin_type (objfile)->builtin_int;
|
index_type = builtin_type (objfile)->builtin_int;
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, cu->lang ());
|
||||||
if (length_is_constant)
|
if (length_is_constant)
|
||||||
range_type = create_static_range_type (alloc, index_type, 1, length);
|
range_type = create_static_range_type (alloc, index_type, 1, length);
|
||||||
else
|
else
|
||||||
@@ -14787,7 +14782,8 @@ read_typedef (struct die_info *die, struct dwarf2_cu *cu)
|
|||||||
return this_type;
|
return this_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
this_type = type_allocator (objfile).new_type (TYPE_CODE_TYPEDEF, 0, name);
|
type_allocator alloc (objfile, cu->lang ());
|
||||||
|
this_type = alloc.new_type (TYPE_CODE_TYPEDEF, 0, name);
|
||||||
this_type->set_target_is_stub (true);
|
this_type->set_target_is_stub (true);
|
||||||
set_die_type (die, this_type, cu);
|
set_die_type (die, this_type, cu);
|
||||||
if (target_type != this_type)
|
if (target_type != this_type)
|
||||||
@@ -15098,7 +15094,7 @@ dwarf2_init_float_type (struct dwarf2_cu *cu, int bits, const char *name,
|
|||||||
const struct floatformat **format;
|
const struct floatformat **format;
|
||||||
struct type *type;
|
struct type *type;
|
||||||
|
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, cu->lang ());
|
||||||
format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits);
|
format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits);
|
||||||
if (format)
|
if (format)
|
||||||
type = init_float_type (alloc, bits, name, format, byte_order);
|
type = init_float_type (alloc, bits, name, format, byte_order);
|
||||||
@@ -15125,7 +15121,7 @@ dwarf2_init_integer_type (struct dwarf2_cu *cu, int bits, int unsigned_p,
|
|||||||
type = builtin_type (objfile)->builtin_void;
|
type = builtin_type (objfile)->builtin_void;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, cu->lang ());
|
||||||
type = init_integer_type (alloc, bits, unsigned_p, name);
|
type = init_integer_type (alloc, bits, unsigned_p, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15311,7 +15307,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, cu->lang ());
|
||||||
switch (encoding)
|
switch (encoding)
|
||||||
{
|
{
|
||||||
case DW_ATE_address:
|
case DW_ATE_address:
|
||||||
@@ -15800,7 +15796,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type_allocator alloc (cu->per_objfile->objfile);
|
type_allocator alloc (cu->per_objfile->objfile, cu->lang ());
|
||||||
if (attr_byte_stride != nullptr
|
if (attr_byte_stride != nullptr
|
||||||
|| attr_bit_stride != nullptr)
|
|| attr_bit_stride != nullptr)
|
||||||
{
|
{
|
||||||
@@ -15845,7 +15841,7 @@ read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu)
|
|||||||
{
|
{
|
||||||
struct type *type;
|
struct type *type;
|
||||||
|
|
||||||
type = (type_allocator (cu->per_objfile->objfile)
|
type = (type_allocator (cu->per_objfile->objfile, cu->lang ())
|
||||||
.new_type (TYPE_CODE_VOID, 0, nullptr));
|
.new_type (TYPE_CODE_VOID, 0, nullptr));
|
||||||
type->set_name (dwarf2_name (die, cu));
|
type->set_name (dwarf2_name (die, cu));
|
||||||
|
|
||||||
@@ -19706,7 +19702,8 @@ build_error_marker_type (struct dwarf2_cu *cu, struct die_info *die)
|
|||||||
sect_offset_str (die->sect_off));
|
sect_offset_str (die->sect_off));
|
||||||
saved = obstack_strdup (&objfile->objfile_obstack, message);
|
saved = obstack_strdup (&objfile->objfile_obstack, message);
|
||||||
|
|
||||||
return type_allocator (objfile).new_type (TYPE_CODE_ERROR, 0, saved);
|
return type_allocator (objfile, cu->lang ()).new_type (TYPE_CODE_ERROR,
|
||||||
|
0, saved);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Look up the type of DIE in CU using its type attribute ATTR.
|
/* Look up the type of DIE in CU using its type attribute ATTR.
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ type_allocator::new_type ()
|
|||||||
/* Alloc the structure and start off with all fields zeroed. */
|
/* Alloc the structure and start off with all fields zeroed. */
|
||||||
struct type *type = OBSTACK_ZALLOC (obstack, struct type);
|
struct type *type = OBSTACK_ZALLOC (obstack, struct type);
|
||||||
TYPE_MAIN_TYPE (type) = OBSTACK_ZALLOC (obstack, struct main_type);
|
TYPE_MAIN_TYPE (type) = OBSTACK_ZALLOC (obstack, struct main_type);
|
||||||
|
TYPE_MAIN_TYPE (type)->m_lang = m_lang;
|
||||||
|
|
||||||
if (m_is_objfile)
|
if (m_is_objfile)
|
||||||
{
|
{
|
||||||
@@ -5385,10 +5386,6 @@ recursive_dump_type (struct type *type, int spaces)
|
|||||||
print_gnat_stuff (type, spaces);
|
print_gnat_stuff (type, spaces);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_SPECIFIC_RUST_STUFF:
|
|
||||||
gdb_printf ("%*srust\n", spaces, "");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TYPE_SPECIFIC_FLOATFORMAT:
|
case TYPE_SPECIFIC_FLOATFORMAT:
|
||||||
gdb_printf ("%*sfloatformat ", spaces, "");
|
gdb_printf ("%*sfloatformat ", spaces, "");
|
||||||
if (TYPE_FLOATFORMAT (type) == NULL
|
if (TYPE_FLOATFORMAT (type) == NULL
|
||||||
@@ -5629,9 +5626,6 @@ copy_type_recursive (struct type *type, htab_t copied_types)
|
|||||||
case TYPE_SPECIFIC_GNAT_STUFF:
|
case TYPE_SPECIFIC_GNAT_STUFF:
|
||||||
INIT_GNAT_SPECIFIC (new_type);
|
INIT_GNAT_SPECIFIC (new_type);
|
||||||
break;
|
break;
|
||||||
case TYPE_SPECIFIC_RUST_STUFF:
|
|
||||||
INIT_RUST_SPECIFIC (new_type);
|
|
||||||
break;
|
|
||||||
case TYPE_SPECIFIC_SELF_TYPE:
|
case TYPE_SPECIFIC_SELF_TYPE:
|
||||||
set_type_self_type (new_type,
|
set_type_self_type (new_type,
|
||||||
copy_type_recursive (TYPE_SELF_TYPE (type),
|
copy_type_recursive (TYPE_SELF_TYPE (type),
|
||||||
@@ -5948,17 +5942,24 @@ type::copy_fields (std::vector<struct field> &src)
|
|||||||
memcpy (this->fields (), src.data (), size);
|
memcpy (this->fields (), src.data (), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See gdbtypes.h. */
|
||||||
|
|
||||||
|
bool
|
||||||
|
type::is_string_like ()
|
||||||
|
{
|
||||||
|
const language_defn *defn = language_def (this->language ());
|
||||||
|
return defn->is_string_type_p (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See gdbtypes.h. */
|
||||||
|
|
||||||
bool
|
bool
|
||||||
type::is_array_like ()
|
type::is_array_like ()
|
||||||
{
|
{
|
||||||
if (code () == TYPE_CODE_ARRAY)
|
if (code () == TYPE_CODE_ARRAY)
|
||||||
return true;
|
return true;
|
||||||
if (HAVE_GNAT_AUX_INFO (this))
|
const language_defn *defn = language_def (this->language ());
|
||||||
return (ada_is_constrained_packed_array_type (this)
|
return defn->is_array_like (this);
|
||||||
|| ada_is_array_descriptor_type (this));
|
|
||||||
if (HAVE_RUST_SPECIFIC (this))
|
|
||||||
return rust_slice_type_p (this);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -501,7 +501,6 @@ enum type_specific_kind
|
|||||||
TYPE_SPECIFIC_NONE,
|
TYPE_SPECIFIC_NONE,
|
||||||
TYPE_SPECIFIC_CPLUS_STUFF,
|
TYPE_SPECIFIC_CPLUS_STUFF,
|
||||||
TYPE_SPECIFIC_GNAT_STUFF,
|
TYPE_SPECIFIC_GNAT_STUFF,
|
||||||
TYPE_SPECIFIC_RUST_STUFF,
|
|
||||||
TYPE_SPECIFIC_FLOATFORMAT,
|
TYPE_SPECIFIC_FLOATFORMAT,
|
||||||
/* Note: This is used by TYPE_CODE_FUNC and TYPE_CODE_METHOD. */
|
/* Note: This is used by TYPE_CODE_FUNC and TYPE_CODE_METHOD. */
|
||||||
TYPE_SPECIFIC_FUNC,
|
TYPE_SPECIFIC_FUNC,
|
||||||
@@ -857,7 +856,11 @@ struct main_type
|
|||||||
/* * A discriminant telling us which field of the type_specific
|
/* * A discriminant telling us which field of the type_specific
|
||||||
union is being used for this type, if any. */
|
union is being used for this type, if any. */
|
||||||
|
|
||||||
ENUM_BITFIELD(type_specific_kind) type_specific_field : 4;
|
ENUM_BITFIELD(type_specific_kind) type_specific_field : 3;
|
||||||
|
|
||||||
|
/* The language for this type. */
|
||||||
|
|
||||||
|
ENUM_BITFIELD(language) m_lang : LANGUAGE_BITS;
|
||||||
|
|
||||||
/* * Number of fields described for this type. This field appears
|
/* * Number of fields described for this type. This field appears
|
||||||
at this location because it packs nicely here. */
|
at this location because it packs nicely here. */
|
||||||
@@ -1430,11 +1433,19 @@ struct type
|
|||||||
return this->code () == TYPE_CODE_PTR || TYPE_IS_REFERENCE (this);
|
return this->code () == TYPE_CODE_PTR || TYPE_IS_REFERENCE (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return true if this type is "string-like", according to its
|
||||||
|
defining language. */
|
||||||
|
bool is_string_like ();
|
||||||
|
|
||||||
/* Return true if this type is "array-like". This includes arrays,
|
/* Return true if this type is "array-like". This includes arrays,
|
||||||
but also some forms of structure type that are recognized as
|
but also some forms of structure type that are recognized as
|
||||||
representations of arrays by the type's language. */
|
representations of arrays by the type's language. */
|
||||||
bool is_array_like ();
|
bool is_array_like ();
|
||||||
|
|
||||||
|
/* Return the language that this type came from. */
|
||||||
|
enum language language () const
|
||||||
|
{ return main_type->m_lang; }
|
||||||
|
|
||||||
/* * Type that is a pointer to this type.
|
/* * Type that is a pointer to this type.
|
||||||
NULL if no such pointer-to type is known yet.
|
NULL if no such pointer-to type is known yet.
|
||||||
The debugger may add the address of such a type
|
The debugger may add the address of such a type
|
||||||
@@ -1839,14 +1850,6 @@ extern void allocate_gnat_aux_type (struct type *);
|
|||||||
|| (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE \
|
|| (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE \
|
||||||
&& (type)->is_fixed_instance ()))
|
&& (type)->is_fixed_instance ()))
|
||||||
|
|
||||||
/* Currently there isn't any associated data -- this is just a
|
|
||||||
marker. */
|
|
||||||
#define INIT_RUST_SPECIFIC(type) \
|
|
||||||
TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_RUST_STUFF
|
|
||||||
|
|
||||||
#define HAVE_RUST_SPECIFIC(type) \
|
|
||||||
(TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_RUST_STUFF)
|
|
||||||
|
|
||||||
#define INIT_FUNC_SPECIFIC(type) \
|
#define INIT_FUNC_SPECIFIC(type) \
|
||||||
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FUNC, \
|
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FUNC, \
|
||||||
TYPE_MAIN_TYPE (type)->type_specific.func_stuff = (struct func_type *) \
|
TYPE_MAIN_TYPE (type)->type_specific.func_stuff = (struct func_type *) \
|
||||||
@@ -2242,14 +2245,16 @@ class type_allocator
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/* Create new types on OBJFILE. */
|
/* Create new types on OBJFILE. */
|
||||||
explicit type_allocator (objfile *objfile)
|
type_allocator (objfile *objfile, enum language lang)
|
||||||
: m_is_objfile (true)
|
: m_is_objfile (true),
|
||||||
|
m_lang (lang)
|
||||||
{
|
{
|
||||||
m_data.objfile = objfile;
|
m_data.objfile = objfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create new types on GDBARCH. */
|
/* Create new types on GDBARCH. */
|
||||||
explicit type_allocator (gdbarch *gdbarch)
|
explicit type_allocator (gdbarch *gdbarch)
|
||||||
|
: m_lang (language_minimal)
|
||||||
{
|
{
|
||||||
m_data.gdbarch = gdbarch;
|
m_data.gdbarch = gdbarch;
|
||||||
}
|
}
|
||||||
@@ -2269,6 +2274,7 @@ public:
|
|||||||
is passed, overwrite TYPE. */
|
is passed, overwrite TYPE. */
|
||||||
explicit type_allocator (struct type *type,
|
explicit type_allocator (struct type *type,
|
||||||
type_allocator_kind kind = SAME)
|
type_allocator_kind kind = SAME)
|
||||||
|
: m_lang (type->language ())
|
||||||
{
|
{
|
||||||
if (kind == SAME)
|
if (kind == SAME)
|
||||||
{
|
{
|
||||||
@@ -2289,7 +2295,8 @@ public:
|
|||||||
|
|
||||||
/* Create new types on the same obstack as TYPE. */
|
/* Create new types on the same obstack as TYPE. */
|
||||||
explicit type_allocator (const struct type *type)
|
explicit type_allocator (const struct type *type)
|
||||||
: m_is_objfile (type->is_objfile_owned ())
|
: m_is_objfile (type->is_objfile_owned ()),
|
||||||
|
m_lang (type->language ())
|
||||||
{
|
{
|
||||||
if (type->is_objfile_owned ())
|
if (type->is_objfile_owned ())
|
||||||
m_data.objfile = type->objfile_owner ();
|
m_data.objfile = type->objfile_owner ();
|
||||||
@@ -2326,6 +2333,8 @@ private:
|
|||||||
/* True if this allocator uses the type field above, indicating that
|
/* True if this allocator uses the type field above, indicating that
|
||||||
the "allocation" should be done in-place. */
|
the "allocation" should be done in-place. */
|
||||||
bool m_smash = false;
|
bool m_smash = false;
|
||||||
|
/* The language for types created by this allocator. */
|
||||||
|
enum language m_lang;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Allocate a TYPE_CODE_INT type structure using ALLOC. BIT is the
|
/* Allocate a TYPE_CODE_INT type structure using ALLOC. BIT is the
|
||||||
|
|||||||
@@ -1382,7 +1382,7 @@ basic_type (int bt, struct objfile *objfile)
|
|||||||
if (map_bt[bt])
|
if (map_bt[bt])
|
||||||
return map_bt[bt];
|
return map_bt[bt];
|
||||||
|
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||||
|
|
||||||
switch (bt)
|
switch (bt)
|
||||||
{
|
{
|
||||||
@@ -1571,7 +1571,7 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type_allocator alloc (mdebugread_objfile);
|
type_allocator alloc (mdebugread_objfile, get_current_subfile ()->language);
|
||||||
|
|
||||||
/* Move on to next aux. */
|
/* Move on to next aux. */
|
||||||
ax++;
|
ax++;
|
||||||
@@ -4291,7 +4291,7 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp,
|
|||||||
rf = rn->rfd;
|
rf = rn->rfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
type_allocator alloc (mdebugread_objfile);
|
type_allocator alloc (mdebugread_objfile, get_current_subfile ()->language);
|
||||||
|
|
||||||
/* mips cc uses a rf of -1 for opaque struct definitions.
|
/* mips cc uses a rf of -1 for opaque struct definitions.
|
||||||
Set TYPE_STUB for these types so that check_typedef will
|
Set TYPE_STUB for these types so that check_typedef will
|
||||||
@@ -4754,7 +4754,8 @@ new_type (char *name)
|
|||||||
{
|
{
|
||||||
struct type *t;
|
struct type *t;
|
||||||
|
|
||||||
t = type_allocator (mdebugread_objfile).new_type ();
|
t = type_allocator (mdebugread_objfile,
|
||||||
|
get_current_subfile ()->language).new_type ();
|
||||||
t->set_name (name);
|
t->set_name (name);
|
||||||
INIT_CPLUS_SPECIFIC (t);
|
INIT_CPLUS_SPECIFIC (t);
|
||||||
return t;
|
return t;
|
||||||
|
|||||||
@@ -448,17 +448,19 @@ static PyObject *
|
|||||||
typy_is_array_like (PyObject *self, void *closure)
|
typy_is_array_like (PyObject *self, void *closure)
|
||||||
{
|
{
|
||||||
struct type *type = ((type_object *) self)->type;
|
struct type *type = ((type_object *) self)->type;
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
type = check_typedef (type);
|
type = check_typedef (type);
|
||||||
|
result = type->is_array_like ();
|
||||||
}
|
}
|
||||||
catch (const gdb_exception &except)
|
catch (const gdb_exception &except)
|
||||||
{
|
{
|
||||||
GDB_PY_HANDLE_EXCEPTION (except);
|
GDB_PY_HANDLE_EXCEPTION (except);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type->is_array_like ())
|
if (result)
|
||||||
Py_RETURN_TRUE;
|
Py_RETURN_TRUE;
|
||||||
else
|
else
|
||||||
Py_RETURN_FALSE;
|
Py_RETURN_FALSE;
|
||||||
@@ -475,14 +477,7 @@ typy_is_string_like (PyObject *self, void *closure)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
type = check_typedef (type);
|
type = check_typedef (type);
|
||||||
|
result = type->is_string_like ();
|
||||||
const language_defn *lang = nullptr;
|
|
||||||
if (HAVE_GNAT_AUX_INFO (type))
|
|
||||||
lang = language_def (language_ada);
|
|
||||||
else if (HAVE_RUST_SPECIFIC (type))
|
|
||||||
lang = language_def (language_rust);
|
|
||||||
if (lang != nullptr)
|
|
||||||
result = lang->is_string_type_p (type);
|
|
||||||
}
|
}
|
||||||
catch (const gdb_exception &except)
|
catch (const gdb_exception &except)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -346,7 +346,8 @@ dbx_alloc_type (int typenums[2], struct objfile *objfile)
|
|||||||
|
|
||||||
if (typenums[0] == -1)
|
if (typenums[0] == -1)
|
||||||
{
|
{
|
||||||
return type_allocator (objfile).new_type ();
|
return type_allocator (objfile,
|
||||||
|
get_current_subfile ()->language).new_type ();
|
||||||
}
|
}
|
||||||
|
|
||||||
type_addr = dbx_lookup_type (typenums, objfile);
|
type_addr = dbx_lookup_type (typenums, objfile);
|
||||||
@@ -356,7 +357,8 @@ dbx_alloc_type (int typenums[2], struct objfile *objfile)
|
|||||||
We will fill it in later if we find out how. */
|
We will fill it in later if we find out how. */
|
||||||
if (*type_addr == 0)
|
if (*type_addr == 0)
|
||||||
{
|
{
|
||||||
*type_addr = type_allocator (objfile).new_type ();
|
*type_addr = type_allocator (objfile,
|
||||||
|
get_current_subfile ()->language).new_type ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*type_addr);
|
return (*type_addr);
|
||||||
@@ -372,7 +374,7 @@ dbx_init_float_type (struct objfile *objfile, int bits)
|
|||||||
struct type *type;
|
struct type *type;
|
||||||
|
|
||||||
format = gdbarch_floatformat_for_type (gdbarch, NULL, bits);
|
format = gdbarch_floatformat_for_type (gdbarch, NULL, bits);
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||||
if (format)
|
if (format)
|
||||||
type = init_float_type (alloc, bits, NULL, format);
|
type = init_float_type (alloc, bits, NULL, format);
|
||||||
else
|
else
|
||||||
@@ -877,7 +879,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
|
|||||||
|
|
||||||
/* NULL terminate the string. */
|
/* NULL terminate the string. */
|
||||||
string_local[ind] = 0;
|
string_local[ind] = 0;
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||||
range_type
|
range_type
|
||||||
= create_static_range_type (alloc,
|
= create_static_range_type (alloc,
|
||||||
builtin_type (objfile)->builtin_int,
|
builtin_type (objfile)->builtin_int,
|
||||||
@@ -2014,7 +2016,7 @@ again:
|
|||||||
case 'S': /* Set type */
|
case 'S': /* Set type */
|
||||||
{
|
{
|
||||||
type1 = read_type (pp, objfile);
|
type1 = read_type (pp, objfile);
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||||
type = create_set_type (alloc, type1);
|
type = create_set_type (alloc, type1);
|
||||||
if (typenums[0] != -1)
|
if (typenums[0] != -1)
|
||||||
*dbx_lookup_type (typenums, objfile) = type;
|
*dbx_lookup_type (typenums, objfile) = type;
|
||||||
@@ -2081,7 +2083,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
|
|||||||
TARGET_CHAR_BIT. */
|
TARGET_CHAR_BIT. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||||
switch (-typenum)
|
switch (-typenum)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@@ -3536,7 +3538,7 @@ read_array_type (const char **pp, struct type *type,
|
|||||||
upper = -1;
|
upper = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||||
range_type =
|
range_type =
|
||||||
create_static_range_type (alloc, index_type, lower, upper);
|
create_static_range_type (alloc, index_type, lower, upper);
|
||||||
type_allocator smash_alloc (type, type_allocator::SMASH);
|
type_allocator smash_alloc (type, type_allocator::SMASH);
|
||||||
@@ -3734,7 +3736,7 @@ read_sun_builtin_type (const char **pp, int typenums[2], struct objfile *objfile
|
|||||||
if (**pp == ';')
|
if (**pp == ';')
|
||||||
++(*pp);
|
++(*pp);
|
||||||
|
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||||
if (type_bits == 0)
|
if (type_bits == 0)
|
||||||
{
|
{
|
||||||
struct type *type = alloc.new_type (TYPE_CODE_VOID,
|
struct type *type = alloc.new_type (TYPE_CODE_VOID,
|
||||||
@@ -4003,7 +4005,7 @@ read_range_type (const char **pp, int typenums[2], int type_size,
|
|||||||
if (n2bits == -1 || n3bits == -1)
|
if (n2bits == -1 || n3bits == -1)
|
||||||
return error_type (pp, objfile);
|
return error_type (pp, objfile);
|
||||||
|
|
||||||
type_allocator alloc (objfile);
|
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||||
|
|
||||||
if (index_type)
|
if (index_type)
|
||||||
goto handle_true_range;
|
goto handle_true_range;
|
||||||
|
|||||||
@@ -262,10 +262,8 @@ value_to_array (struct value *val)
|
|||||||
|
|
||||||
if (type->is_array_like ())
|
if (type->is_array_like ())
|
||||||
{
|
{
|
||||||
if (HAVE_GNAT_AUX_INFO (type))
|
const language_defn *defn = language_def (type->language ());
|
||||||
return ada_coerce_to_simple_array (val);
|
return defn->to_array (val);
|
||||||
if (HAVE_RUST_SPECIFIC (type))
|
|
||||||
return rust_slice_to_array (val);
|
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user