#include "complaints.h"
#include "block.h"
#include "ctfread.h"
-#include "psympriv.h"
+#include "psymtab.h"
#if ENABLE_LIBCTF
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)
{
}
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)
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);
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);
}
}
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);
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)
{
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:
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
{
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++)
{
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 ();
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);
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;
}
}
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);
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;
}
}
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++);
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;
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"),
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);
}
}
/* 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. */
{
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;
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;
}
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;
}