diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 456dbcc..f0d2781 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -1655,9 +1655,13 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR 
pc, CORE_ADDR lim_pc,
  	     remember just the first one, but skip over additional
  	     ones.  */
  	  if (lr_reg == -1)
-	    lr_reg = (op & 0x03e00000) >> 21;
-          if (lr_reg == 0)
-            r0_contains_arg = 0;
+      {
+        lr_reg = (op & 0x03e00000);
+        fdata->lr_register = lr_reg >> 21;
+      }
+    if (lr_reg == 0)
+      r0_contains_arg = 0;
+
  	  continue;
  	}
        else if ((op & 0xfc1fffff) == 0x7c000026)
@@ -2180,8 +2184,8 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR 
pc, CORE_ADDR lim_pc,
      }
  #endif /* 0 */

-  if (pc == lim_pc && lr_reg >= 0)
-    fdata->lr_register = lr_reg;
+  if (pc != lim_pc)
+    fdata->lr_register = -1;

    fdata->offset = -fdata->offset;
    return last_prologue_pc;
diff --git a/gdb/testsuite/gdb.arch/powerpc-prologue-frame.c 
b/gdb/testsuite/gdb.arch/powerpc-prologue-frame.c
new file mode 100644
index 0000000..f59210a
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/powerpc-prologue-frame.c
@@ -0,0 +1,28 @@
+/* This test is part of GDB, the GNU debugger.
+
+   Copyright 2017 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/>.  */
+
+int bar()
+{
+  return 0;
+}
+
+int foo();
+
+int main(void)
+{
+  return foo();
+}
diff --git a/gdb/testsuite/gdb.arch/powerpc-prologue-frame.exp 
b/gdb/testsuite/gdb.arch/powerpc-prologue-frame.exp
new file mode 100644
index 0000000..e90a8c1
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/powerpc-prologue-frame.exp
@@ -0,0 +1,48 @@
+# Copyright 2017 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/>
+
+if {![istarget "powerpc*"] } {
+    verbose "Skipping powerpc back trace test."
+    return
+}
+
+
+set main_testfile ppc-prolog-frame
+
+if {![istarget "powerpc*-*-*"]} then {
+    verbose "Skipping PowerPC instructions disassembly."
+    return -1
+}
+
+
+if {[gdb_compile \
+      [list ${srcdir}/${subdir}/$main_testfile.c 
${srcdir}/${subdir}/$main_testfile.S] \
+      [standard_output_file ${main_testfile}] \
+      executable {debug}] != ""} {
+    untested "failed to build $main_testfile"
+    return -1
+}
+
+
+clean_restart ${main_testfile}
+
+if ![runto bar] {
+  untested "could not run to bar"
+  return -1
+}
+
+gdb_test "bt" \
+         "#0 \[x0-9a-f\]* bar \\(\\) at .*#1 \[x0-9a-f in\]* foo \\(\\) 
at .*#2 \[x0-9a-f in\]* main \\(\\) at .*" \
+         "Backtrace to the main frame"
diff --git a/gdb/testsuite/gdb.arch/powerpc-prologue-frame.s 
b/gdb/testsuite/gdb.arch/powerpc-prologue-frame.s
new file mode 100644
index 0000000..16cd7e2
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/powerpc-prologue-frame.s
@@ -0,0 +1,40 @@
+/* This test is part of GDB, the GNU debugger.
+
+   Copyright 2017 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/>.  */
+
+	.file	"foo.c"
+	.section	".text"
+	.align 2
+	.globl foo
+	.type	foo, @function
+foo:
+	stwu 1,-32(1)
+	mflr 3
+	stw 3,36(1)
+	stw 31,28(1)
+	mr 31,1
+	bl bar
+	mr 9,3
+	mr 3,9
+	addi 11,31,32
+	lwz 0,4(11)
+	mtlr 0
+	lwz 31,-4(11)
+	mr 1,11
+	blr
+	.size	foo,.-foo
+	.ident	"GCC: (Ubuntu 4.8.2-19ubuntu1) 4.8.2"
