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

7b26da
https://bugzilla.redhat.com/show_bug.cgi?id=1260558
7b26da
7b26da
[ppc64le patch v3] Use skip_entrypoint for skip_trampoline_code
7b26da
https://sourceware.org/ml/gdb-patches/2015-09/msg00183.html
7b26da
7b26da
diff --git a/gdb/linespec.c b/gdb/linespec.c
7b26da
index 8f102fa..4c29c12 100644
7b26da
--- a/gdb/linespec.c
7b26da
+++ b/gdb/linespec.c
7b26da
@@ -3423,6 +3423,8 @@ minsym_found (struct linespec_state *sel
7b26da
 	  sal.pc = SYMBOL_VALUE_ADDRESS (msymbol);
7b26da
 	  sal.pc = gdbarch_convert_from_func_ptr_addr (gdbarch, sal.pc,
7b26da
 						       &current_target);
7b26da
+	  if (gdbarch_skip_entrypoint_p (gdbarch))
7b26da
+	    sal.pc = gdbarch_skip_entrypoint (gdbarch, sal.pc);
7b26da
 	}
7b26da
       else
7b26da
 	skip_prologue_sal (&sal;;
7b26da
diff --git a/gdb/ppc64-tdep.c b/gdb/ppc64-tdep.c
7b26da
index bb23b6a..4a0b93a 100644
7b26da
--- a/gdb/ppc64-tdep.c
7b26da
+++ b/gdb/ppc64-tdep.c
7b26da
@@ -454,8 +454,8 @@ ppc64_standard_linkage4_target (struct frame_info *frame,
7b26da
    When the execution direction is EXEC_REVERSE, scan backward to
7b26da
    check whether we are in the middle of a PLT stub.  */
7b26da
 
7b26da
-CORE_ADDR
7b26da
-ppc64_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
7b26da
+static CORE_ADDR
7b26da
+ppc64_skip_trampoline_code_1 (struct frame_info *frame, CORE_ADDR pc)
7b26da
 {
7b26da
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
7b26da
   unsigned int insns[MAX (MAX (MAX (ARRAY_SIZE (ppc64_standard_linkage1),
7b26da
@@ -530,6 +530,20 @@ ppc64_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
7b26da
   return 0;
7b26da
 }
7b26da
 
7b26da
+/* Wrapper of ppc64_skip_trampoline_code_1 checking also
7b26da
+   ppc_elfv2_skip_entrypoint.  */
7b26da
+
7b26da
+CORE_ADDR
7b26da
+ppc64_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
7b26da
+{
7b26da
+  struct gdbarch *gdbarch = get_frame_arch (frame);
7b26da
+
7b26da
+  pc = ppc64_skip_trampoline_code_1 (frame, pc);
7b26da
+  if (pc != 0 && gdbarch_skip_entrypoint_p (gdbarch))
7b26da
+    pc = gdbarch_skip_entrypoint (gdbarch, pc);
7b26da
+  return pc;
7b26da
+}
7b26da
+
7b26da
 /* Support for convert_from_func_ptr_addr (ARCH, ADDR, TARG) on PPC64
7b26da
    GNU/Linux.
7b26da
 
7b26da
diff --git a/gdb/symtab.c b/gdb/symtab.c
7b26da
index 1ba691e..07eb78b 100644
7b26da
--- a/gdb/symtab.c
7b26da
+++ b/gdb/symtab.c
7b26da
@@ -2779,7 +2779,11 @@ find_function_start_sal (struct symbol *
7b26da
       && (sal.symtab->locations_valid
7b26da
 	  || sal.symtab->language == language_asm))
7b26da
     {
7b26da
+      struct gdbarch *gdbarch = get_objfile_arch (SYMBOL_SYMTAB (sym)->objfile);
7b26da
+
7b26da
       sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
7b26da
+      if (gdbarch_skip_entrypoint_p (gdbarch))
7b26da
+	sal.pc = gdbarch_skip_entrypoint (gdbarch, sal.pc);
7b26da
       return sal;
7b26da
     }
7b26da
 
7b26da
diff --git a/gdb/testsuite/gdb.opt/solib-intra-step-lib.c b/gdb/testsuite/gdb.opt/solib-intra-step-lib.c
7b26da
new file mode 100644
7b26da
index 0000000..9ab1211
7b26da
--- /dev/null
7b26da
+++ b/gdb/testsuite/gdb.opt/solib-intra-step-lib.c
7b26da
@@ -0,0 +1,30 @@
7b26da
+/* This testcase is part of GDB, the GNU debugger.
7b26da
+
7b26da
+   Copyright 2015 Free Software Foundation, Inc.
7b26da
+
7b26da
+   This program is free software; you can redistribute it and/or modify
7b26da
+   it under the terms of the GNU General Public License as published by
7b26da
+   the Free Software Foundation; either version 3 of the License, or
7b26da
+   (at your option) any later version.
7b26da
+
7b26da
+   This program is distributed in the hope that it will be useful,
7b26da
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
7b26da
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7b26da
+   GNU General Public License for more details.
7b26da
+
7b26da
+   You should have received a copy of the GNU General Public License
7b26da
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
7b26da
+
7b26da
+#include <stdlib.h>
7b26da
+
7b26da
+void
7b26da
+shlib_second (int dummy)
7b26da
+{ /* second-retry */
7b26da
+  abort (); /* second-hit */
7b26da
+}
7b26da
+
7b26da
+void
7b26da
+shlib_first (void)
7b26da
+{ /* first-retry */
7b26da
+  shlib_second (0); /* first-hit */
7b26da
+}
7b26da
diff --git a/gdb/testsuite/gdb.opt/solib-intra-step-main.c b/gdb/testsuite/gdb.opt/solib-intra-step-main.c
7b26da
new file mode 100644
7b26da
index 0000000..186bd5f
7b26da
--- /dev/null
7b26da
+++ b/gdb/testsuite/gdb.opt/solib-intra-step-main.c
7b26da
@@ -0,0 +1,25 @@
7b26da
+/* This testcase is part of GDB, the GNU debugger.
7b26da
+
7b26da
+   Copyright 2015 Free Software Foundation, Inc.
7b26da
+
7b26da
+   This program is free software; you can redistribute it and/or modify
7b26da
+   it under the terms of the GNU General Public License as published by
7b26da
+   the Free Software Foundation; either version 3 of the License, or
7b26da
+   (at your option) any later version.
7b26da
+
7b26da
+   This program is distributed in the hope that it will be useful,
7b26da
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
7b26da
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7b26da
+   GNU General Public License for more details.
7b26da
+
7b26da
+   You should have received a copy of the GNU General Public License
7b26da
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
7b26da
+
7b26da
+extern void shlib_first (void);
7b26da
+
7b26da
+int
7b26da
+main (void)
7b26da
+{
7b26da
+  shlib_first ();
7b26da
+  return 0;
7b26da
+}
7b26da
diff --git a/gdb/testsuite/gdb.opt/solib-intra-step.exp b/gdb/testsuite/gdb.opt/solib-intra-step.exp
7b26da
new file mode 100644
7b26da
index 0000000..044c4bd
7b26da
--- /dev/null
7b26da
+++ b/gdb/testsuite/gdb.opt/solib-intra-step.exp
7b26da
@@ -0,0 +1,86 @@
7b26da
+# Copyright 2015 Free Software Foundation, Inc.
7b26da
+
7b26da
+# This program is free software; you can redistribute it and/or modify
7b26da
+# it under the terms of the GNU General Public License as published by
7b26da
+# the Free Software Foundation; either version 3 of the License, or
7b26da
+# (at your option) any later version.
7b26da
+#
7b26da
+# This program is distributed in the hope that it will be useful,
7b26da
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
7b26da
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7b26da
+# GNU General Public License for more details.
7b26da
+#
7b26da
+# You should have received a copy of the GNU General Public License
7b26da
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
7b26da
+
7b26da
+standard_testfile
7b26da
+
7b26da
+if {[skip_shlib_tests]} {
7b26da
+    return 0
7b26da
+}
7b26da
+
7b26da
+# Library file.
7b26da
+set libname "${testfile}-lib"
7b26da
+set srcfile_lib ${srcdir}/${subdir}/${libname}.c
7b26da
+set binfile_lib [standard_output_file ${libname}.so]
7b26da
+set lib_flags [list debug optimize=-O2]
7b26da
+# Binary file.
7b26da
+set testfile "${testfile}-main"
7b26da
+set srcfile ${srcdir}/${subdir}/${testfile}.c
7b26da
+set binfile [standard_output_file ${testfile}]
7b26da
+set bin_flags [list debug shlib=${binfile_lib}]
7b26da
+
7b26da
+if [get_compiler_info] {
7b26da
+    return -1
7b26da
+}
7b26da
+
7b26da
+if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
7b26da
+     || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
7b26da
+  untested "Could not compile $binfile_lib or $binfile."
7b26da
+  return -1
7b26da
+}
7b26da
+
7b26da
+clean_restart ${binfile}
7b26da
+gdb_load_shlibs $binfile_lib
7b26da
+
7b26da
+if ![runto_main] then {
7b26da
+  return 0
7b26da
+}
7b26da
+
7b26da
+set test "first-hit"
7b26da
+gdb_test_multiple "step" $test {
7b26da
+    -re " first-hit .*\r\n$gdb_prompt $" {
7b26da
+	pass $test
7b26da
+    }
7b26da
+    -re " first-retry .*\r\n$gdb_prompt $" {
7b26da
+	gdb_test "step" " first-hit .*" "first-hit (optimized)"
7b26da
+    }
7b26da
+}
7b26da
+
7b26da
+set test "second-hit"
7b26da
+gdb_test_multiple "step" $test {
7b26da
+    -re " second-hit .*\r\n$gdb_prompt $" {
7b26da
+	pass $test
7b26da
+    }
7b26da
+    -re " first-retry .*\r\n$gdb_prompt $" {
7b26da
+	set test "second-hit (optimized 1)"
7b26da
+	gdb_test_multiple "step" $test {
7b26da
+	    -re " second-hit .*\r\n$gdb_prompt $" {
7b26da
+		pass $test
7b26da
+	    }
7b26da
+	    -re " first-hit .*\r\n$gdb_prompt $" {
7b26da
+		gdb_test "step" " second-hit .*" "second-hit (optimized 2)"
7b26da
+	    }
7b26da
+	}
7b26da
+    }
7b26da
+    -re " second-retry .*\r\n$gdb_prompt $" {
7b26da
+	gdb_test "step" " second-hit .*" "second-hit (optimized 3)"
7b26da
+    }
7b26da
+}
7b26da
+
7b26da
+if ![runto_main] then {
7b26da
+  return 0
7b26da
+}
7b26da
+
7b26da
+gdb_breakpoint "shlib_second"
7b26da
+gdb_continue_to_breakpoint "second-hit" ".* (second-hit|second-retry) .*"