/* Target-dependent code for OpenBSD/sparc64.
- Copyright (C) 2004-2017 Free Software Foundation, Inc.
+ Copyright (C) 2004-2023 Free Software Foundation, Inc.
This file is part of GDB.
#include "symtab.h"
#include "objfiles.h"
#include "trad-frame.h"
+#include "inferior.h"
#include "obsd-tdep.h"
#include "sparc64-tdep.h"
}
static struct sparc_frame_cache *
-sparc64obsd_frame_cache (struct frame_info *this_frame, void **this_cache)
+sparc64obsd_frame_cache (frame_info_ptr this_frame, void **this_cache)
{
struct sparc_frame_cache *cache;
CORE_ADDR addr;
cache->pc &= ~(sparc64obsd_page_size - 1);
/* Since we couldn't find the frame's function, the cache was
- initialized under the assumption that we're frameless. */
+ initialized under the assumption that we're frameless. */
sparc_record_save_insn (cache);
addr = get_frame_register_unsigned (this_frame, SPARC_FP_REGNUM);
if (addr & 1)
}
static void
-sparc64obsd_frame_this_id (struct frame_info *this_frame, void **this_cache,
+sparc64obsd_frame_this_id (frame_info_ptr this_frame, void **this_cache,
struct frame_id *this_id)
{
struct sparc_frame_cache *cache =
}
static struct value *
-sparc64obsd_frame_prev_register (struct frame_info *this_frame,
+sparc64obsd_frame_prev_register (frame_info_ptr this_frame,
void **this_cache, int regnum)
{
struct sparc_frame_cache *cache =
static int
sparc64obsd_sigtramp_frame_sniffer (const struct frame_unwind *self,
- struct frame_info *this_frame,
+ frame_info_ptr this_frame,
void **this_cache)
{
CORE_ADDR pc = get_frame_pc (this_frame);
static const struct frame_unwind sparc64obsd_frame_unwind =
{
+ "sparc64 openbsd sigtramp",
SIGTRAMP_FRAME,
default_frame_unwind_stop_reason,
sparc64obsd_frame_this_id,
/* Kernel debugging support. */
static struct sparc_frame_cache *
-sparc64obsd_trapframe_cache (struct frame_info *this_frame, void **this_cache)
+sparc64obsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
{
struct sparc_frame_cache *cache;
CORE_ADDR sp, trapframe_addr;
cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
- cache->saved_regs[SPARC64_STATE_REGNUM].addr = trapframe_addr;
- cache->saved_regs[SPARC64_PC_REGNUM].addr = trapframe_addr + 8;
- cache->saved_regs[SPARC64_NPC_REGNUM].addr = trapframe_addr + 16;
+ cache->saved_regs[SPARC64_STATE_REGNUM].set_addr (trapframe_addr);
+ cache->saved_regs[SPARC64_PC_REGNUM].set_addr (trapframe_addr + 8);
+ cache->saved_regs[SPARC64_NPC_REGNUM].set_addr (trapframe_addr + 16);
for (regnum = SPARC_G0_REGNUM; regnum <= SPARC_I7_REGNUM; regnum++)
- cache->saved_regs[regnum].addr =
- trapframe_addr + 48 + (regnum - SPARC_G0_REGNUM) * 8;
+ cache->saved_regs[regnum].set_addr (trapframe_addr + 48
+ + (regnum - SPARC_G0_REGNUM) * 8);
return cache;
}
static void
-sparc64obsd_trapframe_this_id (struct frame_info *this_frame,
+sparc64obsd_trapframe_this_id (frame_info_ptr this_frame,
void **this_cache, struct frame_id *this_id)
{
struct sparc_frame_cache *cache =
}
static struct value *
-sparc64obsd_trapframe_prev_register (struct frame_info *this_frame,
+sparc64obsd_trapframe_prev_register (frame_info_ptr this_frame,
void **this_cache, int regnum)
{
struct sparc_frame_cache *cache =
static int
sparc64obsd_trapframe_sniffer (const struct frame_unwind *self,
- struct frame_info *this_frame,
+ frame_info_ptr this_frame,
void **this_cache)
{
CORE_ADDR pc;
static const struct frame_unwind sparc64obsd_trapframe_unwind =
{
+ "sparc64 openbsd trap",
NORMAL_FRAME,
default_frame_unwind_stop_reason,
sparc64obsd_trapframe_this_id,
sparc64obsd_supply_uthread (struct regcache *regcache,
int regnum, CORE_ADDR addr)
{
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch *gdbarch = regcache->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR fp, fp_addr = addr + SPARC64OBSD_UTHREAD_FP_OFFSET;
gdb_byte buf[8];
+ /* This function calls functions that depend on the global current thread. */
+ gdb_assert (regcache->ptid () == inferior_ptid);
+
gdb_assert (regnum >= -1);
fp = read_memory_unsigned_integer (fp_addr, 8, byte_order);
if (regnum == SPARC_SP_REGNUM || regnum == -1)
{
store_unsigned_integer (buf, 8, byte_order, fp);
- regcache_raw_supply (regcache, SPARC_SP_REGNUM, buf);
+ regcache->raw_supply (SPARC_SP_REGNUM, buf);
if (regnum == SPARC_SP_REGNUM)
return;
if (regnum == SPARC64_PC_REGNUM || regnum == -1)
{
store_unsigned_integer (buf, 8, byte_order, i7 + 8);
- regcache_raw_supply (regcache, SPARC64_PC_REGNUM, buf);
+ regcache->raw_supply (SPARC64_PC_REGNUM, buf);
}
if (regnum == SPARC64_NPC_REGNUM || regnum == -1)
{
store_unsigned_integer (buf, 8, byte_order, i7 + 12);
- regcache_raw_supply (regcache, SPARC64_NPC_REGNUM, buf);
+ regcache->raw_supply (SPARC64_NPC_REGNUM, buf);
}
if (regnum == SPARC64_PC_REGNUM || regnum == SPARC64_NPC_REGNUM)
sparc64obsd_collect_uthread(const struct regcache *regcache,
int regnum, CORE_ADDR addr)
{
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch *gdbarch = regcache->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp;
gdb_byte buf[8];
+ /* This function calls functions that depend on the global current thread. */
+ gdb_assert (regcache->ptid () == inferior_ptid);
+
gdb_assert (regnum >= -1);
if (regnum == SPARC_SP_REGNUM || regnum == -1)
{
CORE_ADDR fp_addr = addr + SPARC64OBSD_UTHREAD_FP_OFFSET;
- regcache_raw_collect (regcache, SPARC_SP_REGNUM, buf);
+ regcache->raw_collect (SPARC_SP_REGNUM, buf);
write_memory (fp_addr,buf, 8);
}
{
CORE_ADDR i7, i7_addr = addr + SPARC64OBSD_UTHREAD_PC_OFFSET;
- regcache_raw_collect (regcache, SPARC64_PC_REGNUM, buf);
+ regcache->raw_collect (SPARC64_PC_REGNUM, buf);
i7 = extract_unsigned_integer (buf, 8, byte_order) - 8;
write_memory_unsigned_integer (i7_addr, 8, byte_order, i7);
return;
}
- regcache_raw_collect (regcache, SPARC_SP_REGNUM, buf);
+ regcache->raw_collect (SPARC_SP_REGNUM, buf);
sp = extract_unsigned_integer (buf, 8, byte_order);
sparc_collect_rwindow (regcache, sp, regnum);
}
static void
sparc64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
tdep->gregset = &sparc64obsd_gregset;
tdep->sizeof_gregset = 288;
bsd_uthread_set_supply_uthread (gdbarch, sparc64obsd_supply_uthread);
bsd_uthread_set_collect_uthread (gdbarch, sparc64obsd_collect_uthread);
}
-\f
-
-/* Provide a prototype to silence -Wmissing-prototypes. */
-void _initialize_sparc64obsd_tdep (void);
+void _initialize_sparc64obsd_tdep ();
void
-_initialize_sparc64obsd_tdep (void)
+_initialize_sparc64obsd_tdep ()
{
gdbarch_register_osabi (bfd_arch_sparc, bfd_mach_sparc_v9,
GDB_OSABI_OPENBSD, sparc64obsd_init_abi);