keiths / rpms / gdb

Forked from rpms/gdb 2 days ago
Clone
Jan Kratochvil 380b734
http://sourceware.org/ml/gdb-patches/2012-03/msg00357.html
Jan Kratochvil 380b734
Subject: [patch 1/2] Fix gdb.cp/gdb2495.exp regression with gcc-4.7 #5
Jan Kratochvil 380b734
Jan Kratochvil 380b734
Hi,
Jan Kratochvil 380b734
Jan Kratochvil 380b734
posted as a new thread.
Jan Kratochvil 380b734
Jan Kratochvil 380b734
As described in
Jan Kratochvil 380b734
	cancel: [patch] Fix gdb.cp/gdb2495.exp regression with gcc-4.7 #4 [Re: [revert] Regression on PowerPC]
Jan Kratochvil 380b734
	http://sourceware.org/ml/gdb-patches/2012-03/msg00322.html
Jan Kratochvil 380b734
just ON_STACK had some regressions.
Jan Kratochvil 380b734
Jan Kratochvil 380b734
The expectations in that mail were wrong (at least that cleanup/fix is not
Jan Kratochvil 380b734
required for gdb.cp/gdb2495.exp).
Jan Kratochvil 380b734
Jan Kratochvil 380b734
The problem is that the inferior call return pad breakpoint instruction is
Jan Kratochvil 380b734
never removed even after inferior call finishes.  It is even still visible in
Jan Kratochvil 380b734
"maintenance info breakpoints".  This does not matter much for AT_ENTRY_POINT
Jan Kratochvil 380b734
but for ON_STACK it just corrupts stack.
Jan Kratochvil 380b734
Jan Kratochvil 380b734
No regressions on
Jan Kratochvil 380b734
{x86_64,x86_64-m32,i686}-fedora(15-rawhide)/rhel(5-6)-linux-gnu and for
Jan Kratochvil 380b734
gdbsever non-extended mode.
Jan Kratochvil 380b734
Jan Kratochvil 380b734
Jan Kratochvil 380b734
Thanks,
Jan Kratochvil 380b734
Jan
Jan Kratochvil 380b734
Jan Kratochvil 380b734
Jan Kratochvil 380b734
gdb/
Jan Kratochvil 380b734
2012-03-09  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan Kratochvil 380b734
Jan Kratochvil 380b734
	Remove momentary breakpoints for completed inferior calls.
Jan Kratochvil 380b734
	* dummy-frame.c: Include gdbthread.h.
Jan Kratochvil 380b734
	(pop_dummy_frame_bpt): New function.
Jan Kratochvil 380b734
	(pop_dummy_frame): Initialie DUMMY earlier.  Call pop_dummy_frame_bpt.
Jan Kratochvil 380b734
Jan Kratochvil 380b734
gdb/testsuite/
Jan Kratochvil 380b734
2012-03-09  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan Kratochvil 380b734
Jan Kratochvil 380b734
	Remove momentary breakpoints for completed inferior calls.
Jan Kratochvil 380b734
	* gdb.base/call-signal-resume.exp (maintenance print dummy-frames)
Jan Kratochvil 380b734
	(maintenance info breakpoints): New tests.
Jan Kratochvil 380b734
Jan Kratochvil 380b734
--- a/gdb/dummy-frame.c
Jan Kratochvil 380b734
+++ b/gdb/dummy-frame.c
Jan Kratochvil 380b734
@@ -29,6 +29,7 @@
Jan Kratochvil 380b734
 #include "gdbcmd.h"
Jan Kratochvil 380b734
 #include "gdb_string.h"
Jan Kratochvil 380b734
 #include "observer.h"
Jan Kratochvil 380b734
+#include "gdbthread.h"
Jan Kratochvil 380b734
 
Jan Kratochvil 380b734
 /* Dummy frame.  This saves the processor state just prior to setting
Jan Kratochvil 380b734
    up the inferior function call.  Older targets save the registers
Jan Kratochvil 380b734
@@ -108,19 +109,36 @@ remove_dummy_frame (struct dummy_frame **dummy_ptr)
Jan Kratochvil 380b734
   xfree (dummy);
Jan Kratochvil 380b734
 }
Jan Kratochvil 380b734
 
Jan Kratochvil 380b734
+/* Delete any breakpoint B which is a momentary breakpoint for return from
Jan Kratochvil 380b734
+   inferior call matching DUMMY_VOIDP.  */
Jan Kratochvil 380b734
+
Jan Kratochvil 380b734
+static int
Jan Kratochvil 380b734
+pop_dummy_frame_bpt (struct breakpoint *b, void *dummy_voidp)
Jan Kratochvil 380b734
+{
Jan Kratochvil 380b734
+  struct dummy_frame *dummy = dummy_voidp;
Jan Kratochvil 380b734
+
Jan Kratochvil 380b734
+  if (b->disposition == disp_del && frame_id_eq (b->frame_id, dummy->id)
Jan Kratochvil 380b734
+      && b->thread == pid_to_thread_id (inferior_ptid))
Jan Kratochvil 380b734
+    delete_breakpoint (b);
Jan Kratochvil 380b734
+
Jan Kratochvil 380b734
+  /* Continue the traversal.  */
Jan Kratochvil 380b734
+  return 0;
Jan Kratochvil 380b734
+}
Jan Kratochvil 380b734
+
Jan Kratochvil 380b734
 /* Pop *DUMMY_PTR, restoring program state to that before the
Jan Kratochvil 380b734
    frame was created.  */
Jan Kratochvil 380b734
 
Jan Kratochvil 380b734
 static void
Jan Kratochvil 380b734
 pop_dummy_frame (struct dummy_frame **dummy_ptr)
Jan Kratochvil 380b734
 {
Jan Kratochvil 380b734
-  struct dummy_frame *dummy;
Jan Kratochvil 380b734
+  struct dummy_frame *dummy = *dummy_ptr;
Jan Kratochvil 380b734
+
Jan Kratochvil 380b734
+  restore_infcall_suspend_state (dummy->caller_state);
Jan Kratochvil 380b734
 
Jan Kratochvil 380b734
-  restore_infcall_suspend_state ((*dummy_ptr)->caller_state);
Jan Kratochvil 380b734
+  iterate_over_breakpoints (pop_dummy_frame_bpt, dummy);
Jan Kratochvil 380b734
 
Jan Kratochvil 380b734
   /* restore_infcall_control_state frees inf_state,
Jan Kratochvil 380b734
      all that remains is to pop *dummy_ptr.  */
Jan Kratochvil 380b734
-  dummy = *dummy_ptr;
Jan Kratochvil 380b734
   *dummy_ptr = dummy->next;
Jan Kratochvil 380b734
   xfree (dummy);
Jan Kratochvil 380b734
 
Jan Kratochvil 380b734
--- a/gdb/testsuite/gdb.base/call-signal-resume.exp
Jan Kratochvil 380b734
+++ b/gdb/testsuite/gdb.base/call-signal-resume.exp
Jan Kratochvil 380b734
@@ -101,6 +101,18 @@ gdb_test "frame $frame_number" ".*"
Jan Kratochvil 380b734
 gdb_test_no_output "set confirm off"
Jan Kratochvil 380b734
 gdb_test_no_output "return"
Jan Kratochvil 380b734
 
Jan Kratochvil 380b734
+# Verify there are no remains of the dummy frame.
Jan Kratochvil 380b734
+gdb_test_no_output "maintenance print dummy-frames"
Jan Kratochvil 380b734
+set test "maintenance info breakpoints"
Jan Kratochvil 380b734
+gdb_test_multiple $test $test {
Jan Kratochvil 380b734
+    -re "call dummy.*\r\n$gdb_prompt $" {
Jan Kratochvil 380b734
+	fail $test
Jan Kratochvil 380b734
+    }
Jan Kratochvil 380b734
+    -re "\r\n$gdb_prompt $" {
Jan Kratochvil 380b734
+	pass $test
Jan Kratochvil 380b734
+    }
Jan Kratochvil 380b734
+}
Jan Kratochvil 380b734
+
Jan Kratochvil 380b734
 # Resume execution, the program should continue without any signal.
Jan Kratochvil 380b734
 
Jan Kratochvil 380b734
 gdb_test "break stop_two" "Breakpoint \[0-9\]* at .*"