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