From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692806372; 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=rvt8JvWtbyY3/wjCy0twPT5XUmUOpr3pw5yWIchwPDY=; b=f3BPGvQ1qTFC+9qXrIXVslFV1lMdjrkEqxWUZPXMykNeaSrb9JbXrsFzQdiOyOn+bOtRMu I+Gjn+QroeKFC3Uf7VaLD3XR1qAgiq9V/1VuMw+YlAzbfFhTQ2bzNM8aYlm+dumaVrf5mV CbR8MtK1Z1CRLQS3Q2LFvBWISDiFiVA= 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) From: Andrew Burgess 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 List-Id: 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