From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SOPlKgYt5mReqAkAWB0awg (envelope-from ) for ; Wed, 23 Aug 2023 12:00:06 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=tAoRE77Y; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AC04E1E0C2; Wed, 23 Aug 2023 12:00:06 -0400 (EDT) Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 97A3F1E092 for ; Wed, 23 Aug 2023 12:00:04 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0AB183839DDF for ; Wed, 23 Aug 2023 16:00:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AB183839DDF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1692806404; bh=rvt8JvWtbyY3/wjCy0twPT5XUmUOpr3pw5yWIchwPDY=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=tAoRE77YP69QI6jFRhHYWzAtR+LCh2UhzClc86peM93AtWOqoC+DKWXqRbmUgKSXY LttmcIvUJFfgLJR60VVfJaQRcX0VF+dpxyvbr1pzyRnfYJ+Et7LxNje3triHzSJgq6 hs7uzGIuvwy00ycb9it8MyLP2gqkhK6Hru2EshOE= 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 DAAEA385734B for ; Wed, 23 Aug 2023 15:59:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DAAEA385734B Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688-brnfGPxgNf6YrIIb0IOS8A-1; Wed, 23 Aug 2023 11:59:31 -0400 X-MC-Unique: brnfGPxgNf6YrIIb0IOS8A-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-99df23d6926so408766066b.0 for ; Wed, 23 Aug 2023 08:59:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692806368; x=1693411168; 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=rvt8JvWtbyY3/wjCy0twPT5XUmUOpr3pw5yWIchwPDY=; b=R4vwuZmmDlWZVoIEz9FRvgS69CMVMsaWD1NmuILFxr5XeZOtPWdXL8tuOL0Oraqbfi AfJWCx9CGvjOktq4xBB2fczcGsXADhqGpsdM0/7pDjaJj/36Pufm+beZBQY9UY1BIQ+Y 7ow4YjAh8gbb41mOJf5JEEd0amcQsv02ktX/MW3F3Npu90/CUMju4QNuoFt+acS8AxyI 9L3lNCGYps/l/SwA1Y7VAglskVObOEu4wr2OVfhTmrltmkWAEr/DJFjUV+FO/SS+QSvN 90fiuQWWZ1MY+w6TmxaUDj45vmJp5+dhkMyjFkBw1Hl2hOYg3Z5EhQmMkTL4z7+yl7Qa P1xA== X-Gm-Message-State: AOJu0YxnfeoMN/Z3v3UEZER2qiQALuJefHJ2zGZyK0bt7CMImoF+wqq3 Ig4I1zOuUPU469NvfdZDRhrEcVgAm72OHT2Wp4io1cxzuX0zeXOoG735BoIJnKkVgqlh7I97tXH toqvmaUus98y3U8mpwtzQSrr1TQjB/TKjlX9YnmJ0ajS24/6FwC2DVZFRpDjYnoBbkoXeEkOTqG gDQqobPw== X-Received: by 2002:a17:907:7851:b0:9a1:f6e0:12f4 with SMTP id lb17-20020a170907785100b009a1f6e012f4mr417060ejc.15.1692806368478; Wed, 23 Aug 2023 08:59:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcJqf3y/o5Buhzdc5AXT+TBRWnbh/mFiY7uTBqOCnG++nLeS00nzb5PHms7q5I6n2W9v62eA== X-Received: by 2002:a17:907:7851:b0:9a1:f6e0:12f4 with SMTP id lb17-20020a170907785100b009a1f6e012f4mr417053ejc.15.1692806368253; Wed, 23 Aug 2023 08:59:28 -0700 (PDT) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id g17-20020a1709061c9100b0099b5a71b0bfsm9921146ejh.94.2023.08.23.08.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 08:59:27 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv4 04/10] gdb: build dprintf commands just once in code_breakpoint constructor Date: Wed, 23 Aug 2023 16:59:09 +0100 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.8 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 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Andrew Burgess via Gdb-patches Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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. I have also changes the 'if' that handles the case where the extra_string (which holds the format/args) is empty. I don't believe that this situation can ever arise -- and if it does we should be catching it earlier and throwing an error at that point. There should be no user visible changes after this commit. --- gdb/breakpoint.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 86225ef82fa..1cf1f4468a1 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8709,19 +8709,17 @@ 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) - { - if (extra_string != nullptr) - update_dprintf_command_list (this); - else - error (_("Format string required")); - } - 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) + { + gdb_assert (extra_string != nullptr); + 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. */ -- 2.25.4