From patchwork Sat Dec 2 10:42:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 81188 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 CE3E1385C6DE for ; Sat, 2 Dec 2023 10:43:34 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id 47E553861878 for ; Sat, 2 Dec 2023 10:42:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 47E553861878 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 47E553861878 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701513766; cv=none; b=gufo9M4SBDEtaH/8O+JPDKzFU6EcOO/YtT5pXDD686aMq4sBGMW2T4MQ/MEjHOz5jvxIp/sySYFp9MiYpSvQePd4PwMKeqbybEpnFcrd9GJnHCHPJD2+IGSq1ejQYPMczgGb1K4sS/9cK5wSXZQwjWQeORCXLjcj0x6+cavSjA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701513766; c=relaxed/simple; bh=VM6Wmcg3XdwqJ4ZNXxIAuR/QBQpsPsr62+2R32W3UW8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=mc/0MaNuc0fcIMwstn0WO3EuzQsLUpgHpCyR7C8134DR+bHFL9hUrGoOkmR6/QXs7EapzMDKnUq238C5rJhd9IS5/03QPnFYJ3pQJ9PK4wf3PESDT8zTpc4kBxFeii6BPwfov9RLkVFI7gRNVJTL5kEUA/QMKvwVSql6E1Ks0b4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701513764; 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=ML8uS5ZyNXQ8Ft3d6DbIF2LLi4hjljekDFheEvCpr6U=; b=h6xjD5mYP3GFlhAWXB4Sz2IlTbdgn+//s3N9OM11bvEFk1ZmW7XF8rK4MmKbN5G594MP7g Olc6CBm9kuzWPHyGIJShaQSBLfGMpHZkCYxJ9lduoAdk843W0cjFCMtYfcLcfOnJhmWUQt JPLoe81VilmJ5oz3OFwkBvR4NQHvAx0= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-195-grlZ8njoPKmVVBfwS-SjLw-1; Sat, 02 Dec 2023 05:42:43 -0500 X-MC-Unique: grlZ8njoPKmVVBfwS-SjLw-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a00d0011a3bso254421566b.2 for ; Sat, 02 Dec 2023 02:42:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701513762; x=1702118562; 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=ML8uS5ZyNXQ8Ft3d6DbIF2LLi4hjljekDFheEvCpr6U=; b=mq63uwNIfl9NEGuV7zdRatfTF74iUNMCO8v6HvZwEQypXgHem+UJ5S3YjbO91p84/J YDikpbo+zdRHzufqYBESsDvCUqxUhvTo1IpsKIe+HOecE8ZXjdteTd+IK3k4mFmsU5UW Jz4k4+tO1ThQxfiaxG4gfFXPGH6f9VNKbVmHF5aCLBfiJgm4GKFzLd5lEvakAxB6iAGG YR/Ba4lYOpLeYz71SzlNYhSrQ6xBuVdw0A0PL7rns2FagL2pijlgfR9VBxkKQT+Oc20T HUKXBfJZrZXo148P6Q/xeMig4EFsjH9vLb+uJbzM5ueyYDdR3O/tX1alUVF4+aXao0SX Cyag== X-Gm-Message-State: AOJu0Yys+oxXcr0msuZ7QpQ7mnIgir0HMzcdUA20w1MPO+WqsHzZaGx6 HHQoPM+ficm17eOYmHnK71MvGzivHSQK+lOGdyDA0a+t6V/eLUWKN04J7gG0dQMXGSDXeNC9lkl JXYxyh76aSVM8ahMpik9WPBgvGACJnVpe5gsVy4A2qnWgJWoMcTnHbkEGBaa/pkuWCEV1hwOtpG hNsNquZQ== X-Received: by 2002:a17:906:243:b0:a16:31b6:f6fd with SMTP id 3-20020a170906024300b00a1631b6f6fdmr1530067ejl.5.1701513762432; Sat, 02 Dec 2023 02:42:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZP/Ro8HOwV+zUQUtCUp+/TOunKQx2QtB5dhGzvBrI0EjlQnWx2xxFRqJhbKkU1QzYDGm2WA== X-Received: by 2002:a17:906:243:b0:a16:31b6:f6fd with SMTP id 3-20020a170906024300b00a1631b6f6fdmr1530059ejl.5.1701513762236; Sat, 02 Dec 2023 02:42:42 -0800 (PST) Received: from localhost (92.40.184.5.threembb.co.uk. [92.40.184.5]) by smtp.gmail.com with ESMTPSA id dq4-20020a170907734400b00a1a575191f8sm822609ejc.102.2023.12.02.02.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 02:42:41 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv6 08/10] gdb: remove breakpoint_re_set_one Date: Sat, 2 Dec 2023 10:42:16 +0000 Message-Id: <2844f2b8fc1bfdea240085b3eb20ed6bafc0089d.1701513410.git.aburgess@redhat.com> 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=-8.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_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, 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 bbf28d82558..7ca3377150d 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -13012,17 +13012,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. */ @@ -13034,12 +13023,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 @@ -13056,7 +13044,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) {