/* Internal type definitions 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 "hashtab.h"
#include "gdbsupport/array-view.h"
+#include "gdbsupport/gdb-hashtab.h"
#include "gdbsupport/gdb_optional.h"
#include "gdbsupport/offset-type.h"
#include "gdbsupport/enum-flags.h"
#include "gdbsupport/underlying.h"
#include "gdbsupport/print-utils.h"
#include "dwarf2.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
#include "gmp-utils.h"
/* Forward declarations for prototypes. */
/* Get the field at index IDX. */
struct field &field (int idx) const
{
+ gdb_assert (idx >= 0 && idx < num_fields ());
return this->fields ()[idx];
}
static int
eq (const call_site *a, const call_site *b)
{
- return core_addr_eq (&a->m_unrelocated_pc, &b->m_unrelocated_pc);
+ return a->m_unrelocated_pc == b->m_unrelocated_pc;
}
static hashval_t
hash (const call_site *a)
{
- return core_addr_hash (&a->m_unrelocated_pc);
+ return a->m_unrelocated_pc;
}
static int
#define TYPE_BASECLASS(thistype,index) ((thistype)->field (index).type ())
#define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
#define TYPE_BASECLASS_NAME(thistype,index) (thistype->field (index).name ())
-#define TYPE_BASECLASS_BITPOS(thistype,index) TYPE_FIELD_BITPOS(thistype,index)
+#define TYPE_BASECLASS_BITPOS(thistype,index) (thistype->field (index).loc_bitpos ())
#define BASETYPE_VIA_PUBLIC(thistype, index) \
((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index)))
#define TYPE_CPLUS_DYNAMIC(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_dynamic
(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
-#define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind ())
-#define FIELD_BITPOS(thisfld) ((thisfld).loc_bitpos ())
-#define FIELD_ENUMVAL(thisfld) ((thisfld).loc_enumval ())
-#define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc_physname ())
-#define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc_physaddr ())
-#define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc_dwarf_block ())
#define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
#define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
-#define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND ((thistype)->field (n))
-#define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS ((thistype)->field (n))
-#define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL ((thistype)->field (n))
-#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME ((thistype)->field (n))
-#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR ((thistype)->field (n))
-#define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK ((thistype)->field (n))
#define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL((thistype)->field (n))
#define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE((thistype)->field (n))
#define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE((thistype)->field (n))!=0)
/* * Resolve all dynamic values of a type e.g. array bounds to static values.
ADDR specifies the location of the variable the type is bound to.
If TYPE has no dynamic properties return TYPE; otherwise a new type with
- static properties is returned. */
+ static properties is returned.
+
+ For an array type, if the element type is dynamic, then that will
+ not be resolved. This is done because each individual element may
+ have a different type when resolved (depending on the contents of
+ memory). In this situation, 'is_dynamic_type' will still return
+ true for the return value of this function. */
extern struct type *resolve_dynamic_type
(struct type *type, gdb::array_view<const gdb_byte> valaddr,
CORE_ADDR addr);
-/* * Predicate if the type has dynamic values, which are not resolved yet. */
+/* * Predicate if the type has dynamic values, which are not resolved yet.
+ See the caveat in 'resolve_dynamic_type' to understand a scenario
+ where an apparently-resolved type may still be considered
+ "dynamic". */
extern int is_dynamic_type (struct type *type);
extern struct type *check_typedef (struct type *);