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

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