public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-pmuldoon-next-over-throw: Clean up exception code for submission
@ 2009-05-29 20:40 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2009-05-29 20:40 UTC (permalink / raw)
  To: archer-commits

The branch, archer-pmuldoon-next-over-throw has been updated
       via  df809d14b6692190f8a82792fa375380ca743af4 (commit)
      from  c6c10659b2f970d13c28db3fceb757392baa0587 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit df809d14b6692190f8a82792fa375380ca743af4
Author: Tom Tromey <tromey@redhat.com>
Date:   Fri May 29 14:40:09 2009 -0600

    Clean up exception code for submission
    
    gdb
    	* breakpoint.c (set_exception_breakpoint): Fix comment.
    	* infrun.c (check_exception_resume): New function.
    	(handle_inferior_event): Use it.
    gdb/testsuite
    	* gdb.cp/gdb9593.exp: Fix check for debug hook.

-----------------------------------------------------------------------

Summary of changes:
 gdb/breakpoint.c                 |    4 +-
 gdb/infrun.c                     |  134 +++++++++++++++++++++-----------------
 gdb/testsuite/gdb.cp/gdb9593.exp |    2 +-
 3 files changed, 77 insertions(+), 63 deletions(-)

First 500 lines of diff:
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 8adbd1f..2760f3e 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -4500,11 +4500,9 @@ set_exception_breakpoint (struct frame_info *frame)
       struct value *lhs, *rhs;
       CORE_ADDR pc;
 
-      /* FIXME: dwarfy.  */
       /* We use the current stack pointer and not the CFA here,
 	 because the unwinder seems to compute the callee's CFA, and
-	 so the breakpoint does not trigger.  This approach is
-	 probably broken.  */
+	 so the breakpoint does not trigger.  */
       stack_ptr = get_frame_sp (frame);
 
       pc = find_function_start_pc (get_frame_arch (frame),
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 635765e..8997cf5 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1553,10 +1553,8 @@ static void insert_step_resume_breakpoint_at_caller (struct frame_info *);
 static void insert_step_resume_breakpoint_at_sal (struct symtab_and_line sr_sal,
 						  struct frame_id sr_id);
 static void insert_longjmp_resume_breakpoint (CORE_ADDR);
-static void insert_exception_resume_breakpoint (struct thread_info *tp,
-						struct block *b,
-						struct frame_info *frame,
-						struct symbol *sym);
+static void check_exception_resume (struct execution_control_state *,
+				    struct frame_info *, struct symbol *);
 
 static void stop_stepping (struct execution_control_state *ecs);
 static void prepare_to_wait (struct execution_control_state *ecs);
@@ -3050,62 +3048,8 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n");
 	    struct frame_info *frame = get_current_frame ();
 	    struct symbol *func = get_frame_function (frame);
 
-	    /* FIXME: need a big try/catch  */
 	    if (func)
-	      {
-		struct block *b;
-		struct dict_iterator iter;
-		struct symbol *sym;
-		int pass = 0;
-
-		b = SYMBOL_BLOCK_VALUE (func);
-		ALL_BLOCK_SYMBOLS (b, iter, sym)
-		  {
-		    if (!SYMBOL_IS_ARGUMENT (sym))
-		      continue;
-
-		    if (pass == 0)
-		      {
-			struct symbol *vsym;
-			struct value *value;
-			CORE_ADDR cfa, nexting_cfa;
-			struct gdbarch *arch;
-
-			vsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
-					      b, VAR_DOMAIN, NULL);
-			value = read_var_value (vsym, frame);
-			cfa = value_as_address (value);
-
-			arch = get_frame_arch (frame);
-			nexting_cfa = ecs->event_thread->exception_frame;
-			if (debug_infrun)
-			  fprintf_unfiltered (gdb_stdlog,
-					      "infrun: comparing exception target %lx with next-frame %lx: %d\n",
-					      (unsigned long) cfa,
-					      (unsigned long) nexting_cfa,
-					      !nexting_cfa || gdbarch_inner_than (arch, cfa, nexting_cfa));
-
-			if (!nexting_cfa
-			    || gdbarch_inner_than (arch, cfa, nexting_cfa))
-			  {
-			    /* Not an interesting exception.  */
-			    break;
-			  }
-			++pass;
-		      }
-		    else
-		      {
-			/* If we got here, then we want to set the
-			   exception resume breakpoint at the
-			   address held in the second argument to
-			   the function.  */
-
-			insert_exception_resume_breakpoint (ecs->event_thread,
-							    b, frame, sym);
-			break;
-		      }
-		  }
-	      }
+	      check_exception_resume (ecs, frame, func);
 	  }
 	keep_going (ecs);
 	return;
@@ -3932,6 +3876,12 @@ insert_longjmp_resume_breakpoint (CORE_ADDR pc)
     set_momentary_breakpoint_at_pc (pc, bp_longjmp_resume);
 }
 
+/* Insert an exception resume breakpoint.  TP is the thread throwing
+   the exception.  The block B is the block of the unwinder debug hook
+   function.  FRAME is the frame corresponding to the call to this
+   function.  SYM is the symbol of the function argument holding the
+   target PC of the exception.  */
+
 static void
 insert_exception_resume_breakpoint (struct thread_info *tp,
 				    struct block *b,
@@ -3966,6 +3916,72 @@ insert_exception_resume_breakpoint (struct thread_info *tp,
     }
 }
 
+/* This is called when an exception has been intercepted.  Check to
+   see whether the exception's destination is of interest, and if so,
+   set an exception resume breakpoint there.  */
+
+static void
+check_exception_resume (struct execution_control_state *ecs,
+			struct frame_info *frame, struct symbol *func)
+{
+  struct gdb_exception e;
+
+  TRY_CATCH (e, RETURN_MASK_ALL)
+    {
+      struct block *b;
+      struct dict_iterator iter;
+      struct symbol *sym;
+      int argno = 0;
+
+      b = SYMBOL_BLOCK_VALUE (func);
+      ALL_BLOCK_SYMBOLS (b, iter, sym)
+	{
+	  if (!SYMBOL_IS_ARGUMENT (sym))
+	    continue;
+
+	  if (argno == 0)
+	    {
+	      struct symbol *vsym;
+	      struct value *value;
+	      CORE_ADDR cfa, nexting_cfa;
+	      struct gdbarch *arch;
+
+	      vsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
+				    b, VAR_DOMAIN, NULL);
+	      value = read_var_value (vsym, frame);
+	      cfa = value_as_address (value);
+
+	      arch = get_frame_arch (frame);
+	      nexting_cfa = ecs->event_thread->exception_frame;
+	      if (debug_infrun)
+		fprintf_unfiltered (gdb_stdlog,
+				    "infrun: comparing exception target %lx with next-frame %lx: %d\n",
+				    (unsigned long) cfa,
+				    (unsigned long) nexting_cfa,
+				    !nexting_cfa || gdbarch_inner_than (arch, cfa, nexting_cfa));
+
+	      if (!nexting_cfa
+		  || gdbarch_inner_than (arch, cfa, nexting_cfa))
+		{
+		  /* Not an interesting exception.  */
+		  break;
+		}
+	      ++argno;
+	    }
+	  else
+	    {
+	      /* If we got here, then we want to set the exception
+		 resume breakpoint at the address held in the second
+		 argument to the function.  */
+
+	      insert_exception_resume_breakpoint (ecs->event_thread,
+						  b, frame, sym);
+	      break;
+	    }
+	}
+    }
+}
+
 static void
 stop_stepping (struct execution_control_state *ecs)
 {
diff --git a/gdb/testsuite/gdb.cp/gdb9593.exp b/gdb/testsuite/gdb.cp/gdb9593.exp
index 5fcab3a..b0fcfbc 100644
--- a/gdb/testsuite/gdb.cp/gdb9593.exp
+++ b/gdb/testsuite/gdb.cp/gdb9593.exp
@@ -60,7 +60,7 @@ if ![runto_main] then {
 # See whether we have the needed unwinder hooks.
 set ok 1
 gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" {
-    -re "= 0\r\n$gdb_prompt $" {
+    -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
 	pass "check for unwinder hook"
     }
     -re "No symbol .* in current context.\r\n$gdb_prompt $" {


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-05-29 20:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-29 20:40 [SCM] archer-pmuldoon-next-over-throw: Clean up exception code for submission tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).