mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-04-24 14:53:34 +08:00
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:
parent
26733fc747
commit
76fc0f6213
@ -354,7 +354,7 @@ coff_alloc_type (int index)
|
||||
We will fill it in later if we find out how. */
|
||||
if (type == NULL)
|
||||
{
|
||||
type = type_allocator (coffread_objfile).new_type ();
|
||||
type = type_allocator (coffread_objfile, language_c).new_type ();
|
||||
*type_addr = 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);
|
||||
index_type = builtin_type (objfile)->builtin_int;
|
||||
type_allocator alloc (objfile);
|
||||
type_allocator alloc (objfile, language_c);
|
||||
range_type
|
||||
= create_static_range_type (alloc, index_type, 0, n - 1);
|
||||
type = create_array_type (alloc, base_type, range_type);
|
||||
|
@ -370,7 +370,7 @@ ctf_init_float_type (struct objfile *objfile,
|
||||
const struct floatformat **format;
|
||||
struct type *type;
|
||||
|
||||
type_allocator alloc (objfile);
|
||||
type_allocator alloc (objfile, language_c);
|
||||
format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits);
|
||||
if (format != nullptr)
|
||||
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)));
|
||||
}
|
||||
|
||||
type_allocator alloc (of);
|
||||
type_allocator alloc (of, language_c);
|
||||
kind = ctf_type_kind (fp, tid);
|
||||
if (kind == CTF_K_INTEGER)
|
||||
{
|
||||
@ -629,7 +629,7 @@ read_structure_type (struct ctf_context *ccp, ctf_id_t tid)
|
||||
struct type *type;
|
||||
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);
|
||||
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;
|
||||
uint32_t argc;
|
||||
|
||||
type = type_allocator (of).new_type ();
|
||||
type = type_allocator (of, language_c).new_type ();
|
||||
|
||||
type->set_code (TYPE_CODE_FUNC);
|
||||
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;
|
||||
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);
|
||||
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)
|
||||
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);
|
||||
type = create_array_type (alloc, element_type, range_type);
|
||||
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;
|
||||
|
||||
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);
|
||||
target_type = fetch_tid_type (ccp, btid);
|
||||
if (target_type != this_type)
|
||||
@ -976,7 +977,7 @@ read_forward_type (struct ctf_context *ccp, ctf_id_t tid)
|
||||
struct type *type;
|
||||
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);
|
||||
if (name != nullptr && strlen (name) != 0)
|
||||
|
@ -5890,8 +5890,8 @@ fixup_go_packaging (struct dwarf2_cu *cu)
|
||||
struct objfile *objfile = cu->per_objfile->objfile;
|
||||
const char *saved_package_name = objfile->intern (package_name.get ());
|
||||
struct type *type
|
||||
= type_allocator (objfile).new_type (TYPE_CODE_MODULE, 0,
|
||||
saved_package_name);
|
||||
= type_allocator (objfile, cu->lang ()).new_type (TYPE_CODE_MODULE, 0,
|
||||
saved_package_name);
|
||||
struct symbol *sym;
|
||||
|
||||
sym = new (&objfile->objfile_obstack) symbol;
|
||||
@ -6077,8 +6077,8 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
|
||||
= rust_fully_qualify (&objfile->objfile_obstack, type->name (),
|
||||
name);
|
||||
struct type *dataless_type
|
||||
= type_allocator (objfile).new_type (TYPE_CODE_VOID, 0,
|
||||
dataless_name);
|
||||
= type_allocator (type).new_type (TYPE_CODE_VOID, 0,
|
||||
dataless_name);
|
||||
type->field (2).set_type (dataless_type);
|
||||
/* NAME points into the original discriminant name, which
|
||||
already has the correct lifetime. */
|
||||
@ -12215,7 +12215,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
|
||||
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);
|
||||
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;
|
||||
|
||||
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 (),
|
||||
pfn_type->fields (), pfn_type->num_fields (),
|
||||
pfn_type->has_varargs ());
|
||||
@ -12680,15 +12680,8 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
return set_die_type (die, type, cu);
|
||||
}
|
||||
|
||||
type = type_allocator (objfile).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);
|
||||
type = type_allocator (objfile, cu->lang ()).new_type ();
|
||||
INIT_CPLUS_SPECIFIC (type);
|
||||
|
||||
name = dwarf2_name (die, cu);
|
||||
if (name != NULL)
|
||||
@ -13291,7 +13284,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *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);
|
||||
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));
|
||||
}
|
||||
|
||||
type_allocator alloc (objfile);
|
||||
type_allocator alloc (objfile, cu->lang ());
|
||||
struct type *bounds = alloc.new_type ();
|
||||
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 ();
|
||||
}
|
||||
|
||||
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->alloc_fields (2);
|
||||
@ -13722,7 +13715,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
if (die->child == NULL)
|
||||
{
|
||||
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);
|
||||
type = create_array_type_with_stride (alloc, element_type, range_type,
|
||||
byte_stride_prop, bit_stride);
|
||||
@ -13761,7 +13754,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
|
||||
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)
|
||||
{
|
||||
int i = 0;
|
||||
@ -13891,7 +13884,7 @@ read_set_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
if (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);
|
||||
|
||||
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);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
@ -14173,7 +14167,8 @@ read_module_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
struct type *type;
|
||||
|
||||
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);
|
||||
}
|
||||
@ -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)
|
||||
{
|
||||
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 (),
|
||||
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;
|
||||
type_allocator alloc (objfile);
|
||||
type_allocator alloc (objfile, cu->lang ());
|
||||
if (length_is_constant)
|
||||
range_type = create_static_range_type (alloc, index_type, 1, length);
|
||||
else
|
||||
@ -14787,7 +14782,8 @@ read_typedef (struct die_info *die, struct dwarf2_cu *cu)
|
||||
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);
|
||||
set_die_type (die, this_type, cu);
|
||||
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;
|
||||
struct type *type;
|
||||
|
||||
type_allocator alloc (objfile);
|
||||
type_allocator alloc (objfile, cu->lang ());
|
||||
format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits);
|
||||
if (format)
|
||||
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;
|
||||
else
|
||||
{
|
||||
type_allocator alloc (objfile);
|
||||
type_allocator alloc (objfile, cu->lang ());
|
||||
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)
|
||||
{
|
||||
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
|
||||
|| attr_bit_stride != nullptr)
|
||||
{
|
||||
@ -15845,7 +15841,7 @@ read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
{
|
||||
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));
|
||||
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));
|
||||
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.
|
||||
|
@ -217,6 +217,7 @@ type_allocator::new_type ()
|
||||
/* Alloc the structure and start off with all fields zeroed. */
|
||||
struct type *type = OBSTACK_ZALLOC (obstack, struct type);
|
||||
TYPE_MAIN_TYPE (type) = OBSTACK_ZALLOC (obstack, struct main_type);
|
||||
TYPE_MAIN_TYPE (type)->m_lang = m_lang;
|
||||
|
||||
if (m_is_objfile)
|
||||
{
|
||||
@ -5385,10 +5386,6 @@ recursive_dump_type (struct type *type, int spaces)
|
||||
print_gnat_stuff (type, spaces);
|
||||
break;
|
||||
|
||||
case TYPE_SPECIFIC_RUST_STUFF:
|
||||
gdb_printf ("%*srust\n", spaces, "");
|
||||
break;
|
||||
|
||||
case TYPE_SPECIFIC_FLOATFORMAT:
|
||||
gdb_printf ("%*sfloatformat ", spaces, "");
|
||||
if (TYPE_FLOATFORMAT (type) == NULL
|
||||
@ -5629,9 +5626,6 @@ copy_type_recursive (struct type *type, htab_t copied_types)
|
||||
case TYPE_SPECIFIC_GNAT_STUFF:
|
||||
INIT_GNAT_SPECIFIC (new_type);
|
||||
break;
|
||||
case TYPE_SPECIFIC_RUST_STUFF:
|
||||
INIT_RUST_SPECIFIC (new_type);
|
||||
break;
|
||||
case TYPE_SPECIFIC_SELF_TYPE:
|
||||
set_type_self_type (new_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);
|
||||
}
|
||||
|
||||
/* 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
|
||||
type::is_array_like ()
|
||||
{
|
||||
if (code () == TYPE_CODE_ARRAY)
|
||||
return true;
|
||||
if (HAVE_GNAT_AUX_INFO (this))
|
||||
return (ada_is_constrained_packed_array_type (this)
|
||||
|| ada_is_array_descriptor_type (this));
|
||||
if (HAVE_RUST_SPECIFIC (this))
|
||||
return rust_slice_type_p (this);
|
||||
return false;
|
||||
const language_defn *defn = language_def (this->language ());
|
||||
return defn->is_array_like (this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -501,7 +501,6 @@ enum type_specific_kind
|
||||
TYPE_SPECIFIC_NONE,
|
||||
TYPE_SPECIFIC_CPLUS_STUFF,
|
||||
TYPE_SPECIFIC_GNAT_STUFF,
|
||||
TYPE_SPECIFIC_RUST_STUFF,
|
||||
TYPE_SPECIFIC_FLOATFORMAT,
|
||||
/* Note: This is used by TYPE_CODE_FUNC and TYPE_CODE_METHOD. */
|
||||
TYPE_SPECIFIC_FUNC,
|
||||
@ -857,7 +856,11 @@ struct main_type
|
||||
/* * A discriminant telling us which field of the type_specific
|
||||
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
|
||||
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 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,
|
||||
but also some forms of structure type that are recognized as
|
||||
representations of arrays by the type's language. */
|
||||
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.
|
||||
NULL if no such pointer-to type is known yet.
|
||||
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)->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) \
|
||||
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FUNC, \
|
||||
TYPE_MAIN_TYPE (type)->type_specific.func_stuff = (struct func_type *) \
|
||||
@ -2242,14 +2245,16 @@ class type_allocator
|
||||
public:
|
||||
|
||||
/* Create new types on OBJFILE. */
|
||||
explicit type_allocator (objfile *objfile)
|
||||
: m_is_objfile (true)
|
||||
type_allocator (objfile *objfile, enum language lang)
|
||||
: m_is_objfile (true),
|
||||
m_lang (lang)
|
||||
{
|
||||
m_data.objfile = objfile;
|
||||
}
|
||||
|
||||
/* Create new types on GDBARCH. */
|
||||
explicit type_allocator (gdbarch *gdbarch)
|
||||
: m_lang (language_minimal)
|
||||
{
|
||||
m_data.gdbarch = gdbarch;
|
||||
}
|
||||
@ -2269,6 +2274,7 @@ public:
|
||||
is passed, overwrite TYPE. */
|
||||
explicit type_allocator (struct type *type,
|
||||
type_allocator_kind kind = SAME)
|
||||
: m_lang (type->language ())
|
||||
{
|
||||
if (kind == SAME)
|
||||
{
|
||||
@ -2289,7 +2295,8 @@ public:
|
||||
|
||||
/* Create new types on the same obstack as 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 ())
|
||||
m_data.objfile = type->objfile_owner ();
|
||||
@ -2326,6 +2333,8 @@ private:
|
||||
/* True if this allocator uses the type field above, indicating that
|
||||
the "allocation" should be done in-place. */
|
||||
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
|
||||
|
@ -1382,7 +1382,7 @@ basic_type (int bt, struct objfile *objfile)
|
||||
if (map_bt[bt])
|
||||
return map_bt[bt];
|
||||
|
||||
type_allocator alloc (objfile);
|
||||
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||
|
||||
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. */
|
||||
ax++;
|
||||
@ -4291,7 +4291,7 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp,
|
||||
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.
|
||||
Set TYPE_STUB for these types so that check_typedef will
|
||||
@ -4754,7 +4754,8 @@ new_type (char *name)
|
||||
{
|
||||
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);
|
||||
INIT_CPLUS_SPECIFIC (t);
|
||||
return t;
|
||||
|
@ -448,17 +448,19 @@ static PyObject *
|
||||
typy_is_array_like (PyObject *self, void *closure)
|
||||
{
|
||||
struct type *type = ((type_object *) self)->type;
|
||||
bool result = false;
|
||||
|
||||
try
|
||||
{
|
||||
type = check_typedef (type);
|
||||
result = type->is_array_like ();
|
||||
}
|
||||
catch (const gdb_exception &except)
|
||||
{
|
||||
GDB_PY_HANDLE_EXCEPTION (except);
|
||||
}
|
||||
|
||||
if (type->is_array_like ())
|
||||
if (result)
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
@ -475,14 +477,7 @@ typy_is_string_like (PyObject *self, void *closure)
|
||||
try
|
||||
{
|
||||
type = check_typedef (type);
|
||||
|
||||
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);
|
||||
result = type->is_string_like ();
|
||||
}
|
||||
catch (const gdb_exception &except)
|
||||
{
|
||||
|
@ -346,7 +346,8 @@ dbx_alloc_type (int typenums[2], struct objfile *objfile)
|
||||
|
||||
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);
|
||||
@ -356,7 +357,8 @@ dbx_alloc_type (int typenums[2], struct objfile *objfile)
|
||||
We will fill it in later if we find out how. */
|
||||
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);
|
||||
@ -372,7 +374,7 @@ dbx_init_float_type (struct objfile *objfile, int bits)
|
||||
struct type *type;
|
||||
|
||||
format = gdbarch_floatformat_for_type (gdbarch, NULL, bits);
|
||||
type_allocator alloc (objfile);
|
||||
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||
if (format)
|
||||
type = init_float_type (alloc, bits, NULL, format);
|
||||
else
|
||||
@ -877,7 +879,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
|
||||
|
||||
/* NULL terminate the string. */
|
||||
string_local[ind] = 0;
|
||||
type_allocator alloc (objfile);
|
||||
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||
range_type
|
||||
= create_static_range_type (alloc,
|
||||
builtin_type (objfile)->builtin_int,
|
||||
@ -2014,7 +2016,7 @@ again:
|
||||
case 'S': /* Set type */
|
||||
{
|
||||
type1 = read_type (pp, objfile);
|
||||
type_allocator alloc (objfile);
|
||||
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||
type = create_set_type (alloc, type1);
|
||||
if (typenums[0] != -1)
|
||||
*dbx_lookup_type (typenums, objfile) = type;
|
||||
@ -2081,7 +2083,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
|
||||
TARGET_CHAR_BIT. */
|
||||
#endif
|
||||
|
||||
type_allocator alloc (objfile);
|
||||
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||
switch (-typenum)
|
||||
{
|
||||
case 1:
|
||||
@ -3536,7 +3538,7 @@ read_array_type (const char **pp, struct type *type,
|
||||
upper = -1;
|
||||
}
|
||||
|
||||
type_allocator alloc (objfile);
|
||||
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||
range_type =
|
||||
create_static_range_type (alloc, index_type, lower, upper);
|
||||
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 == ';')
|
||||
++(*pp);
|
||||
|
||||
type_allocator alloc (objfile);
|
||||
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||
if (type_bits == 0)
|
||||
{
|
||||
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)
|
||||
return error_type (pp, objfile);
|
||||
|
||||
type_allocator alloc (objfile);
|
||||
type_allocator alloc (objfile, get_current_subfile ()->language);
|
||||
|
||||
if (index_type)
|
||||
goto handle_true_range;
|
||||
|
@ -262,10 +262,8 @@ value_to_array (struct value *val)
|
||||
|
||||
if (type->is_array_like ())
|
||||
{
|
||||
if (HAVE_GNAT_AUX_INFO (type))
|
||||
return ada_coerce_to_simple_array (val);
|
||||
if (HAVE_RUST_SPECIFIC (type))
|
||||
return rust_slice_to_array (val);
|
||||
const language_defn *defn = language_def (type->language ());
|
||||
return defn->to_array (val);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user