diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index fa7a4d5b4e8..7500e7e4438 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -757,7 +757,7 @@ write_var_from_sym (struct parser_state *par_state,
 		    struct symbol *sym)
 {
   if (symbol_read_needs_frame (sym))
-    innermost_block.update (block);
+    innermost_block.update (block, innermost_block_tracker::for_symbols);
 
   write_exp_elt_opcode (par_state, OP_VAR_VALUE);
   write_exp_elt_block (par_state, block);
diff --git a/gdb/parse.c b/gdb/parse.c
index 042df51bf8a..0abfed13962 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -126,9 +126,12 @@ static expression_up parse_exp_in_context_1 (const char **, CORE_ADDR,
    the currently stored block, or if no block is stored yet.  */
 
 void
-innermost_block_tracker::update (const struct block *b)
+innermost_block_tracker::update (const struct block *b,
+				 enum innermost_block_tracker::track_type t)
 {
-  if (m_innermost_block == NULL || contained_in (b, m_innermost_block))
+  if ((m_type & t) != 0
+      && (m_innermost_block == NULL
+	  || contained_in (b, m_innermost_block)))
     m_innermost_block = b;
 }
 
@@ -693,6 +696,8 @@ handle_register:
   str.ptr++;
   write_exp_string (ps, str);
   write_exp_elt_opcode (ps, OP_REGISTER);
+  innermost_block.update (expression_context_block,
+			  innermost_block_tracker::for_registers);
   return;
 }
 
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 5265b394bea..36741ad050b 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -81,20 +81,27 @@ extern CORE_ADDR expression_context_pc;
 class innermost_block_tracker
 {
 public:
+  enum track_type
+    {
+     for_symbols = 0x1,
+     for_registers = 0x2
+    };
+
   innermost_block_tracker ()
     : m_innermost_block (NULL)
   { /* Nothing.  */ }
 
-  void reset ()
+  void reset (enum track_type t = for_symbols)
   {
+    m_type = t;
     m_innermost_block = NULL;
   }
 
-  void update (const struct block *b);
+  void update (const struct block *b, track_type t);
 
   void update (const struct block_symbol &bs)
   {
-    update (bs.block);
+    update (bs.block, for_symbols);
   }
 
   const struct block *block () const
@@ -103,9 +110,20 @@ public:
   }
 
 private:
+  enum track_type m_type;
   const struct block *m_innermost_block;
 };
 
+/* Allow the enum for block type to be bitwise-or together.  */
+
+inline enum innermost_block_tracker::track_type operator|
+		(enum innermost_block_tracker::track_type a,
+		 enum innermost_block_tracker::track_type b)
+{
+  return static_cast<enum innermost_block_tracker::track_type>
+    (static_cast<int> (a) | static_cast<int> (b));
+}
+
 /* The innermost context required by the stack and register variables
    we've encountered so far.  This should be cleared before parsing an
    expression, and queried once the parse is complete.  */
diff --git a/gdb/testsuite/gdb.mi/basics.c b/gdb/testsuite/gdb.mi/basics.c
index 08d9ccae178..327f33c6eca 100644
--- a/gdb/testsuite/gdb.mi/basics.c
+++ b/gdb/testsuite/gdb.mi/basics.c
@@ -20,6 +20,8 @@
  *      on function calls.  Useful to test printing frames, stepping, etc.
  */
 
+unsigned long long global_zero = 0;
+
 int callee4 (void)
 {
   int A=1;
diff --git a/gdb/testsuite/gdb.mi/mi-frame-regs.exp b/gdb/testsuite/gdb.mi/mi-frame-regs.exp
new file mode 100644
index 00000000000..413fa5c3c92
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-frame-regs.exp
@@ -0,0 +1,186 @@
+# Copyright 2018 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test essential Machine interface (MI) operations
+#
+# Verify that -var-update will provide the correct values for floating
+# and fixed varobjs that represent the pc register.
+#
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi"
+
+standard_testfile basics.c
+
+if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
+		 executable {debug}] != "" } then {
+     untested mi-frame-regs.exp
+     return -1
+}
+
+# Return the address of the specified breakpoint.
+
+proc breakpoint_address {bpnum} {
+    global hex
+    global expect_out
+    global mi_gdb_prompt
+
+    send_gdb "info breakpoint $bpnum\n"
+    gdb_expect {
+	-re ".*($hex).*$mi_gdb_prompt$" {
+	    return $expect_out(1,string)
+	}
+	-re ".*$mi_gdb_prompt$" {
+	    unresolved "get address of breakpoint $bpnum"
+	    return ""
+	}
+	timeout {
+	    unresolved "get address of breakpoint $bpnum (timeout)"
+	    return ""
+	}
+    }
+}
+
+# Test that a floating varobj representing $pc will provide the
+# correct value via -var-update as the program stops at
+# breakpoints in different functions.
+
+proc_with_prefix do_floating_varobj_test {} {
+    global srcfile
+    global hex
+    global expect_out
+
+    gdb_exit
+    if {[mi_gdb_start]} then {
+	fail "couldn't start gdb"
+	return
+    }
+
+    mi_run_to_main
+
+    # Create a floating varobj for $pc.
+    mi_gdb_test "-var-create --thread 1 --frame 0 - @ \$pc" \
+	"\\^done,.*value=\"$hex.*" \
+	"create varobj for pc in frame 0"
+
+    set nframes 4
+    for {set i 1} {$i < $nframes} {incr i} {
+
+	# Run to a breakpoint in each callee function in succession.
+	# Note that we can't use mi_runto because we need the
+	# breakpoint to be persistent, so we can use its address.
+	set bpnum [expr $i + 1]
+	mi_create_breakpoint \
+	    "basics.c:callee$i" \
+	    "insert breakpoint at basics.c:callee$i" \
+	    -number $bpnum -func callee$i -file ".*basics.c"
+
+	mi_execute_to "exec-continue" "breakpoint-hit" \
+	    "callee$i" ".*" ".*${srcfile}" ".*" \
+	    { "" "disp=\"keep\"" } "breakpoint hit in callee$i"
+
+	# Get the value of $pc from the floating varobj.
+	mi_gdb_test "-var-update 1 var1" \
+	    "\\^done,.*value=\"($hex) .*" \
+	    "-var-update for frame $i"
+	set pcval $expect_out(3,string)
+
+	# Get the address of the current breakpoint.
+	set bpaddr [breakpoint_address $bpnum]
+	if {$bpaddr == ""} then { return }
+
+	# Check that the addresses are the same.
+	gdb_assert [expr $bpaddr == $pcval] "\$pc equals address of breakpoint in callee$i"
+    }
+}
+
+# Test that fixed varobjs representing $pc in different stack frames
+# will provide the correct value via -var-update after the program
+# counter changes (without substantially changing the stack).
+
+proc_with_prefix do_fixed_varobj_test {} {
+    global srcfile
+    global hex
+
+    gdb_exit
+    if {[mi_gdb_start]} then {
+	fail "couldn't start gdb"
+	return
+    }
+
+    mi_run_to_main
+
+    # Run to the function 'callee3' so we have several frames.
+    mi_create_breakpoint "basics.c:callee3" \
+	"insert breakpoint at basics.c:callee3" \
+	-number 2 -func callee3 -file ".*basics.c"
+
+    mi_execute_to "exec-continue" "breakpoint-hit" \
+	"callee3" ".*" ".*${srcfile}" ".*" \
+	{ "" "disp=\"keep\"" } "breakpoint hit in callee3"
+
+    # At the breakpoint in callee3 there are 4 frames.
+    #
+    # Create some varobj based on $pc in all frames.  When we single
+    # step we expect the varobj for frame 0 to change, while the
+    # varobj for all other frames should be unchanged.
+    #
+    # Track in FIRST_UNCHANGING_VARNUM the number of the first varobj
+    # that is not in frame 0, varobj with a lower number we expect to
+    # change, while this and later varobj should not change.
+    #
+    # Track the number of the next varobj to be created in VARNUM.
+    set first_unchanging_varnum 0
+    set varnum 1
+
+    for {set i 0} {$i < 4} {incr i} {
+
+	if { $i == 1 } then { set first_unchanging_varnum $varnum }
+
+	mi_gdb_test "-var-create --thread 1 --frame $i - \* \$pc" \
+	    "\\^done,.*value=\"$hex.*" \
+	    "create varobj for \$pc in frame $i"
+	incr varnum
+
+	mi_gdb_test "-var-create --thread 1 --frame $i - \* \"global_zero + \$pc\"" \
+	    "\\^done,.*value=\"$hex.*" \
+	    "create varobj for 'global_zero + \$pc' in frame $i"
+	incr varnum
+    }
+
+    # Step one instruction to change the program counter.
+    mi_execute_to "exec-next-instruction" "end-stepping-range" \
+	"callee3" ".*" ".*${srcfile}" ".*" "" \
+	"next instruction in callee3"
+
+    # Check that -var-update reports that the values are changed for
+    # varobj in frame 0.
+    for {set i 1} {$i < $first_unchanging_varnum} {incr i} {
+	mi_gdb_test "-var-update 1 var$i" \
+	    "\\^done,(changelist=\\\[\{name=\"var$i\"\[^\\\]\]+\\\])" \
+	    "varobj var$i has changed"
+    }
+
+    # Check that -var-update reports that the values are unchanged for
+    # varobj in frames other than 0.
+    for {set i $first_unchanging_varnum} {$i < $varnum} {incr i} {
+	mi_gdb_test "-var-update 1 var$i" \
+	    "\\^done,(changelist=\\\[\\\])" \
+	    "varobj var$i has not changed"
+    }
+}
+
+do_fixed_varobj_test
+do_floating_varobj_test
diff --git a/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp b/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp
index b61c495ab41..9ea5784bcad 100644
--- a/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp
@@ -49,6 +49,9 @@ mi_gdb_test "-gdb-set print object on" ".*"
 # We use a explicit cast to (void *) as that is the
 # type that caused the bug this testcase is testing for.
 mi_gdb_test "-var-create sp1 * ((void*)\$sp)" \
-	    "\\^done,name=\"sp1\",numchild=\"0\",value=\"$hex\",type=\"void \\*\",has_more=\"0\"" \
+	    "\\^done,name=\"sp1\",numchild=\"0\",value=\"$hex\",type=\"void \\*\",thread-id=\"$decimal\",has_more=\"0\"" \
 	    "-var-create sp1 * \$sp"
+mi_gdb_test "-var-create sp2 @ ((void*)\$sp)" \
+	    "\\^done,name=\"sp2\",numchild=\"0\",value=\"$hex\",type=\"void \\*\",thread-id=\"$decimal\",has_more=\"0\"" \
+	    "-var-create sp2 @ \$sp"
 gdb_exit
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 20dd09bd585..586bf5fc53b 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -311,7 +311,8 @@ varobj_create (const char *objname,
 	}
 
       p = expression;
-      innermost_block.reset ();
+      innermost_block.reset (innermost_block_tracker::for_symbols
+			     | innermost_block_tracker::for_registers);
       /* Wrap the call to parse expression, so we can 
          return a sensible error.  */
       TRY
