* ada-lang.c (standard_exc): New static constant.
authorJoel Brobecker <brobecker@gnat.com>
Tue, 30 Sep 2008 20:42:21 +0000 (20:42 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Tue, 30 Sep 2008 20:42:21 +0000 (20:42 +0000)
        (ada_exception_catchpoint_cond_string): Add special handling
        for the predefined exceptions.

gdb/ChangeLog
gdb/ada-lang.c

index 9b8d0f4..4a02fb7 100644 (file)
@@ -1,5 +1,11 @@
 2008-09-30  Joel Brobecker  <brobecker@adacore.com>
 
+       * ada-lang.c (standard_exc): New static constant.
+       (ada_exception_catchpoint_cond_string): Add special handling
+       for the predefined exceptions.
+
+2008-09-30  Joel Brobecker  <brobecker@adacore.com>
+
        * ada-lang.c (ADA_RETAIN_DOTS): Delete this dead macro.  Update
        the code accordingly.
 
index 2b73bdb..45a59f2 100644 (file)
@@ -9650,6 +9650,15 @@ enum exception_catchpoint_kind
   ex_catch_assert
 };
 
+/* Ada's standard exceptions.  */
+
+static char *standard_exc[] = {
+  "constraint_error",
+  "program_error",
+  "storage_error",
+  "tasking_error"
+};
+
 typedef CORE_ADDR (ada_unhandled_exception_name_addr_ftype) (void);
 
 /* A structure that describes how to support exception catchpoints
@@ -10334,6 +10343,35 @@ ada_exception_breakpoint_ops (enum exception_catchpoint_kind ex)
 static char *
 ada_exception_catchpoint_cond_string (const char *exp_string)
 {
+  int i;
+
+  /* The standard exceptions are a special case. They are defined in
+     runtime units that have been compiled without debugging info; if
+     EXP_STRING is the not-fully-qualified name of a standard
+     exception (e.g. "constraint_error") then, during the evaluation
+     of the condition expression, the symbol lookup on this name would
+     *not* return this standard exception. The catchpoint condition
+     may then be set only on user-defined exceptions which have the
+     same not-fully-qualified name (e.g. my_package.constraint_error).
+
+     To avoid this unexcepted behavior, these standard exceptions are
+     systematically prefixed by "standard". This means that "catch
+     exception constraint_error" is rewritten into "catch exception
+     standard.constraint_error".
+
+     If an exception named contraint_error is defined in another package of
+     the inferior program, then the only way to specify this exception as a
+     breakpoint condition is to use its fully-qualified named:
+     e.g. my_package.constraint_error.  */
+
+  for (i = 0; i < sizeof (standard_exc) / sizeof (char *); i++)
+    {
+      if (strcmp (standard_exc [i], exp_string) == 0)
+       {
+          return xstrprintf ("long_integer (e) = long_integer (&standard.%s)",
+                             exp_string);
+       }
+    }
   return xstrprintf ("long_integer (e) = long_integer (&%s)", exp_string);
 }