[gdb/f17] Fix an implied regression by the inferior calls fix below (BZ 799531).
Jan Kratochvil
jankratochvil at fedoraproject.org
Fri Mar 9 21:30:56 UTC 2012
commit 380b73491384d40b7c20f02bfda85cb773b22b65
Author: Jan Kratochvil <jan.kratochvil at redhat.com>
Date: Fri Mar 9 22:30:50 2012 +0100
Fix an implied regression by the inferior calls fix below (BZ 799531).
gdb-x86-onstack-1of2.patch | 115 ++++++++++++++++++++++++++++++
gdb-x86-onstack-2of2.patch | 166 ++++++++++++++++++++++++++++++++++++++++++++
gdb-x86-onstack.patch | 36 ----------
gdb.spec | 9 ++-
4 files changed, 288 insertions(+), 38 deletions(-)
---
diff --git a/gdb-x86-onstack-1of2.patch b/gdb-x86-onstack-1of2.patch
new file mode 100644
index 0000000..a7f611d
--- /dev/null
+++ b/gdb-x86-onstack-1of2.patch
@@ -0,0 +1,115 @@
+http://sourceware.org/ml/gdb-patches/2012-03/msg00357.html
+Subject: [patch 1/2] Fix gdb.cp/gdb2495.exp regression with gcc-4.7 #5
+
+Hi,
+
+posted as a new thread.
+
+As described in
+ cancel: [patch] Fix gdb.cp/gdb2495.exp regression with gcc-4.7 #4 [Re: [revert] Regression on PowerPC]
+ http://sourceware.org/ml/gdb-patches/2012-03/msg00322.html
+just ON_STACK had some regressions.
+
+The expectations in that mail were wrong (at least that cleanup/fix is not
+required for gdb.cp/gdb2495.exp).
+
+The problem is that the inferior call return pad breakpoint instruction is
+never removed even after inferior call finishes. It is even still visible in
+"maintenance info breakpoints". This does not matter much for AT_ENTRY_POINT
+but for ON_STACK it just corrupts stack.
+
+No regressions on
+{x86_64,x86_64-m32,i686}-fedora(15-rawhide)/rhel(5-6)-linux-gnu and for
+gdbsever non-extended mode.
+
+
+Thanks,
+Jan
+
+
+gdb/
+2012-03-09 Jan Kratochvil <jan.kratochvil at redhat.com>
+
+ Remove momentary breakpoints for completed inferior calls.
+ * dummy-frame.c: Include gdbthread.h.
+ (pop_dummy_frame_bpt): New function.
+ (pop_dummy_frame): Initialie DUMMY earlier. Call pop_dummy_frame_bpt.
+
+gdb/testsuite/
+2012-03-09 Jan Kratochvil <jan.kratochvil at redhat.com>
+
+ Remove momentary breakpoints for completed inferior calls.
+ * gdb.base/call-signal-resume.exp (maintenance print dummy-frames)
+ (maintenance info breakpoints): New tests.
+
+--- a/gdb/dummy-frame.c
++++ b/gdb/dummy-frame.c
+@@ -29,6 +29,7 @@
+ #include "gdbcmd.h"
+ #include "gdb_string.h"
+ #include "observer.h"
++#include "gdbthread.h"
+
+ /* Dummy frame. This saves the processor state just prior to setting
+ up the inferior function call. Older targets save the registers
+@@ -108,19 +109,36 @@ remove_dummy_frame (struct dummy_frame **dummy_ptr)
+ xfree (dummy);
+ }
+
++/* Delete any breakpoint B which is a momentary breakpoint for return from
++ inferior call matching DUMMY_VOIDP. */
++
++static int
++pop_dummy_frame_bpt (struct breakpoint *b, void *dummy_voidp)
++{
++ struct dummy_frame *dummy = dummy_voidp;
++
++ if (b->disposition == disp_del && frame_id_eq (b->frame_id, dummy->id)
++ && b->thread == pid_to_thread_id (inferior_ptid))
++ delete_breakpoint (b);
++
++ /* Continue the traversal. */
++ return 0;
++}
++
+ /* Pop *DUMMY_PTR, restoring program state to that before the
+ frame was created. */
+
+ static void
+ pop_dummy_frame (struct dummy_frame **dummy_ptr)
+ {
+- struct dummy_frame *dummy;
++ struct dummy_frame *dummy = *dummy_ptr;
++
++ restore_infcall_suspend_state (dummy->caller_state);
+
+- restore_infcall_suspend_state ((*dummy_ptr)->caller_state);
++ iterate_over_breakpoints (pop_dummy_frame_bpt, dummy);
+
+ /* restore_infcall_control_state frees inf_state,
+ all that remains is to pop *dummy_ptr. */
+- dummy = *dummy_ptr;
+ *dummy_ptr = dummy->next;
+ xfree (dummy);
+
+--- a/gdb/testsuite/gdb.base/call-signal-resume.exp
++++ b/gdb/testsuite/gdb.base/call-signal-resume.exp
+@@ -101,6 +101,18 @@ gdb_test "frame $frame_number" ".*"
+ gdb_test_no_output "set confirm off"
+ gdb_test_no_output "return"
+
++# Verify there are no remains of the dummy frame.
++gdb_test_no_output "maintenance print dummy-frames"
++set test "maintenance info breakpoints"
++gdb_test_multiple $test $test {
++ -re "call dummy.*\r\n$gdb_prompt $" {
++ fail $test
++ }
++ -re "\r\n$gdb_prompt $" {
++ pass $test
++ }
++}
++
+ # Resume execution, the program should continue without any signal.
+
+ gdb_test "break stop_two" "Breakpoint \[0-9\]* at .*"
diff --git a/gdb-x86-onstack-2of2.patch b/gdb-x86-onstack-2of2.patch
new file mode 100644
index 0000000..a49904a
--- /dev/null
+++ b/gdb-x86-onstack-2of2.patch
@@ -0,0 +1,166 @@
+http://sourceware.org/ml/gdb-patches/2012-03/msg00358.html
+Subject: [patch 2/2] Fix gdb.cp/gdb2495.exp regression with gcc-4.7 #5
+
+Hi,
+
+here is the ON_STACK code again, with fixed alignment for i386 SSE.
+
+It is generalized for all OSes on i386/amd64. I can move it to
+{i386,amd64)-linux-tdep.c but I find this code much more lightweight than
+i386_push_dummy_call which is already present in i386-tdep.
+
+No regressions on
+{x86_64,x86_64-m32,i686}-fedora(15-rawhide)/rhel(5-6)-linux-gnu and for
+gdbsever non-extended mode.
+
+For x86_64-fedora17-linux-gnu it fixes:
+-FAIL: gdb.cp/gdb2495.exp: Call a function that raises an exception without a handler.
+-FAIL: gdb.cp/gdb2495.exp: bt after returning from a popped frame
++PASS: gdb.cp/gdb2495.exp: Call a function that raises an exception without a handler.
++PASS: gdb.cp/gdb2495.exp: bt after returning from a popped frame
+
+
+Thanks,
+Jan
+
+
+gdb/
+2012-03-09 Jan Kratochvil <jan.kratochvil at redhat.com>
+
+ * amd64-dicos-tdep.c (amd64_dicos_push_dummy_code): Remove.
+ (amd64_dicos_init_abi): Remove its installment.
+ * dicos-tdep.c (dicos_init_abi): Remove the
+ set_gdbarch_call_dummy_location call. Update the comment here.
+ * i386-dicos-tdep.c (i386_dicos_push_dummy_code): Remove.
+ (i386_dicos_init_abi): Remove its installment.
+ * i386-tdep.c (i386_push_dummy_code): New function.
+ (i386_gdbarch_init): Call set_gdbarch_call_dummy_location, install
+ i386_push_dummy_code.
+
+--- a/gdb/amd64-dicos-tdep.c
++++ b/gdb/amd64-dicos-tdep.c
+@@ -23,24 +23,6 @@
+ #include "amd64-tdep.h"
+ #include "dicos-tdep.h"
+
+-static CORE_ADDR
+-amd64_dicos_push_dummy_code (struct gdbarch *gdbarch,
+- CORE_ADDR sp, CORE_ADDR funaddr,
+- struct value **args, int nargs,
+- struct type *value_type,
+- CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
+- struct regcache *regcache)
+-{
+- int bplen;
+- CORE_ADDR bppc = sp;
+-
+- gdbarch_breakpoint_from_pc (gdbarch, &bppc, &bplen);
+- *bp_addr = sp - bplen;
+- *real_pc = funaddr;
+-
+- return *bp_addr;
+-}
+-
+ static void
+ amd64_dicos_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ {
+@@ -49,8 +31,6 @@ amd64_dicos_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ amd64_init_abi (info, gdbarch);
+
+ dicos_init_abi (gdbarch);
+-
+- set_gdbarch_push_dummy_code (gdbarch, amd64_dicos_push_dummy_code);
+ }
+
+ static enum gdb_osabi
+--- a/gdb/dicos-tdep.c
++++ b/gdb/dicos-tdep.c
+@@ -43,8 +43,8 @@ dicos_init_abi (struct gdbarch *gdbarch)
+
+ /* There's no (standard definition of) entry point or a guaranteed
+ text location with a symbol where to place the call dummy, so we
+- put it on the stack. */
+- set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
++ need it on the stack. Rely on i386_gdbarch_init used also for
++ amd64 to set up ON_STACK inferior calls. */
+
+ /* DICOS rewinds the PC itself. */
+ set_gdbarch_decr_pc_after_break (gdbarch, 0);
+--- a/gdb/i386-dicos-tdep.c
++++ b/gdb/i386-dicos-tdep.c
+@@ -22,32 +22,12 @@
+ #include "gdb_string.h"
+ #include "dicos-tdep.h"
+
+-static CORE_ADDR
+-i386_dicos_push_dummy_code (struct gdbarch *gdbarch,
+- CORE_ADDR sp, CORE_ADDR funaddr,
+- struct value **args, int nargs,
+- struct type *value_type,
+- CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
+- struct regcache *regcache)
+-{
+- int bplen;
+- CORE_ADDR bppc = sp;
+-
+- gdbarch_breakpoint_from_pc (gdbarch, &bppc, &bplen);
+- *bp_addr = sp - bplen;
+- *real_pc = funaddr;
+-
+- return *bp_addr;
+-}
+-
+ static void
+ i386_dicos_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ {
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ dicos_init_abi (gdbarch);
+-
+- set_gdbarch_push_dummy_code (gdbarch, i386_dicos_push_dummy_code);
+ }
+
+ static enum gdb_osabi
+--- a/gdb/i386-tdep.c
++++ b/gdb/i386-tdep.c
+@@ -2326,6 +2326,30 @@ i386_16_byte_align_p (struct type *type)
+ return 0;
+ }
+
++/* Implementation for set_gdbarch_push_dummy_code. */
++
++static CORE_ADDR
++i386_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr,
++ struct value **args, int nargs, struct type *value_type,
++ CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
++ struct regcache *regcache)
++{
++ int bplen;
++ CORE_ADDR bppc = sp;
++
++ gdbarch_breakpoint_from_pc (gdbarch, &bppc, &bplen);
++ sp -= bplen;
++
++ /* amd64_push_dummy_call does alignment on its own but i386_push_dummy_call
++ does not. ABI requires stack alignment for executables using SSE. */
++ if (gdbarch_frame_align_p (gdbarch))
++ sp = gdbarch_frame_align (gdbarch, sp);
++
++ *bp_addr = sp;
++ *real_pc = funaddr;
++ return sp;
++}
++
+ static CORE_ADDR
+ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
+ struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
+@@ -7372,6 +7396,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
+ set_gdbarch_get_longjmp_target (gdbarch, i386_get_longjmp_target);
+
+ /* Call dummy code. */
++ set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
++ set_gdbarch_push_dummy_code (gdbarch, i386_push_dummy_code);
+ set_gdbarch_push_dummy_call (gdbarch, i386_push_dummy_call);
+ set_gdbarch_frame_align (gdbarch, i386_frame_align);
+
+
diff --git a/gdb.spec b/gdb.spec
index a144a7a..a275a41 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -33,7 +33,7 @@ Version: 7.4.50.%{snap}
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
-Release: 30%{?dist}
+Release: 31%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain
Group: Development/Debuggers
@@ -562,7 +562,8 @@ Patch653: gdb-attach-fail-reasons-5of5.patch
Patch657: gdb-attach-fail-reasons-5of5configure.patch
# Fix inferior calls, particularly uncaught thrown exceptions (BZ 799531).
-Patch654: gdb-x86-onstack.patch
+Patch654: gdb-x86-onstack-1of2.patch
+Patch658: gdb-x86-onstack-2of2.patch
# Fix DWARF DIEs CU vs. section relative offsets (Joel Brobecker, me).
Patch655: gdb-die-cu-offset-1of2.patch
@@ -853,6 +854,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch653 -p1
%patch657 -p1
%patch654 -p1
+%patch658 -p1
%patch655 -p1
%patch656 -p1
@@ -1323,6 +1325,9 @@ fi
%endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch"
%changelog
+* Fri Mar 9 2012 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.4.50.20120120-31.fc17
+- Fix an implied regression by the inferior calls fix below (BZ 799531).
+
* Fri Mar 9 2012 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.4.50.20120120-30.fc17
- Fix SELinux deny_ptrace .spec build rules (BZ 786878).
More information about the scm-commits
mailing list