diff --git a/gdb/testsuite/gdb.tui/regs.exp b/gdb/testsuite/gdb.tui/regs.exp
index c325952185f..ea78b57d1a7 100644
--- a/gdb/testsuite/gdb.tui/regs.exp
+++ b/gdb/testsuite/gdb.tui/regs.exp
@@ -30,6 +30,9 @@ if {![runto_main]} {
     return
 }
 
+# This is convenient later on.
+gdb_test_no_output "set confirm off"
+
 if {![Term::enter_tui]} {
     unsupported "TUI not supported"
     return
@@ -48,6 +51,11 @@ gdb_assert \
     { ![Term::check_region_contents_p 0 0 80 8 $re_reg_vals_unavailable] } \
     "Register values available"
 
+Term::command "kill"
+gdb_assert \
+    { [Term::check_region_contents_p 0 0 80 8 $re_reg_vals_unavailable] } \
+    "Register values no longer available"
+
 # Check that we can successfully cause the register window to appear
 # using the 'tui reg next' and 'tui reg prev' commands.
 foreach_with_prefix cmd { next prev } {
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index fc7ffb4f202..28d0b742ed7 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -126,19 +126,23 @@ tui_refresh_frame_and_register_information ()
   target_terminal::scoped_restore_terminal_state term_state;
   target_terminal::ours_for_output ();
 
-  if (from_stack && has_stack_frames ())
+  if (from_stack)
     {
-      frame_info_ptr fi = get_selected_frame (NULL);
+      frame_info_ptr fi;
+      if (has_stack_frames ())
+	{
+	  fi = get_selected_frame (NULL);
 
-      /* Display the frame position (even if there is no symbols or
-	 the PC is not known).  */
-      tui_show_frame_info (fi);
+	  /* Display the frame position (even if there is no symbols or
+	     the PC is not known).  */
+	  tui_show_frame_info (fi);
+	}
 
       /* Refresh the register window if it's visible.  */
       if (tui_is_window_visible (DATA_WIN))
 	TUI_DATA_WIN->check_register_values (fi);
     }
-  else if (!from_stack)
+  else
     {
       /* Make sure that the source window is displayed.  */
       tui_add_win_to_layout (SRC_WIN);
@@ -169,6 +173,7 @@ tui_inferior_exit (struct inferior *inf)
   tui_set_key_mode (TUI_COMMAND_MODE);
   tui_show_frame_info (0);
   tui_display_main ();
+  from_stack = true;
 }
 
 /* Observer for the before_prompt notification.  */
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index fa4d10d1039..504aed4b81f 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -107,12 +107,9 @@ tui_register_format (frame_info_ptr frame, int regnum)
 void
 tui_register_info::update (const frame_info_ptr &frame)
 {
-  if (target_has_registers ())
-    {
-      std::string new_content = tui_register_format (frame, m_regno);
-      highlight = content != new_content;
-      content = std::move (new_content);
-    }
+  std::string new_content = tui_register_format (frame, m_regno);
+  highlight = content != new_content;
+  content = std::move (new_content);
 }
 
 /* See tui-regs.h.  */
@@ -185,13 +182,22 @@ tui_data_window::update_register_data (const reggroup *group)
     {
       set_title (_("Registers"));
       m_current_group = nullptr;
+      m_gdbarch = nullptr;
       m_regs_content.clear ();
       return;
     }
 
   frame_info_ptr frame = get_selected_frame (nullptr);
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+
+  if (m_current_group == group && m_gdbarch == gdbarch)
+    {
+      /* Nothing to do here.  */
+      return;
+    }
 
   m_current_group = group;
+  m_gdbarch = gdbarch;
 
   /* Make a new title showing which group we display.  */
   this->set_title (string_printf ("Register group: %s", group->name ()));
@@ -199,7 +205,6 @@ tui_data_window::update_register_data (const reggroup *group)
   /* Create the registers.  */
   m_regs_content.clear ();
 
-  struct gdbarch *gdbarch = get_frame_arch (frame);
   for (int regnum = 0;
        regnum < gdbarch_num_cooked_regs (gdbarch);
        regnum++)
@@ -403,24 +408,31 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
 void
 tui_data_window::check_register_values (frame_info_ptr frame)
 {
-  if (m_regs_content.empty ())
-    set_register_group (m_current_group);
+  if (frame == nullptr)
+    set_register_group (nullptr);
   else
     {
-      for (tui_register_info &data_item_win : m_regs_content)
+      /* If the frame architecture changed, we need to reset the
+	 register group.  */
+      struct gdbarch *gdbarch = get_frame_arch (frame);
+      if (gdbarch != m_gdbarch)
+	set_register_group (nullptr);
+      else
 	{
-	  bool was_hilighted = data_item_win.highlight;
+	  for (tui_register_info &data_item_win : m_regs_content)
+	    {
+	      bool was_hilighted = data_item_win.highlight;
 
-	  data_item_win.update (frame);
+	      data_item_win.update (frame);
 
-	  /* Register windows whose y == 0 are outside the visible area.  */
-	  if ((data_item_win.highlight || was_hilighted)
-	      && data_item_win.visible ())
-	    data_item_win.rerender (handle.get (), m_item_width);
+	      /* Register windows whose y == 0 are outside the visible area.  */
+	      if ((data_item_win.highlight || was_hilighted)
+		  && data_item_win.visible ())
+		data_item_win.rerender (handle.get (), m_item_width);
+	    }
 	}
+      tui_wrefresh (handle.get ());
     }
-
-  tui_wrefresh (handle.get ());
 }
 
 /* Display a register in a window.  If hilite is TRUE, then the value
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index caa9d395bec..9d9cae40fe0 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -139,6 +139,10 @@ struct tui_data_window : public tui_win_info
 
   /* Width of each register's display area.  */
   int m_item_width = 0;
+
+  /* Architecture of frame whose registers are being displayed, or
+     nullptr if the display is empty (i.e., there is no frame).  */
+  gdbarch *m_gdbarch = nullptr;
 };
 
 #endif /* TUI_TUI_REGS_H */
