From patchwork Tue Oct 3 21:29:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 77060 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 5C64F3861888 for ; Tue, 3 Oct 2023 21:30:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C64F3861888 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696368646; bh=IT+fkMam1oNqZLOHNkCUfgElycn+ovMaeMKzJLz6OpA=; 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=YWEJtfita5CnjpcvQNk4/DD2kvtxLtNTbn4p0NnO2KBj5RS2IG/IgU+sHytRFIZIQ wpAO8KUIEJEJH+G272mKOjLIZ2xpjPeeDBk14nDIk+HFLwDkqt4C+67pm0NrwV5ii8 UDuTRVUjs6Y1AQG+N+NJZ52Gia00lIcDosF5BnjE= 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 D7A96385800A for ; Tue, 3 Oct 2023 21:29:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D7A96385800A Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-564-qJ3Qz93HNiGWt77gklUIsQ-1; Tue, 03 Oct 2023 17:29:56 -0400 X-MC-Unique: qJ3Qz93HNiGWt77gklUIsQ-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-9ae70250ef5so28131766b.0 for ; Tue, 03 Oct 2023 14:29:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696368595; x=1696973395; 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=IT+fkMam1oNqZLOHNkCUfgElycn+ovMaeMKzJLz6OpA=; b=qwIsr4SAj4Es9oVsKa8nISAwm6B25ZCUuXjYQxH9HFD9y0xLnyHuFZZ95p/gRQFjK8 5oKn65lZkeaVQcKwodgnNGHc/0staFTd/8XRtvS6E26qKcVTXJgPh5/FBDRdpH93HnyT ghDXFdy0NBq2Zh31gx7FdnDbHrEOxU17jSYMtIEKSrR5U9uQmvuZmSfnGIJHMDm6jLXe M0IDzIO4lnjpGBcYNUeb/9bvaPBfkgwjb+QuuvasKUONR1mWLDzBVdS12NhfSfN4qm8K UcjBWd3fHhVDrVescvIZuNHqAPke5PJXMqKy7am2P/sJ042rUGJShvFfSinvXZEz4KvN aURA== X-Gm-Message-State: AOJu0YzG1+Qm5hyOhIhxnh9BDTMUdHbaoUPUeH90yr74K3iORL9AcWTQ 6pvjLNkR8bwM8ZkclE24ve4Xj+i79huhFq8bYJfGfTUHtXgKOYx0Dz1O1zYst2CGTKxJiAzSjeH TfPy2jgC0XsKyd3+puknZ5hwmuxyDb98oVM49NE6tst3HSp+JaWSQM/BQ2laj+SxOW26th4AQoA cmbVllAQ== X-Received: by 2002:a17:906:3295:b0:9ae:659f:4d2f with SMTP id 21-20020a170906329500b009ae659f4d2fmr373094ejw.26.1696368595217; Tue, 03 Oct 2023 14:29:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/9qvps3fwEi0lHUkdbG/SGq65zQFwyVjP6XYpCj+xomL4aYvcNlAK1JnFMLHmGYg63PGH0A== X-Received: by 2002:a17:906:3295:b0:9ae:659f:4d2f with SMTP id 21-20020a170906329500b009ae659f4d2fmr373082ejw.26.1696368595019; Tue, 03 Oct 2023 14:29:55 -0700 (PDT) Received: from localhost ([31.111.84.209]) by smtp.gmail.com with ESMTPSA id y22-20020a170906449600b0099bcf1c07c6sm1645427ejo.138.2023.10.03.14.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 14:29:54 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Andrew Burgess , Lancelot SIX Subject: [PATCHv5 04/10] gdb: build dprintf commands just once in code_breakpoint constructor Date: Tue, 3 Oct 2023 22:29:37 +0100 Message-Id: <60f698f461e0cd1a8b19c613c5df11780bb132a5.1696368409.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.6 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 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: , 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 c615ed65011..ee5978bd3a3 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8708,19 +8708,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. */