From patchwork Wed Dec 13 22:38:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 82099 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 760B6385E02A for ; Wed, 13 Dec 2023 22:39:27 +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 CA710385DC3E for ; Wed, 13 Dec 2023 22:38:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CA710385DC3E 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 CA710385DC3E 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=1702507133; cv=none; b=cnzu8v3Gro3rpEWgNGg0JeQ53Offp8Ajk3RdrpT+8B2v3Mo90dL18y5GPmwbspEQqPiv7MdGFc0IeSs74y5wZmAgfEZ1dNdVtH195Z7F3JsWpo8237ynfzm8MNWKkGZRJLQT3cGAhDoXk6kwKjfs9HDSuPuW9iPnpEhioI3neqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702507133; c=relaxed/simple; bh=Woi4mJh+QBeK1r72B4Ip5DLarNHWW1LQZGTHO8vHSfI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=BHOMwv2MYejqH22L1piWH6ZuCeX4q545+ELX91ydu6G8C3Seq3+i8/YXe/Q0UdWRtD0azxWsB72Ci2e2M1PCJ90cZbPGfdLerTmK1TpDRk2DlF0MmLVOIYhKSmsAkSelvNBc9P1JRkqj43l0diqEVB2hXRK1FJ/4Tx3MiM3S9Hk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702507131; 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=0x1tvU5/Ak4YvmWyq2zC8BfwrCByXhrblmgbo0nwVSk=; b=BZKKulHDeLTDjWPh4of9TYEJKqozydH/We1AXpg6MJvSsRlqFfTeAX7+aL/KuY6In1VqCU knFu2mME1l50139q0MK7sqS/jLyO27olhLIQv+DWR7OkQOkJuv60Pa+u0i5ErfSmf7byva zEPVuUKH0v+qpkrGnBMJ067W5EXuCOY= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-694-Pis5PGFcOl-x7Y87ZjRKfQ-1; Wed, 13 Dec 2023 17:38:48 -0500 X-MC-Unique: Pis5PGFcOl-x7Y87ZjRKfQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-40c49cb08fcso24141375e9.2 for ; Wed, 13 Dec 2023 14:38:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702507126; x=1703111926; 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=0x1tvU5/Ak4YvmWyq2zC8BfwrCByXhrblmgbo0nwVSk=; b=kl4cLEpzEY7RxW1gu6hlRklNVMeVAKSUVUe1k6w97bj9ro+OCKHt9/NRH32AQlf0r1 nuvlq5uBOm9h6z+qG11sK8OVDt/CwZhHRaX5qsD+fnzkNKaaSmoo2ueSPxJFzHNLVHoI t6v+5eZb+OaDlaQj/J2+MJiy/uoqvx+M2Xe2cVp8YMVa2wISEdK/KrNRk8kT7wGfpyTZ ICD/sOtFGmmDIpzq6Lo1420z7tHhY0JdjQ5CBeZq3Lyl2OlKvsrpsb3P9YSHgqp0Ia72 ns5PQmxdZ3BI91YxHTJ+fL8n56JzYEUocKWw+4DnZsfDUk4u3S+tNiKYQEMA5pU/0I3z 4rnQ== X-Gm-Message-State: AOJu0YwZfQnksIb9SPuYTHQJNz3LSKDWBvhPDwn3y4dnwLoBwx92LUcY hpK7khyiD281ppxPcCm54uHQ3Rxv4AQAumphiXy7SslGemDLOWetD+/GzvDWmHnbeTG56huIctF IxNadz5dvh9nxjcdWOumwnGZnLwZNvIS52SSnqPZMj8SHznTORsAGqlClSTFzn8vGOhnkXYdThW oA11oHHw== X-Received: by 2002:a05:600c:44c7:b0:40c:246c:bd70 with SMTP id f7-20020a05600c44c700b0040c246cbd70mr4573386wmo.91.1702507126725; Wed, 13 Dec 2023 14:38:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdWIsuecnlAj7w2j7sUxdkO+oOexcC0gif9bcGlfv/ZfkDen4AC7a3YBXmfkVxOfGagE0fkQ== X-Received: by 2002:a05:600c:44c7:b0:40c:246c:bd70 with SMTP id f7-20020a05600c44c700b0040c246cbd70mr4573382wmo.91.1702507126466; Wed, 13 Dec 2023 14:38:46 -0800 (PST) Received: from localhost (105.226.159.143.dyn.plus.net. [143.159.226.105]) by smtp.gmail.com with ESMTPSA id o16-20020a5d6850000000b0033332df65absm14335265wrw.50.2023.12.13.14.38.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 14:38:45 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv7 05/11] gdb: build dprintf commands just once in code_breakpoint constructor Date: Wed, 13 Dec 2023 22:38:29 +0000 Message-Id: <82f72ab0a5d61d8845b5812fb09308768f82f8bb.1702507015.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=-11.7 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_H3, 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 I noticed in code_breakpoint::code_breakpoint that we are calling update_dprintf_command_list once for each breakpoint location, when we really only need to call this once per breakpoint -- the data updated by this function, the breakpoint command list -- is per breakpoint, not per breakpoint location. Calling update_dprintf_command_list multiple times is just wasted effort, there's no per location error checking, we don't even pass the current location to the function. This commit moves the update_dprintf_command_list call outside of the per-location loop. There should be no user visible changes after this commit. --- gdb/breakpoint.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 783a05d9a6b..99496f8de76 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8707,15 +8707,15 @@ code_breakpoint::code_breakpoint (struct gdbarch *gdbarch_, /* Do not set breakpoint locations conditions yet. As locations are inserted, they get sorted based on their addresses. Let the list stabilize to have reliable location numbers. */ - - /* Dynamic printf requires and uses additional arguments on the - command line, otherwise it's an error. */ - if (type == bp_dprintf) - update_dprintf_command_list (this); - else if (extra_string != nullptr) - error (_("Garbage '%s' at end of command"), extra_string.get ()); } + /* Dynamic printf requires and uses additional arguments on the + command line, otherwise it's an error. */ + if (type == bp_dprintf) + update_dprintf_command_list (this); + else if (extra_string != nullptr) + error (_("Garbage '%s' at end of command"), extra_string.get ()); + /* The order of the locations is now stable. Set the location condition using the location's number. */ int loc_num = 1;