gdb/MAINTAINERS: add Luis Machado as global maintainer
[binutils-gdb.git] / gdb / sparc64-obsd-tdep.c
index 0da50b1dc76f05cb19e21d1980060a09f659bade..a4ab45350787dc2d561d1db5838f832bd85e235f 100644 (file)
@@ -1,6 +1,6 @@
 /* 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.
 
@@ -27,6 +27,7 @@
 #include "symtab.h"
 #include "objfiles.h"
 #include "trad-frame.h"
+#include "inferior.h"
 
 #include "obsd-tdep.h"
 #include "sparc64-tdep.h"
@@ -149,7 +150,7 @@ sparc64obsd_pc_in_sigtramp (CORE_ADDR pc, const char *name)
 }
 
 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;
@@ -168,7 +169,7 @@ sparc64obsd_frame_cache (struct frame_info *this_frame, void **this_cache)
       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)
@@ -185,7 +186,7 @@ sparc64obsd_frame_cache (struct frame_info *this_frame, void **this_cache)
 }
 
 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 =
@@ -195,7 +196,7 @@ sparc64obsd_frame_this_id (struct frame_info *this_frame, void **this_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 =
@@ -206,7 +207,7 @@ sparc64obsd_frame_prev_register (struct frame_info *this_frame,
 
 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);
@@ -221,6 +222,7 @@ sparc64obsd_sigtramp_frame_sniffer (const struct frame_unwind *self,
 
 static const struct frame_unwind sparc64obsd_frame_unwind =
 {
+  "sparc64 openbsd sigtramp",
   SIGTRAMP_FRAME,
   default_frame_unwind_stop_reason,
   sparc64obsd_frame_this_id,
@@ -232,7 +234,7 @@ static const struct frame_unwind sparc64obsd_frame_unwind =
 /* 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;
@@ -249,19 +251,19 @@ sparc64obsd_trapframe_cache (struct frame_info *this_frame, void **this_cache)
 
   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 =
@@ -271,7 +273,7 @@ sparc64obsd_trapframe_this_id (struct frame_info *this_frame,
 }
 
 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 =
@@ -282,7 +284,7 @@ sparc64obsd_trapframe_prev_register (struct frame_info *this_frame,
 
 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;
@@ -304,6 +306,7 @@ sparc64obsd_trapframe_sniffer (const struct frame_unwind *self,
 
 static const struct frame_unwind sparc64obsd_trapframe_unwind =
 {
+  "sparc64 openbsd trap",
   NORMAL_FRAME,
   default_frame_unwind_stop_reason,
   sparc64obsd_trapframe_this_id,
@@ -323,18 +326,21 @@ static void
 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;
@@ -349,12 +355,12 @@ sparc64obsd_supply_uthread (struct regcache *regcache,
       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)
@@ -368,18 +374,21 @@ static void
 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);
     }
 
@@ -387,7 +396,7 @@ sparc64obsd_collect_uthread(const struct regcache *regcache,
     {
       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);
 
@@ -395,7 +404,7 @@ sparc64obsd_collect_uthread(const struct regcache *regcache,
        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);
 }
@@ -414,7 +423,7 @@ static const struct regset sparc64obsd_fpregset =
 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;
@@ -439,13 +448,10 @@ sparc64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   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);