From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20753 invoked by alias); 11 Dec 2011 17:41:25 -0000 Received: (qmail 20744 invoked by uid 22791); 11 Dec 2011 17:41:24 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 11 Dec 2011 17:41:08 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id F31CD2BAED7; Sun, 11 Dec 2011 12:41:07 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id i2RcRjM428-X; Sun, 11 Dec 2011 12:41:07 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id DED182BAEB2; Sun, 11 Dec 2011 12:41:07 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id B2008145615; Sun, 11 Dec 2011 09:41:07 -0800 (PST) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Joel Brobecker Subject: [commit] Ada exception catchpoint support cleanup. Date: Sun, 11 Dec 2011 17:42:00 -0000 Message-Id: <1323625260-21663-1-git-send-email-brobecker@adacore.com> In-Reply-To: <20111207100101.GC21915@adacore.com> References: <20111207100101.GC21915@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-12/txt/msg00331.txt.bz2 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 + + * 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 * 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