X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fctfread.c;h=c04b043d6d3a1c5fd53443c1465e59be2ca55cc8;hb=4bc4551bdc5cd8e0811e1c94b7367de00e3e4fb8;hp=3940a4f8c6715bcb561ef5baa3b5eae21aec37b8;hpb=f50b437c3da71d91dfb04db8e06b2cdb69d16294;p=binutils-gdb.git diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 3940a4f8c67..c04b043d6d3 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -80,7 +80,7 @@ #include "complaints.h" #include "block.h" #include "ctfread.h" -#include "psympriv.h" +#include "psymtab.h" #if ENABLE_LIBCTF @@ -127,7 +127,7 @@ struct ctf_psymtab : public standard_psymtab ctf_psymtab (const char *filename, psymtab_storage *partial_symtabs, objfile_per_bfd_storage *objfile_per_bfd, - CORE_ADDR addr) + unrelocated_addr addr) : standard_psymtab (filename, partial_symtabs, objfile_per_bfd, addr) { } @@ -346,9 +346,7 @@ attach_fields_to_type (struct ctf_field_info *fip, struct type *type) return; /* Record the field count, allocate space for the array of fields. */ - type->set_num_fields (nfields); - type->set_fields - ((struct field *) TYPE_ZALLOC (type, sizeof (struct field) * nfields)); + type->alloc_fields (nfields); /* Copy the saved-up fields into the field vector. */ for (int i = 0; i < nfields; ++i) @@ -375,7 +373,7 @@ ctf_init_float_type (struct objfile *objfile, type_allocator alloc (objfile); format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits); if (format != nullptr) - type = init_float_type (objfile, bits, name, format); + type = init_float_type (alloc, bits, name, format); else type = alloc.new_type (TYPE_CODE_ERROR, bits, name); @@ -410,7 +408,7 @@ ctf_add_member_cb (const char *name, if (t == nullptr) { complaint (_("ctf_add_member_cb: %s has NO type (%ld)"), name, tid); - t = objfile_type (ccp->of)->builtin_error; + t = builtin_type (ccp->of)->builtin_error; set_tid_type (ccp->of, tid, t); } } @@ -420,7 +418,7 @@ ctf_add_member_cb (const char *name, fp->set_type (t); fp->set_loc_bitpos (offset / TARGET_CHAR_BIT); - FIELD_BITSIZE (*fp) = get_bitsize (ccp->fp, tid, kind); + fp->set_bitsize (get_bitsize (ccp->fp, tid, kind)); fip->fields.emplace_back (new_field); @@ -442,7 +440,7 @@ ctf_add_enum_member_cb (const char *name, int enum_value, void *arg) fp->set_name (name); fp->set_type (nullptr); fp->set_loc_enumval (enum_value); - FIELD_BITSIZE (*fp) = 0; + fp->set_bitsize (0); if (name != nullptr) { @@ -501,7 +499,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid) break; case CTF_K_CONST: if (sym->type ()->code () == TYPE_CODE_VOID) - sym->set_type (objfile_type (objfile)->builtin_int); + sym->set_type (builtin_type (objfile)->builtin_int); break; case CTF_K_TYPEDEF: case CTF_K_INTEGER: @@ -568,7 +566,7 @@ read_base_type (struct ctf_context *ccp, ctf_id_t tid) if (ischar) type = init_character_type (alloc, TARGET_CHAR_BIT, !issigned, name); else if (isbool) - type = init_boolean_type (of, gdbarch_int_bit (gdbarch), + type = init_boolean_type (alloc, gdbarch_int_bit (gdbarch), !issigned, name); else { @@ -715,9 +713,8 @@ read_func_kind_type (struct ctf_context *ccp, ctf_id_t tid) if (ctf_func_type_args (fp, tid, argc, argv.data ()) == CTF_ERR) return nullptr; - type->set_fields - ((struct field *) TYPE_ZALLOC (type, argc * sizeof (struct field))); - struct type *void_type = objfile_type (of)->builtin_void; + type->alloc_fields (argc); + struct type *void_type = builtin_type (of)->builtin_void; /* If failed to find the argument type, fill it with void_type. */ for (int iparam = 0; iparam < argc; iparam++) { @@ -829,10 +826,11 @@ read_array_type (struct ctf_context *ccp, ctf_id_t tid) idx_type = fetch_tid_type (ccp, ar.ctr_index); if (idx_type == nullptr) - idx_type = objfile_type (objfile)->builtin_int; + idx_type = builtin_type (objfile)->builtin_int; - range_type = create_static_range_type (NULL, idx_type, 0, ar.ctr_nelems - 1); - type = create_array_type (NULL, element_type, range_type); + type_allocator alloc (objfile); + 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. */ { range_type->bounds ()->high.set_undefined (); @@ -862,7 +860,7 @@ read_const_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) if (base_type == nullptr) { complaint (_("read_const_type: NULL base type (%ld)"), btid); - base_type = objfile_type (objfile)->builtin_error; + base_type = builtin_type (objfile)->builtin_error; } } cv_type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type, 0); @@ -886,7 +884,7 @@ read_volatile_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) if (base_type == nullptr) { complaint (_("read_volatile_type: NULL base type (%ld)"), btid); - base_type = objfile_type (objfile)->builtin_error; + base_type = builtin_type (objfile)->builtin_error; } } @@ -912,7 +910,7 @@ read_restrict_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) if (base_type == nullptr) { complaint (_("read_restrict_type: NULL base type (%ld)"), btid); - base_type = objfile_type (objfile)->builtin_error; + base_type = builtin_type (objfile)->builtin_error; } } cv_type = make_restrict_type (base_type); @@ -958,7 +956,7 @@ read_pointer_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) if (target_type == nullptr) { complaint (_("read_pointer_type: NULL target type (%ld)"), btid); - target_type = objfile_type (ccp->of)->builtin_error; + target_type = builtin_type (ccp->of)->builtin_error; } } @@ -1166,7 +1164,7 @@ ctf_add_var_cb (const char *name, ctf_id_t id, void *arg) if (type == nullptr) { complaint (_("ctf_add_var_cb: %s has NO type (%ld)"), name, id); - type = objfile_type (ccp->of)->builtin_error; + type = builtin_type (ccp->of)->builtin_error; } sym = new (&ccp->of->objfile_obstack) symbol; OBJSTAT (ccp->of, n_syms++); @@ -1231,10 +1229,10 @@ add_stt_func (struct ctf_context *ccp) add_stt_entries (ccp, 1); } -/* Get text segment base for OBJFILE, TSIZE contains the segment size. */ +/* Get text section base for OBJFILE, TSIZE contains the size. */ static CORE_ADDR -get_objfile_text_range (struct objfile *of, int *tsize) +get_objfile_text_range (struct objfile *of, size_t *tsize) { bfd *abfd = of->obfd.get (); const asection *codes; @@ -1290,7 +1288,8 @@ ctf_psymtab_add_enums (struct ctf_context *ccp, ctf_id_t tid) ccp->pst->add_psymbol (ename, true, VAR_DOMAIN, LOC_CONST, -1, psymbol_placement::GLOBAL, - 0, language_c, ccp->partial_symtabs, ccp->of); + unrelocated_addr (0), + language_c, ccp->partial_symtabs, ccp->of); } if (ctf_errno (ccp->fp) != ECTF_NEXT_END) complaint (_("ctf_enum_next ctf_psymtab_add_enums failed - %s"), @@ -1335,7 +1334,8 @@ ctf_psymtab_add_stt_entries (ctf_dict_t *cfp, ctf_psymtab *pst, pst->add_psymbol (tname, true, tdomain, aclass, -1, psymbol_placement::GLOBAL, - 0, language_c, pst->context.partial_symtabs, of); + unrelocated_addr (0), + language_c, pst->context.partial_symtabs, of); } } @@ -1404,14 +1404,14 @@ ctf_psymtab::read_symtab (struct objfile *objfile) /* Start a symtab. */ CORE_ADDR offset; /* Start of text segment. */ - int tsize; + size_t tsize; offset = get_objfile_text_range (objfile, &tsize); ctf_start_compunit_symtab (this, objfile, offset); expand_psymtab (objfile); - set_text_low (offset); - set_text_high (offset + tsize); + set_text_low (unrelocated_addr (0)); + set_text_high (unrelocated_addr (tsize)); compunit_symtab = ctf_end_compunit_symtab (this, offset + tsize); /* Finish up the debug error message. */ @@ -1441,7 +1441,8 @@ create_partial_symtab (const char *name, { ctf_psymtab *pst; - pst = new ctf_psymtab (name, partial_symtabs, objfile->per_bfd, 0); + pst = new ctf_psymtab (name, partial_symtabs, objfile->per_bfd, + unrelocated_addr (0)); pst->context.arc = arc; pst->context.fp = cfp; @@ -1511,7 +1512,8 @@ ctf_psymtab_type_cb (ctf_id_t tid, void *arg) ccp->pst->add_psymbol (name, false, domain, aclass, section, psymbol_placement::STATIC, - 0, language_c, ccp->partial_symtabs, ccp->of); + unrelocated_addr (0), + language_c, ccp->partial_symtabs, ccp->of); return 0; } @@ -1526,7 +1528,8 @@ ctf_psymtab_var_cb (const char *name, ctf_id_t id, void *arg) ccp->pst->add_psymbol (name, true, VAR_DOMAIN, LOC_STATIC, -1, psymbol_placement::GLOBAL, - 0, language_c, ccp->partial_symtabs, ccp->of); + unrelocated_addr (0), + language_c, ccp->partial_symtabs, ccp->of); return 0; }