This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Code cleanup/protection: Reset stale frame_info *s


Hi,

I would prefer some "deinitialization" to give compile-time warning but at
least one will no longer rely on stale pointer during development/debugging
this way.  This causes bugs like:
	[commit+7.4] Fix stale frame_info * (PR 13716)
	http://sourceware.org/ml/gdb-patches/2012-02/msg00500.html

No regressions on {x86_64,x86_64-m32,i686}-fedora17-linux-gnu.

I will check it in.


Thanks,
Jan


gdb/
2012-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* arm-linux-tdep.c (arm_linux_copy_svc): Reset stale FRAME.
	* breakpoint.c (until_break_command): Likewise.
	* elfread.c (elf_gnu_ifunc_resolver_stop): Likewise.
	* infcall.c (call_function_by_hand): Likewise.
	* infcmd.c (finish_forward): Likewise.
	* infrun.c (insert_exception_resume_breakpoint): Likewise.

--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -937,6 +937,9 @@ arm_linux_copy_svc (struct gdbarch *gdbarch, struct regcache *regs,
         	= set_momentary_breakpoint (gdbarch, sal, get_frame_id (frame),
 					    bp_step_resume);
 
+	      /* set_momentary_breakpoint invalidates FRAME.  */
+	      frame = NULL;
+
 	      /* We need to make sure we actually insert the momentary
 	         breakpoint set above.  */
 	      insert_breakpoints ();
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9895,6 +9901,9 @@ until_break_command (char *arg, int from_tty, int anywhere)
 					   get_stack_frame_id (frame),
 					   bp_until);
 
+  /* set_momentary_breakpoint invalidates FRAME.  */
+  frame = NULL;
+
   old_chain = make_cleanup_delete_breakpoint (breakpoint);
 
   tp = inferior_thread ();
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -995,6 +995,9 @@ elf_gnu_ifunc_resolver_stop (struct breakpoint *b)
 					   prev_frame_id,
 					   bp_gnu_ifunc_resolver_return);
 
+      /* set_momentary_breakpoint invalidates PREV_FRAME.  */
+      prev_frame = NULL;
+
       /* Add new b_return to the ring list b->related_breakpoint.  */
       gdb_assert (b_return->related_breakpoint == b_return);
       b_return->related_breakpoint = b->related_breakpoint;
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -783,6 +783,10 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
        PUSH_DUMMY_CALL, saved as the dummy-frame TOS, and used by
        dummy_id to form the frame ID's stack address.  */
     bpt = set_momentary_breakpoint (gdbarch, sal, dummy_id, bp_call_dummy);
+
+    /* set_momentary_breakpoint invalidates FRAME.  */
+    frame = NULL;
+
     bpt->disposition = disp_del;
   }
 
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1652,6 +1652,9 @@ finish_forward (struct symbol *function, struct frame_info *frame)
 					 get_stack_frame_id (frame),
                                          bp_finish);
 
+  /* set_momentary_breakpoint invalidates FRAME.  */
+  frame = NULL;
+
   old_chain = make_cleanup_delete_breakpoint (breakpoint);
 
   set_longjmp_breakpoint (tp, frame_id);
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -5519,6 +5519,10 @@ insert_exception_resume_breakpoint (struct thread_info *tp,
 
 	  bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame),
 					       handler, bp_exception_resume);
+
+	  /* set_momentary_breakpoint_at_pc invalidates FRAME.  */
+	  frame = NULL;
+
 	  bp->thread = tp->num;
 	  inferior_thread ()->control.exception_resume_breakpoint = bp;
 	}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]