From patchwork Tue Mar 5 15:21:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 86807 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 53CA63858282 for ; Tue, 5 Mar 2024 15:24:13 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id AA1DE38582B5 for ; Tue, 5 Mar 2024 15:22:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA1DE38582B5 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AA1DE38582B5 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709652131; cv=none; b=fOfR9eFRB9DmWtItgwF4wna22Jg1HnoFwGAyOu5iSMt+sou4FQdaNEB/U57zmbbTWPHjljzieuDt2UX0SCi+iAlmRSjoncAgsgp53zLbUNIYQ0lz9SUHRGgqlNMCUadjRARbqJDzt2niE1bXQunvsHB+HPJvuI51lk5ZCn0fEek= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709652131; c=relaxed/simple; bh=MuEY32hUfqxXrPxFgmwNaR07Si8UXwqQmkMYa8LlWE0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=alu/dntBzITszRVsMEux8FDW1yi40LwnyT6aGIU4BD0vXoNhmhgIPW0k5KhQNwdYN1tsxoWkbrcSMkcS/byZg+4R0djs9iNPu4sSrgZxXwuP/MCj1fbdlX7z6U9hqCdgdRRIoF+a14y4oDZ3MAwNVSuIBj7mTXf7dc6ei3tG83w= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709652125; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+d7s2oX3AeLev582oG3v6tLz5GSs1KhEiXjOZEI+wa0=; b=Y2ODJX7/RoH8ZjV9Rg3ER4sZx27wuDMnB3q4Q/TwPDK6qinZJ0EJUuzKTGgrecSHPkv9jn KQ0R5t5EIcJX54gzJA4uPNq2FGa5vu/K1ehZNuBOmT5nTOqz6Djhkb6l25LtguBzm4gsDk yJkZypsiBSvvvjRfB4skewr1YyHm890= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-564-6sNMw89QObqrKrWSQm2sEA-1; Tue, 05 Mar 2024 10:22:03 -0500 X-MC-Unique: 6sNMw89QObqrKrWSQm2sEA-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a45a7d558feso87799766b.0 for ; Tue, 05 Mar 2024 07:22:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709652120; x=1710256920; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+d7s2oX3AeLev582oG3v6tLz5GSs1KhEiXjOZEI+wa0=; b=oXHbHvWOs5iZAqty+Td+MzVR925Uw9rQL37eqL/k/NlEudqCY6BnnEGpuglicaIUDh rU5aAqNwazrlbkkwK4XlL+AMhoznhwctRDsxjkqiyOpNFJGiK776UgNZmzDY9YTr0Fhm A1zX22G/b9niQtC3j0iKKZJcQdIa8Pfcd8D423StNVAr6Ov7S0ixBVntl7mWbMSzyU1T w1z4+79VD5YBjHj2xi0ZX39kNedBe7i/mKyYF2+Vm49gvUyiW7XjGtNcwuJrsk+EI2QH b//4tRLir+ejgIVuCSuda0f9kVwFtRo7jP5GZPbOv4w2Tai6qBgEaR09I3wvQcDmNbFB ZtGg== X-Gm-Message-State: AOJu0YzWliTmZExaza7PVVord+TKU6U/rOASGp8+gnH6/c+BKlva/EK2 Ju6dmyzI14PW7GcybYFFx3tXcE+JqifZA7qp82AgVyiGnVt7YGgFDfC1FC3BwAy/TYoHi5+Mrcf CEdSdyp+YCap+TVbUa5KIixbGWoTXMI82F32s5eOBia8O5q3+9hczy8Hn9pLn8I8vAxNex+HHrQ XEohs/i5l6mISIxgBzQw2xZlOZfq1HKdXJE17uJH9DRig= X-Received: by 2002:a17:906:f751:b0:a45:566a:b652 with SMTP id jp17-20020a170906f75100b00a45566ab652mr3134913ejb.11.1709652120173; Tue, 05 Mar 2024 07:22:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQmCIaChvWg0EcPsk+Y0nBbTWJ4wGPliTV++jZk1RDt1s9UrjPnHvWr7Yham9bMvvC3GRwcg== X-Received: by 2002:a17:906:f751:b0:a45:566a:b652 with SMTP id jp17-20020a170906f75100b00a45566ab652mr3134888ejb.11.1709652119767; Tue, 05 Mar 2024 07:21:59 -0800 (PST) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id x23-20020a170906135700b00a3e4c47bad1sm6113511ejb.8.2024.03.05.07.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 07:21:59 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv9 07/14] gdb: remove breakpoint_re_set_one Date: Tue, 5 Mar 2024 15:21:38 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org During a later patch I wanted to reset a single breakpoint, so I called breakpoint_re_set_one. However, this is not the right thing to do. If we look at breakpoint_re_set then we see that there's a whole bunch of state that needs to be preserved prior to calling breakpoint_re_set_one, and after calling breakpoint_re_set_one we still need to call update_global_location_list. I could just update the comment on breakpoint_re_set_one to make it clearer how the function should be used -- or more likely to warn that the function should only be used as a helper from breakpoint_re_set. However, breakpoint_re_set_one is only 3 lines long. So I figure it might actually be easier to just fold breakpoint_re_set_one into breakpoint_re_set, then there's no risk of accidentally calling breakpoint_re_set_one when we shouldn't. There should be no user visible changes after this commit. --- gdb/breakpoint.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index aae1b932a5d..5e97d27bbf5 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -13210,17 +13210,6 @@ create_sals_from_location_spec_default (location_spec *locspec, parse_breakpoint_sals (locspec, canonical); } -/* Reset a breakpoint. */ - -static void -breakpoint_re_set_one (breakpoint *b) -{ - input_radix = b->input_radix; - set_language (b->language); - - b->re_set (); -} - /* Re-set breakpoint locations for the current program space. Locations bound to other program spaces are left untouched. */ @@ -13232,12 +13221,11 @@ breakpoint_re_set (void) scoped_restore save_input_radix = make_scoped_restore (&input_radix); scoped_restore_current_pspace_and_thread restore_pspace_thread; - /* breakpoint_re_set_one sets the current_language to the language - of the breakpoint it is resetting (see prepare_re_set_context) - before re-evaluating the breakpoint's location. This change can - unfortunately get undone by accident if the language_mode is set - to auto, and we either switch frames, or more likely in this context, - we select the current frame. + /* To ::re_set each breakpoint we set the current_language to the + language of the breakpoint before re-evaluating the breakpoint's + location. This change can unfortunately get undone by accident if + the language_mode is set to auto, and we either switch frames, or + more likely in this context, we select the current frame. We prevent this by temporarily turning the language_mode to language_mode_manual. We restore it once all breakpoints @@ -13254,7 +13242,9 @@ breakpoint_re_set (void) { try { - breakpoint_re_set_one (&b); + input_radix = b.input_radix; + set_language (b.language); + b.re_set (); } catch (const gdb_exception &ex) {