Blame SOURCES/gdb-rhbz1125820-ppc64le-enablement-37of37.patch

01917d
  <https://sourceware.org/ml/gdb-patches/2014-09/msg00398.html>
01917d
  Message-Id: <1410525085-29172-1-git-send-email-emachado@linux.vnet.ibm.com>
01917d
01917d
commit 9d9bf2df89db515958b429a1aeb1db38884ba488
01917d
Author: Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com>
01917d
Date:   Fri Sep 12 09:20:25 2014 -0300
01917d
01917d
    PR tdep/17379: Fix internal-error when stack pointer is invalid.
01917d
    
01917d
    The problem is that rs6000_frame_cache attempts to read the stack backchain via
01917d
    read_memory_unsigned_integer, which throws an exception if the stack pointer is
01917d
    invalid.  With this patch, it calls safe_read_memory_integer instead, which
01917d
    doesn't throw an exception and allows for safe handling of that situation.
01917d
    
01917d
    gdb/ChangeLog
01917d
    2014-09-12  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>
01917d
    	    Ulrich Weigand  <uweigand@de.ibm.com>
01917d
    
01917d
    	PR tdep/17379
01917d
    	* rs6000-tdep.c (rs6000_frame_cache): Use safe_read_memory_integer
01917d
    	instead of read_memory_unsigned_integer.
01917d
    
01917d
    gdb/testcase/ChangeLog
01917d
    2014-09-12  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>
01917d
    
01917d
    	PR tdep/17379
01917d
    	* gdb.arch/powerpc-stackless.S: New file.
01917d
    	* gdb.arch/powerpc-stackless.exp: New file.
01917d
01917d
Index: gdb-7.6.1/gdb/rs6000-tdep.c
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/rs6000-tdep.c
01917d
+++ gdb-7.6.1/gdb/rs6000-tdep.c
01917d
@@ -3241,9 +3241,14 @@ rs6000_frame_cache (struct frame_info *t
01917d
     }
01917d
 
01917d
   if (!fdata.frameless)
01917d
-    /* Frameless really means stackless.  */
01917d
-    cache->base
01917d
-      = read_memory_unsigned_integer (cache->base, wordsize, byte_order);
01917d
+    {
01917d
+      /* Frameless really means stackless.  */
01917d
+      LONGEST backchain;
01917d
+
01917d
+      if (safe_read_memory_integer (cache->base, wordsize,
01917d
+				    byte_order, &backchain))
01917d
+        cache->base = (CORE_ADDR) backchain;
01917d
+    }
01917d
 
01917d
   trad_frame_set_value (cache->saved_regs,
01917d
 			gdbarch_sp_regnum (gdbarch), cache->base);
01917d
Index: gdb-7.6.1/gdb/testsuite/gdb.arch/powerpc-stackless.S
01917d
===================================================================
01917d
--- /dev/null
01917d
+++ gdb-7.6.1/gdb/testsuite/gdb.arch/powerpc-stackless.S
01917d
@@ -0,0 +1,24 @@
01917d
+/* This testcase is part of GDB, the GNU debugger.
01917d
+
01917d
+   Copyright 2014 Free Software Foundation, Inc.
01917d
+
01917d
+   This program is free software; you can redistribute it and/or modify
01917d
+   it under the terms of the GNU General Public License as published by
01917d
+   the Free Software Foundation; either version 3 of the License, or
01917d
+   (at your option) any later version.
01917d
+
01917d
+   This program is distributed in the hope that it will be useful,
01917d
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
01917d
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
01917d
+   GNU General Public License for more details.
01917d
+
01917d
+   You should have received a copy of the GNU General Public License
01917d
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
01917d
+
01917d
+#include <ppc-asm.h>
01917d
+
01917d
+FUNC_START(main)
01917d
+        li      sp,0
01917d
+        mtlr    sp
01917d
+        blr
01917d
+FUNC_END(main)
01917d
Index: gdb-7.6.1/gdb/testsuite/gdb.arch/powerpc-stackless.exp
01917d
===================================================================
01917d
--- /dev/null
01917d
+++ gdb-7.6.1/gdb/testsuite/gdb.arch/powerpc-stackless.exp
01917d
@@ -0,0 +1,42 @@
01917d
+# Copyright 2014 Free Software Foundation, Inc.
01917d
+
01917d
+# This program is free software; you can redistribute it and/or modify
01917d
+# it under the terms of the GNU General Public License as published by
01917d
+# the Free Software Foundation; either version 2 of the License, or
01917d
+# (at your option) any later version.
01917d
+#
01917d
+# This program is distributed in the hope that it will be useful,
01917d
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
01917d
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
01917d
+# GNU General Public License for more details.
01917d
+#
01917d
+# You should have received a copy of the GNU General Public License
01917d
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
01917d
+
01917d
+# Testcase for PR tdep/17379.
01917d
+
01917d
+if {![istarget "powerpc*-*-*"]} then {
01917d
+    verbose "Skipping powerpc-stackless.exp"
01917d
+    return
01917d
+}
01917d
+
01917d
+standard_testfile .S
01917d
+
01917d
+if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
01917d
+    untested powerpc-stackless.exp
01917d
+    return -1
01917d
+}
01917d
+
01917d
+# Run until SIGSEGV.
01917d
+gdb_run_cmd
01917d
+
01917d
+set test "run until SIGSEGV"
01917d
+gdb_test_multiple "" $test {
01917d
+    -re "Program received signal SIGSEGV.*$gdb_prompt $" {
01917d
+  pass $test
01917d
+    }
01917d
+}
01917d
+
01917d
+# Ensure that 'info registers' works properly and does not generate
01917d
+# an internal-error.
01917d
+gdb_test "info registers" "r0.*" "info registers"