diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index 1901b9449e6c..289d6f08782c 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -269,8 +269,9 @@ alpha_value_to_register (frame_info_ptr frame, int regnum,
 
   gdb_byte out[ALPHA_REGISTER_SIZE];
   alpha_lds (get_frame_arch (frame), out, in);
+
   auto out_view = gdb::make_array_view (out, reg_size);
-  put_frame_register (frame, regnum, out_view);
+  put_frame_register (get_next_frame_sentinel_okay (frame), regnum, out_view);
 }
 
 
diff --git a/gdb/frame.c b/gdb/frame.c
index 5d8ecb52fe2f..753dde189814 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1397,10 +1397,10 @@ read_frame_register_unsigned (frame_info_ptr frame, int regnum,
 }
 
 void
-put_frame_register (frame_info_ptr frame, int regnum,
-		    gdb::array_view<const gdb_byte> buf)
+put_frame_register (frame_info_ptr next_frame, int regnum,
+		     gdb::array_view<const gdb_byte> buf)
 {
-  struct gdbarch *gdbarch = get_frame_arch (frame);
+  gdbarch *gdbarch = frame_unwind_arch (next_frame);
   int realnum;
   int optim;
   int unavail;
@@ -1410,8 +1410,8 @@ put_frame_register (frame_info_ptr frame, int regnum,
 
   gdb_assert (buf.size () == size);
 
-  frame_register_unwind (get_next_frame_sentinel_okay (frame), regnum, &optim,
-			 &unavail, &lval, &addr, &realnum, nullptr);
+  frame_register_unwind (next_frame, regnum, &optim, &unavail, &lval, &addr,
+			 &realnum, nullptr);
   if (optim)
     error (_("Attempt to assign to a register that was not saved."));
   switch (lval)
@@ -1556,7 +1556,8 @@ put_frame_register_bytes (frame_info_ptr frame, int regnum,
 				    buffer.size ());
 
       if (curr_len == register_size (gdbarch, regnum))
-	put_frame_register (frame, regnum, buffer.slice (0, curr_len));
+	put_frame_register (get_next_frame_sentinel_okay (frame), regnum,
+			    buffer.slice (0, curr_len));
       else
 	{
 	  value *value
@@ -1566,7 +1567,8 @@ put_frame_register_bytes (frame_info_ptr frame, int regnum,
 
 	  copy (buffer.slice (0, curr_len),
 		value->contents_writeable ().slice (offset, curr_len));
-	  put_frame_register (frame, regnum, value->contents_raw ());
+	  put_frame_register (get_next_frame_sentinel_okay (frame), regnum,
+			      value->contents_raw ());
 	  release_value (value);
 	}
 
diff --git a/gdb/frame.h b/gdb/frame.h
index e3393cdd972c..7d3b8da0243d 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -720,10 +720,10 @@ extern ULONGEST get_frame_register_unsigned (frame_info_ptr frame,
 extern bool read_frame_register_unsigned (frame_info_ptr frame,
 					  int regnum, ULONGEST *val);
 
-/* The reverse.  Store a register value relative to the specified
-   frame.  Note: this call makes the frame's state undefined.  The
-   register and frame caches must be flushed.  */
-extern void put_frame_register (frame_info_ptr frame, int regnum,
+/* The reverse.  Store a register value relative to NEXT_FRAME's previous frame.
+   Note: this call makes the frame's state undefined.  The register and frame
+   caches must be flushed.  */
+extern void put_frame_register (frame_info_ptr next_frame, int regnum,
 				gdb::array_view<const gdb_byte> buf);
 
 /* Read LEN bytes from one or multiple registers starting with REGNUM
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 7f6ea5ba06ec..9666e1dba890 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3918,7 +3918,8 @@ i386_value_to_register (frame_info_ptr frame, int regnum,
       gdb_assert (register_size (get_frame_arch (frame), regnum) == 4);
 
       auto from_view = gdb::make_array_view (from, 4);
-      put_frame_register (frame, regnum, from_view);
+      put_frame_register (get_next_frame_sentinel_okay (frame), regnum,
+			  from_view);
       regnum = i386_next_regnum (regnum);
       len -= 4;
       from += 4;
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index 74481f5aeb3c..cfa2a1e297ff 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -400,7 +400,7 @@ i387_value_to_register (frame_info_ptr frame, int regnum,
   struct type *to_type = i387_ext_type (gdbarch);
   target_float_convert (from, type, to, to_type);
   auto to_view = gdb::make_array_view (to, to_type->length ());
-  put_frame_register (frame, regnum, to_view);
+  put_frame_register (get_next_frame_sentinel_okay (frame), regnum, to_view);
 }
 
 
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index 113d384e8649..facb1bbac19c 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -1248,7 +1248,7 @@ ia64_value_to_register (frame_info_ptr frame, int regnum,
   type *to_type = ia64_ext_type (gdbarch);
   target_float_convert (in, valtype, out, to_type);
   auto out_view = gdb::make_array_view (out, to_type->length ());
-  put_frame_register (frame, regnum, out_view);
+  put_frame_register (get_next_frame_sentinel_okay (frame), regnum, out_view);
 }
 
 
diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index 5a80ecb94390..bee411f6e61f 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -250,7 +250,7 @@ m68k_value_to_register (frame_info_ptr frame, int regnum,
   /* Convert from TYPE.  */
   target_float_convert (from, type, to, fpreg_type);
   auto to_view = gdb::make_array_view (to, fpreg_type->length ());
-  put_frame_register (frame, regnum, to_view);
+  put_frame_register (get_next_frame_sentinel_okay (frame), regnum, to_view);
 }
 
 
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index ac90aa1f2c5f..941397b7ccdc 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -991,8 +991,9 @@ mips_value_to_register (frame_info_ptr frame, int regnum,
   if (mips_convert_register_float_case_p (gdbarch, regnum, type))
     {
       auto from_view = gdb::make_array_view (from, 8);
-      put_frame_register (frame, regnum, from_view.slice (4));
-      put_frame_register (frame, regnum + 1, from_view.slice (0, 4));
+      frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
+      put_frame_register (next_frame, regnum, from_view.slice (4));
+      put_frame_register (next_frame, regnum + 1, from_view.slice (0, 4));
     }
   else if (mips_convert_register_gpreg_case_p (gdbarch, regnum, type))
     {
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 9fb3f326bd07..a8626c32c2c1 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -2718,7 +2718,7 @@ rs6000_value_to_register (frame_info_ptr frame,
   struct type *to_type = builtin_type (gdbarch)->builtin_double;
   target_float_convert (from, type, to, to_type);
   auto to_view = gdb::make_array_view (to, to_type->length ());
-  put_frame_register (frame, regnum, to_view);
+  put_frame_register (get_next_frame_sentinel_okay (frame), regnum, to_view);
 }
 
  /* The type of a function that moves the value of REG between CACHE
