From patchwork Mon May 15 19:27:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 69396 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 88FA13854142 for ; Mon, 15 May 2023 19:28:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 88FA13854142 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684178910; bh=+QTPgKqm3qDcTYnvIUX1xDLdxtWpSpqooPEAUApNYFI=; 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=vdQyJP/eQ5+AVg1bp1LQK3/CN2drzJyyKuQDTa0QsdKSrLcwI0SZMNxVAs3TxsJ8O NtFwK+ZQ8EE4+Jdcq4HijNIS96dmhpxAkm7sJ0Pl/zJlCJCANr68nkny3gjDoCAJhf lqwl7yPAL+xuE1XdgdXO0OYC8T8EMTeI5uvVvnz0= 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 167DA3857720 for ; Mon, 15 May 2023 19:28:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 167DA3857720 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-K9FKz4SxP-q2fxS1KcU1AA-1; Mon, 15 May 2023 15:27:57 -0400 X-MC-Unique: K9FKz4SxP-q2fxS1KcU1AA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3f426ffdbc6so53331485e9.3 for ; Mon, 15 May 2023 12:27:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684178876; x=1686770876; 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=+QTPgKqm3qDcTYnvIUX1xDLdxtWpSpqooPEAUApNYFI=; b=fYygntTMW9rSKgEFTHX8zK89Y9GgbHqna7SrcO77SR532sTGIL/WyBoabvQNfJ+06s 1Qks6YP/2LKH86t8tvWYOJdRmsnw84BU0AS/Pz7k1X/UKUF1oQMgBxvLp8L8f7WRjdCk IMqCDipYS1mAyuhFoo31lRcwHr8YDePe1Y0L9I3TU/dw+GW2xIxpMet7mzXRxcSErQeW fHWK4Osc3LPozSYK+8H9GwhJDqHyWON0IMiKiFCUtqPgkOLJvyU5GrqDMeH+OehCOXyQ 4n3dQgua4nfO8CM4c7aAbJ3lWBZZvP8jyDI0fmgdiLk8L7Ps/APxzdjYDC7b88PQKUZ8 0uMQ== X-Gm-Message-State: AC+VfDwnxGzlEUWVLNg0bzgIM3qEaVm9/1fVFUmiVj041q5XfASfJ67n jN96WY5phFqCeXTL2X3EfALNi19Uo57AhzC/WSgE4CDshMN14xbz6Z2LTHdOqrBFF746s6uV8Qs 3ePzgDDzk3oV9T53OnomSHjO/yVa3FiwwONxaRdn0G4NWz+KzHuDyz/qzD9iAW+oPlAUdB7go21 PyeyzksQ== X-Received: by 2002:a1c:7712:0:b0:3f4:1dd9:e9e0 with SMTP id t18-20020a1c7712000000b003f41dd9e9e0mr22032866wmi.7.1684178876525; Mon, 15 May 2023 12:27:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5lTv8TI0ghpjeFzdlrIiEV8s+QVGW+es2cqbDG2XIcOTF2Y8eZjloL7MXRxgPMJ7nrpr5ICQ== X-Received: by 2002:a1c:7712:0:b0:3f4:1dd9:e9e0 with SMTP id t18-20020a1c7712000000b003f41dd9e9e0mr22032856wmi.7.1684178876248; Mon, 15 May 2023 12:27:56 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id s3-20020a7bc383000000b003f4bef65a65sm309839wmj.28.2023.05.15.12.27.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 12:27:55 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 4/9] gdb: build dprintf commands just once in code_breakpoint constructor Date: Mon, 15 May 2023 20:27:40 +0100 Message-Id: <10b2c00a69eec9fe610e00f1ae10e1efad991737.1684178710.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_H2, 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@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 0827b587d5f..d03c55587be 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8544,19 +8544,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. */