support Ada EH ABI v1

Message ID ora7cvvvjb.fsf@lxoliva.fsfla.org
State New, archived
Headers

Commit Message

Alexandre Oliva July 31, 2019, 1:32 a.m. UTC
  A new pair of hooks used by Ada exception handlers, for correct
release of reraised exception occurrences, involves the introduction
of new v1 symbols that GDB should use when available.  The older, v0
ABI remains available in newer runtimes for bootstrapping purposes
only.

I've just contributed the corresponding compiler and runtime changes
https://gcc.gnu.org/ml/gcc-patches/2019-07/msg01836.html

without the changes below, GDB will fail to catch handlers compiled by
v1-capable compilers, so I'm going to hold off from installing the GCC
changes until these are at least in GDB trunk.

This patch was regressions tested on x86_64-linux-gnu.  The pristine test
run used a v0-generating compiler; its results were compared with those
obtained with a patched gdb using both v0- and v1-generating compilers.

Ok to install?


for  gdb/ChangeLog

	* ada-lang.c (exception_support_info_v0): Renamed from...
	(default_exception_support_info): ... this.  Create new
	definition for v1.
	(ada_has_this_exception_support): Look up catch_handlers_sym.
	(ada_exception_support_info_sniffer): Try v0 after default.
---
 ada-lang.c |   52 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 49 insertions(+), 3 deletions(-)
  

Comments

Tom Tromey Aug. 2, 2019, 1:13 p.m. UTC | #1
>>>>> "Alexandre" == Alexandre Oliva <oliva@adacore.com> writes:

Alexandre> Ok to install?

Alexandre> for  gdb/ChangeLog

Alexandre> 	* ada-lang.c (exception_support_info_v0): Renamed from...
Alexandre> 	(default_exception_support_info): ... this.  Create new
Alexandre> 	definition for v1.
Alexandre> 	(ada_has_this_exception_support): Look up catch_handlers_sym.
Alexandre> 	(ada_exception_support_info_sniffer): Try v0 after default.

Thank you for the patch.
This is OK.

Tom
  

Patch

diff --git gdb/ada-lang.c gdb/ada-lang.c
index 7a5cc4272c6bb..15a7a902b824a 100644
--- gdb/ada-lang.c
+++ gdb/ada-lang.c
@@ -11867,9 +11867,22 @@  static CORE_ADDR ada_unhandled_exception_name_addr_from_raise (void);
 
 /* The following exception support info structure describes how to
    implement exception catchpoints with the latest version of the
-   Ada runtime (as of 2007-03-06).  */
+   Ada runtime (as of 2019-08-??).  */
 
 static const struct exception_support_info default_exception_support_info =
+{
+  "__gnat_debug_raise_exception", /* catch_exception_sym */
+  "__gnat_unhandled_exception", /* catch_exception_unhandled_sym */
+  "__gnat_debug_raise_assert_failure", /* catch_assert_sym */
+  "__gnat_begin_handler_v1", /* catch_handlers_sym */
+  ada_unhandled_exception_name_addr
+};
+
+/* The following exception support info structure describes how to
+   implement exception catchpoints with an earlier version of the
+   Ada runtime (as of 2007-03-06) using v0 of the EH ABI.  */
+
+static const struct exception_support_info exception_support_info_v0 =
 {
   "__gnat_debug_raise_exception", /* catch_exception_sym */
   "__gnat_unhandled_exception", /* catch_exception_unhandled_sym */
@@ -11938,8 +11951,34 @@  ada_has_this_exception_support (const struct exception_support_info *einfo)
   /* Make sure that the symbol we found corresponds to a function.  */
 
   if (SYMBOL_CLASS (sym) != LOC_BLOCK)
-    error (_("Symbol \"%s\" is not a function (class = %d)"),
-           SYMBOL_LINKAGE_NAME (sym), SYMBOL_CLASS (sym));
+    {
+      error (_("Symbol \"%s\" is not a function (class = %d)"),
+	     SYMBOL_LINKAGE_NAME (sym), SYMBOL_CLASS (sym));
+      return 0;
+    }
+
+  sym = standard_lookup (einfo->catch_handlers_sym, NULL, VAR_DOMAIN);
+  if (sym == NULL)
+    {
+      struct bound_minimal_symbol msym
+	= lookup_minimal_symbol (einfo->catch_handlers_sym, NULL, NULL);
+
+      if (msym.minsym && MSYMBOL_TYPE (msym.minsym) != mst_solib_trampoline)
+	error (_("Your Ada runtime appears to be missing some debugging "
+		 "information.\nCannot insert Ada exception catchpoint "
+		 "in this configuration."));
+
+      return 0;
+    }
+
+  /* Make sure that the symbol we found corresponds to a function.  */
+
+  if (SYMBOL_CLASS (sym) != LOC_BLOCK)
+    {
+      error (_("Symbol \"%s\" is not a function (class = %d)"),
+	     SYMBOL_LINKAGE_NAME (sym), SYMBOL_CLASS (sym));
+      return 0;
+    }
 
   return 1;
 }
@@ -11966,6 +12005,13 @@  ada_exception_support_info_sniffer (void)
       return;
     }
 
+  /* Try the v0 exception suport info.  */
+  if (ada_has_this_exception_support (&exception_support_info_v0))
+    {
+      data->exception_info = &exception_support_info_v0;
+      return;
+    }
+
   /* Try our fallback exception suport info.  */
   if (ada_has_this_exception_support (&exception_support_info_fallback))
     {