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 CA021385C6DA for ; Mon, 30 Oct 2023 16:11:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CA021385C6DA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CA021385C6DA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698682287; cv=none; b=KYGZsCj+/Gpj5zcS2KTmRKdT3wQraHenNz9CF4cG42jOkkyNQaY0RDhT0Bey+j4p6MiILQ+7wTahBBKFuIR8d0h57GR/WtjZ1R0VCrGpzxtk0DPurCEt582o69kMLSBmd8TsWx4Z10v3L1rK5LIrQaFmiekW7JbxADllnvA5Usc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698682287; c=relaxed/simple; bh=v/HYRh8x5Accr9ihJ7ydAHHq6S/V58mKK5GQY16aCXc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=l3y5DeB9UvAOBM0kLaSktgNG1LsAcUjqTMi9Lz/qm6h/A174sgf/UfUl+aGqTaMbUsSoLGvQqMDAkuLw3JTsBsNCaUeH6bmxclfeYztaGfPuBXbRn4W1RKA+5OS18kacimaKwjloNXynh80bBawrOXRKaoLePz5Tm+ay/mpQPG0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698682286; 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=RxxJK8/DMlERXkd0KACpF809ocACdjNm8WHbc5KsXxs=; b=LNccd11dKTCWTH7n8ZBLW1mqZV8LKOSIq6mbuIYiJtaldvIoSbuEKZ6omw6DD8IDz0d5f/ Dj0SCNExemLtFnUkeTSwlkrzUaWitQHI6q+GIZnWw6oFdryHX3ISut9Rc/M3ugmNKkKSIO ZqAdv24AEeUVnRFBnbDUjHEf10WWArk= 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-680-nwkOyUdSNrS7Kq6aceM_8Q-1; Mon, 30 Oct 2023 12:11:24 -0400 X-MC-Unique: nwkOyUdSNrS7Kq6aceM_8Q-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9d2ab03a586so112439166b.0 for ; Mon, 30 Oct 2023 09:11:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698682283; x=1699287083; 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=RxxJK8/DMlERXkd0KACpF809ocACdjNm8WHbc5KsXxs=; b=Dm8DqqijhCAoo8ig28aigrTgQTZ7g+zYPJkX8A4E39kapu965vsUB2shRQIaNPfId0 mIMo81UYtWPRZC/T2R2qDJ6Xy2FE2OelJcuKyv+DwnhJS16Q3jXPanmexIc62AKbcz4B IK3BOX6dPLe7CGaT63IVw/2BWPh2qDEE3r86F8JK7ns5cl3n+50U1E/GJO0fDCmgmKHN lsBvYdnNt8HAJLKIhftIinLJzCw/V4f0YBoqBX/CKWUfhxTxA/x2qa/Vvy02SQw2KAc8 T16TKkYanroHJgfdP1ruNinA96evYBU/V3pBYAbHEBpEKLwGxJLorQWRH0JbYfcdycWg UtZA== X-Gm-Message-State: AOJu0YwoX2UWKXDwfkXHFBhNknbQ5x8tNFp7kZcEjY8r5Wn0CPR71fWT 2j/unKoPm/McXmbDhgkCyHAMvuOmw9S0WyHYLoaLI/y1ZvRZiVRzluGgEvoxTyNlcr/iJU1uPic LyD8Fu0QH0TrIwqO/otcXrE4Eb7/eZ0lE39XXedr4/hOudGDa+VrFtvKW2ms3ZpoTemNMH2WGNj 5jwsd1QA== X-Received: by 2002:a17:907:70b:b0:9c3:e158:316a with SMTP id xb11-20020a170907070b00b009c3e158316amr8525236ejb.68.1698682283475; Mon, 30 Oct 2023 09:11:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGR2AO7BEicdhyXnOGImlyPMNpGDlQ+36Rkq/9T18i2MFtPbu7W1CMPXz9vq7pvyrjZ66LCTg== X-Received: by 2002:a17:907:70b:b0:9c3:e158:316a with SMTP id xb11-20020a170907070b00b009c3e158316amr8525206ejb.68.1698682282984; Mon, 30 Oct 2023 09:11:22 -0700 (PDT) Received: from localhost ([31.111.84.209]) by smtp.gmail.com with ESMTPSA id jt21-20020a170906dfd500b0099bd1ce18fesm6286686ejc.10.2023.10.30.09.11.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 09:11:22 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv6 04/10] gdb: build dprintf commands just once in code_breakpoint constructor Date: Mon, 30 Oct 2023 16:11:08 +0000 Message-Id: <7a3d9762fa151ca1f03b35d4387f76c8d18bf078.1698682161.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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.9 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 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 f7279811e99..0c2f77244f2 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8705,19 +8705,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