Fix crash when creating index from index
[binutils-gdb.git] / gdb / sparc-ravenscar-thread.c
index c619f6e3c10c917c8231b833b5350434097f8b97..014d8981d7b74e18ca8548cf4cfcbb388781a2ac 100644 (file)
@@ -1,6 +1,6 @@
 /* Ravenscar SPARC target support.
 
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
+   Copyright (C) 2004-2022 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -24,6 +24,7 @@
 #include "inferior.h"
 #include "ravenscar-thread.h"
 #include "sparc-ravenscar-thread.h"
+#include "gdbarch.h"
 
 struct sparc_ravenscar_ops : public ravenscar_arch_ops
 {
@@ -60,7 +61,7 @@ static const int sparc_register_offsets[] =
 
 static void
 supply_register_at_address (struct regcache *regcache, int regnum,
-                            CORE_ADDR register_addr)
+                           CORE_ADDR register_addr)
 {
   struct gdbarch *gdbarch = regcache->arch ();
   int buf_size = register_size (gdbarch, regnum);
@@ -124,19 +125,19 @@ sparc_ravenscar_ops::fetch_registers (struct regcache *regcache, int regnum)
   for (current_regnum = 0; current_regnum < num_regs; current_regnum ++)
     {
       if (register_in_thread_descriptor_p (current_regnum))
-        {
-          current_address = thread_descriptor_address
-            + sparc_register_offsets [current_regnum];
-          supply_register_at_address (regcache, current_regnum,
-                                      current_address);
-        }
+       {
+         current_address = thread_descriptor_address
+           + sparc_register_offsets [current_regnum];
+         supply_register_at_address (regcache, current_regnum,
+                                     current_address);
+       }
       else if (register_on_stack_p (current_regnum))
-        {
-          current_address = stack_address
-            + sparc_register_offsets [current_regnum];
-          supply_register_at_address (regcache, current_regnum,
-                                      current_address);
-        }
+       {
+         current_address = stack_address
+           + sparc_register_offsets [current_regnum];
+         supply_register_at_address (regcache, current_regnum,
+                                     current_address);
+       }
     }
 }
 
@@ -157,7 +158,7 @@ sparc_ravenscar_ops::store_registers (struct regcache *regcache, int regnum)
   else if (register_on_stack_p (regnum))
     {
       regcache_cooked_read_unsigned (regcache, SPARC_SP_REGNUM,
-                                     &register_address);
+                                    &register_address);
       register_address += sparc_register_offsets [regnum];
     }
   else
@@ -165,8 +166,8 @@ sparc_ravenscar_ops::store_registers (struct regcache *regcache, int regnum)
 
   regcache->raw_collect (regnum, buf);
   write_memory (register_address,
-                buf,
-                buf_size);
+               buf,
+               buf_size);
 }
 
 static struct sparc_ravenscar_ops sparc_ravenscar_ops;