From patchwork Thu Aug 1 17:04:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33897 Received: (qmail 116388 invoked by alias); 1 Aug 2019 17:04:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 116281 invoked by uid 89); 1 Aug 2019 17:04:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=bl X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 01 Aug 2019 17:04:17 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id C6C745604E; Thu, 1 Aug 2019 13:04:15 -0400 (EDT) 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 w4u+U9-awv9A; Thu, 1 Aug 2019 13:04:15 -0400 (EDT) Received: from murgatroyd.Home (97-122-178-82.hlrn.qwest.net [97.122.178.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 71E2756018; Thu, 1 Aug 2019 13:04:15 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 3/8] Back out earlier Ada exception change Date: Thu, 1 Aug 2019 11:04:07 -0600 Message-Id: <20190801170412.5553-4-tromey@adacore.com> In-Reply-To: <20190801170412.5553-1-tromey@adacore.com> References: <20190801170412.5553-1-tromey@adacore.com> MIME-Version: 1.0 commit 2ff0a9473 (Fix "catch exception" with dynamic linking) changed how ada-lang.c creates expressions to determine if an exception catchpoint should stop. That patch is no longer needed now that copy relocations are handled more directly. gdb/ChangeLog 2019-08-01 Tom Tromey * ada-lang.c (ada_lookup_simple_minsyms): Remove. (create_excep_cond_exprs): Simplify exception string computation. (ada_exception_catchpoint_cond_string): Likewise. --- gdb/ChangeLog | 6 +++ gdb/ada-lang.c | 107 ++++++++++++------------------------------------- 2 files changed, 31 insertions(+), 82 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 4e1ee31887a..6851386b48b 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -4846,36 +4846,6 @@ ada_lookup_simple_minsym (const char *name) return result; } -/* Return all the bound minimal symbols matching NAME according to Ada - decoding rules. Returns an empty vector if there is no such - minimal symbol. Names prefixed with "standard__" are handled - specially: "standard__" is first stripped off, and only static and - global symbols are searched. */ - -static std::vector -ada_lookup_simple_minsyms (const char *name) -{ - std::vector result; - - symbol_name_match_type match_type = name_match_type_from_name (name); - lookup_name_info lookup_name (name, match_type); - - symbol_name_matcher_ftype *match_name - = ada_get_symbol_name_matcher (lookup_name); - - for (objfile *objfile : current_program_space->objfiles ()) - { - for (minimal_symbol *msymbol : objfile->msymbols ()) - { - if (match_name (MSYMBOL_LINKAGE_NAME (msymbol), lookup_name, NULL) - && MSYMBOL_TYPE (msymbol) != mst_solib_trampoline) - result.push_back ({msymbol, objfile}); - } - } - - return result; -} - /* For all subprograms that statically enclose the subprogram of the selected frame, add symbols matching identifier NAME in DOMAIN and their blocks to the list of data in OBSTACKP, as for @@ -12316,6 +12286,8 @@ static void create_excep_cond_exprs (struct ada_catchpoint *c, enum ada_exception_catchpoint_kind ex) { + struct bp_location *bl; + /* Nothing to do if there's no specific exception to catch. */ if (c->excep_string.empty ()) return; @@ -12324,45 +12296,28 @@ create_excep_cond_exprs (struct ada_catchpoint *c, if (c->loc == NULL) return; - /* We have to compute the expression once for each program space, - because the expression may hold the addresses of multiple symbols - in some cases. */ - std::multimap loc_map; - for (bp_location *bl = c->loc; bl != NULL; bl = bl->next) - loc_map.emplace (bl->pspace, bl); - - scoped_restore_current_program_space save_pspace; + /* Compute the condition expression in text form, from the specific + expection we want to catch. */ + std::string cond_string + = ada_exception_catchpoint_cond_string (c->excep_string.c_str (), ex); - std::string cond_string; - program_space *last_ps = nullptr; - for (auto iter : loc_map) + /* Iterate over all the catchpoint's locations, and parse an + expression for each. */ + for (bl = c->loc; bl != NULL; bl = bl->next) { struct ada_catchpoint_location *ada_loc - = (struct ada_catchpoint_location *) iter.second; - - if (ada_loc->pspace != last_ps) - { - last_ps = ada_loc->pspace; - set_current_program_space (last_ps); - - /* Compute the condition expression in text form, from the - specific expection we want to catch. */ - cond_string - = ada_exception_catchpoint_cond_string (c->excep_string.c_str (), - ex); - } - + = (struct ada_catchpoint_location *) bl; expression_up exp; - if (!ada_loc->shlib_disabled) + if (!bl->shlib_disabled) { const char *s; s = cond_string.c_str (); try { - exp = parse_exp_1 (&s, ada_loc->address, - block_for_pc (ada_loc->address), + exp = parse_exp_1 (&s, bl->address, + block_for_pc (bl->address), 0); } catch (const gdb_exception_error &e) @@ -13032,18 +12987,18 @@ ada_exception_catchpoint_cond_string (const char *excep_string, enum ada_exception_catchpoint_kind ex) { int i; + bool is_standard_exc = false; std::string result; - const char *name; if (ex == ada_catch_handlers) { /* For exception handlers catchpoints, the condition string does not use the same parameter as for the other exceptions. */ - name = ("long_integer (GNAT_GCC_exception_Access" - "(gcc_exception).all.occurrence.id)"); + result = ("long_integer (GNAT_GCC_exception_Access" + "(gcc_exception).all.occurrence.id)"); } else - name = "long_integer (e)"; + result = "long_integer (e)"; /* The standard exceptions are a special case. They are defined in runtime units that have been compiled without debugging info; if @@ -13062,35 +13017,23 @@ ada_exception_catchpoint_cond_string (const char *excep_string, 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. - - Furthermore, in some situations a standard exception's symbol may - be present in more than one objfile, because the compiler may - choose to emit copy relocations for them. So, we have to compare - against all the possible addresses. */ + e.g. my_package.constraint_error. */ - /* Storage for a rewritten symbol name. */ - std::string std_name; for (i = 0; i < sizeof (standard_exc) / sizeof (char *); i++) { if (strcmp (standard_exc [i], excep_string) == 0) { - std_name = std::string ("standard.") + excep_string; - excep_string = std_name.c_str (); + is_standard_exc = true; break; } } - excep_string = ada_encode (excep_string); - std::vector symbols - = ada_lookup_simple_minsyms (excep_string); - for (const bound_minimal_symbol &msym : symbols) - { - if (!result.empty ()) - result += " or "; - string_appendf (result, "%s = %s", name, - pulongest (BMSYMBOL_VALUE_ADDRESS (msym))); - } + result += " = "; + + if (is_standard_exc) + string_appendf (result, "long_integer (&standard.%s)", excep_string); + else + string_appendf (result, "long_integer (&%s)", excep_string); return result; }