From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by sourceware.org (Postfix) with ESMTPS id CFA323858418 for ; Wed, 24 May 2023 16:37:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CFA323858418 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-77496b0b345so17095339f.3 for ; Wed, 24 May 2023 09:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1684946247; x=1687538247; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Gp0zTsbqMHN6vDWP2h2EVG9c9AWF2LVTzlpnIK+s93w=; b=AkTAWkmeUAAUq+z7SNIxF6I5yjB3Qc7+NCwI9x88CX9SkUm+GUCZMJy4WS8L7Qel7X JF1/hk9dlplrPeWylo65wdyUyYJn/6K39aw7I7cYg24ZmoFYTti4EzN9HNZW3BWcxppH 9y1Jw6GbxPmZoFmYlFjzAKJQ2E5VcH1gZ5qT04Eem9CbPCCYrIN+EtzqaHCuvLDF3TAW An9REve0X7FnaSmVjMwDZjLDhnVAaI9eZorEtBY3thF6Eus/hUcJGrvDqwyOMX4KDr+0 og5WcZtJfCd3AjLqbreg9VQWrOuk7SqN6cJYosqyWOw6WnBRr3zPKyPBrIPO0/VNEoZh PkbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684946247; x=1687538247; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gp0zTsbqMHN6vDWP2h2EVG9c9AWF2LVTzlpnIK+s93w=; b=R/PuliJ7HzW+URjKOmJpqcyXvIR9q1YM9zn951DNyTw79bJgtj237u5oo46YTBvyM2 6NHyzpF7aWaVK46vvF57OHRr+iYmf5fSz3qOJME6T571E0gnAjTQqKCu9+yei1UGOeZI y9imYChGQhMC/bzjJz4CVzJ32DvQ0urqMRjwJX7y/Qo304kdLJLxdgvbi8EZLVoFBAH0 UIzDyzq889DJE+b0UWa9SeGcn+xLGJhQkOsXem6A3lLZblaByDgM+Cdj7ic5haSyM8XP d1l5SYMY1fbvAu5EIET3PKpfVRsjZD/o0gnmTlsTv5yC1Bqo7vjwReFCZwpN7M7W/UyI KOEA== X-Gm-Message-State: AC+VfDwgG36rDQtoKL0bzIe1xt7TXrwvrjc/FM05Z0Miyj7NahZGUDht C4t/kQGIsfWRP/eOdKPUgFdsuF7X2SfBZaTuNZuRJw== X-Google-Smtp-Source: ACHHUZ7FSMHuToBPV5jA/qtFNaJn755Go5yewcq25wqz1JDoRLLW7yxV40001J8sRmgwx1zTgue2cg== X-Received: by 2002:a5d:91d4:0:b0:76e:fc55:fdc4 with SMTP id k20-20020a5d91d4000000b0076efc55fdc4mr11527389ior.5.1684946247004; Wed, 24 May 2023 09:37:27 -0700 (PDT) Received: from localhost.localdomain (71-211-130-244.hlrn.qwest.net. [71.211.130.244]) by smtp.gmail.com with ESMTPSA id o22-20020a6bcf16000000b0076c81bf2731sm3397266ioa.20.2023.05.24.09.37.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 09:37:26 -0700 (PDT) From: Tom Tromey Date: Wed, 24 May 2023 10:36:56 -0600 Subject: [PATCH 05/25] Combine create_excep_cond_exprs and ada_catchpoint::re_set MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230427-ada-catch-exception-v1-5-947caa9905e3@adacore.com> References: <20230427-ada-catch-exception-v1-0-947caa9905e3@adacore.com> In-Reply-To: <20230427-ada-catch-exception-v1-0-947caa9905e3@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This patch merges create_excep_cond_exprs into ada_catchpoint::re_set. This is less verbose and is also a step toward making ada_catchpoint work more like the other code_breakpoint-based exception catchpoints. --- gdb/ada-lang.c | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 374cec57090..24ed93f2004 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -12174,6 +12174,8 @@ struct ada_catchpoint : public code_breakpoint locspec = string_to_location_spec (&addr_string_, language_def (language_ada)); language = language_ada; + + re_set (); } struct bp_location *allocate_location () override; @@ -12207,29 +12209,35 @@ class ada_catchpoint_location : public bp_location expression_up excep_cond_expr; }; -/* Parse the exception condition string in the context of each of the - catchpoint's locations, and store them for later evaluation. */ +/* Implement the RE_SET method in the structure for all exception + catchpoint kinds. */ -static void -create_excep_cond_exprs (struct ada_catchpoint *c, - enum ada_exception_catchpoint_kind ex) +void +ada_catchpoint::re_set () { + /* Call the base class's method. This updates the catchpoint's + locations. */ + this->code_breakpoint::re_set (); + + /* Reparse the exception conditional expressions. One for each + location. */ + /* Nothing to do if there's no specific exception to catch. */ - if (c->excep_string.empty ()) + if (excep_string.empty ()) return; /* Same if there are no locations... */ - if (c->loc == NULL) + if (loc == NULL) return; /* 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); + = ada_exception_catchpoint_cond_string (excep_string.c_str (), m_kind); /* Iterate over all the catchpoint's locations, and parse an expression for each. */ - for (bp_location *bl : c->locations ()) + for (bp_location *bl : locations ()) { struct ada_catchpoint_location *ada_loc = (struct ada_catchpoint_location *) bl; @@ -12250,7 +12258,7 @@ create_excep_cond_exprs (struct ada_catchpoint *c, { warning (_("failed to reevaluate internal exception condition " "for catchpoint %d: %s"), - c->number, e.what ()); + number, e.what ()); } } @@ -12267,21 +12275,6 @@ ada_catchpoint::allocate_location () return new ada_catchpoint_location (this); } -/* Implement the RE_SET method in the structure for all exception - catchpoint kinds. */ - -void -ada_catchpoint::re_set () -{ - /* Call the base class's method. This updates the catchpoint's - locations. */ - this->code_breakpoint::re_set (); - - /* Reparse the exception conditional expressions. One for each - location. */ - create_excep_cond_exprs (this, m_kind); -} - /* Returns true if we should stop for this breakpoint hit. If the user specified a specific exception, we only want to cause a stop if the program thrown that exception. */ @@ -12822,7 +12815,6 @@ create_ada_exception_catchpoint (struct gdbarch *gdbarch, (new ada_catchpoint (gdbarch, ex_kind, sal, addr_string.c_str (), tempflag, enabled, from_tty, std::move (excep_string))); - create_excep_cond_exprs (c.get (), ex_kind); if (!cond_string.empty ()) set_breakpoint_condition (c.get (), cond_string.c_str (), from_tty, false); install_breakpoint (0, std::move (c), 1); -- 2.40.0