From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mNh+M5pZTGRLDjkAWB0awg (envelope-from ) for ; Fri, 28 Apr 2023 19:41:14 -0400 Received: by simark.ca (Postfix, from userid 112) id CECE11E221; Fri, 28 Apr 2023 19:41:14 -0400 (EDT) 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=ax8UdwA7; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 86C851E0D5 for ; Fri, 28 Apr 2023 19:41:14 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 938A33858C74 for ; Fri, 28 Apr 2023 23:41:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 938A33858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682725273; bh=xaa4eUGc2q8bGBeCAA/NMzUdFPMz54uOSOfYHLV1lBs=; 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=ax8UdwA7O48HXkyXmZBgEP95lzTXaVrY6T+g2kSsUWFC+fpKOUKnsb+FFH2pTZpW2 mJlbK8qhY+kDxm505vg/XTYx0pq2v49F0r0vJr+noEtCt31SGA44q2fFnG1VzFoIJu seT/M8YidGYhL5XnXtA43WQLU5puRP6m84pJcCQE= 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 3B3ED385770C for ; Fri, 28 Apr 2023 23:35:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B3ED385770C Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-658-sIpEF5HoOlSQM8mXEkCUMA-1; Fri, 28 Apr 2023 19:35:55 -0400 X-MC-Unique: sIpEF5HoOlSQM8mXEkCUMA-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-2fe3fb8e32aso88979f8f.1 for ; Fri, 28 Apr 2023 16:35:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682724954; x=1685316954; 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=xaa4eUGc2q8bGBeCAA/NMzUdFPMz54uOSOfYHLV1lBs=; b=W1SJIks1tG9SPAswxsXh70ZkJ6rJtkffP8nKQwBXp5XvJTYeD6z2YyXNnoKYx3sF5R 4m8tLl3i4tIW4SrVD4+2xIIrdTi0RAscz6NYzvIglYh7RyvC9ndLQTf4kPOt1BzP7Z6o w/uWU4VbM8BTQ4TBwUviXB3DNPe267TNL6P4SfVkXnY0CiBjkjdLkWo5Z7mpdyh3+X7J jM6OuFBYLVwf1zZMntG4U1KA4rA1hKsMnxaE06Zm4BlK7Y2IT1r19GRVspUit4TISmYD 9xZ7rjocGQ5yXL4aegRt6O3s93G5aS3Xrf0MAgukkB+siJH7y1KPWlZEdes+XhIVypTd yEIw== X-Gm-Message-State: AC+VfDwbSeNBy+ep629PB7MA8PhQoZ73WZNx5D5JbNmrzMdnA3NHS2j8 JcmRMNRWHjjStMu1dPOY9Wf/N5H7GAmgbiIWVpn4kwbQdkhRQsR1O5XTijLYiG1nQWNT55hff42 8HEf7CS22s9AYwONfDzfG8WWxwH4NUtl6vmNvxzFx71xrG12Bham9KorOawLu9X3VcnvRtpt0K1 UobQLiHg== X-Received: by 2002:adf:fa8f:0:b0:2fb:1f34:dc6d with SMTP id h15-20020adffa8f000000b002fb1f34dc6dmr5636497wrr.64.1682724954154; Fri, 28 Apr 2023 16:35:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4jBKNr2Ga5RdxOBCJY/rTGvRr3a7DmZaRwDqIXL/dSJrzKP5oYiZwU9pOivlyBVzdDLe2lZw== X-Received: by 2002:adf:fa8f:0:b0:2fb:1f34:dc6d with SMTP id h15-20020adffa8f000000b002fb1f34dc6dmr5636489wrr.64.1682724953799; Fri, 28 Apr 2023 16:35:53 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id z16-20020a5d4410000000b002f79ea6746asm22103680wrq.94.2023.04.28.16.35.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Apr 2023 16:35:53 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 4/9] gdb: build dprintf commands just once in code_breakpoint constructor Date: Sat, 29 Apr 2023 00:35:40 +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-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 b75990963ca..1b06c7e0f5b 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8543,19 +8543,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