Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: [commit] Ada exception catchpoint support cleanup.
Date: Sun, 11 Dec 2011 17:42:00 -0000	[thread overview]
Message-ID: <1323625260-21663-1-git-send-email-brobecker@adacore.com> (raw)
In-Reply-To: <20111207100101.GC21915@adacore.com>

Hello,

This patch cleans up a bit the way we detect which type of runtime
the program uses with respect to Ada exceptions. It also removes
an unnecessary check in ada_exception_sal which is already performed
by ada_exception_support_info_sniffer.

Some of the changes are preparation work for detecting the situation
where the Ada runtime is found, but lacking debugging info.

gdb/ChangeLog:

        * ada-lang.c (ada_has_this_exception_support): New function,
        extracted out of ada_exception_sal and ada_exception_sal.
        (ada_exception_support_info_sniffer): Simplify by using
        ada_has_this_exception_support.
        (ada_exception_sal): Replace unnecessary checks by assertions.
        Minor simplifications.

Tested on x86_64-linux, with both normal and stripped runtimes.
Checked in.

---
 gdb/ChangeLog  |    9 +++++++
 gdb/ada-lang.c |   74 +++++++++++++++++++++++++++++--------------------------
 2 files changed, 48 insertions(+), 35 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a4698d8..cbd770b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2011-12-11  Joel Brobecker  <brobecker@adacore.com>
+
+	* ada-lang.c (ada_has_this_exception_support): New function,
+	extracted out of ada_exception_sal and ada_exception_sal.
+	(ada_exception_support_info_sniffer): Simplify by using
+	ada_has_this_exception_support.
+	(ada_exception_sal): Replace unnecessary checks by assertions.
+	Minor simplifications.
+
 2011-12-10  Andrey Smirnov  <andrew.smirnov@gmail.com>
 
 	* breakpoint.c (update_global_location_list): Remove nested
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7499dfb..97558f1 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10648,6 +10648,35 @@ static const struct exception_support_info exception_support_info_fallback =
   ada_unhandled_exception_name_addr_from_raise
 };
 
+/* Return nonzero if we can detect the exception support routines
+   described in EINFO.
+
+   This function errors out if an abnormal situation is detected
+   (for instance, if we find the exception support routines, but
+   that support is found to be incomplete).  */
+
+static int
+ada_has_this_exception_support (const struct exception_support_info *einfo)
+{
+  struct symbol *sym;
+
+  /* The symbol we're looking up is provided by a unit in the GNAT runtime
+     that should be compiled with debugging information.  As a result, we
+     expect to find that symbol in the symtabs.  */
+
+  sym = standard_lookup (einfo->catch_exception_sym, NULL, VAR_DOMAIN);
+  if (sym == NULL)
+    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 1;
+}
+
 /* For each executable, we sniff which exception info structure to use
    and cache it in the following global variable.  */
 
@@ -10668,18 +10697,14 @@ ada_exception_support_info_sniffer (void)
     return;
 
   /* Check the latest (default) exception support info.  */
-  sym = standard_lookup (default_exception_support_info.catch_exception_sym,
-                         NULL, VAR_DOMAIN);
-  if (sym != NULL)
+  if (ada_has_this_exception_support (&default_exception_support_info))
     {
       exception_info = &default_exception_support_info;
       return;
     }
 
   /* Try our fallback exception suport info.  */
-  sym = standard_lookup (exception_support_info_fallback.catch_exception_sym,
-                         NULL, VAR_DOMAIN);
-  if (sym != NULL)
+  if (ada_has_this_exception_support (&exception_support_info_fallback))
     {
       exception_info = &exception_support_info_fallback;
       return;
@@ -11693,52 +11718,31 @@ ada_exception_sal (enum exception_catchpoint_kind ex, char *excep_string,
 {
   const char *sym_name;
   struct symbol *sym;
-  struct symtab_and_line sal;
 
   /* First, find out which exception support info to use.  */
   ada_exception_support_info_sniffer ();
 
   /* Then lookup the function on which we will break in order to catch
      the Ada exceptions requested by the user.  */
-
   sym_name = ada_exception_sym_name (ex);
   sym = standard_lookup (sym_name, NULL, VAR_DOMAIN);
 
-  /* The symbol we're looking up is provided by a unit in the GNAT runtime
-     that should be compiled with debugging information.  As a result, we
-     expect to find that symbol in the symtabs.  If we don't find it, then
-     the target most likely does not support Ada exceptions, or we cannot
-     insert exception breakpoints yet, because the GNAT runtime hasn't been
-     loaded yet.  */
-
-  /* brobecker/2006-12-26: It is conceivable that the runtime was compiled
-     in such a way that no debugging information is produced for the symbol
-     we are looking for.  In this case, we could search the minimal symbols
-     as a fall-back mechanism.  This would still be operating in degraded
-     mode, however, as we would still be missing the debugging information
-     that is needed in order to extract the name of the exception being
-     raised (this name is printed in the catchpoint message, and is also
-     used when trying to catch a specific exception).  We do not handle
-     this case for now.  */
-
-  if (sym == NULL)
-    error (_("Unable to break on '%s' in this configuration."), sym_name);
-
-  /* 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)"),
-           sym_name, SYMBOL_CLASS (sym));
+  /* We can assume that SYM is not NULL at this stage.  If the symbol
+     did not exist, ada_exception_support_info_sniffer would have
+     raised an exception.
 
-  sal = find_function_start_sal (sym, 1);
+     Also, ada_exception_support_info_sniffer should have already
+     verified that SYM is a function symbol.  */
+  gdb_assert (sym != NULL);
+  gdb_assert (SYMBOL_CLASS (sym) == LOC_BLOCK);
 
   /* Set ADDR_STRING.  */
-
   *addr_string = xstrdup (sym_name);
 
   /* Set OPS.  */
   *ops = ada_exception_breakpoint_ops (ex);
 
-  return sal;
+  return find_function_start_sal (sym, 1);
 }
 
 /* Parse the arguments (ARGS) of the "catch exception" command.
-- 
1.7.1


  parent reply	other threads:[~2011-12-11 17:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-06 17:33 [PATCH] gdb.ada/catch_ex.exp, gdb.ada/mi_catch_ex.exp and unsupported catchpoints Pedro Alves
2011-12-07 10:07 ` Joel Brobecker
2011-12-07 15:29   ` Pedro Alves
2011-12-07 16:10     ` Pedro Alves
2011-12-07 22:01   ` Tom Tromey
2011-12-07 23:18     ` Joel Brobecker
2011-12-09  3:50       ` Tom Tromey
2011-12-09 17:20       ` Pedro Alves
2011-12-09 18:00         ` Tom Tromey
2011-12-09 18:13           ` Pedro Alves
2011-12-09 18:40             ` Tom Tromey
2011-12-10 22:53               ` Pedro Alves
2011-12-11 20:33                 ` Joel Brobecker
2011-12-20 14:53                 ` Tom Tromey
2012-01-10 20:26                   ` Pedro Alves
2011-12-11 17:42   ` Joel Brobecker [this message]
2011-12-11 17:44   ` [commit] Warn if missing debug info for Ada exception catchpoints Joel Brobecker
2011-12-11 18:04   ` [commit/Ada] improve message when cannot insert Ada exception catchpoint Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1323625260-21663-1-git-send-email-brobecker@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox