[05/25] Combine create_excep_cond_exprs and ada_catchpoint::re_set

Message ID 20230427-ada-catch-exception-v1-5-947caa9905e3@adacore.com
State New
Headers
Series Many updates to DAP implementation |

Commit Message

Tom Tromey May 24, 2023, 4:36 p.m. UTC
  This patch merges create_excep_cond_exprs into ada_catchpoint::re_set.
This is less verbose and is also a step toward making ada_catchpoint
work more like the other code_breakpoint-based exception catchpoints.
---
 gdb/ada-lang.c | 44 ++++++++++++++++++--------------------------
 1 file changed, 18 insertions(+), 26 deletions(-)
  

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 374cec57090..24ed93f2004 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12174,6 +12174,8 @@  struct ada_catchpoint : public code_breakpoint
     locspec = string_to_location_spec (&addr_string_,
 				       language_def (language_ada));
     language = language_ada;
+
+    re_set ();
   }
 
   struct bp_location *allocate_location () override;
@@ -12207,29 +12209,35 @@  class ada_catchpoint_location : public bp_location
   expression_up excep_cond_expr;
 };
 
-/* Parse the exception condition string in the context of each of the
-   catchpoint's locations, and store them for later evaluation.  */
+/* Implement the RE_SET method in the structure for all exception
+   catchpoint kinds.  */
 
-static void
-create_excep_cond_exprs (struct ada_catchpoint *c,
-			 enum ada_exception_catchpoint_kind ex)
+void
+ada_catchpoint::re_set ()
 {
+  /* Call the base class's method.  This updates the catchpoint's
+     locations.  */
+  this->code_breakpoint::re_set ();
+
+  /* Reparse the exception conditional expressions.  One for each
+     location.  */
+
   /* Nothing to do if there's no specific exception to catch.  */
-  if (c->excep_string.empty ())
+  if (excep_string.empty ())
     return;
 
   /* Same if there are no locations... */
-  if (c->loc == NULL)
+  if (loc == NULL)
     return;
 
   /* Compute the condition expression in text form, from the specific
      expection we want to catch.  */
   std::string cond_string
-    = ada_exception_catchpoint_cond_string (c->excep_string.c_str (), ex);
+    = ada_exception_catchpoint_cond_string (excep_string.c_str (), m_kind);
 
   /* Iterate over all the catchpoint's locations, and parse an
      expression for each.  */
-  for (bp_location *bl : c->locations ())
+  for (bp_location *bl : locations ())
     {
       struct ada_catchpoint_location *ada_loc
 	= (struct ada_catchpoint_location *) bl;
@@ -12250,7 +12258,7 @@  create_excep_cond_exprs (struct ada_catchpoint *c,
 	    {
 	      warning (_("failed to reevaluate internal exception condition "
 			 "for catchpoint %d: %s"),
-		       c->number, e.what ());
+		       number, e.what ());
 	    }
 	}
 
@@ -12267,21 +12275,6 @@  ada_catchpoint::allocate_location ()
   return new ada_catchpoint_location (this);
 }
 
-/* Implement the RE_SET method in the structure for all exception
-   catchpoint kinds.  */
-
-void
-ada_catchpoint::re_set ()
-{
-  /* Call the base class's method.  This updates the catchpoint's
-     locations.  */
-  this->code_breakpoint::re_set ();
-
-  /* Reparse the exception conditional expressions.  One for each
-     location.  */
-  create_excep_cond_exprs (this, m_kind);
-}
-
 /* Returns true if we should stop for this breakpoint hit.  If the
    user specified a specific exception, we only want to cause a stop
    if the program thrown that exception.  */
@@ -12822,7 +12815,6 @@  create_ada_exception_catchpoint (struct gdbarch *gdbarch,
     (new ada_catchpoint (gdbarch, ex_kind, sal, addr_string.c_str (),
 			 tempflag, enabled, from_tty,
 			 std::move (excep_string)));
-  create_excep_cond_exprs (c.get (), ex_kind);
   if (!cond_string.empty ())
     set_breakpoint_condition (c.get (), cond_string.c_str (), from_tty, false);
   install_breakpoint (0, std::move (c), 1);