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

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