/* Support routines for manipulating internal types for GDB.
- Copyright (C) 1992-2021 Free Software Foundation, Inc.
+ Copyright (C) 1992-2022 Free Software Foundation, Inc.
Contributed by Cygnus Support, using pieces from other GDB modules.
#include "cp-support.h"
#include "bcache.h"
#include "dwarf2/loc.h"
+#include "dwarf2/read.h"
#include "gdbcore.h"
#include "floatformat.h"
#include "f-lang.h"
{
/* The enums may not be sorted by value, so search all
entries. */
- LONGEST low = TYPE_FIELD_ENUMVAL (type, 0);
+ LONGEST low = type->field (0).loc_enumval ();
for (int i = 0; i < type->num_fields (); i++)
{
- if (TYPE_FIELD_ENUMVAL (type, i) < low)
- low = TYPE_FIELD_ENUMVAL (type, i);
+ if (type->field (i).loc_enumval () < low)
+ low = type->field (i).loc_enumval ();
}
/* Set unsigned indicator if warranted. */
{
/* The enums may not be sorted by value, so search all
entries. */
- LONGEST high = TYPE_FIELD_ENUMVAL (type, 0);
+ LONGEST high = type->field (0).loc_enumval ();
for (int i = 0; i < type->num_fields (); i++)
{
- if (TYPE_FIELD_ENUMVAL (type, i) > high)
- high = TYPE_FIELD_ENUMVAL (type, i);
+ if (type->field (i).loc_enumval () > high)
+ high = type->field (i).loc_enumval ();
}
return high;
for (i = 0; i < type->num_fields (); i += 1)
{
- if (val == TYPE_FIELD_ENUMVAL (type, i))
+ if (val == type->field (i).loc_enumval ())
return i;
}
for (i = type->num_fields () - 1; i >= TYPE_N_BASECLASSES (type); i--)
{
- const char *t_field_name = TYPE_FIELD_NAME (type, i);
+ const char *t_field_name = type->field (i).name ();
if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
{
- return {&type->field (i), TYPE_FIELD_BITPOS (type, i)};
+ return {&type->field (i), type->field (i).loc_bitpos ()};
}
- else if (!t_field_name || *t_field_name == '\0')
+ else if (!t_field_name || *t_field_name == '\0')
{
struct_elt elt
= lookup_struct_elt (type->field (i).type (), name, 1);
if (elt.field != NULL)
{
- elt.offset += TYPE_FIELD_BITPOS (type, i);
+ elt.offset += type->field (i).loc_bitpos ();
return elt;
}
}
return 1;
/* If the field is at a fixed offset, then it is not
dynamic. */
- if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_DWARF_BLOCK)
+ if (type->field (i).loc_kind () != FIELD_LOC_KIND_DWARF_BLOCK)
continue;
/* Do not consider C++ virtual base types to be dynamic
due to the field's offset being dynamic; these are
{
int idx = part.discriminant_index;
- if (TYPE_FIELD_LOC_KIND (type, idx) != FIELD_LOC_KIND_BITPOS)
+ if (type->field (idx).loc_kind () != FIELD_LOC_KIND_BITPOS)
error (_("Cannot determine struct field location"
" (invalid location kind)"));
else
{
CORE_ADDR addr = (addr_stack->addr
- + (TYPE_FIELD_BITPOS (type, idx)
+ + (type->field (idx).loc_bitpos ()
/ TARGET_CHAR_BIT));
LONGEST bitsize = TYPE_FIELD_BITSIZE (type, idx);
gdb_byte bits[sizeof (ULONGEST)];
read_memory (addr, bits, size);
- LONGEST bitpos = (TYPE_FIELD_BITPOS (type, idx)
+ LONGEST bitpos = (type->field (idx).loc_bitpos ()
% TARGET_CHAR_BIT);
discr_value = unpack_bits_as_long (type->field (idx).type (),
if (field_is_static (&resolved_type->field (i)))
continue;
- if (TYPE_FIELD_LOC_KIND (resolved_type, i) == FIELD_LOC_KIND_DWARF_BLOCK)
+ if (resolved_type->field (i).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK)
{
struct dwarf2_property_baton baton;
baton.property_type
= lookup_pointer_type (resolved_type->field (i).type ());
- baton.locexpr = *TYPE_FIELD_DWARF_BLOCK (resolved_type, i);
+ baton.locexpr = *resolved_type->field (i).loc_dwarf_block ();
struct dynamic_prop prop;
prop.set_locexpr (&baton);
CORE_ADDR addr;
if (dwarf2_evaluate_property (&prop, nullptr, addr_stack, &addr,
true))
- SET_FIELD_BITPOS (resolved_type->field (i),
- TARGET_CHAR_BIT * (addr - addr_stack->addr));
+ resolved_type->field (i).set_loc_bitpos
+ (TARGET_CHAR_BIT * (addr - addr_stack->addr));
}
/* As we know this field is not a static field, the field's
that verification indicates a bug in our code, the error
is not severe enough to suggest to the user he stops
his debugging session because of it. */
- if (TYPE_FIELD_LOC_KIND (resolved_type, i) != FIELD_LOC_KIND_BITPOS)
+ if (resolved_type->field (i).loc_kind () != FIELD_LOC_KIND_BITPOS)
error (_("Cannot determine struct field location"
" (invalid location kind)"));
pinfo.type = check_typedef (resolved_type->field (i).type ());
+ size_t offset = resolved_type->field (i).loc_bitpos () / TARGET_CHAR_BIT;
pinfo.valaddr = addr_stack->valaddr;
- pinfo.addr
- = (addr_stack->addr
- + (TYPE_FIELD_BITPOS (resolved_type, i) / TARGET_CHAR_BIT));
+ if (!pinfo.valaddr.empty ())
+ pinfo.valaddr = pinfo.valaddr.slice (offset);
+ pinfo.addr = addr_stack->addr + offset;
pinfo.next = addr_stack;
resolved_type->field (i).set_type
(resolve_dynamic_type_internal (resolved_type->field (i).type (),
&pinfo, 0));
- gdb_assert (TYPE_FIELD_LOC_KIND (resolved_type, i)
+ gdb_assert (resolved_type->field (i).loc_kind ()
== FIELD_LOC_KIND_BITPOS);
- new_bit_length = TYPE_FIELD_BITPOS (resolved_type, i);
+ new_bit_length = resolved_type->field (i).loc_bitpos ();
if (TYPE_FIELD_BITSIZE (resolved_type, i) != 0)
new_bit_length += TYPE_FIELD_BITSIZE (resolved_type, i);
else
struct gdbarch *gdbarch = type->arch ();
struct fn_field *f;
char *mangled_name = gdb_mangle_name (type, method_id, signature_id);
- char *demangled_name = gdb_demangle (mangled_name,
- DMGL_PARAMS | DMGL_ANSI);
+ gdb::unique_xmalloc_ptr<char> demangled_name
+ = gdb_demangle (mangled_name, DMGL_PARAMS | DMGL_ANSI);
char *argtypetext, *p;
int depth = 0, argcount = 1;
struct field *argtypes;
/* Make sure we got back a function string that we can use. */
if (demangled_name)
- p = strchr (demangled_name, '(');
+ p = strchr (demangled_name.get (), '(');
else
p = NULL;
argtypes, argcount, p[-2] == '.');
mtype->set_is_stub (false);
TYPE_FN_FIELD_STUB (f, signature_id) = 0;
-
- xfree (demangled_name);
}
/* This is the external interface to check_stub_method, above. This
int offset = -1;
return is_unique_ancestor_worker (base, value_type (val), &offset,
- value_contents_for_printing (val),
+ value_contents_for_printing (val).data (),
value_embedded_offset (val),
value_address (val), val) == 1;
}
if (FIELD_ARTIFICIAL (*field1) != FIELD_ARTIFICIAL (*field2)
|| FIELD_BITSIZE (*field1) != FIELD_BITSIZE (*field2)
- || FIELD_LOC_KIND (*field1) != FIELD_LOC_KIND (*field2))
+ || field1->loc_kind () != field2->loc_kind ())
return false;
- if (!compare_maybe_null_strings (FIELD_NAME (*field1),
- FIELD_NAME (*field2)))
+ if (!compare_maybe_null_strings (field1->name (), field2->name ()))
return false;
- switch (FIELD_LOC_KIND (*field1))
+ switch (field1->loc_kind ())
{
case FIELD_LOC_KIND_BITPOS:
- if (FIELD_BITPOS (*field1) != FIELD_BITPOS (*field2))
+ if (field1->loc_bitpos () != field2->loc_bitpos ())
return false;
break;
case FIELD_LOC_KIND_ENUMVAL:
- if (FIELD_ENUMVAL (*field1) != FIELD_ENUMVAL (*field2))
+ if (field1->loc_enumval () != field2->loc_enumval ())
return false;
/* Don't compare types of enum fields, because they don't
have a type. */
continue;
case FIELD_LOC_KIND_PHYSADDR:
- if (FIELD_STATIC_PHYSADDR (*field1)
- != FIELD_STATIC_PHYSADDR (*field2))
+ if (field1->loc_physaddr () != field2->loc_physaddr ())
return false;
break;
case FIELD_LOC_KIND_PHYSNAME:
- if (!compare_maybe_null_strings (FIELD_STATIC_PHYSNAME (*field1),
- FIELD_STATIC_PHYSNAME (*field2)))
+ if (!compare_maybe_null_strings (field1->loc_physname (),
+ field2->loc_physname ()))
return false;
break;
case FIELD_LOC_KIND_DWARF_BLOCK:
{
struct dwarf2_locexpr_baton *block1, *block2;
- block1 = FIELD_DWARF_BLOCK (*field1);
- block2 = FIELD_DWARF_BLOCK (*field2);
+ block1 = field1->loc_dwarf_block ();
+ block2 = field2->loc_dwarf_block ();
if (block1->per_cu != block2->per_cu
|| block1->size != block2->size
|| memcmp (block1->data, block2->data, block1->size) != 0)
default:
internal_error (__FILE__, __LINE__, _("Unsupported field kind "
"%d by check_types_equal"),
- FIELD_LOC_KIND (*field1));
+ field1->loc_kind ());
}
worklist->emplace_back (field1->type (), field2->type ());
struct type *t2 = arg;
/* For pointers and references, compare target type. */
- if (parm->code () == TYPE_CODE_PTR || TYPE_IS_REFERENCE (parm))
+ if (parm->is_pointer_or_reference ())
{
t1 = TYPE_TARGET_TYPE (parm);
t2 = TYPE_TARGET_TYPE (arg);
for (i = 0; i < nargs; i++)
{
- printf_filtered ("%*s[%d] name '%s'\n", spaces, "", i,
- args[i].name != NULL ? args[i].name : "<NULL>");
+ printf_filtered
+ ("%*s[%d] name '%s'\n", spaces, "", i,
+ args[i].name () != NULL ? args[i].name () : "<NULL>");
recursive_dump_type (args[i].type (), spaces + 2);
}
}
have a dedicated flag that would be set for static fields when
the type is being created. But in practice, checking the field
loc_kind should give us an accurate answer. */
- return (FIELD_LOC_KIND (*f) == FIELD_LOC_KIND_PHYSNAME
- || FIELD_LOC_KIND (*f) == FIELD_LOC_KIND_PHYSADDR);
+ return (f->loc_kind () == FIELD_LOC_KIND_PHYSNAME
+ || f->loc_kind () == FIELD_LOC_KIND_PHYSADDR);
}
static void
int overload_idx;
struct fn_field *f;
- printf_filtered ("%*sfn_fieldlists ", spaces, "");
- gdb_print_host_address (TYPE_FN_FIELDLISTS (type), gdb_stdout);
- printf_filtered ("\n");
+ printf_filtered ("%*sfn_fieldlists %s\n", spaces, "",
+ host_address_to_string (TYPE_FN_FIELDLISTS (type)));
for (method_idx = 0; method_idx < TYPE_NFN_FIELDS (type); method_idx++)
{
f = TYPE_FN_FIELDLIST1 (type, method_idx);
- printf_filtered ("%*s[%d] name '%s' (", spaces + 2, "",
- method_idx,
- TYPE_FN_FIELDLIST_NAME (type, method_idx));
- gdb_print_host_address (TYPE_FN_FIELDLIST_NAME (type, method_idx),
- gdb_stdout);
- printf_filtered (_(") length %d\n"),
- TYPE_FN_FIELDLIST_LENGTH (type, method_idx));
+ printf_filtered
+ ("%*s[%d] name '%s' (%s) length %d\n", spaces + 2, "",
+ method_idx,
+ TYPE_FN_FIELDLIST_NAME (type, method_idx),
+ host_address_to_string (TYPE_FN_FIELDLIST_NAME (type, method_idx)),
+ TYPE_FN_FIELDLIST_LENGTH (type, method_idx));
for (overload_idx = 0;
overload_idx < TYPE_FN_FIELDLIST_LENGTH (type, method_idx);
overload_idx++)
{
- printf_filtered ("%*s[%d] physname '%s' (",
- spaces + 4, "", overload_idx,
- TYPE_FN_FIELD_PHYSNAME (f, overload_idx));
- gdb_print_host_address (TYPE_FN_FIELD_PHYSNAME (f, overload_idx),
- gdb_stdout);
- printf_filtered (")\n");
- printf_filtered ("%*stype ", spaces + 8, "");
- gdb_print_host_address (TYPE_FN_FIELD_TYPE (f, overload_idx),
- gdb_stdout);
- printf_filtered ("\n");
+ printf_filtered
+ ("%*s[%d] physname '%s' (%s)\n",
+ spaces + 4, "", overload_idx,
+ TYPE_FN_FIELD_PHYSNAME (f, overload_idx),
+ host_address_to_string (TYPE_FN_FIELD_PHYSNAME (f,
+ overload_idx)));
+ printf_filtered
+ ("%*stype %s\n", spaces + 8, "",
+ host_address_to_string (TYPE_FN_FIELD_TYPE (f, overload_idx)));
recursive_dump_type (TYPE_FN_FIELD_TYPE (f, overload_idx),
spaces + 8 + 2);
- printf_filtered ("%*sargs ", spaces + 8, "");
- gdb_print_host_address (TYPE_FN_FIELD_ARGS (f, overload_idx),
- gdb_stdout);
- printf_filtered ("\n");
+ printf_filtered
+ ("%*sargs %s\n", spaces + 8, "",
+ host_address_to_string (TYPE_FN_FIELD_ARGS (f, overload_idx)));
print_args (TYPE_FN_FIELD_ARGS (f, overload_idx),
TYPE_FN_FIELD_TYPE (f, overload_idx)->num_fields (),
spaces + 8 + 2);
- printf_filtered ("%*sfcontext ", spaces + 8, "");
- gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx),
- gdb_stdout);
- printf_filtered ("\n");
+ printf_filtered
+ ("%*sfcontext %s\n", spaces + 8, "",
+ host_address_to_string (TYPE_FN_FIELD_FCONTEXT (f,
+ overload_idx)));
printf_filtered ("%*sis_const %d\n", spaces + 8, "",
TYPE_FN_FIELD_CONST (f, overload_idx));
{
printf_filtered ("%*svptr_fieldno %d\n", spaces, "",
TYPE_VPTR_FIELDNO (type));
- printf_filtered ("%*svptr_basetype ", spaces, "");
- gdb_print_host_address (TYPE_VPTR_BASETYPE (type), gdb_stdout);
- puts_filtered ("\n");
+ printf_filtered ("%*svptr_basetype %s\n", spaces, "",
+ host_address_to_string (TYPE_VPTR_BASETYPE (type)));
if (TYPE_VPTR_BASETYPE (type) != NULL)
recursive_dump_type (TYPE_VPTR_BASETYPE (type), spaces + 2);
TYPE_NFN_FIELDS (type));
if (TYPE_N_BASECLASSES (type) > 0)
{
- printf_filtered ("%*svirtual_field_bits (%d bits at *",
- spaces, "", TYPE_N_BASECLASSES (type));
- gdb_print_host_address (TYPE_FIELD_VIRTUAL_BITS (type),
- gdb_stdout);
- printf_filtered (")");
+ printf_filtered
+ ("%*svirtual_field_bits (%d bits at *%s)",
+ spaces, "", TYPE_N_BASECLASSES (type),
+ host_address_to_string (TYPE_FIELD_VIRTUAL_BITS (type)));
print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type),
TYPE_N_BASECLASSES (type));
{
if (TYPE_FIELD_PRIVATE_BITS (type) != NULL)
{
- printf_filtered ("%*sprivate_field_bits (%d bits at *",
- spaces, "", type->num_fields ());
- gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type),
- gdb_stdout);
- printf_filtered (")");
+ printf_filtered
+ ("%*sprivate_field_bits (%d bits at *%s)",
+ spaces, "", type->num_fields (),
+ host_address_to_string (TYPE_FIELD_PRIVATE_BITS (type)));
print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type),
type->num_fields ());
puts_filtered ("\n");
}
if (TYPE_FIELD_PROTECTED_BITS (type) != NULL)
{
- printf_filtered ("%*sprotected_field_bits (%d bits at *",
- spaces, "", type->num_fields ());
- gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type),
- gdb_stdout);
- printf_filtered (")");
+ printf_filtered
+ ("%*sprotected_field_bits (%d bits at *%s",
+ spaces, "", type->num_fields (),
+ host_address_to_string (TYPE_FIELD_PROTECTED_BITS (type)));
print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type),
type->num_fields ());
puts_filtered ("\n");
{
if (type == first_dont_print[i])
{
- printf_filtered ("%*stype node ", spaces, "");
- gdb_print_host_address (type, gdb_stdout);
+ printf_filtered ("%*stype node %s", spaces, "",
+ host_address_to_string (type));
printf_filtered (_(" <same as already seen type>\n"));
return;
}
obstack_ptr_grow (&dont_print_type_obstack, type);
}
- printf_filtered ("%*stype node ", spaces, "");
- gdb_print_host_address (type, gdb_stdout);
- printf_filtered ("\n");
- printf_filtered ("%*sname '%s' (", spaces, "",
- type->name () ? type->name () : "<NULL>");
- gdb_print_host_address (type->name (), gdb_stdout);
- printf_filtered (")\n");
+ printf_filtered ("%*stype node %s\n", spaces, "",
+ host_address_to_string (type));
+ printf_filtered ("%*sname '%s' (%s)\n", spaces, "",
+ type->name () ? type->name () : "<NULL>",
+ host_address_to_string (type->name ()));
printf_filtered ("%*scode 0x%x ", spaces, "", type->code ());
switch (type->code ())
{
printf_filtered ("%*slength %s\n", spaces, "",
pulongest (TYPE_LENGTH (type)));
if (type->is_objfile_owned ())
- {
- printf_filtered ("%*sobjfile ", spaces, "");
- gdb_print_host_address (type->objfile_owner (), gdb_stdout);
- }
+ printf_filtered ("%*sobjfile %s\n", spaces, "",
+ host_address_to_string (type->objfile_owner ()));
else
- {
- printf_filtered ("%*sgdbarch ", spaces, "");
- gdb_print_host_address (type->arch_owner (), gdb_stdout);
- }
- printf_filtered ("\n");
- printf_filtered ("%*starget_type ", spaces, "");
- gdb_print_host_address (TYPE_TARGET_TYPE (type), gdb_stdout);
- printf_filtered ("\n");
+ printf_filtered ("%*sgdbarch %s\n", spaces, "",
+ host_address_to_string (type->arch_owner ()));
+ printf_filtered ("%*starget_type %s\n", spaces, "",
+ host_address_to_string (TYPE_TARGET_TYPE (type)));
if (TYPE_TARGET_TYPE (type) != NULL)
{
recursive_dump_type (TYPE_TARGET_TYPE (type), spaces + 2);
}
- printf_filtered ("%*spointer_type ", spaces, "");
- gdb_print_host_address (TYPE_POINTER_TYPE (type), gdb_stdout);
- printf_filtered ("\n");
- printf_filtered ("%*sreference_type ", spaces, "");
- gdb_print_host_address (TYPE_REFERENCE_TYPE (type), gdb_stdout);
- printf_filtered ("\n");
- printf_filtered ("%*stype_chain ", spaces, "");
- gdb_print_host_address (TYPE_CHAIN (type), gdb_stdout);
- printf_filtered ("\n");
+ printf_filtered ("%*spointer_type %s\n", spaces, "",
+ host_address_to_string (TYPE_POINTER_TYPE (type)));
+ printf_filtered ("%*sreference_type %s\n", spaces, "",
+ host_address_to_string (TYPE_REFERENCE_TYPE (type)));
+ printf_filtered ("%*stype_chain %s\n", spaces, "",
+ host_address_to_string (TYPE_CHAIN (type)));
printf_filtered ("%*sinstance_flags 0x%x", spaces, "",
(unsigned) type->instance_flags ());
if (TYPE_CONST (type))
}
printf_filtered ("\n");
}
- gdb_print_host_address (type->fields (), gdb_stdout);
- puts_filtered ("\n");
+ printf_filtered ("%s\n", host_address_to_string (type->fields ()));
for (idx = 0; idx < type->num_fields (); idx++)
{
if (type->code () == TYPE_CODE_ENUM)
printf_filtered ("%*s[%d] enumval %s type ", spaces + 2, "",
- idx, plongest (TYPE_FIELD_ENUMVAL (type, idx)));
+ idx, plongest (type->field (idx).loc_enumval ()));
else
printf_filtered ("%*s[%d] bitpos %s bitsize %d type ", spaces + 2, "",
- idx, plongest (TYPE_FIELD_BITPOS (type, idx)),
+ idx, plongest (type->field (idx).loc_bitpos ()),
TYPE_FIELD_BITSIZE (type, idx));
- gdb_print_host_address (type->field (idx).type (), gdb_stdout);
- printf_filtered (" name '%s' (",
- TYPE_FIELD_NAME (type, idx) != NULL
- ? TYPE_FIELD_NAME (type, idx)
- : "<NULL>");
- gdb_print_host_address (TYPE_FIELD_NAME (type, idx), gdb_stdout);
- printf_filtered (")\n");
+ printf_filtered ("%s name '%s' (%s)\n",
+ host_address_to_string (type->field (idx).type ()),
+ type->field (idx).name () != NULL
+ ? type->field (idx).name ()
+ : "<NULL>",
+ host_address_to_string (type->field (idx).name ()));
if (type->field (idx).type () != NULL)
{
recursive_dump_type (type->field (idx).type (), spaces + 4);
switch (TYPE_SPECIFIC_FIELD (type))
{
case TYPE_SPECIFIC_CPLUS_STUFF:
- printf_filtered ("%*scplus_stuff ", spaces, "");
- gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type),
- gdb_stdout);
- puts_filtered ("\n");
+ printf_filtered ("%*scplus_stuff %s\n", spaces, "",
+ host_address_to_string (TYPE_CPLUS_SPECIFIC (type)));
print_cplus_stuff (type, spaces);
break;
case TYPE_SPECIFIC_GNAT_STUFF:
- printf_filtered ("%*sgnat_stuff ", spaces, "");
- gdb_print_host_address (TYPE_GNAT_SPECIFIC (type), gdb_stdout);
- puts_filtered ("\n");
+ printf_filtered ("%*sgnat_stuff %s\n", spaces, "",
+ host_address_to_string (TYPE_GNAT_SPECIFIC (type)));
print_gnat_stuff (type, spaces);
break;
break;
case TYPE_SPECIFIC_SELF_TYPE:
- printf_filtered ("%*sself_type ", spaces, "");
- gdb_print_host_address (TYPE_SELF_TYPE (type), gdb_stdout);
- puts_filtered ("\n");
+ printf_filtered ("%*sself_type %s\n", spaces, "",
+ host_address_to_string (TYPE_SELF_TYPE (type)));
break;
case TYPE_SPECIFIC_FIXED_POINT:
new_type->field (i).set_type
(copy_type_recursive (objfile, type->field (i).type (),
copied_types));
- if (TYPE_FIELD_NAME (type, i))
- TYPE_FIELD_NAME (new_type, i) =
- xstrdup (TYPE_FIELD_NAME (type, i));
- switch (TYPE_FIELD_LOC_KIND (type, i))
+ if (type->field (i).name ())
+ new_type->field (i).set_name (xstrdup (type->field (i).name ()));
+
+ switch (type->field (i).loc_kind ())
{
case FIELD_LOC_KIND_BITPOS:
- SET_FIELD_BITPOS (new_type->field (i),
- TYPE_FIELD_BITPOS (type, i));
+ new_type->field (i).set_loc_bitpos (type->field (i).loc_bitpos ());
break;
case FIELD_LOC_KIND_ENUMVAL:
- SET_FIELD_ENUMVAL (new_type->field (i),
- TYPE_FIELD_ENUMVAL (type, i));
+ new_type->field (i).set_loc_enumval (type->field (i).loc_enumval ());
break;
case FIELD_LOC_KIND_PHYSADDR:
- SET_FIELD_PHYSADDR (new_type->field (i),
- TYPE_FIELD_STATIC_PHYSADDR (type, i));
+ new_type->field (i).set_loc_physaddr
+ (type->field (i).loc_physaddr ());
break;
case FIELD_LOC_KIND_PHYSNAME:
- SET_FIELD_PHYSNAME (new_type->field (i),
- xstrdup (TYPE_FIELD_STATIC_PHYSNAME (type,
- i)));
+ new_type->field (i).set_loc_physname
+ (xstrdup (type->field (i).loc_physname ()));
break;
+ case FIELD_LOC_KIND_DWARF_BLOCK:
+ new_type->field (i).set_loc_dwarf_block
+ (type->field (i).loc_dwarf_block ());
+ break;
default:
internal_error (__FILE__, __LINE__,
_("Unexpected type field location kind: %d"),
- TYPE_FIELD_LOC_KIND (type, i));
+ type->field (i).loc_kind ());
}
}
}
gdb_assert (type->code () == TYPE_CODE_FLAGS);
gdb_assert (type->num_fields () + 1 <= type_bitsize);
gdb_assert (start_bitpos >= 0 && start_bitpos < type_bitsize);
- gdb_assert (nr_bits >= 1 && nr_bits <= type_bitsize);
+ gdb_assert (nr_bits >= 1 && (start_bitpos + nr_bits) <= type_bitsize);
gdb_assert (name != NULL);
- TYPE_FIELD_NAME (type, field_nr) = xstrdup (name);
+ type->set_num_fields (type->num_fields () + 1);
+ type->field (field_nr).set_name (xstrdup (name));
type->field (field_nr).set_type (field_type);
- SET_FIELD_BITPOS (type->field (field_nr), start_bitpos);
+ type->field (field_nr).set_loc_bitpos (start_bitpos);
TYPE_FIELD_BITSIZE (type, field_nr) = nr_bits;
- type->set_num_fields (type->num_fields () + 1);
}
/* Special version of append_flags_type_field to add a flag field.
f = &t->field (t->num_fields () - 1);
memset (f, 0, sizeof f[0]);
f[0].set_type (field);
- FIELD_NAME (f[0]) = name;
+ f[0].set_name (name);
return f;
}
TYPE_LENGTH (t) = TYPE_LENGTH (t) + TYPE_LENGTH (field);
if (t->num_fields () > 1)
{
- SET_FIELD_BITPOS (f[0],
- (FIELD_BITPOS (f[-1])
- + (TYPE_LENGTH (f[-1].type ())
- * TARGET_CHAR_BIT)));
+ f->set_loc_bitpos
+ (f[-1].loc_bitpos () + (TYPE_LENGTH (f[-1].type ()) * TARGET_CHAR_BIT));
if (alignment)
{
int left;
alignment *= TARGET_CHAR_BIT;
- left = FIELD_BITPOS (f[0]) % alignment;
+ left = f[0].loc_bitpos () % alignment;
if (left)
{
- SET_FIELD_BITPOS (f[0], FIELD_BITPOS (f[0]) + (alignment - left));
+ f->set_loc_bitpos (f[0].loc_bitpos () + (alignment - left));
TYPE_LENGTH (t) += (alignment - left) / TARGET_CHAR_BIT;
}
}
builtin_type->builtin_string
= arch_type (gdbarch, TYPE_CODE_STRING, TARGET_CHAR_BIT, "string");
builtin_type->builtin_bool
- = arch_type (gdbarch, TYPE_CODE_BOOL, TARGET_CHAR_BIT, "bool");
+ = arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "bool");
/* The following three are about decimal floating point types, which
are 32-bits, 64-bits and 128-bits respectively. */
return objfile_type;
}
+/* See gdbtypes.h. */
+
+CORE_ADDR
+call_site::pc () const
+{
+ compunit_symtab *cust = this->per_objfile->get_symtab (this->per_cu);
+ CORE_ADDR delta
+ = this->per_objfile->objfile->section_offsets[COMPUNIT_BLOCK_LINE_SECTION (cust)];
+ return m_unrelocated_pc + delta;
+}
+
void _initialize_gdbtypes ();
void
_initialize_gdbtypes ()