Blame SOURCES/gdb-rhbz1260558-ppc64le-skip_trampoline_code.patch

01917d
https://bugzilla.redhat.com/show_bug.cgi?id=1260558
01917d
01917d
[ppc64le patch v3] Use skip_entrypoint for skip_trampoline_code
01917d
https://sourceware.org/ml/gdb-patches/2015-09/msg00183.html
01917d
01917d
diff --git a/gdb/linespec.c b/gdb/linespec.c
01917d
index 8f102fa..4c29c12 100644
01917d
--- a/gdb/linespec.c
01917d
+++ b/gdb/linespec.c
01917d
@@ -3423,6 +3423,8 @@ minsym_found (struct linespec_state *sel
01917d
 	  sal.pc = SYMBOL_VALUE_ADDRESS (msymbol);
01917d
 	  sal.pc = gdbarch_convert_from_func_ptr_addr (gdbarch, sal.pc,
01917d
 						       &current_target);
01917d
+	  if (gdbarch_skip_entrypoint_p (gdbarch))
01917d
+	    sal.pc = gdbarch_skip_entrypoint (gdbarch, sal.pc);
01917d
 	}
01917d
       else
01917d
 	skip_prologue_sal (&sal;;
01917d
diff --git a/gdb/ppc64-tdep.c b/gdb/ppc64-tdep.c
01917d
index bb23b6a..4a0b93a 100644
01917d
--- a/gdb/ppc64-tdep.c
01917d
+++ b/gdb/ppc64-tdep.c
01917d
@@ -454,8 +454,8 @@ ppc64_standard_linkage4_target (struct frame_info *frame,
01917d
    When the execution direction is EXEC_REVERSE, scan backward to
01917d
    check whether we are in the middle of a PLT stub.  */
01917d
 
01917d
-CORE_ADDR
01917d
-ppc64_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
01917d
+static CORE_ADDR
01917d
+ppc64_skip_trampoline_code_1 (struct frame_info *frame, CORE_ADDR pc)
01917d
 {
01917d
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
01917d
   unsigned int insns[MAX (MAX (MAX (ARRAY_SIZE (ppc64_standard_linkage1),
01917d
@@ -530,6 +530,20 @@ ppc64_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
01917d
   return 0;
01917d
 }
01917d
 
01917d
+/* Wrapper of ppc64_skip_trampoline_code_1 checking also
01917d
+   ppc_elfv2_skip_entrypoint.  */
01917d
+
01917d
+CORE_ADDR
01917d
+ppc64_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
01917d
+{
01917d
+  struct gdbarch *gdbarch = get_frame_arch (frame);
01917d
+
01917d
+  pc = ppc64_skip_trampoline_code_1 (frame, pc);
01917d
+  if (pc != 0 && gdbarch_skip_entrypoint_p (gdbarch))
01917d
+    pc = gdbarch_skip_entrypoint (gdbarch, pc);
01917d
+  return pc;
01917d
+}
01917d
+
01917d
 /* Support for convert_from_func_ptr_addr (ARCH, ADDR, TARG) on PPC64
01917d
    GNU/Linux.
01917d
 
01917d
diff --git a/gdb/symtab.c b/gdb/symtab.c
01917d
index 1ba691e..07eb78b 100644
01917d
--- a/gdb/symtab.c
01917d
+++ b/gdb/symtab.c
01917d
@@ -2779,7 +2779,11 @@ find_function_start_sal (struct symbol *
01917d
       && (sal.symtab->locations_valid
01917d
 	  || sal.symtab->language == language_asm))
01917d
     {
01917d
+      struct gdbarch *gdbarch = get_objfile_arch (SYMBOL_SYMTAB (sym)->objfile);
01917d
+
01917d
       sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
01917d
+      if (gdbarch_skip_entrypoint_p (gdbarch))
01917d
+	sal.pc = gdbarch_skip_entrypoint (gdbarch, sal.pc);
01917d
       return sal;
01917d
     }
01917d
 
01917d
diff --git a/gdb/testsuite/gdb.opt/solib-intra-step-lib.c b/gdb/testsuite/gdb.opt/solib-intra-step-lib.c
01917d
new file mode 100644
01917d
index 0000000..9ab1211
01917d
--- /dev/null
01917d
+++ b/gdb/testsuite/gdb.opt/solib-intra-step-lib.c
01917d
@@ -0,0 +1,30 @@
01917d
+/* This testcase is part of GDB, the GNU debugger.
01917d
+
01917d
+   Copyright 2015 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 <stdlib.h>
01917d
+
01917d
+void
01917d
+shlib_second (int dummy)
01917d
+{ /* second-retry */
01917d
+  abort (); /* second-hit */
01917d
+}
01917d
+
01917d
+void
01917d
+shlib_first (void)
01917d
+{ /* first-retry */
01917d
+  shlib_second (0); /* first-hit */
01917d
+}
01917d
diff --git a/gdb/testsuite/gdb.opt/solib-intra-step-main.c b/gdb/testsuite/gdb.opt/solib-intra-step-main.c
01917d
new file mode 100644
01917d
index 0000000..186bd5f
01917d
--- /dev/null
01917d
+++ b/gdb/testsuite/gdb.opt/solib-intra-step-main.c
01917d
@@ -0,0 +1,25 @@
01917d
+/* This testcase is part of GDB, the GNU debugger.
01917d
+
01917d
+   Copyright 2015 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
+extern void shlib_first (void);
01917d
+
01917d
+int
01917d
+main (void)
01917d
+{
01917d
+  shlib_first ();
01917d
+  return 0;
01917d
+}
01917d
diff --git a/gdb/testsuite/gdb.opt/solib-intra-step.exp b/gdb/testsuite/gdb.opt/solib-intra-step.exp
01917d
new file mode 100644
01917d
index 0000000..044c4bd
01917d
--- /dev/null
01917d
+++ b/gdb/testsuite/gdb.opt/solib-intra-step.exp
01917d
@@ -0,0 +1,86 @@
01917d
+# Copyright 2015 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
+standard_testfile
01917d
+
01917d
+if {[skip_shlib_tests]} {
01917d
+    return 0
01917d
+}
01917d
+
01917d
+# Library file.
01917d
+set libname "${testfile}-lib"
01917d
+set srcfile_lib ${srcdir}/${subdir}/${libname}.c
01917d
+set binfile_lib [standard_output_file ${libname}.so]
01917d
+set lib_flags [list debug optimize=-O2]
01917d
+# Binary file.
01917d
+set testfile "${testfile}-main"
01917d
+set srcfile ${srcdir}/${subdir}/${testfile}.c
01917d
+set binfile [standard_output_file ${testfile}]
01917d
+set bin_flags [list debug shlib=${binfile_lib}]
01917d
+
01917d
+if [get_compiler_info] {
01917d
+    return -1
01917d
+}
01917d
+
01917d
+if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
01917d
+     || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
01917d
+  untested "Could not compile $binfile_lib or $binfile."
01917d
+  return -1
01917d
+}
01917d
+
01917d
+clean_restart ${binfile}
01917d
+gdb_load_shlibs $binfile_lib
01917d
+
01917d
+if ![runto_main] then {
01917d
+  return 0
01917d
+}
01917d
+
01917d
+set test "first-hit"
01917d
+gdb_test_multiple "step" $test {
01917d
+    -re " first-hit .*\r\n$gdb_prompt $" {
01917d
+	pass $test
01917d
+    }
01917d
+    -re " first-retry .*\r\n$gdb_prompt $" {
01917d
+	gdb_test "step" " first-hit .*" "first-hit (optimized)"
01917d
+    }
01917d
+}
01917d
+
01917d
+set test "second-hit"
01917d
+gdb_test_multiple "step" $test {
01917d
+    -re " second-hit .*\r\n$gdb_prompt $" {
01917d
+	pass $test
01917d
+    }
01917d
+    -re " first-retry .*\r\n$gdb_prompt $" {
01917d
+	set test "second-hit (optimized 1)"
01917d
+	gdb_test_multiple "step" $test {
01917d
+	    -re " second-hit .*\r\n$gdb_prompt $" {
01917d
+		pass $test
01917d
+	    }
01917d
+	    -re " first-hit .*\r\n$gdb_prompt $" {
01917d
+		gdb_test "step" " second-hit .*" "second-hit (optimized 2)"
01917d
+	    }
01917d
+	}
01917d
+    }
01917d
+    -re " second-retry .*\r\n$gdb_prompt $" {
01917d
+	gdb_test "step" " second-hit .*" "second-hit (optimized 3)"
01917d
+    }
01917d
+}
01917d
+
01917d
+if ![runto_main] then {
01917d
+  return 0
01917d
+}
01917d
+
01917d
+gdb_breakpoint "shlib_second"
01917d
+gdb_continue_to_breakpoint "second-hit" ".* (second-hit|second-retry) .*"