/* Target-dependent code for FreeBSD, architecture-independent.
- Copyright (C) 2002-2022 Free Software Foundation, Inc.
+ Copyright (C) 2002-2023 Free Software Foundation, Inc.
This file is part of GDB.
.ru_majflt = 0x48,
};
-static struct gdbarch_data *fbsd_gdbarch_data_handle;
-
struct fbsd_gdbarch_data
{
- struct type *siginfo_type;
+ struct type *siginfo_type = nullptr;
};
-static void *
-init_fbsd_gdbarch_data (struct gdbarch *gdbarch)
-{
- return GDBARCH_OBSTACK_ZALLOC (gdbarch, struct fbsd_gdbarch_data);
-}
+static const registry<gdbarch>::key<fbsd_gdbarch_data>
+ fbsd_gdbarch_data_handle;
static struct fbsd_gdbarch_data *
get_fbsd_gdbarch_data (struct gdbarch *gdbarch)
{
- return ((struct fbsd_gdbarch_data *)
- gdbarch_data (gdbarch, fbsd_gdbarch_data_handle));
+ struct fbsd_gdbarch_data *result = fbsd_gdbarch_data_handle.get (gdbarch);
+ if (result == nullptr)
+ result = fbsd_gdbarch_data_handle.emplace (gdbarch);
+ return result;
}
struct fbsd_pspace_data
gdb::byte_vector desc (sizeof (structsize) + buf->size ());
memcpy (desc.data (), &structsize, sizeof (structsize));
- memcpy (desc.data () + sizeof (structsize), buf->data (), buf->size ());
+ std::copy (buf->begin (), buf->end (), desc.data () + sizeof (structsize));
return desc;
}
TAG (PS_STRINGS, _("Pointer to ps_strings"), AUXV_FORMAT_HEX);
TAG (FXRNG, _("Pointer to root RNG seed version"), AUXV_FORMAT_HEX);
TAG (KPRELOAD, _("Base address of vDSO"), AUXV_FORMAT_HEX);
+ TAG (USRSTACKBASE, _("Top of user stack"), AUXV_FORMAT_HEX);
+ TAG (USRSTACKLIM, _("Grow limit of user stack"), AUXV_FORMAT_HEX);
}
fprint_auxv_entry (file, name, description, format, type, val);
if (fbsd_gdbarch_data->siginfo_type != NULL)
return fbsd_gdbarch_data->siginfo_type;
- int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
+ type_allocator alloc (gdbarch);
+ int_type = init_integer_type (alloc, gdbarch_int_bit (gdbarch),
0, "int");
- int32_type = arch_integer_type (gdbarch, 32, 0, "int32_t");
- uint32_type = arch_integer_type (gdbarch, 32, 1, "uint32_t");
- long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
+ int32_type = init_integer_type (alloc, 32, 0, "int32_t");
+ uint32_type = init_integer_type (alloc, 32, 1, "uint32_t");
+ long_type = init_integer_type (alloc, gdbarch_long_bit (gdbarch),
0, "long");
void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type);
/* __pid_t */
- pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
- TYPE_LENGTH (int32_type) * TARGET_CHAR_BIT, "__pid_t");
- TYPE_TARGET_TYPE (pid_type) = int32_type;
+ pid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+ int32_type->length () * TARGET_CHAR_BIT,
+ "__pid_t");
+ pid_type->set_target_type (int32_type);
pid_type->set_target_is_stub (true);
/* __uid_t */
- uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
- TYPE_LENGTH (uint32_type) * TARGET_CHAR_BIT,
- "__uid_t");
- TYPE_TARGET_TYPE (uid_type) = uint32_type;
+ uid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+ uint32_type->length () * TARGET_CHAR_BIT,
+ "__uid_t");
+ uid_type->set_target_type (uint32_type);
pid_type->set_target_is_stub (true);
/* _reason */
However, system call catching requires this function to be
set. */
- internal_error (__FILE__, __LINE__, _("fbsd_get_sycall_number called"));
+ internal_error (_("fbsd_get_sycall_number called"));
}
/* Read an integer symbol value from the current target. */
CORE_ADDR addr = gdbarch_pointer_to_address (gdbarch,
builtin->builtin_data_ptr, buf);
- addr += (tls_index + 1) * TYPE_LENGTH (builtin->builtin_data_ptr);
+ addr += (tls_index + 1) * builtin->builtin_data_ptr->length ();
if (target_read_memory (addr, buf, sizeof buf) != 0)
throw_error (TLS_GENERIC_ERROR,
_("Cannot find thread-local variables on this target"));
static bool
fbsd_vdso_range (struct gdbarch *gdbarch, struct mem_range *range)
{
- struct target_ops *ops = current_inferior ()->top_target ();
-
- if (target_auxv_search (ops, AT_FREEBSD_KPRELOAD, &range->start) <= 0)
+ if (target_auxv_search (AT_FREEBSD_KPRELOAD, &range->start) <= 0)
return false;
if (!target_has_execution ())
{
/* Fetch the list of address space entries from the running target. */
gdb::optional<gdb::byte_vector> buf =
- target_read_alloc (ops, TARGET_OBJECT_FREEBSD_VMMAP, nullptr);
+ target_read_alloc (current_inferior ()->top_target (),
+ TARGET_OBJECT_FREEBSD_VMMAP, nullptr);
if (!buf || buf->empty ())
return false;
set_xml_syscall_file_name (gdbarch, "syscalls/freebsd.xml");
set_gdbarch_get_syscall_number (gdbarch, fbsd_get_syscall_number);
}
-
-void _initialize_fbsd_tdep ();
-void
-_initialize_fbsd_tdep ()
-{
- fbsd_gdbarch_data_handle =
- gdbarch_data_register_post_init (init_fbsd_gdbarch_data);
-}