public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: [commit] Warn if missing debug info for Ada exception catchpoints
Date: Sun, 11 Dec 2011 17:44:00 -0000	[thread overview]
Message-ID: <1323625341-21755-1-git-send-email-brobecker@adacore.com> (raw)
In-Reply-To: <20111207100101.GC21915@adacore.com>

This is the second part that takes advantage of the cleanup we just
did.

This patch should help the user understand why the debugger is not
able to insert Ada exception catchpoints when the Ada runtime was
stripped of debugging info, as is often the case on many GNU/Linux
distros:

    (gdb) catch exception
    Your Ada runtime appears to be missing some debugging information.
    Cannot insert Ada exception catchpoint in this configuration.

gdb/ChangeLog:

        * ada-lang.c (ada_has_this_exception_support): Raise an error
        if we could find the Ada exception hook in the Ada runtime,
        but no debugging info for that hook.

gdb/testsuite/ChangeLog:

        * gdb.ada/catch_ex.exp, gdb.ada/mi_catch_ex.exp: Adjust
        expected output for unsupported case.

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

---
 gdb/ChangeLog                         |    6 ++++++
 gdb/ada-lang.c                        |   23 ++++++++++++++++++++++-
 gdb/testsuite/ChangeLog               |    5 +++++
 gdb/testsuite/gdb.ada/catch_ex.exp    |    2 +-
 gdb/testsuite/gdb.ada/mi_catch_ex.exp |    2 +-
 5 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index cbd770b..31397e0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
 2011-12-11  Joel Brobecker  <brobecker@adacore.com>
 
+	* ada-lang.c (ada_has_this_exception_support): Raise an error
+	if we could find the Ada exception hook in the Ada runtime,
+	but no debugging info for that hook.
+
+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
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 97558f1..b3c0a24 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10666,7 +10666,28 @@ ada_has_this_exception_support (const struct exception_support_info *einfo)
 
   sym = standard_lookup (einfo->catch_exception_sym, NULL, VAR_DOMAIN);
   if (sym == NULL)
-    return 0;
+    {
+      /* Perhaps we did not find our symbol because the Ada runtime was
+	 compiled without debugging info, or simply stripped of it.
+	 It happens on some GNU/Linux distributions for instance, where
+	 users have to install a separate debug package in order to get
+	 the runtime's debugging info.  In that situation, let the user
+	 know why we cannot insert an Ada exception catchpoint.
+
+	 Note: Just for the purpose of inserting our Ada exception
+	 catchpoint, we could rely purely on the associated minimal symbol.
+	 But we would be operating in degraded mode anyway, since we are
+	 still lacking the debugging info needed later on 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 (lookup_minimal_symbol (einfo->catch_exception_sym, NULL, NULL))
+	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.  */
 
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 1a02cf9..f95ac4d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-12-11  Joel Brobecker  <brobecker@adacore.com>
+
+	* gdb.ada/catch_ex.exp, gdb.ada/mi_catch_ex.exp: Adjust
+	expected output for unsupported case.
+
 2011-12-10  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
 	PR testsuite/12649
diff --git a/gdb/testsuite/gdb.ada/catch_ex.exp b/gdb/testsuite/gdb.ada/catch_ex.exp
index 0ea3256..0cb8874 100644
--- a/gdb/testsuite/gdb.ada/catch_ex.exp
+++ b/gdb/testsuite/gdb.ada/catch_ex.exp
@@ -56,7 +56,7 @@ gdb_test_multiple "catch exception" $msg {
     -re "Catchpoint $any_nb: all Ada exceptions$eol$gdb_prompt $" {
 	pass $msg
     }
-    -re "Cannot (insert catchpoints|break on __gnat_raise_nodefer_with_msg) in this configuration\.$eol$gdb_prompt $" {
+    -re "Your Ada runtime appears to be missing some debugging information.*$eol$gdb_prompt $" {
 	# If the runtime was not built with enough debug information,
 	# or if it was stripped, we can not test exception
 	# catchpoints.
diff --git a/gdb/testsuite/gdb.ada/mi_catch_ex.exp b/gdb/testsuite/gdb.ada/mi_catch_ex.exp
index 4be1cad..584cc00 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_ex.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_ex.exp
@@ -46,7 +46,7 @@ gdb_test_multiple "catch exception" $msg {
     -re "Catchpoint $any_nb: all Ada exceptions$eol$gdb_prompt $" {
 	pass $msg
     }
-    -re "Cannot (insert catchpoints|break on __gnat_raise_nodefer_with_msg) in this configuration\.\[\r\n\]+$gdb_prompt $" {
+    -re "Your Ada runtime appears to be missing some debugging information.*\[\r\n\]+$gdb_prompt $" {
 	# If the runtime was not built with enough debug information,
 	# or if it was stripped, we can not test exception
 	# catchpoints.
-- 
1.7.1

  parent reply	other threads:[~2011-12-11 17:42 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   ` [commit] Ada exception catchpoint support cleanup Joel Brobecker
2011-12-11 17:44   ` Joel Brobecker [this message]
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=1323625341-21755-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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).